--- /dev/null
+SangJin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>
--- /dev/null
+Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
--- /dev/null
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+SUBDIRS = common lib module bin
--- /dev/null
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under MIT License.
+Please, see the LICENSE.MIT file for MIT License terms and conditions.
--- /dev/null
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+#$srcdir/configure --enable-maintainer-mode "$@"
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+SUBDIRS = xdbg xevlog_analyze
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+bin_PROGRAMS = xdbg
+
+xdbg_LDADD = $(XDBG_CLIENT_LIBS) ../../common/libcommon-client.la
+xdbg_LDFLAGS = ${LDFLAGS} -pie
+xdbg_CFLAGS = \
+ ${CFLAGS} \
+ -fPIE \
+ @XDBG_CLIENT_CFLAGS@ \
+ -I$(top_srcdir)/common
+
+xdbg_sc_SOURCES = \
+ xdbg.c
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <X11/Xlib.h>
+#include "xdbg_dbus_client.h"
+
+int main(int argc, char ** argv)
+{
+ XDbgDBusClientInfo* dbus_info;
+ Display *dpy;
+ char **new_argv;
+ int new_argc, i;
+ char temp[1024];
+ char cwd[1024];
+ dpy = XOpenDisplay (NULL);
+ if (!dpy)
+ {
+ fprintf (stderr, "failed: open display\n");
+ exit (-1);
+ }
+
+ dbus_info = xDbgDBusClientConnect ();
+ if (!dbus_info)
+ {
+ fprintf (stderr, "failed: connect dbus\n");
+ exit (-1);
+ }
+
+ new_argc = argc + 2;
+ new_argv = (char**)malloc (new_argc * sizeof (char*));
+ if (!new_argv)
+ {
+ fprintf (stderr, "failed: malloc new argv\n");
+ exit (-1);
+ }
+
+ snprintf (temp, sizeof(temp), "%d", getpid ());
+ new_argv[0] = temp;
+
+ if (!getcwd (cwd, sizeof(cwd)))
+ snprintf (cwd, sizeof(cwd), "/tmp");
+ new_argv[1] = cwd;
+
+ for (i = 0; i < argc; i++)
+ new_argv[i+2] = argv[i];
+
+ xDbugDBusClientSendMessage (dbus_info, new_argc, new_argv);
+
+ xDbgDBusClientDisconnect (dbus_info);
+
+ free (new_argv);
+
+ XCloseDisplay (dpy);
+
+ return 0;
+}
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+bin_PROGRAMS = xevlog_analyze
+
+xevlog_analyze_LDADD = $(XDBG_CLIENT_LIBS) ../../common/libcommon-client.la
+xevlog_analyze_LDFLAGS = ${LDFLAGS} -pie
+xevlog_analyze_CFLAGS = \
+ ${CFLAGS} \
+ -fPIE \
+ @XDBG_CLIENT_CFLAGS@ \
+ -I$(top_srcdir)/common
+
+xevlog_analyze_sc_SOURCES = \
+ xevlog_analyze.c
--- /dev/null
+/**************************************************************************
+
+xevlog-analyze
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xw32defs.h>
+#include <xdbg_types.h>
+#include <xdbg_evlog.h>
+
+#define LOG_SIZE 1024
+
+typedef struct _EvlogOption
+{
+ int pid;
+ char command_name[PATH_MAX+1];
+ char path_name[PATH_MAX+1];
+ Bool isRule;
+ int detail_level;
+} EvlogOption;
+
+
+static void
+_printUsage(char* name)
+{
+ printf("Usage: %s [OPTION]...\n", name);
+ printf("\n");
+ printf(" Options:\n");
+ printf(" -f [File_Name] File to save information\n");
+ printf("\n");
+ printf(" -r [Rule_File_Name] Setting Rule of certain policy read in File to find information you want\n");
+ printf("\n");
+ printf(" [How To write Rule file form]\n");
+ printf(" ------------------------\n");
+ printf(" | allow [RULE] |\n");
+ printf(" | deny [RULE] |\n");
+ printf(" ------------------------\n");
+ printf(" * It is possible to write multiple policies.\n");
+ printf("\n");
+ printf(" -a [ALLOW Rule] Setting Rule of 'ALLOW' policy to find information you want\n");
+ printf("\n");
+ printf(" -n [Deny Rule] Setting Rule of 'Deny' policy to find information you want\n");
+ printf("\n");
+ printf(" [RULE] : C Language-style boolean expression syntax. [VARIABLE] [COMPAROTOR] [VALUE]\n");
+ printf(" [VARIABLE] : type / major / minor / command / cmd / pid\n");
+ printf(" [COMPARATOR] : & / && / and / | / || / or / = / == / != / > / >= / < / <=\n");
+ printf(" [VALUE] : string / number \n");
+ printf("\n");
+ printf(" ie)\n");
+ printf(" xevlog_analyze -a \"(type=request) && (major == X11 and (minor = SendEvent or minor = ReceiveEvent))\"\n");
+ printf(" xevlog_analyze -n cmd!=ls\n");
+ printf("\n");
+ printf(" * WARNING : If you set both -a and -n option, must set -a option first. Otherwise Logs you DO NOT want can be printed.\n");
+ printf("\n");
+ printf(" -d [0-2] To Set printing detail log level\n");
+ printf("\n");
+ printf(" 0: To Print Primary Logs (XID, Root, Atom, Region ...)\n");
+ printf(" 1: To Print More Detail Logs (Time, State, Mask ...\n");
+ printf(" 2: To Print Supplementary Reply Logs (Information Including Each Item)\n");
+ printf("\n");
+ printf(" -h Usage of xevlog_anlayze\n");
+ printf("\n");
+}
+
+static void _xEvlogAnalyzePrint (EvlogOption *eo, char* reply, int* len)
+{
+ int fd = -1, cfd = -1;
+ int total, read_len;
+ int evlog_len;
+ char fd_name[256];
+ EvlogInfo evinfo={0,};
+ int i;
+
+ if (!eo || !strlen(eo->path_name))
+ {
+ printf ("failed: no evlog path\n");
+ _printUsage(eo->command_name);
+ return;
+ }
+
+ fd = open (eo->path_name, O_RDONLY);
+ if (fd < 0)
+ {
+ printf ("failed: open '%s'. (%s)\n", eo->path_name, strerror(errno));
+ return;
+ }
+
+ snprintf (fd_name, sizeof (fd_name), "/proc/%d/fd/1", eo->pid);
+ cfd = open (fd_name, O_RDWR);
+
+ if (cfd < 0)
+ {
+ printf ("failed: open consol '%s'. (%s)\n", fd_name, strerror(errno));
+ goto print_done;
+ }
+
+ while ((read_len = read (fd, &evlog_len, sizeof (int))) == sizeof (int))
+ {
+ char log[LOG_SIZE];
+ int size = sizeof (log);
+ static int init = 0;
+
+ memset (&evinfo, 0, sizeof (EvlogInfo));
+ total = read_len;
+
+ if (!init)
+ {
+ extern ExtensionInfo Evlog_extensions[];
+ extern int Extensions_size;
+ int new_argc = 3;
+ char* new_argv[3] = {"add", "allow", "all"};
+ int i;
+
+ if(!eo->isRule)
+ xDbgEvlogRuleSet ((const int) new_argc, (const char**) new_argv, reply, len);
+
+ printf("%s\n", reply);
+
+ read_len = read (fd, &Extensions_size, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof (int), print_done);
+ GOTO_IF_FAIL (Extensions_size > 0, print_done);
+ total += read_len;
+
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ read_len = read (fd, &Evlog_extensions[i].opcode, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof (int), print_done);
+ total += read_len;
+
+ read_len = read (fd, &Evlog_extensions[i].evt_base, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof (int), print_done);
+ total += read_len;
+
+ read_len = read (fd, &Evlog_extensions[i].err_base, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof (int), print_done);
+ total += read_len;
+ }
+
+ if (!xDbgEvlogGetExtensionEntry ())
+ {
+ printf ("failed: get extentions\n");
+ goto print_done;
+ }
+
+ init = 1;
+ }
+
+ read_len = read (fd, &evinfo.time, sizeof (CARD32));
+ GOTO_IF_FAIL (read_len == sizeof (CARD32), print_done);
+ total += read_len;
+
+ read_len = read (fd, &evinfo.type, sizeof (EvlogType));
+ GOTO_IF_FAIL (read_len == sizeof (EvlogType), print_done);
+ GOTO_IF_FAIL (evinfo.type >= EVENT && evinfo.type <= ERROR, print_done);
+ total += read_len;
+
+ read_len = read (fd, &evinfo.mask, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof (int), print_done);
+ total += read_len;
+
+ if (evinfo.mask & EVLOG_MASK_CLIENT)
+ {
+ read_len = read (fd, &evinfo.client, sizeof (EvlogClient));
+ GOTO_IF_FAIL (read_len == sizeof (EvlogClient), print_done);
+ total += read_len;
+ }
+
+ if (evinfo.mask & EVLOG_MASK_REQUEST)
+ {
+ int size;
+
+ read_len = read (fd, &evinfo.req, sizeof(EvlogRequest));
+ GOTO_IF_FAIL (read_len == sizeof(EvlogRequest), print_done);
+ total += read_len;
+
+ size = (int)(evinfo.req.length * 4);
+ GOTO_IF_FAIL (size > 0, print_done);
+
+ evinfo.req.ptr = malloc (size);
+ GOTO_IF_FAIL (evinfo.req.ptr != NULL, print_done);
+
+ read_len = read (fd, evinfo.req.ptr, size);
+ GOTO_IF_FAIL (read_len == size, print_done);
+ total += read_len;
+ }
+
+ if (evinfo.mask & EVLOG_MASK_EVENT)
+ {
+ read_len = read (fd, &evinfo.evt, sizeof(EvlogEvent));
+ GOTO_IF_FAIL (read_len == sizeof(EvlogEvent), print_done);
+ total += read_len;
+
+ evinfo.evt.ptr = malloc (evinfo.evt.size);
+ GOTO_IF_FAIL (evinfo.evt.ptr != NULL, print_done);
+
+ WARNING_IF_FAIL (evinfo.evt.size > 0);
+
+ read_len = read (fd, evinfo.evt.ptr, evinfo.evt.size);
+ GOTO_IF_FAIL (read_len == evinfo.evt.size, print_done);
+ total += read_len;
+ }
+
+ if (evinfo.mask & EVLOG_MASK_REPLY)
+ {
+ read_len = read (fd, &evinfo.rep, sizeof(EvlogReply));
+ GOTO_IF_FAIL (read_len == sizeof(EvlogReply), print_done);
+ total += read_len;
+
+ evinfo.rep.ptr = malloc (evinfo.rep.size);
+ GOTO_IF_FAIL (evinfo.rep.ptr != NULL, print_done);
+
+ WARNING_IF_FAIL (evinfo.rep.size > 0);
+
+ read_len = read (fd, evinfo.rep.ptr, evinfo.rep.size);
+ GOTO_IF_FAIL (read_len == evinfo.rep.size, print_done);
+ total += read_len;
+ }
+
+ if (evinfo.mask & EVLOG_MASK_ERROR)
+ {
+ read_len = read (fd, &evinfo.err, sizeof(EvlogError));
+ GOTO_IF_FAIL (read_len == sizeof(EvlogError), print_done);
+ total += read_len;
+ }
+
+ if (evinfo.mask & EVLOG_MASK_ATOM)
+ {
+ EvlogAtomTable *table;
+
+ read_len = read (fd, &evinfo.evatom.size, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof(int), print_done);
+ total += read_len;
+
+ for (i = 0 ; i < evinfo.evatom.size ; i++)
+ {
+ table = malloc (sizeof(EvlogAtomTable));
+ GOTO_IF_FAIL (table != NULL, print_done);
+
+ if (!evinfo.evatom.init)
+ {
+ xorg_list_init(&evinfo.evatom.list);
+ evinfo.evatom.init = 1;
+ }
+
+ read_len = read (fd, table, sizeof (EvlogAtomTable));
+ if (read_len != sizeof(EvlogAtomTable))
+ {
+ WARNING_IF_FAIL (read_len == sizeof(EvlogAtomTable));
+ free (table);
+ goto print_done;
+ }
+ total += read_len;
+
+ xorg_list_add(&table->link, &evinfo.evatom.list);
+ }
+ }
+
+ if (evinfo.mask & EVLOG_MASK_REGION)
+ {
+ EvlogRegionTable *table;
+
+ read_len = read (fd, &evinfo.evregion.size, sizeof (int));
+ GOTO_IF_FAIL (read_len == sizeof(int), print_done);
+ total += read_len;
+
+ for (i = 0 ; i < evinfo.evregion.size ; i++)
+ {
+ table = malloc (sizeof(EvlogRegionTable));
+ GOTO_IF_FAIL (table != NULL, print_done);
+
+ if (!evinfo.evregion.init)
+ {
+ xorg_list_init(&evinfo.evregion.list);
+ evinfo.evregion.init = 1;
+ }
+
+ read_len = read (fd, table, sizeof (EvlogRegionTable));
+ if (read_len != sizeof(EvlogRegionTable))
+ {
+ WARNING_IF_FAIL (read_len == sizeof(EvlogRegionTable));
+ free (table);
+ goto print_done;
+ }
+ total += read_len;
+
+ xorg_list_add(&table->link, &evinfo.evregion.list);
+ }
+ }
+
+ GOTO_IF_FAIL (evlog_len == total, print_done);
+
+ if (xDbgEvlogRuleValidate (&evinfo))
+ {
+ if (xDbgEvlogFillLog(&evinfo, eo->detail_level, log, &size))
+ printf ("%s", log);
+ }
+
+ if (evinfo.req.ptr)
+ {
+ free (evinfo.req.ptr);
+ evinfo.req.ptr = NULL;
+ }
+
+ if (evinfo.evt.ptr)
+ {
+ free (evinfo.evt.ptr);
+ evinfo.evt.ptr = NULL;
+ }
+
+ xDbgDistroyAtomList(&evinfo);
+ xDbgDistroyRegionList(&evinfo);
+ }
+
+
+print_done:
+ if (evinfo.req.ptr)
+ free (evinfo.req.ptr);
+
+ if (evinfo.evt.ptr)
+ free (evinfo.evt.ptr);
+
+ xDbgDistroyAtomList(&evinfo);
+ xDbgDistroyRegionList(&evinfo);
+
+ if (cfd >= 0)
+ close (cfd);
+
+ if (fd >= 0)
+ close (fd);
+}
+
+
+static void
+_checkOption(int argc, char** argv)
+{
+ int c;
+ EvlogOption eo = {0,};
+ char rule_log[LOG_SIZE];
+ int rule_size = sizeof (rule_log);
+
+ eo.pid = atoi (argv[0]);
+ eo.isRule = FALSE;
+ eo.detail_level = 0;
+ snprintf (eo.command_name, sizeof (eo.command_name), "%s", argv[1]);
+
+ if (argc < 3)
+ {
+ _printUsage( eo.command_name );
+ return;
+ }
+
+ while ((c = getopt(argc, argv, "f:a:n:r:d:h")) != EOF)
+ {
+ switch (c)
+ {
+ case 'f':
+ {
+ if (!optarg || strlen(optarg) <= 0)
+ break;
+ snprintf (eo.path_name, sizeof (eo.path_name), "%s", optarg);
+ break;
+ }
+
+ case 'a':
+ {
+ int new_argc = 3;
+ char* new_argv[3] = {"add", "allow", };
+
+ if (!optarg || strlen(optarg) <= 0)
+ break;
+
+ new_argv[2] = (char*)calloc (1, PATH_MAX);
+ if(!new_argv[2])
+ {
+ printf ("failed: malloc new_argv[2]\n");
+ return;
+ }
+
+ snprintf (new_argv[2], PATH_MAX, "%s", optarg);
+ if(!xDbgEvlogRuleSet ((const int) new_argc,
+ (const char**) new_argv,
+ rule_log, &rule_size))
+ {
+ printf("%s\n", rule_log);
+ return;
+ }
+ eo.isRule = TRUE;
+
+ free (new_argv[2]);
+
+ break;
+ }
+
+ case 'n':
+ {
+ int new_argc = 3;
+ char* new_argv[3] = {"add", "deny", };
+
+ if (!optarg || strlen(optarg) <= 0)
+ break;
+
+ new_argv[2] = (char*)calloc (1, PATH_MAX);
+ if(!new_argv[2])
+ {
+ printf ("failed: malloc new_argv[2]\n");
+ return;
+ }
+
+ snprintf (new_argv[2], PATH_MAX, "%s", optarg);
+ if(!xDbgEvlogRuleSet ((const int) new_argc,
+ (const char**) new_argv,
+ rule_log, &rule_size))
+ {
+ printf("%s\n", rule_log);
+ return;
+ }
+ eo.isRule = TRUE;
+
+ free (new_argv[2]);
+
+ break;
+ }
+
+ case 'r':
+ {
+ if (!optarg || strlen(optarg) <= 0)
+ break;
+
+ if(!xDbgEvlogReadRuleFile(optarg, rule_log, &rule_size))
+ {
+ printf("%s", rule_log);
+ return;
+ }
+ eo.isRule = TRUE;
+ break;
+ }
+
+ case 'd':
+ {
+ if (!optarg || strlen(optarg) <= 0 || strlen(optarg) > 2)
+ break;
+
+ eo.detail_level = atoi(optarg);
+ printf ("Detail Level: %d\n", eo.detail_level);
+ break;
+ }
+
+ case 'h':
+ case '?':
+ {
+ _printUsage( eo.command_name );
+ return;
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ _xEvlogAnalyzePrint(&eo, rule_log, &rule_size);
+}
+
+
+
+int main(int argc, char** argv)
+{
+ char **new_argv;
+ int new_argc, i;
+ char temp[128];
+
+ new_argc = argc + 1;
+ new_argv = (char**)malloc (new_argc * sizeof (char*));
+ if (!new_argv)
+ {
+ printf ("failed: malloc new argv\n");
+ exit (-1);
+ }
+
+ snprintf (temp, sizeof(temp), "%d", (int)getpid());
+ new_argv[0] = temp;
+
+ for (i = 0; i < argc; i++)
+ new_argv[i+1] = argv[i];
+
+ _checkOption(new_argc, new_argv);
+
+ free (new_argv);
+
+ return 0;
+}
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+COMMON_SOURCE = \
+ xdbg_dbus_client.c \
+ xdbg_evlog.c \
+ xdbg_evlog_request.c \
+ xdbg_evlog_core.c \
+ xdbg_evlog_composite.c \
+ xdbg_evlog_dri2.c \
+ xdbg_evlog_damage.c \
+ xdbg_evlog_gesture.c \
+ xdbg_evlog_xext.c \
+ xdbg_evlog_randr.c \
+ xdbg_evlog_xinput.c \
+ xdbg_evlog_xv.c \
+ xdbg_evlog_event.c \
+ xdbg_evlog_reply.c \
+ ds/bintree.c \
+ ds/bool_exp_parser.c \
+ ds/bool_exp_rule_checker.c \
+ ds/bool_exp_tokenizer.c
+
+if HAVE_HWC
+COMMON_SOURCE += xdbg_evlog_hwc.c
+endif
+
+COMMON_CFLAGS = \
+ ${CFLAGS} \
+ @XDBG_CFLAGS@ \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/common \
+ -I$(top_srcdir)/common/ds
+
+COMMON_CLIENT_CFLAGS = \
+ ${CFLAGS} \
+ @XDBG_CLIENT_CFLAGS@ \
+ -I$(top_srcdir)/common \
+ -I$(top_srcdir)/common/ds
+
+
+noinst_LTLIBRARIES = libcommon-client.la \
+ libcommon-server.la
+
+libcommon_client_la_LIBADD = ${LDFLAGS} @XDBG_LIBS@
+libcommon_client_la_LDFLAGS = ${LDFLAGS} @XDBG_LIBS@
+libcommon_client_la_CFLAGS = ${COMMON_CLIENT_CFLAGS}
+libcommon_client_la_SOURCES = $(COMMON_SOURCE)
+
+libcommon_server_la_LIBADD = ${LDFLAGS} @XDBG_LIBS@
+libcommon_server_la_LDFLAGS = ${LDFLAGS} @XDBG_LIBS@
+libcommon_server_la_CFLAGS = ${COMMON_CFLAGS}
+libcommon_server_la_SOURCES = $(COMMON_SOURCE) \
+ xdbg_dbus_server.c
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "bintree.h"
+
+struct _BINARY_TREE_NODE
+{
+ BINARY_TREE_NODE left;
+ BINARY_TREE_NODE right;
+};
+
+struct _BINARY_TREE
+{
+ int size;
+ BINARY_TREE_NODE head;
+};
+
+BINARY_TREE bintree_create_tree (int size)
+{
+ BINARY_TREE tree = calloc (sizeof (struct _BINARY_TREE) + size, 1);
+ if (!tree) return NULL;
+
+ tree->size = size;
+ tree->head = NULL;
+
+ return tree;
+}
+
+BINARY_TREE_NODE bintree_create_node (BINARY_TREE tree)
+{
+ BINARY_TREE_NODE node = calloc (sizeof (struct _BINARY_TREE_NODE) + tree->size, 1);
+ if (!node) return NULL;
+
+ node->left = NULL;
+ node->right = NULL;
+
+ return node;
+}
+
+BINARY_TREE_NODE bintree_get_head (BINARY_TREE tree)
+{
+ return tree->head;
+}
+
+void bintree_set_head (BINARY_TREE tree, BINARY_TREE_NODE head)
+{
+ tree->head = head;
+}
+
+void bintree_set_left_child (BINARY_TREE_NODE node, BINARY_TREE_NODE child)
+{
+ node->left = child;
+}
+
+void bintree_set_right_child (BINARY_TREE_NODE node, BINARY_TREE_NODE child)
+{
+ node->right = child;
+}
+
+BINARY_TREE_NODE bintree_get_left_child (BINARY_TREE_NODE node)
+{
+ return node->left;
+}
+
+BINARY_TREE_NODE bintree_get_right_child (BINARY_TREE_NODE node)
+{
+ return node->right;
+}
+
+void * bintree_get_node_data (BINARY_TREE_NODE node)
+{
+ return (void*)(node + 1);
+}
+
+void bintree_remove_node (BINARY_TREE_NODE node)
+{
+ free (node);
+}
+
+void bintree_remove_node_recursive (BINARY_TREE_NODE node)
+{
+ if (node->left)
+ bintree_remove_node_recursive (node->left);
+ if (node->right)
+ bintree_remove_node_recursive (node->right);
+
+ bintree_remove_node (node);
+}
+
+void bintree_destroy_tree (BINARY_TREE tree)
+{
+ if (tree->head)
+ bintree_remove_node_recursive (tree->head);
+
+ free (tree);
+}
+
+static int bintree_inorder_traverse_recursive (BINARY_TREE tree, BINARY_TREE_NODE node, BINARY_TREE_NODE parent, BINTREE_TRAVERSE_FUNC func, void * arg)
+{
+ if (node->left)
+ if (bintree_inorder_traverse_recursive (tree, node->left, node, func, arg) != 0)
+ return 1;
+
+ if (func (tree, node, parent, arg))
+ return 1;
+
+ if (node->right)
+ if (bintree_inorder_traverse_recursive (tree, node->right, node, func, arg) != 0)
+ return 1;
+
+ return 0;
+}
+
+void bintree_inorder_traverse (BINARY_TREE tree, BINTREE_TRAVERSE_FUNC func, void * arg)
+{
+ if (tree->head)
+ bintree_inorder_traverse_recursive (tree, tree->head, tree->head, func, arg);
+}
+
+static int bintree_postorder_traverse_recursive (BINARY_TREE tree, BINARY_TREE_NODE node, BINARY_TREE_NODE parent, BINTREE_TRAVERSE_FUNC func, void * arg)
+{
+ if (node->left)
+ if (bintree_postorder_traverse_recursive (tree, node->left, node, func, arg) != 0)
+ return 1;
+ if (node->right)
+ if (bintree_postorder_traverse_recursive (tree, node->right, node, func, arg) != 0)
+ return 1;
+
+ return func (tree, node, parent, arg);
+}
+
+void bintree_postorder_traverse (BINARY_TREE tree, BINTREE_TRAVERSE_FUNC func, void * arg)
+{
+ if (tree->head)
+ bintree_postorder_traverse_recursive (tree, tree->head, tree->head, func, arg);
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _BOOL_EXP_BINTREE_H_
+#define _BOOL_EXP_BINTREE_H_
+
+typedef struct _BINARY_TREE_NODE * BINARY_TREE_NODE;
+typedef struct _BINARY_TREE * BINARY_TREE;
+typedef int (*BINTREE_TRAVERSE_FUNC) (BINARY_TREE tree, BINARY_TREE_NODE node, BINARY_TREE_NODE parent, void * arg);
+
+BINARY_TREE bintree_create_tree (int data_size);
+
+BINARY_TREE_NODE bintree_create_node (BINARY_TREE tree);
+
+BINARY_TREE_NODE bintree_get_head (BINARY_TREE tree);
+
+void bintree_set_head (BINARY_TREE tree, BINARY_TREE_NODE head);
+
+void bintree_set_left_child (BINARY_TREE_NODE node, BINARY_TREE_NODE child);
+
+void bintree_set_right_child (BINARY_TREE_NODE node, BINARY_TREE_NODE child);
+
+BINARY_TREE_NODE bintree_get_left_child (BINARY_TREE_NODE node);
+
+BINARY_TREE_NODE bintree_get_right_child (BINARY_TREE_NODE node);
+
+void * bintree_get_node_data (BINARY_TREE_NODE node);
+
+void bintree_remove_node (BINARY_TREE_NODE node);
+
+void bintree_remove_node_recursive (BINARY_TREE_NODE node);
+
+void bintree_destroy_tree (BINARY_TREE tree);
+
+void bintree_inorder_traverse (BINARY_TREE tree, BINTREE_TRAVERSE_FUNC func, void * arg);
+
+void bintree_postorder_traverse (BINARY_TREE tree, BINTREE_TRAVERSE_FUNC func, void * arg);
+
+#endif /* _BOOL_EXP_BINTREE_H_ */
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+
+#include "bool_exp_tokenizer.h"
+#include "bool_exp_parser.h"
+#include "bintree.h"
+
+typedef struct _TOKEN_DATA * TOKEN_DATA;
+
+struct _TOKEN_DATA
+{
+ const char ** string;
+ TOKEN last_token;
+ const char * last_symbol;
+ int symbol_len;
+};
+
+static BINARY_TREE_NODE bool_exp_parse_line (BINARY_TREE tree, TOKEN_DATA token);
+
+#define PARSE_DEBUG 0
+
+#if PARSE_DEBUG
+#define process_token(t) _process_token(t, __LINE__)
+static void _process_token (TOKEN_DATA token, int line)
+#else
+static void process_token (TOKEN_DATA token)
+#endif
+{
+ do
+ {
+ token->last_symbol = *(token->string);
+ token->last_token = get_next_token (token->string);
+ token->symbol_len = *(token->string) - token->last_symbol;
+
+ }
+ while (token->last_token == BET_SPACE);
+#if PARSE_DEBUG
+ printf ("token : %d remained string : [%s] (line:%d)\n", token->last_token, *token->string, line);
+#endif
+}
+
+static BINARY_TREE_NODE bool_exp_parse_statement (BINARY_TREE tree, TOKEN_DATA token)
+{
+ BINARY_TREE_NODE node = NULL;
+ PARSE_DATA data = NULL;
+
+#if PARSE_DEBUG
+ printf ("%s:%d (token->last_token %d)\n", __FILE__, __LINE__, token->last_token);
+#endif
+
+ if (token->last_token == BET_L_BR)
+ {
+ process_token (token);
+
+ node = bool_exp_parse_line (tree, token);
+ if (node == NULL)
+ {
+ return NULL;
+ }
+
+ if (token->last_token != BET_R_BR)
+ {
+ goto fail;
+ }
+ process_token (token);
+
+ return node;
+ }
+
+ if (token->last_token != BET_SYMBOL)
+ goto fail;
+
+ node = bintree_create_node (tree);
+
+ data = (PARSE_DATA) bintree_get_node_data (node);
+
+ strncpy (data->variable_name, token->last_symbol, token->symbol_len);
+ data->variable_name[token->symbol_len] = '\0';
+
+ if (!strcasecmp (data->variable_name, "all"))
+ {
+ data->node_type = ALL;
+ process_token (token);
+
+ return node;
+ }
+
+ data->node_type = DATA;
+
+ process_token (token);
+
+ switch (token->last_token)
+ {
+ case BET_NOT_EQ:
+ data->compare = NOT_EQ;
+ break;
+ case BET_EQUAL:
+ data->compare = EQUAL;
+ break;
+ case BET_LSS_THAN:
+ data->compare = LESS;
+ break;
+ case BET_LSS_EQ:
+ data->compare = LESS_EQ;
+ break;
+ case BET_GRT_THAN:
+ data->compare = GREATER;
+ break;
+ case BET_GRT_EQ:
+ data->compare = GREATER_EQ;
+ break;
+ default:
+ goto fail;
+ }
+
+ process_token (token);
+
+ if (token->last_token == BET_NUMBER)
+ {
+ data->value_type = INTEGER;
+ data->value.integer = atoi (token->last_symbol);
+ }
+ else if (token->last_token == BET_SYMBOL)
+ {
+ data->value_type = STRING;
+ strncpy (data->value.string, token->last_symbol, token->symbol_len);
+ data->value.string[token->symbol_len] = '\0';
+ }
+ else
+ {
+ goto fail;
+ }
+
+ process_token (token);
+
+ return node;
+
+fail:
+ if (node)
+ bintree_remove_node_recursive (node);
+
+ return NULL;
+}
+
+static BINARY_TREE_NODE bool_exp_parse_line (BINARY_TREE tree, TOKEN_DATA token)
+{
+ BINARY_TREE_NODE node = NULL;
+ BINARY_TREE_NODE left = NULL;
+ BINARY_TREE_NODE right = NULL;
+
+ PARSE_DATA data;
+
+#if PARSE_DEBUG
+ printf ("%s:%d\n", __FILE__, __LINE__);
+#endif
+
+ node = bool_exp_parse_statement (tree, token);
+ if (node == NULL)
+ {
+ printf ("PARSE statement error\n");
+ goto fail;
+ }
+
+ while (token->last_token == BET_AND)
+ {
+ left = node;
+ node = NULL;
+
+ process_token (token);
+ right = bool_exp_parse_statement (tree, token);
+ if (right == NULL)
+ goto fail;
+
+ node = bintree_create_node (tree);
+
+ data = (PARSE_DATA) bintree_get_node_data (node);
+ data->node_type = AND;
+ bintree_set_left_child (node, left);
+ bintree_set_right_child (node, right);
+ }
+
+ if (token->last_token == BET_OR)
+ {
+ left = node;
+ node = NULL;
+
+ process_token (token);
+ right = bool_exp_parse_line (tree, token);
+ if (right == NULL)
+ goto fail;
+
+ node = bintree_create_node (tree);
+
+ data = (PARSE_DATA) bintree_get_node_data (node);
+ data->node_type = OR;
+ bintree_set_left_child (node, left);
+ bintree_set_right_child (node, right);
+ }
+
+ return node;
+
+fail:
+ if (left)
+ bintree_remove_node_recursive (left);
+ return NULL;
+}
+
+BINARY_TREE bool_exp_parse (const char * string)
+{
+ BINARY_TREE tree = bintree_create_tree (sizeof (struct _PARSE_DATA));
+ BINARY_TREE_NODE node;
+
+ struct _TOKEN_DATA token;
+
+ if (!tree)
+ return NULL;
+
+ token.string = &string;
+ process_token (&token);
+
+ node = bool_exp_parse_line (tree, &token);
+ if (node == NULL)
+ {
+ bintree_destroy_tree (tree);
+ return NULL;
+ }
+
+ bintree_set_head (tree, node);
+
+ return tree;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _BOOL_EXP_PARSER_H_
+#define _BOOL_EXP_PARSER_H_
+
+#include "bintree.h"
+
+#define STRING_MAX 64
+
+typedef enum { NONE, AND, OR, DATA, ALL } NODE_TYPE;
+typedef enum { EQUAL, LESS, GREATER, LESS_EQ, GREATER_EQ, NOT_EQ } COMPARER;
+typedef enum { INTEGER, STRING } DATA_TYPE;
+
+typedef struct _PARSE_DATA * PARSE_DATA;
+
+struct _PARSE_DATA
+{
+ NODE_TYPE node_type;
+
+ char variable_name[STRING_MAX];
+ COMPARER compare;
+ DATA_TYPE value_type;
+ union
+ {
+ char string[STRING_MAX];
+ int integer;
+ } value;
+
+ enum { BEP_UNKNOWN, BEP_TRUE, BEP_FALSE } result;
+};
+
+BINARY_TREE bool_exp_parse (const char * string);
+
+#endif /* _BOOL_EXP_PARSER_H_ */
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+
+#include "bool_exp_parser.h"
+#include "bool_exp_rule_checker.h"
+
+#define MAX_RULE 64
+
+#ifndef REPLY
+#define REPLY(fmt, ARG...) \
+ do { \
+ if (reply && len && *len > 0) \
+ { \
+ int s = snprintf (reply, *len, fmt, ##ARG); \
+ reply += s; \
+ *len -= s; \
+ } \
+ } while (0)
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+typedef struct
+{
+ POLICY_TYPE policy;
+
+ BINARY_TREE tree;
+} RULE;
+
+struct _RULE_CHECKER
+{
+ RULE rules[MAX_RULE];
+
+ int count;
+};
+
+typedef struct
+{
+ int type;
+ int reqID;
+ const char * name;
+ int pid;
+ char * cmd;
+} VAL_ARGUMENTS;
+
+typedef struct
+{
+ char **reply;
+ int *len;
+} REPLY_BUFFER;
+
+static int print_func (BINARY_TREE tree, BINARY_TREE_NODE node, BINARY_TREE_NODE parent, void * arg)
+{
+ REPLY_BUFFER *buffer = (REPLY_BUFFER*)arg;
+ char *reply = *buffer->reply;
+ int *len = buffer->len;
+ char * operators[] = { "==", "<", ">", "<=", ">=", "!=" };
+
+ PARSE_DATA data = bintree_get_node_data (node);
+
+ if (data->node_type == ALL)
+ REPLY ("ALL");
+ else if (data->node_type == AND)
+ REPLY (" and ");
+ else if (data->node_type == OR)
+ REPLY (" or ");
+ else // data->node_type == DATA
+ {
+ if (node == bintree_get_left_child (parent))
+ REPLY ("(");
+
+ REPLY ("%s %s ", data->variable_name, operators[data->compare]);
+
+ if (data->value_type == INTEGER)
+ REPLY ("%d", data->value.integer);
+ else
+ REPLY ("%s", data->value.string);
+
+ if (node == bintree_get_right_child (parent))
+ REPLY (")");
+ }
+
+ *buffer->reply = reply;
+
+ return 0;
+}
+
+static int compare_string (COMPARER compare, char * str2, char * str1)
+{
+ int result = strcasecmp (str2, str1);
+ switch (compare)
+ {
+ case EQUAL:
+ return result == 0;
+ case LESS:
+ return result < 0;
+ case GREATER:
+ return result > 0;
+ case LESS_EQ:
+ return result <= 0;
+ case GREATER_EQ:
+ return result >= 0;
+ case NOT_EQ:
+ return result != 0;
+ }
+
+ return 0;
+}
+
+static int compare_int (COMPARER compare, int int2, int int1)
+{
+ switch (compare)
+ {
+ case EQUAL:
+ return int1 == int2;
+ case LESS:
+ return int1 < int2;
+ case GREATER:
+ return int1 > int2;
+ case LESS_EQ:
+ return int1 <= int2;
+ case GREATER_EQ:
+ return int1 >= int2;
+ case NOT_EQ:
+ return int1 != int2;
+ }
+
+ return 0;
+}
+
+static int validate_func (BINARY_TREE tree, BINARY_TREE_NODE node, BINARY_TREE_NODE parent, void * arg)
+{
+ VAL_ARGUMENTS * args = (VAL_ARGUMENTS*)arg;
+ BINARY_TREE_NODE left, right;
+
+ PARSE_DATA left_data = NULL, right_data = NULL;
+ PARSE_DATA data = bintree_get_node_data (node);
+
+ data->result = BEP_UNKNOWN;
+
+ if (data->node_type == AND || data->node_type == OR)
+ {
+ left = bintree_get_left_child (node);
+ right = bintree_get_right_child (node);
+ if (left == NULL || right == NULL)
+ {
+ printf ("Node error\n");
+ return -1;
+ }
+
+ left_data = bintree_get_node_data (left);
+ right_data = bintree_get_node_data (right);
+ }
+
+ if (data->node_type == ALL)
+ {
+ data->result = BEP_TRUE;
+ }
+ else if (data->node_type == DATA)
+ {
+ char major[64];
+ char * minor = NULL;
+
+ if (args->name)
+ minor = index (args->name, ':');
+ if (minor)
+ {
+ int min = MIN (sizeof(major)-1, minor-args->name);
+ strncpy (major, args->name, min);
+ major[min] = '\0';
+ minor++;
+ }
+ if (!strcasecmp (data->variable_name, "TYPE"))
+ {
+ char * type_string;
+ if (args->type == 0) // EVENT
+ type_string = "EVENT";
+ else if (args->type == 1)
+ type_string = "REQUEST";
+ else if (args->type == 2)
+ type_string = "REPLY";
+ else if (args->type == 3)
+ type_string = "FLUSH";
+ else if (args->type == 4)
+ type_string = "ERROR";
+ else
+ {
+ fprintf (stderr, "Invalid type %d\n", args->type);
+ return -1;
+ }
+
+ if (compare_string (data->compare, data->value.string, type_string))
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else if (!strcasecmp (data->variable_name, "MAJOR"))
+ {
+ if (minor && compare_string (data->compare, data->value.string, major))
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else if (!strcasecmp (data->variable_name, "MINOR"))
+ {
+ if (minor && compare_string (data->compare, data->value.string, minor))
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else if (!strcasecmp (data->variable_name, "PID"))
+ {
+ if (compare_int (data->compare, data->value.integer, args->pid))
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else if (!strcasecmp (data->variable_name, "CMD") || !strcasecmp (data->variable_name, "COMMAND"))
+ {
+ if (args->cmd && compare_string (data->compare, data->value.string, args->cmd))
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ }
+ else if (data->node_type == AND)
+ {
+ if (left_data->result == BEP_TRUE && right_data->result == BEP_TRUE)
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else if (data->node_type == OR)
+ {
+ if (left_data->result == BEP_TRUE || right_data->result == BEP_TRUE)
+ data->result = BEP_TRUE;
+ else
+ data->result = BEP_FALSE;
+ }
+ else
+ return -1;
+
+ return 0;
+}
+
+
+RULE_CHECKER rulechecker_init()
+{
+ RULE_CHECKER rc = calloc (sizeof (struct _RULE_CHECKER), 1);
+ if (rc == NULL)
+ return NULL;
+
+ rc->count = 0;
+
+ return rc;
+}
+
+void rulechecker_destroy (RULE_CHECKER rc)
+{
+ int i;
+ for (i=rc->count - 1; i>=0; i--)
+ rulechecker_remove_rule (rc, i);
+
+ free (rc);
+}
+
+RC_RESULT_TYPE rulechecker_add_rule (RULE_CHECKER rc, POLICY_TYPE policy, const char * rule_string)
+{
+ if (rc->count == MAX_RULE)
+ return RC_ERR_TOO_MANY_RULES;
+
+ rc->rules[rc->count].tree = bool_exp_parse (rule_string);
+ if (rc->rules[rc->count].tree == NULL)
+ return RC_ERR_PARSE_ERROR;
+ rc->rules[rc->count].policy = policy;
+
+ rc->count++;
+
+ return RC_OK;
+}
+
+RC_RESULT_TYPE rulechecker_remove_rule (RULE_CHECKER rc, int index)
+{
+ if (index < 0 || index >= rc->count)
+ return RC_ERR_NO_RULE;
+
+ bintree_destroy_tree (rc->rules[index].tree);
+
+ rc->count--;
+ if (index != rc->count)
+ memmove (&rc->rules[index], &rc->rules[index + 1], sizeof (RULE) * (rc->count - index));
+
+ return RC_OK;
+}
+
+void rulechecker_print_rule (RULE_CHECKER rc, char *reply, int *len)
+{
+ REPLY_BUFFER buffer = {&reply, len};
+ int i;
+
+ REPLY (" ---------------- Evlog Rules ----------------\n");
+
+ for (i=0; i<rc->count; i++)
+ {
+ REPLY (" [Rule %d] [%s] \"", i, rc->rules[i].policy == ALLOW ? "ALLOW" : "DENY");
+
+ bintree_inorder_traverse (rc->rules[i].tree, print_func, (void*)&buffer);
+ REPLY ("\"\n");
+ }
+}
+
+const char * rulechecker_print_usage()
+{
+ return
+ "######################################################################\n"
+ "### RuleChecker 1.0 for XDBG EvLog filtering. ###\n"
+ "### Designed and developed by ###\n"
+ "### YoungHoon Jung <yhoon.jung@samsung.com> ###\n"
+ "######################################################################\n"
+ "\n"
+ "-----------------------------------------------------------------\n"
+ "How to read evlog messages :\n"
+ " Client(pid: [PID]| [CMD]) <====== [TYPE]( [MAJOR]: [MINOR]) ===== XServer\n"
+ "\n"
+ " ie)\n"
+ " Client(pid:00345| xdbg) <====== Event ( X11:SendEvent) ===== XServer\n"
+ " ==> type = event && pid = 345 && cmd = xdbg && major = X11 && minor = SendEvent\n"
+ " Client(pid:00111| xeyes) ===== Request( SHM:ShmAttach) ======> XServer\n"
+ " ==> type = request && pid = 111 && cmd = xeyes && major = SHM && minor = ShmAttach\n"
+ "\n"
+ "-----------------------------------------------------------------\n"
+ "Usage : xdbg evlog_rule add [POLICY] [RULE]\n"
+ " xdbg evlog_rule remove [INDEX]\n"
+ " xdbg evlog_rule file [RULE_FILE]\n"
+ " xdbg evlog_rule help / print\n"
+ " [POLICY] : allow / deny \n"
+ " [RULE] : C Language-style boolean expression syntax. [VARIABLE] [COMPAROTOR] [VALUE]\n"
+ " [VARIABLE] : type / major / minor / command / cmd / pid\n"
+ " [COMPARATOR] : & / && / and / | / || / or / = / == / != / > / >= / < / <=\n"
+ " [VALUE] : string / number \n"
+ "\n"
+ " ie)\n"
+ " xdbg evlog_rule add allow \"(type=request) && (major == X11 and (minor = SendEvent or minor = ReceiveEvent))\"\n"
+ " xdbg evlog_rule add deny cmd!=ls\n"
+ " xdbg evlog_rule remove 1\n"
+ "\n";
+}
+
+int rulechecker_validate_rule (RULE_CHECKER rc, int type, int reqID, const char * name, int pid, char * cmd)
+{
+ VAL_ARGUMENTS args = { type, reqID, name, pid, cmd };
+ BINARY_TREE_NODE node;
+ PARSE_DATA data;
+
+ // set default value here
+ POLICY_TYPE default_policy = DENY;
+ int i;
+ for (i=rc->count - 1; i >= 0; i--)
+ {
+ bintree_postorder_traverse (rc->rules[i].tree, validate_func, &args);
+ node = bintree_get_head (rc->rules[i].tree);
+ data = bintree_get_node_data (node);
+
+ if (data->result == BEP_TRUE)
+ {
+ return rc->rules[i].policy == ALLOW;
+ }
+ }
+
+ return default_policy == ALLOW;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _BOOL_EXP_RULE_CHECKER_H_
+#define _BOOL_EXP_RULE_CHECKER_H_
+
+typedef enum { UNDEFINED, ALLOW, DENY } POLICY_TYPE;
+
+typedef enum { RC_OK, RC_ERR_TOO_MANY_RULES, RC_ERR_PARSE_ERROR, RC_ERR_NO_RULE } RC_RESULT_TYPE;
+
+typedef struct _RULE_CHECKER * RULE_CHECKER;
+
+RULE_CHECKER rulechecker_init();
+
+void rulechecker_destroy (RULE_CHECKER rc);
+
+RC_RESULT_TYPE rulechecker_add_rule (RULE_CHECKER rc, POLICY_TYPE policy, const char * rule_string);
+
+RC_RESULT_TYPE rulechecker_remove_rule (RULE_CHECKER rc, int index);
+
+void rulechecker_print_rule (RULE_CHECKER rc, char *reply, int *len);
+
+const char * rulechecker_print_usage (void);
+
+int rulechecker_validate_rule (RULE_CHECKER rc, int direct, int reqID, const char * name, int pid, char * cmd);
+
+#endif /* _BOOL_EXP_RULE_CHECKER_H_ */
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _BOOL_EXP_TOKEN_H_
+#define _BOOL_EXP_TOKEN_H_
+
+typedef enum
+{
+ BET_UNKNOWN = 0,
+ BET_L_BR = 1,
+ BET_R_BR = 2,
+ BET_NOT_EQ = 3,
+ BET_EQUAL = 4,
+ BET_LSS_THAN = 5,
+ BET_LSS_EQ = 6,
+ BET_GRT_THAN = 7,
+ BET_GRT_EQ = 8,
+ BET_AND = 9,
+ BET_OR = 10,
+ BET_SPACE = 11,
+ BET_SYMBOL = 12,
+ BET_NUMBER = 13,
+ BET_EOS = 14,
+} TOKEN;
+
+#endif /* _BOOL_EXP_TOKEN_H_ */
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+#include "bool_exp_tokenizer.h"
+
+//#define debugf printf
+#define debugf(...)
+
+// should be increasing order for binary search
+static struct
+{
+ const char * token_char;
+ const int token_length;
+ TOKEN token_name;
+} token_table[] =
+{
+ { "\0", 1, BET_EOS }, // 0
+ { "\t", 1, BET_SPACE }, // 9
+ { " ", 1, BET_SPACE }, // 32
+ { "!=", 2, BET_NOT_EQ }, // 33 61
+ { "&", 1, BET_AND }, // 38
+ { "&&", 2, BET_AND }, // 38 38
+ { "(", 1, BET_L_BR }, // 40
+ { ")", 1, BET_R_BR }, // 41
+ { "<", 1, BET_LSS_THAN }, // 60
+ { "<=", 2, BET_LSS_EQ }, // 60 61
+ { "<>", 2, BET_NOT_EQ }, // 60 62
+ { "=", 1, BET_EQUAL }, // 61
+ { "==", 2, BET_EQUAL }, // 61 61
+ { ">", 1, BET_GRT_THAN }, // 62
+ { ">=", 2, BET_GRT_EQ }, // 62 61
+ { "and",3, BET_AND }, // 97 110
+ { "or", 2, BET_OR }, // 111 114
+ { "|", 1, BET_OR }, // 124
+ { "||", 2, BET_OR }, // 124 124
+};
+
+TOKEN get_next_token (const char ** string)
+{
+ static int token_cnt = sizeof (token_table) / sizeof (token_table[0]);
+ int i;
+ int first = 0;
+ int last = token_cnt - 1;
+ int compare_res;
+ int found = 0;
+
+ i = (first + last) / 2;
+ while (1)
+ {
+ compare_res = strncmp (*string, token_table[i].token_char, token_table[i].token_length);
+ debugf ("string [%s] token[%s] res = %d i=%d, first=%d, last=%d\n", *string, token_table[i].token_char, compare_res, i, first, last);
+ while (compare_res == 0)
+ {
+ found = 1;
+ i++;
+ if (i == token_cnt)
+ break;
+ compare_res = strncmp (*string, token_table[i].token_char, token_table[i].token_length);
+ debugf ("string [%s] token[%s] res = %d i=%d, first=%d, last=%d\n", *string, token_table[i].token_char, compare_res, i, first, last);
+ }
+ if (found)
+ {
+ i--;
+ *string += token_table[i].token_length;
+
+ return token_table[i].token_name;
+ }
+
+ if (first >= last)
+ break;
+
+ if (compare_res > 0)
+ {
+ first = i + 1;
+ }
+ else
+ {
+ last = i - 1;
+ }
+ i = (first + last) / 2;
+ }
+ if (isalpha (**string))
+ {
+ (*string) ++;
+ while (isalpha (**string) || isdigit (**string) || **string == '_' || **string == '-')
+ (*string) ++;
+ return BET_SYMBOL;
+ }
+ if (isdigit (**string))
+ {
+ (*string) ++;
+ while (isdigit (**string))
+ (*string) ++;
+ return BET_NUMBER;
+
+ }
+
+ return BET_UNKNOWN;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-exynos
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _BOOL_EXP_TOKENIZER_
+#define _BOOL_EXP_TOKENIZER_
+#include "bool_exp_token.h"
+
+TOKEN get_next_token (const char ** string);
+
+#endif /* _BOOL_EXP_TOKENIZER_ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __X_DEBUG_DBUS_H__
+#define __X_DEBUG_DBUS_H__
+
+#define XDBG_DBUS_INTERFACE "org.x.dbg.interface"
+#define XDBG_DBUS_CLIENT "org.x.dbg.client"
+#define XDBG_DBUS_METHOD "x_dbg_method"
+
+#define MDBUS XDBG_M('D','B','U','S')
+
+#endif /* __X_DEBUG_DBUS_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "xdbg_types.h"
+#include "xdbg_dbus_client.h"
+
+#define REPLY_TIME 1000
+#define STR_LEN 128
+
+struct _XDbgDBusClientInfo
+{
+ DBusConnection *conn;
+ char reqname[STR_LEN];
+ char client[STR_LEN];
+ int pid;
+ char xdbg_dbus_server[STR_LEN];
+ char xdbg_dbus_path[STR_LEN];
+};
+
+static DBusHandlerResult
+_xDbgDBusClinetMsgFilter (DBusConnection *conn, DBusMessage *msg, void *data)
+{
+ XDbgDBusClientInfo *info = (XDbgDBusClientInfo*)data;
+
+ /* If we get disconnected, then take everything down, and attempt to
+ * reconnect immediately (assuming it's just a restart). The
+ * connection isn't valid at this point, so throw it out immediately. */
+ if (dbus_message_is_signal (msg, DBUS_INTERFACE_LOCAL, "Disconnected"))
+ {
+ XDBG_LOG ("[CLIENT:%s] disconnected by signal\n", info->client);
+ info->conn = NULL;
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static Bool
+_xDbgDBusClinetInit (XDbgDBusClientInfo *info)
+{
+ DBusError err;
+ int ret;
+ char *display_num;
+
+ if(!(display_num = getenv("DISPLAY")))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: get DISPLAY ENV\n", info->client);
+ return FALSE;
+ }
+
+ snprintf(info->xdbg_dbus_server, sizeof(info->xdbg_dbus_path), "org.x.dbg.server%d", atoi(display_num));
+ snprintf(info->xdbg_dbus_path, sizeof(info->xdbg_dbus_path), "/org/x/dbg/path/%d", atoi(display_num));
+
+ XDBG_LOG ("[CLIENT:%s] display number :%d\n", info->client, atoi(display_num));
+
+ dbus_error_init (&err);
+ RETURN_VAL_IF_FAIL (info->conn == NULL, FALSE);
+
+ info->conn = dbus_bus_get (DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: connection (%s)\n", info->client, err.message);
+ goto err_get;
+ }
+ if (!info->conn)
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: connection NULL\n", info->client);
+ goto err_get;
+ }
+
+ dbus_connection_set_exit_on_disconnect (info->conn, FALSE);
+
+ if (!dbus_connection_add_filter (info->conn, _xDbgDBusClinetMsgFilter, info, NULL))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: add filter (%s)\n", info->client, err.message);
+ goto err_get;
+ }
+
+ ret = dbus_bus_request_name (info->conn, info->reqname,
+ DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: request name (%s)\n", info->client, err.message);
+ goto err_request;
+ }
+ if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: Not Primary Owner (%d)\n", info->client, ret);
+ goto err_request;
+ }
+
+ dbus_error_free (&err);
+
+// XDBG_LOG ("[CLIENT:%s] connected\n", info->client);
+
+ return TRUE;
+
+err_request:
+ dbus_connection_remove_filter (info->conn, _xDbgDBusClinetMsgFilter, info);
+
+err_get:
+ if (info->conn)
+ {
+ dbus_connection_unref (info->conn);
+ info->conn = NULL;
+ }
+
+ dbus_error_free (&err);
+
+ return FALSE;
+}
+
+
+static void
+_xDbgDBusClinetDeinit (XDbgDBusClientInfo *info)
+{
+ DBusError err;
+
+ if (!info->conn)
+ return;
+
+ dbus_error_init (&err);
+ dbus_bus_release_name (info->conn, info->reqname, &err);
+ if (dbus_error_is_set (&err))
+ XDBG_LOG ("[CLIENT:%s] failed: release name (%s)\n", info->client, err.message);
+ dbus_error_free (&err);
+
+ dbus_connection_remove_filter (info->conn, _xDbgDBusClinetMsgFilter, info);
+ dbus_connection_unref (info->conn);
+ info->conn = NULL;
+
+// XDBG_LOG ("[CLIENT:%s] disconnected\n", info->client);
+}
+
+XDbgDBusClientInfo*
+xDbgDBusClientConnect (void)
+{
+ XDbgDBusClientInfo *info = NULL;
+
+ info = calloc (1, sizeof (XDbgDBusClientInfo));
+ GOTO_IF_FAIL (info != NULL, err_conn);
+
+ snprintf (info->client, STR_LEN, "%d", getpid());
+ snprintf (info->reqname, STR_LEN, "%s%d", XDBG_DBUS_CLIENT, getpid());
+
+ if (!_xDbgDBusClinetInit (info))
+ goto err_conn;
+
+ return info;
+
+err_conn:
+ if (info)
+ free (info);
+
+ return NULL;
+}
+
+void
+xDbgDBusClientDisconnect (XDbgDBusClientInfo* info)
+{
+ if (!info)
+ return;
+
+ _xDbgDBusClinetDeinit (info);
+
+ free (info);
+}
+
+void
+xDbugDBusClientSendMessage (XDbgDBusClientInfo *info, int argc, char **argv)
+{
+ DBusMessage *msg = NULL;
+ DBusMessage *reply_msg = NULL;
+ DBusMessageIter iter;
+ DBusError err;
+ char *arg = NULL;
+ int i;
+
+ RETURN_IF_FAIL (info != NULL);
+ RETURN_IF_FAIL (info->conn != NULL);
+ RETURN_IF_FAIL (argc > 0);
+ RETURN_IF_FAIL (argv[0] != '\0');
+
+ dbus_error_init (&err);
+
+ msg = dbus_message_new_method_call (info->xdbg_dbus_server, info->xdbg_dbus_path,
+ XDBG_DBUS_INTERFACE, XDBG_DBUS_METHOD);
+ GOTO_IF_FAIL (msg != NULL, err_send);
+
+ dbus_message_iter_init_append (msg, &iter);
+ for (i = 0; i < argc; i++)
+ if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &argv[i]))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: append\n", info->client);
+ goto err_send;
+ }
+
+ reply_msg = dbus_connection_send_with_reply_and_block (info->conn, msg,
+ REPLY_TIME, &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_LOG ("[CLIENT:%s] failed: send (%s)\n", info->client, err.message);
+ goto err_send;
+ }
+ GOTO_IF_FAIL (reply_msg != NULL, err_send);
+
+ if (!dbus_message_iter_init (reply_msg, &iter))
+ {
+ XDBG_LOG ("[CLIENT:%s] Message has no arguments\n", info->client);
+ goto err_send;
+ }
+
+ do
+ {
+ arg = NULL;
+
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ {
+ XDBG_LOG ("[CLIENT:%s] Argument is not string!\n", info->client);
+ goto err_send;
+ }
+
+ dbus_message_iter_get_basic (&iter, &arg);
+ if (!arg)
+ {
+ XDBG_LOG ("[CLIENT:%s] arg is NULL\n", info->client);
+ goto err_send;
+ }
+ else
+ XDBG_LOG ("%s\n", arg);
+ } while (dbus_message_iter_has_next (&iter) &&
+ dbus_message_iter_next (&iter));
+
+err_send:
+ if (msg)
+ dbus_message_unref(msg);
+ if (reply_msg)
+ dbus_message_unref(reply_msg);
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __X_DEBUG_DBUS_CLIENT_H__
+#define __X_DEBUG_DBUS_CLIENT_H__
+
+#include <dbus/dbus.h>
+
+#include "xdbg_dbus.h"
+
+typedef struct _XDbgDBusClientInfo XDbgDBusClientInfo;
+
+XDbgDBusClientInfo* xDbgDBusClientConnect (void);
+void xDbgDBusClientDisconnect (XDbgDBusClientInfo *info);
+void xDbugDBusClientSendMessage (XDbgDBusClientInfo *info,
+ int argc, char **argv);
+
+#endif /* __X_DEBUG_DBUS_CLIENT_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dbus/dbus.h>
+#include <os.h>
+#include <dix.h>
+
+#include "xdbg.h"
+#include "xdbg_types.h"
+#include "xdbg_dbus_server.h"
+
+#define ARGV_NUM 128
+#define REP_MSG_SIZE 8192
+#define STR_LEN 128
+
+#define RECONNECT_TIME 1000
+#define DISPATCH_TIME 50
+
+extern _X_EXPORT char *display;
+
+typedef struct _XDbgDBusServerInfo
+{
+ OsTimerPtr timer;
+ DBusConnection *conn;
+ XDbgDbusServerMethod *methods;
+ char rule[STR_LEN];
+ int fd;
+ char xdbg_dbus_server[STR_LEN];
+ char xdbg_dbus_path[STR_LEN];
+} XDbgDBusServerInfo;
+
+static XDbgDBusServerInfo server_info;
+
+static CARD32 _xDbgDBusServerTimeout (OsTimerPtr timer, CARD32 time, pointer arg);
+static Bool _xDbgDBusServerInit (XDbgDBusServerInfo *info);
+static void _xDbgDBusServerDeinit (XDbgDBusServerInfo *info);
+
+static Bool
+_xDbgDBusServerReplyMessage (XDbgDBusServerInfo *info, DBusMessage *msg, char *reply)
+{
+ DBusMessage *reply_msg = NULL;
+ DBusMessageIter iter;
+
+ XDBG_RETURN_VAL_IF_FAIL (info->conn != NULL, FALSE);
+
+ reply_msg = dbus_message_new_method_return (msg);
+ XDBG_RETURN_VAL_IF_FAIL (reply_msg != NULL, FALSE);
+
+ dbus_message_iter_init_append (reply_msg, &iter);
+ if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &reply))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] out of memory\n");
+ dbus_message_unref (reply_msg);
+ return FALSE;
+ }
+
+ if (!dbus_connection_send (info->conn, reply_msg, NULL))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: send reply\n");
+ dbus_message_unref (reply_msg);
+ return FALSE;
+ }
+
+ XDBG_DEBUG (MDBUS, "[SERVER] send reply\n");
+
+ dbus_connection_flush (info->conn);
+ dbus_message_unref (reply_msg);
+
+ return TRUE;
+}
+
+static void
+_xDbgDBusServerProcessMessage (XDbgDBusServerInfo *info, DBusMessage *msg)
+{
+ XDbgDbusServerMethod **prev;
+ DBusError err;
+ char err_buf[REP_MSG_SIZE] = {0,};
+ char *argv[ARGV_NUM] = {0,};
+ int argc = 0;
+ int i;
+
+ snprintf (err_buf, REP_MSG_SIZE, "error message!\n");
+
+ dbus_error_init (&err);
+
+ XDBG_DEBUG (MDBUS, "[SERVER] Process a message (%s.%s)\n",
+ dbus_message_get_interface (msg), dbus_message_get_member (msg));
+
+ XDBG_RETURN_IF_FAIL (info->conn != NULL);
+
+ for (prev = &info->methods; *prev; prev = &(*prev)->next)
+ {
+ XDbgDbusServerMethod *method = *prev;
+
+ if (!strcmp (dbus_message_get_member (msg), method->name))
+ {
+ DBusMessageIter iter;
+ char reply[REP_MSG_SIZE] = {0,};
+ char *p;
+ int len;
+
+ if (!dbus_message_iter_init (msg, &iter))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] Message has no arguments!\n");
+ snprintf (err_buf, REP_MSG_SIZE, "Message has no arguments!\n");
+ goto send_fail;
+ }
+
+ do
+ {
+ p = NULL;
+
+ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] Argument is not string!\n");
+ snprintf (err_buf, REP_MSG_SIZE, "Argument is not string!\n");
+ goto send_fail;
+ }
+
+ dbus_message_iter_get_basic (&iter, &p);
+
+ if (!p)
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] Can't get string!\n");
+ snprintf (err_buf, REP_MSG_SIZE, "Can't get string!\n");
+ goto send_fail;
+ }
+
+ argv[argc] = strdup (p);
+ argc++;
+ } while (dbus_message_iter_has_next (&iter) &&
+ dbus_message_iter_next (&iter) &&
+ argc < ARGV_NUM);
+
+ len = REP_MSG_SIZE - 1;
+
+ if (method->func)
+ method->func (method->data, argc, argv, reply, &len);
+
+ _xDbgDBusServerReplyMessage (info, msg, reply);
+
+ for (i = 0; i < ARGV_NUM; i++)
+ if (argv[i])
+ free (argv[i]);
+ dbus_error_free (&err);
+
+ return;
+ }
+ }
+
+ return;
+
+send_fail:
+ _xDbgDBusServerReplyMessage (info, msg, err_buf);
+
+ for (i = 0; i < ARGV_NUM; i++)
+ if (argv[i])
+ free (argv[i]);
+ dbus_error_free (&err);
+}
+
+static void
+_xDbgDBusServerWakeupHandler (pointer data, int error, pointer pRead)
+{
+ XDbgDBusServerInfo *info = (XDbgDBusServerInfo*)data;
+
+ if (!info || !info->conn || info->fd < 0)
+ return;
+
+ if (FD_ISSET(info->fd, (fd_set*)pRead))
+ {
+ do {
+ dbus_connection_read_write_dispatch (info->conn, 0);
+ } while (info->conn &&
+ dbus_connection_get_is_connected (info->conn) &&
+ dbus_connection_get_dispatch_status (info->conn) ==
+ DBUS_DISPATCH_DATA_REMAINS);
+
+ /* DON'T use info->conn from here. info->conn becomes NULL by
+ * dbus_connection_read_write_dispatch(_xDbgDBusServerMsgFilter)
+ */
+ }
+}
+
+static DBusHandlerResult
+_xDbgDBusServerMsgHandler (DBusConnection *connection, DBusMessage *msg, void *data)
+{
+ XDbgDBusServerInfo *info = (XDbgDBusServerInfo*)data;
+
+ if (!info || !info->conn || !msg)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ XDBG_DEBUG (MDBUS, "[SERVER] Got a message (%s.%s)\n",
+ dbus_message_get_interface (msg), dbus_message_get_member (msg));
+
+ if (!dbus_message_is_method_call (msg, XDBG_DBUS_INTERFACE, XDBG_DBUS_METHOD))
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ _xDbgDBusServerProcessMessage (info, msg);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult
+_xDbgDBusServerMsgFilter (DBusConnection *conn, DBusMessage *msg, void *data)
+{
+ XDbgDBusServerInfo *info = (XDbgDBusServerInfo*)data;
+
+ if (!info)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (dbus_message_is_signal (msg, DBUS_INTERFACE_LOCAL, "Disconnected"))
+ {
+ XDBG_DEBUG (MDBUS, "[SERVER] disconnected by signal\n");
+ _xDbgDBusServerDeinit (info);
+
+ if (info->timer)
+ TimerFree(info->timer);
+ info->timer = TimerSet(NULL, 0, 1, _xDbgDBusServerTimeout, info);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static CARD32
+_xDbgDBusServerTimeout (OsTimerPtr timer, CARD32 time, pointer arg)
+{
+ XDbgDBusServerInfo *info = (XDbgDBusServerInfo*)arg;
+
+ if (!info)
+ return 0;
+
+ XDBG_DEBUG (MDBUS, "[SERVER] timeout\n");
+
+ if (_xDbgDBusServerInit (info))
+ {
+ TimerFree (info->timer);
+ info->timer = NULL;
+ return 0;
+ }
+
+ return RECONNECT_TIME;
+}
+
+static Bool
+_xDbgDBusServerInit (XDbgDBusServerInfo *info)
+{
+ DBusObjectPathVTable vtable = {.message_function = _xDbgDBusServerMsgHandler, };
+ DBusError err;
+ int ret;
+
+ dbus_error_init (&err);
+
+ XDBG_RETURN_VAL_IF_FAIL (info->conn == NULL, FALSE);
+
+ snprintf(info->xdbg_dbus_server, sizeof(info->xdbg_dbus_server), "org.x.dbg.server%d", atoi(display));
+ snprintf(info->xdbg_dbus_path, sizeof(info->xdbg_dbus_path), "/org/x/dbg/path/%d", atoi(display));
+
+ XDBG_DEBUG (MDBUS, "[SERVER] display number %d\n", atoi(display));
+
+ info->conn = dbus_bus_get (DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: connection (%s)\n", err.message);
+ goto free_err;
+ }
+ if (!info->conn)
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: connection NULL\n");
+ goto free_err;
+ }
+
+ ret = dbus_bus_request_name (info->conn, info->xdbg_dbus_server,
+ DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: request name (%s)\n", err.message);
+ goto free_conn;
+ }
+ if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: Not Primary Owner (%d)\n", ret);
+ goto free_conn;
+ }
+
+ snprintf (info->rule, sizeof (info->rule), "type='method_call',interface='%s'",
+ XDBG_DBUS_INTERFACE);
+
+ /* blocks until we get a reply. */
+ dbus_bus_add_match (info->conn, info->rule, &err);
+ if (dbus_error_is_set (&err))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: add match (%s)\n", err.message);
+ goto free_name;
+ }
+
+ if (!dbus_connection_register_object_path (info->conn,
+ info->xdbg_dbus_path, &vtable,
+ info))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: register object path\n");
+ goto free_match;
+ }
+
+ dbus_connection_set_exit_on_disconnect (info->conn, FALSE);
+
+ if (!dbus_connection_add_filter (info->conn, _xDbgDBusServerMsgFilter, info, NULL))
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: add filter (%s)\n", err.message);
+ goto free_register;
+ }
+
+ if (!dbus_connection_get_unix_fd (info->conn, &info->fd) || info->fd < 0)
+ {
+ XDBG_ERROR (MDBUS, "[SERVER] failed: get fd\n");
+ goto free_filter;
+ }
+
+ AddGeneralSocket (info->fd);
+ RegisterBlockAndWakeupHandlers ((BlockHandlerProcPtr)NoopDDA,
+ _xDbgDBusServerWakeupHandler, info);
+
+ XDBG_INFO (MDBUS, "[SERVER] connected\n");
+
+ dbus_error_free (&err);
+
+ return TRUE;
+
+free_filter:
+ dbus_connection_remove_filter (info->conn, _xDbgDBusServerMsgFilter, info);
+free_register:
+ dbus_connection_unregister_object_path (info->conn, info->xdbg_dbus_path);
+free_match:
+ dbus_bus_remove_match (info->conn, info->rule, &err);
+ dbus_error_free (&err);
+free_name:
+ dbus_bus_release_name (info->conn, info->xdbg_dbus_server, &err);
+ dbus_error_free (&err);
+free_conn:
+ dbus_connection_close (info->conn);
+free_err:
+ dbus_error_free (&err);
+ info->conn = NULL;
+ info->fd = -1;
+
+ return FALSE;
+}
+
+static void
+_xDbgDBusServerDeinit (XDbgDBusServerInfo *info)
+{
+ if (info->timer)
+ {
+ TimerFree (info->timer);
+ info->timer = NULL;
+ }
+
+ if (info->conn)
+ {
+ DBusError err;
+ dbus_error_init (&err);
+ dbus_connection_remove_filter (info->conn, _xDbgDBusServerMsgFilter, info);
+ dbus_connection_unregister_object_path (info->conn, info->xdbg_dbus_path);
+ dbus_bus_remove_match (info->conn, info->rule, &err);
+ dbus_error_free (&err);
+ dbus_bus_release_name (info->conn, info->xdbg_dbus_server, &err);
+ dbus_error_free (&err);
+ dbus_connection_unref (info->conn);
+ info->conn = NULL;
+ }
+
+ RemoveBlockAndWakeupHandlers ((BlockHandlerProcPtr)NoopDDA,
+ _xDbgDBusServerWakeupHandler, info);
+ if (info->fd >= 0)
+ {
+ RemoveGeneralSocket (info->fd);
+ info->fd = -1;
+ }
+
+ XDBG_INFO (MDBUS, "[SERVER] disconnected\n");
+}
+
+Bool
+xDbgDBusServerConnect (void)
+{
+ XDBG_DEBUG (MDBUS, "[SERVER] connecting\n");
+
+ memset (&server_info, 0, sizeof(server_info));
+
+ server_info.fd = -1;
+ server_info.timer = TimerSet (NULL, 0, 1, _xDbgDBusServerTimeout, &server_info);
+
+ return TRUE;
+}
+
+void
+xDbgDBusServerDisconnect (void)
+{
+ XDBG_DEBUG (MDBUS, "[SERVER] disconnecting\n");
+
+ _xDbgDBusServerDeinit (&server_info);
+}
+
+Bool
+xDbgDBusServerAddMethod (XDbgDbusServerMethod *method)
+{
+ XDbgDbusServerMethod **prev;
+
+ for (prev = &server_info.methods; *prev; prev = &(*prev)->next);
+
+ method->next = NULL;
+ *prev = method;
+
+ return TRUE;
+}
+
+void
+xDbgDBusServerRemoveMethod (XDbgDbusServerMethod *method)
+{
+ XDbgDbusServerMethod **prev;
+
+ for (prev = &server_info.methods; *prev; prev = &(*prev)->next)
+ if (*prev == method)
+ {
+ *prev = method->next;
+ break;
+ }
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __X_DEBUG_DBUS_SERVER_H__
+#define __X_DEBUG_DBUS_SERVER_H__
+
+#include <dbus/dbus.h>
+
+#include "xdbg_dbus.h"
+
+typedef void (*MethodFunc) (void *data, int argc, char **argv, char *reply, int *len);
+
+typedef struct _XDbgDbusServerMethod
+{
+ char name[128];
+ MethodFunc func;
+ void *data;
+
+ struct _XDbgDbusServerMethod *next;
+} XDbgDbusServerMethod;
+
+Bool xDbgDBusServerAddMethod (XDbgDbusServerMethod *method);
+void xDbgDBusServerRemoveMethod (XDbgDbusServerMethod *method);
+Bool xDbgDBusServerConnect (void);
+void xDbgDBusServerDisconnect (void);
+
+#endif /* __X_DEBUG_DBUS_SERVER_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+#include <X11/Xlib.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog.h"
+#include "bool_exp_rule_checker.h"
+#include <X11/Xlibint.h>
+
+#ifndef XDBG_CLIENT
+#include "resource.h"
+#include "region.h"
+#include "dix.h"
+#endif
+
+static char *evt_type[] = { "Event", "Request", "Reply", "Flush", "Error" };
+static char *evt_dir[] = { "<====", "---->", "<----", "*****", "<----"};
+
+static RULE_CHECKER rc = NULL;
+
+static void
+_mergeArgs (char *target, int target_size, int argc, const char ** argv)
+{
+ int i;
+ int len;
+
+ for (i=0; i<argc; i++)
+ {
+ len = snprintf (target, target_size, "%s", argv[i]);
+ target += len;
+ target_size -= len;
+
+ if (i != argc - 1)
+ {
+ *(target++) = ' ';
+ target_size--;
+ }
+ }
+}
+
+static int
+_strcasecmp(const char *str1, const char *str2)
+{
+ const u_char *us1 = (const u_char *) str1, *us2 = (const u_char *) str2;
+
+ while (tolower(*us1) == tolower(*us2)) {
+ if (*us1++ == '\0')
+ return 0;
+ us2++;
+ }
+
+ return (tolower(*us1) - tolower(*us2));
+}
+
+char*
+xDbgEvlogGetCmd (char *path)
+{
+ char *p;
+ if (!path)
+ return NULL;
+ p = strrchr (path, '/');
+ return (p)?p+1:path;
+}
+
+Bool
+xDbgEvlogRuleSet (const int argc, const char **argv, char *reply, int *len)
+{
+ const char * command;
+
+ if (rc == NULL)
+ rc = rulechecker_init();
+
+ if (argc == 0)
+ {
+ rulechecker_print_rule (rc, reply, len);
+ return TRUE;
+ }
+
+ command = argv[0];
+
+ if (!_strcasecmp (command, "add"))
+ {
+ POLICY_TYPE policy_type;
+ RC_RESULT_TYPE result;
+ const char * policy = argv[1];
+ char merge[8192]={0,}, rule[8192]={0,};
+ int i, index = 0, size_rule;
+ int apply = 0;
+
+ if (argc < 3)
+ {
+ REPLY ("Error : Too few arguments.\n");
+ return FALSE;
+ }
+
+ if (!_strcasecmp (policy, "ALLOW"))
+ policy_type = ALLOW;
+ else if (!_strcasecmp (policy, "DENY"))
+ policy_type = DENY;
+ else
+ {
+ REPLY ("Error : Unknown policy : [%s].\n Policy should be ALLOW or DENY.\n", policy);
+ return FALSE;
+ }
+
+ _mergeArgs (merge, sizeof (merge), argc - 2, &(argv[2]));
+
+ size_rule = sizeof (rule) - 1;
+
+ for (i = 0 ; i < strlen(merge) ; i++)
+ {
+ if(merge[i] == '\"' || merge[i] == '\'')
+ {
+ rule[index++] = ' ';
+ if (index > size_rule)
+ return FALSE;
+
+ continue;
+ }
+
+ if(merge[i] == '+')
+ {
+ rule[index++] = ' ';
+ if (index > size_rule)
+ return FALSE;
+
+ if (apply == 0)
+ {
+ const char* plus = "|| type=reply || type=error";
+ int len = MIN (size_rule - index, strlen(plus));
+ strncat(rule, plus, len);
+ index += len;
+ if (index > size_rule)
+ return FALSE;
+
+ apply = 1;
+ }
+ continue;
+ }
+ rule[index++] = merge[i];
+ if (index > size_rule)
+ return FALSE;
+ }
+
+ result = rulechecker_add_rule (rc, policy_type, rule);
+ if (result == RC_ERR_TOO_MANY_RULES)
+ {
+ REPLY ("Error : Too many rules were added.\n");
+ return FALSE;
+ }
+ else if (result == RC_ERR_PARSE_ERROR)
+ {
+ REPLY ("Error : An error occured during parsing the rule [%s]\n", rule);
+ return FALSE;
+ }
+
+ REPLY ("The rule was successfully added.\n\n");
+ rulechecker_print_rule (rc, reply, len);
+ return TRUE;
+ }
+ else if (!_strcasecmp (command, "remove"))
+ {
+ const char * remove_idx;
+ int i;
+
+ if (argc < 2)
+ {
+ REPLY ("Error : Too few arguments.\n");
+ return FALSE;
+ }
+
+ for (i=0; i<argc - 1; i++)
+ {
+ remove_idx = argv[i+1];
+
+ if (!_strcasecmp (remove_idx, "all"))
+ {
+ rulechecker_destroy (rc);
+ rc = rulechecker_init();
+ REPLY ("Every rules were successfully removed.\n");
+ }
+ else
+ {
+ int index = atoi (remove_idx);
+ if (isdigit (*remove_idx) && rulechecker_remove_rule (rc, index) == 0)
+ REPLY ("The rule [%d] was successfully removed.\n", index);
+ else
+ REPLY ("Rule remove fail : No such rule [%s].\n", remove_idx);
+ }
+ }
+ rulechecker_print_rule (rc, reply, len);
+ return TRUE;
+ }
+ else if (!_strcasecmp (command, "file"))
+ {
+ if (argc < 2)
+ {
+ REPLY ("Error : Too few arguments.\n");
+ return FALSE;
+ }
+
+ if (!xDbgEvlogReadRuleFile(argv[1], reply, len))
+ return FALSE;
+ rulechecker_print_rule (rc, reply, len);
+
+ return TRUE;
+ }
+ else if (!_strcasecmp (command, "print"))
+ {
+ rulechecker_print_rule (rc, reply, len);
+ return TRUE;
+ }
+ else if (!_strcasecmp (command, "help"))
+ {
+ REPLY ("%s", rulechecker_print_usage());
+ return TRUE;
+ }
+
+ REPLY ("%s\nUnknown command : [%s].\n\n", rulechecker_print_usage(), command);
+
+ return TRUE;
+}
+
+Bool
+xDbgEvlogRuleValidate (EvlogInfo *evinfo)
+{
+ const char *evlog_name = "";
+ char *cmd = "";
+
+ if (rc == NULL)
+ rc = rulechecker_init ();
+
+ if (!rc)
+ {
+ XDBG_LOG ("failed: create rulechecker\n");
+ return FALSE;
+ }
+
+ cmd = xDbgEvlogGetCmd (evinfo->client.command);
+
+ if (evinfo->type == REQUEST)
+ evlog_name = evinfo->req.name;
+ else if (evinfo->type == EVENT)
+ evlog_name = evinfo->evt.name;
+ else if (evinfo ->type == REPLY)
+ evlog_name = evinfo->rep.name;
+
+ return rulechecker_validate_rule (rc,
+ evinfo->type,
+ evinfo->req.id,
+ evlog_name,
+ evinfo->client.pid,
+ cmd);
+}
+
+Bool
+xDbgEvlogReadRuleFile(const char *filename, char *reply, int *len)
+{
+ int fd = -1;
+ char fs[8096];
+ char *pfs;
+ int rule_len;
+
+ fd = open (filename, O_RDONLY);
+ if (fd < 0)
+ {
+ REPLY ("failed: open '%s'. (%s)\n", filename, strerror(errno));
+ return FALSE;
+ }
+
+ rule_len = read(fd, fs, sizeof(fs));
+ pfs = fs;
+
+ while (pfs - fs < rule_len)
+ {
+ int new_argc = 3;
+ char *new_argv[3] = {"add", };
+ char policy[64] = {0, };
+ char rule[1024] = {0, };
+ int i;
+
+ if (pfs[0] == ' ' || pfs[0] == '\n')
+ {
+ pfs++;
+ continue;
+ }
+ for (i = 0 ; pfs[i] != ' ' ; i++)
+ policy[i] = pfs[i];
+
+ new_argv[1] = policy;
+ pfs += (strlen(new_argv[1]) + 1);
+
+ memset(rule, 0, sizeof(rule));
+ for (i = 0 ; pfs[i] != '\n' ; i++)
+ rule[i] = pfs[i];
+
+ new_argv[2] = rule;
+
+ pfs += (strlen(new_argv[2]) + 1);
+
+ if(!xDbgEvlogRuleSet ((const int) new_argc, (const char**) new_argv, reply, len))
+ {
+ if (fd >= 0)
+ close (fd);
+
+ return FALSE;
+ }
+ }
+
+ if (fd >= 0)
+ close (fd);
+
+ return TRUE;
+}
+
+ExtensionInfo Evlog_extensions[] = {
+ {xDbgEvlogCompositeGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogDamageGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogDri2GetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogGestureGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXinputGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogRandrGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextDpmsGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextShmGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextSyncGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextXtestGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextXtestExt1GetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXextShapeGetBase, 0, 0, 0, NULL, NULL},
+ {xDbgEvlogXvGetBase, 0, 0, 0, NULL, NULL},
+#if HAVE_HWC
+ {xDbgEvlogHwcGetBase, 0, 0, 0, NULL, NULL},
+#endif
+};
+
+ExtensionInfo* Sorted_Evlog_extensions;
+int Extensions_size = 0;
+
+static void
+_ExtensionsSwap(ExtensionInfo* first, ExtensionInfo* second)
+{
+ ExtensionInfo temp;
+
+ temp = *first ;
+ *first = *second ;
+ *second = temp ;
+}
+
+static Bool
+_SortEvlogExtensions ()
+{
+ int i,j;
+ int swap;
+
+ Sorted_Evlog_extensions = (ExtensionInfo*)malloc(sizeof(Evlog_extensions));
+ RETURN_VAL_IF_FAIL (Sorted_Evlog_extensions != NULL, FALSE);
+
+ memcpy(Sorted_Evlog_extensions, Evlog_extensions, sizeof(Evlog_extensions));
+
+ for (i = 0 ; i < Extensions_size - 1 ; i++)
+ {
+ swap = 0;
+ for (j = 1 ; j < Extensions_size - i ; j++)
+ {
+ if(Sorted_Evlog_extensions[j-1].evt_base > Sorted_Evlog_extensions[j].evt_base)
+ {
+ _ExtensionsSwap(&Sorted_Evlog_extensions[j-1], &Sorted_Evlog_extensions[j]);
+ swap = 1;
+ }
+ }
+ if (!swap) break;
+ }
+
+ return TRUE;
+}
+
+
+Bool
+xDbgEvlogGetExtensionEntry ()
+{
+ static int init = 0;
+ static Bool success = FALSE;
+ int i;
+
+ if (init)
+ return success;
+
+ init = 1;
+ Extensions_size = sizeof(Evlog_extensions) / sizeof (ExtensionInfo);
+
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ Evlog_extensions[i].get_base_func (Evlog_extensions + i);
+ }
+
+ if(!_SortEvlogExtensions ())
+ return FALSE;
+
+
+ success = TRUE;
+
+ return success;
+}
+
+
+Bool
+xDbgEvlogFillLog (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ static CARD32 prev;
+
+ RETURN_VAL_IF_FAIL (evinfo->type >= 0 && (sizeof (evt_dir) / sizeof (char*)), FALSE);
+ RETURN_VAL_IF_FAIL (evinfo->type >= 0 && (sizeof (evt_type) / sizeof (char*)), FALSE);
+
+ if (evinfo->type == REPLY && !evinfo->rep.isStart)
+ {
+ if (detail_level >= EVLOG_PRINT_REPLY_DETAIL)
+ REPLY ("%67s"," ");
+ else
+ return FALSE;
+ }
+ else
+ REPLY ("[%10.3f][%5ld] %22s(%2d:%5d) %s %7s ",
+ evinfo->time / 1000.0,
+ (long int)evinfo->time - prev,
+ xDbgEvlogGetCmd (evinfo->client.command),
+ evinfo->client.index,
+ evinfo->client.pid,
+ evt_dir[evinfo->type],
+ evt_type[evinfo->type]);
+
+ if (evinfo->type == REQUEST)
+ {
+ REPLY ("(");
+ reply = xDbgEvlogReqeust (evinfo, detail_level, reply, len);
+ REPLY (")");
+ }
+ else if (evinfo->type == EVENT)
+ {
+ evinfo->evt.size = sizeof (xEvent);
+ REPLY ("(");
+ reply = xDbgEvlogEvent (evinfo, detail_level, reply, len);
+ REPLY (")");
+ }
+ else if (evinfo->type == REPLY)
+ {
+ REPLY ("(");
+ reply = xDbgEvlogReply (evinfo, detail_level, reply, len);
+ REPLY (")");
+ }
+ else if (evinfo->type == ERROR)
+ {
+ REPLY("(ErrorCode(0x%02x) resourceID(0x%x) majorCode(%d) minorCode(%d))",
+ evinfo->err.errorCode,
+ (unsigned int)evinfo->err.resourceID,
+ evinfo->err.majorCode,
+ evinfo->err.minorCode);
+ }
+ else
+ {
+ const char *evlog_name = "";
+ if (evinfo->type == REQUEST)
+ evlog_name = evinfo->req.name;
+ else if (evinfo->type == EVENT)
+ evlog_name = evinfo->evt.name;
+ else if (evinfo->type == REPLY)
+ evlog_name = evinfo->rep.name;
+ REPLY ("(%s)", evlog_name);
+ }
+
+ REPLY ("\n");
+
+ prev = evinfo->time;
+
+ return TRUE;
+}
+
+
+void xDbgDistroyAtomList (EvlogInfo *evinfo)
+{
+ EvlogAtomTable *cur = NULL, *next = NULL;
+
+ if (!evinfo->evatom.init)
+ return;
+
+ xorg_list_for_each_entry_safe(cur, next, &evinfo->evatom.list, link)
+ {
+ xorg_list_del(&cur->link);
+ free (cur);
+ cur = NULL;
+ }
+ evinfo->evatom.init = 0;
+ evinfo->evatom.size = 0;
+}
+
+void xDbgDistroyRegionList (EvlogInfo *evinfo)
+{
+ EvlogRegionTable *cur = NULL, *next = NULL;
+
+ if (!evinfo->evregion.init)
+ return;
+
+ xorg_list_for_each_entry_safe(cur, next, &evinfo->evregion.list, link)
+ {
+ xorg_list_del(&cur->link);
+ free (cur);
+ cur = NULL;
+ }
+ evinfo->evregion.init = 0;
+ evinfo->evregion.size = 0;
+}
+
+char* xDbgGetAtom(Atom atom, EvlogInfo *evinfo, char *reply, int *len)
+{
+ EvlogAtomTable *table;
+#ifndef XDBG_CLIENT
+ table = malloc (sizeof(EvlogAtomTable));
+ if (!table)
+ return reply;
+
+ evinfo->mask |= EVLOG_MASK_ATOM;
+ table->xid = atom;
+
+ if (!evinfo->evatom.init)
+ {
+ xorg_list_init(&evinfo->evatom.list);
+ evinfo->evatom.init = 1;
+ }
+
+ if (NameForAtom(atom))
+ snprintf (table->buf, XDBG_BUF_SIZE, "%s", (char*)NameForAtom(atom));
+ else
+ snprintf (table->buf, XDBG_BUF_SIZE, "0x%x", (unsigned int)atom);
+
+ xorg_list_add(&table->link, &evinfo->evatom.list);
+ evinfo->evatom.size++;
+#endif
+ xorg_list_for_each_entry(table, &evinfo->evatom.list, link)
+ if(table->xid == atom)
+ {
+ REPLY ("(%s)", table->buf);
+ break;
+ }
+
+ return reply;
+}
+
+char* xDbgGetRegion(XserverRegion region, EvlogInfo *evinfo, char *reply, int *len)
+{
+ EvlogRegionTable *table;
+#ifndef XDBG_CLIENT
+ extern _X_EXPORT RESTYPE RegionResType;
+ RegionPtr pRegion;
+ BoxPtr rects;
+ int nrect, i;
+ int s;
+ int err = dixLookupResourceByType((pointer *) &pRegion, region,
+ RegionResType, (ClientPtr)evinfo->client.pClient,
+ DixReadAccess);
+
+ evinfo->mask |= EVLOG_MASK_REGION;
+
+ if (!evinfo->evregion.init)
+ {
+ xorg_list_init(&evinfo->evregion.list);
+ evinfo->evregion.init = 1;
+ }
+
+ if (err != Success)
+ {
+ table = malloc (sizeof(EvlogAtomTable));
+ if (!table)
+ return reply;
+
+ table->xid = region;
+
+ snprintf (table->buf, XDBG_BUF_SIZE, "0x%x", (unsigned int)region);
+ xorg_list_add(&table->link, &evinfo->evregion.list);
+ evinfo->evregion.size++;
+ }
+ else
+ {
+ nrect = RegionNumRects(pRegion);
+ rects = RegionRects(pRegion);
+
+ for (i = 0; i < nrect; i++)
+ {
+ table = malloc (sizeof(EvlogAtomTable));
+ if (!table)
+ return reply;
+
+ table->xid = region;
+
+ s = 0;
+ s += snprintf (table->buf + s, XDBG_BUF_SIZE - s,
+ "[%d,%d %dx%d]",
+ rects[i].x1,
+ rects[i].y1,
+ rects[i].x2 - rects[i].x1,
+ rects[i].y2 - rects[i].y1);
+ xorg_list_add(&table->link, &evinfo->evregion.list);
+ evinfo->evregion.size++;
+ }
+ }
+
+#endif
+ REPLY("(");
+ xorg_list_for_each_entry(table, &evinfo->evregion.list, link)
+ if(table->xid == region)
+ {
+ REPLY ("%s", table->buf);
+ if(table != xorg_list_last_entry(&evinfo->evregion.list, EvlogRegionTable, link))
+ REPLY (", ");
+ }
+ REPLY(")");
+
+ return reply;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_H__
+#define __XDBG_EVLOG_H__
+
+#include <config.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_request.h"
+#include "xdbg_evlog_event.h"
+#include "xdbg_evlog_reply.h"
+
+#include "xdbg_evlog_core.h"
+#include "xdbg_evlog_dri2.h"
+#include "xdbg_evlog_composite.h"
+#include "xdbg_evlog_damage.h"
+#include "xdbg_evlog_gesture.h"
+#include "xdbg_evlog_xext.h"
+#include "xdbg_evlog_randr.h"
+#include "xdbg_evlog_xinput.h"
+#include "xdbg_evlog_xv.h"
+#if HAVE_HWC
+#include "xdbg_evlog_hwc.h"
+#endif
+#include <list.h>
+
+
+char* xDbgEvlogGetCmd (char *path);
+Bool xDbgEvlogRuleSet (const int argc, const char **argv, char *reply, int *len);
+Bool xDbgEvlogRuleValidate (EvlogInfo *evinfo);
+Bool xDbgEvlogGetExtensionEntry ();
+Bool xDbgEvlogFillLog (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+Bool xDbgEvlogReadRuleFile(const char *filename, char *reply, int *len);
+
+void xDbgDistroyAtomList (EvlogInfo *evinfo);
+void xDbgDistroyRegionList (EvlogInfo *evinfo);
+char* xDbgGetAtom (Atom atom, EvlogInfo *evinfo, char *reply, int *len);
+char* xDbgGetRegion (XserverRegion region, EvlogInfo *evinfo, char *reply, int *len);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/compositeproto.h>
+#include <X11/extensions/composite.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_composite.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestComposite(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_CompositeRedirectWindow:
+ {
+ xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" update(%d)",
+ stuff->update);
+ }
+
+ return reply;
+ }
+
+ case X_CompositeRedirectSubwindows:
+ {
+ xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" update(%d)",
+ stuff->update);
+ }
+
+ return reply;
+ }
+
+ case X_CompositeUnredirectWindow:
+ {
+ xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" update(%d)",
+ stuff->update);
+ }
+
+ return reply;
+ }
+
+ case X_CompositeUnredirectSubwindows:
+ {
+ xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" update(%d)",
+ stuff->update);
+ }
+
+ return reply;
+ }
+
+ case X_CompositeNameWindowPixmap:
+ {
+ xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)req;
+ REPLY (": XID(0x%x) Pixmap(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->pixmap);
+
+ return reply;
+ }
+
+#ifdef _F_INPUT_REDIRECTION_
+ case X_CompositeSetCoordinateTransform:
+ {
+ xCompositeSetCoordinateTransformReq *stuff = (xCompositeSetCoordinateTransformReq *)req;
+ REPLY (": XID(0x%x) (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)",
+ (unsigned int)stuff->window,
+ (float)pixman_fixed_to_double(stuff->transform.matrix11), (float)pixman_fixed_to_double(stuff->transform.matrix12), (float)pixman_fixed_to_double(stuff->transform.matrix13),
+ (float)pixman_fixed_to_double(stuff->transform.matrix21), (float)pixman_fixed_to_double(stuff->transform.matrix22), (float)pixman_fixed_to_double(stuff->transform.matrix23),
+ (float)pixman_fixed_to_double(stuff->transform.matrix31), (float)pixman_fixed_to_double(stuff->transform.matrix32), (float)pixman_fixed_to_double(stuff->transform.matrix33));
+
+ return reply;
+ }
+#endif
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventComposite (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyComposite (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+#if 0
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+
+ default:
+ break;
+ }
+
+#endif
+ return reply;
+}
+
+void
+xDbgEvlogCompositeGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestComposite;
+ extinfo->evt_func = _EvlogEventComposite;
+ extinfo->rep_func = _EvlogReplyComposite;
+#else
+ ExtensionEntry *xext = CheckExtension (COMPOSITE_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestComposite;
+ extinfo->evt_func = _EvlogEventComposite;
+ extinfo->rep_func = _EvlogReplyComposite;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_COMPOSITE_H__
+#define __XDBG_EVLOG_COMPOSITE_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogCompositeGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <X11/Xproto.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_core.h"
+#include "xdbg_evlog.h"
+
+
+static char*
+_getWindowAttributeMask (CARD32 mask, char *reply, int *len)
+{
+ int i;
+ int init = 0;
+
+ for (i = 0 ; i < sizeof(mask) * 4 ; i++)
+ {
+ if(mask & (1 << i))
+ {
+ if (init)
+ REPLY(" ");
+ else
+ init = 1;
+
+ switch (1 << i)
+ {
+ case CWBackPixmap: REPLY("CWBackPixmap"); break;
+ case CWBackPixel: REPLY("CWBackPixel"); break;
+ case CWBorderPixmap: REPLY("CWBorderPixmap"); break;
+ case CWBorderPixel: REPLY("CWBorderPixel"); break;
+ case CWBitGravity: REPLY("CWBitGravity"); break;
+ case CWWinGravity: REPLY("CWWinGravity"); break;
+ case CWBackingStore: REPLY("CWBackingStore"); break;
+ case CWBackingPlanes: REPLY("CWBackingPlanes"); break;
+ case CWBackingPixel: REPLY("CWBackingPixel"); break;
+ case CWOverrideRedirect: REPLY("CWOverrideRedirect"); break;
+ case CWSaveUnder: REPLY("CWSaveUnder"); break;
+ case CWEventMask: REPLY("CWEventMask"); break;
+ case CWDontPropagate: REPLY("CWDontPropagate"); break;
+ case CWColormap: REPLY("CWColormap"); break;
+ case CWCursor: REPLY("CWCursor"); break;
+ }
+ }
+ }
+
+ return reply;
+}
+
+#define GET_INT16(m, f) \
+ if (m & mask) \
+ { \
+ f = (INT16) *pVlist;\
+ pVlist++; \
+ }
+#define GET_CARD16(m, f) \
+ if (m & mask) \
+ { \
+ f = (CARD16) *pVlist;\
+ pVlist++;\
+ }
+
+#define GET_CARD8(m, f) \
+ if (m & mask) \
+ { \
+ f = (CARD8) *pVlist;\
+ pVlist++;\
+ }
+
+static char*
+_getConfigureWindowMask (CARD16 mask, char *reply, int *len, XID *vlist)
+{
+ int i;
+ int init = 0;
+ short x=0, y=0;
+ unsigned short w=0, h=0;
+ XID *pVlist;
+
+ if(vlist)
+ {
+ pVlist = vlist;
+
+ if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) {
+ GET_INT16(CWX, x);
+ GET_INT16(CWY, y);
+ }
+ /* or should be resized */
+ else if (mask & (CWX | CWY | CWWidth | CWHeight)) {
+ GET_INT16(CWX, x);
+ GET_INT16(CWY, y);
+ GET_CARD16(CWWidth, w);
+ GET_CARD16(CWHeight, h);
+ }
+ }
+
+ for (i = 0 ; i < sizeof(mask) * 4 ; i++)
+ {
+ if(mask & (1 << i))
+ {
+ if (init)
+ REPLY(" ");
+ else
+ init = 1;
+
+ if (vlist)
+ {
+ switch (1 << i)
+ {
+ case CWX: REPLY("CWX:%d",x); break;
+ case CWY: REPLY("CWY:%d",y); break;
+ case CWWidth: REPLY("CWWidth:%d",w); break;
+ case CWHeight: REPLY("CWHeight:%d",h); break;
+ case CWBorderWidth: REPLY("CWBorderWidth"); break;
+ case CWSibling: REPLY("CWSibling"); break;
+ case CWStackMode: REPLY("CWStackMode"); break;
+ }
+ }
+ else
+ {
+ switch (1 << i)
+ {
+ case CWX: REPLY("CWX"); break;
+ case CWY: REPLY("CWY"); break;
+ case CWWidth: REPLY("CWWidth"); break;
+ case CWHeight: REPLY("CWHeight"); break;
+ case CWBorderWidth: REPLY("CWBorderWidth"); break;
+ case CWSibling: REPLY("CWSibling"); break;
+ case CWStackMode: REPLY("CWStackMode"); break;
+ }
+ }
+ }
+ }
+
+ return reply;
+}
+
+static char*
+_getKeyMask (CARD16 mask, char *reply, int *len)
+{
+ int i;
+ int init = 0;
+
+ for (i = 0 ; i < sizeof(mask) * 4 ; i++)
+ {
+ if(mask & (1 << i))
+ {
+ if (init)
+ REPLY(" ");
+ else
+ init = 1;
+
+ switch (1 << i)
+ {
+ case ShiftMask: REPLY("ShiftMask"); break;
+ case LockMask: REPLY("LockMask"); break;
+ case ControlMask: REPLY("ControlMask"); break;
+ case Mod1Mask: REPLY("Mod1Mask"); break;
+ case Mod2Mask: REPLY("Mod2Mask"); break;
+ case Mod3Mask: REPLY("Mod3Mask"); break;
+ case Mod4Mask: REPLY("Mod4Mask"); break;
+ case Mod5Mask: REPLY("Mod5Mask"); break;
+ case Button1Mask: REPLY("Button1Mask"); break;
+ case Button2Mask: REPLY("Button2Mask"); break;
+ case Button3Mask: REPLY("Button3Mask"); break;
+ case Button4Mask: REPLY("Button4Mask"); break;
+ case Button5Mask: REPLY("Button5Mask"); break;
+ case AnyModifier: REPLY("AnyModifier"); break;
+ }
+ }
+ }
+
+ return reply;
+}
+
+static char*
+_getEventMask (CARD32 mask, char *reply, int *len)
+{
+ int i;
+ int init = 0;
+
+ for (i = 0 ; i < sizeof(mask) * 4 ; i++)
+ {
+ if(mask & (1 << i))
+ {
+ if (init)
+ REPLY(" ");
+ else
+ init = 1;
+
+ switch (1 << i)
+ {
+ case NoEventMask: REPLY("NoEventMask"); break;
+ case KeyPressMask: REPLY("KeyPressMask"); break;
+ case KeyReleaseMask: REPLY("KeyReleaseMask"); break;
+ case ButtonPressMask: REPLY("ButtonPressMask"); break;
+ case ButtonReleaseMask: REPLY("ButtonReleaseMask"); break;
+ case EnterWindowMask: REPLY("EnterWindowMask"); break;
+ case LeaveWindowMask: REPLY("LeaveWindowMask"); break;
+ case PointerMotionMask: REPLY("PointerMotionMask"); break;
+ case PointerMotionHintMask: REPLY("PointerMotionHintMask"); break;
+ case Button1MotionMask: REPLY("Button1MotionMask"); break;
+ case Button2MotionMask: REPLY("Button2MotionMask"); break;
+ case Button3MotionMask: REPLY("Button3MotionMask"); break;
+ case Button4MotionMask: REPLY("Button4MotionMask"); break;
+ case Button5MotionMask: REPLY("Button5MotionMask"); break;
+ case ButtonMotionMask: REPLY("ButtonMotionMask"); break;
+ case KeymapStateMask: REPLY("KeymapStateMask"); break;
+ case ExposureMask: REPLY("ExposureMask"); break;
+ case VisibilityChangeMask: REPLY("VisibilityChangeMask"); break;
+ case StructureNotifyMask: REPLY("StructureNotifyMask"); break;
+ case ResizeRedirectMask: REPLY("ResizeRedirectMask"); break;
+ case SubstructureNotifyMask: REPLY("SubstructureNotifyMask"); break;
+ case SubstructureRedirectMask: REPLY("SubstructureRedirectMask"); break;
+ case FocusChangeMask: REPLY("FocusChangeMask"); break;
+ case PropertyChangeMask: REPLY("PropertyChangeMask"); break;
+ case ColormapChangeMask: REPLY("ColormapChangeMask"); break;
+ case OwnerGrabButtonMask: REPLY("OwnerGrabButtonMask"); break;
+ }
+ }
+ }
+
+ return reply;
+}
+
+char * xDbgEvlogRequestCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->reqType)
+ {
+ case X_CreateWindow:
+ {
+ xCreateWindowReq *stuff = (xCreateWindowReq *)req;
+
+ REPLY (": Window(0x%x) Parent(0x%x) size(%dx%d) boaderWid(%d) coordinate(%d,%d)",
+ (unsigned int)stuff->wid,
+ (unsigned int)stuff->parent,
+ stuff->width,
+ stuff->height,
+ stuff->borderWidth,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *visual, *class;
+ char dvisual[10], dclass[10];
+
+ switch (stuff->visual)
+ {
+ case CopyFromParent: visual = "CopyFromParent"; break;
+ default: visual = dvisual; snprintf (dvisual, 10, "0x%x", (unsigned int)stuff->visual); break;
+ }
+
+ switch (stuff->class)
+ {
+ case CopyFromParent: class = "CopyFromParent"; break;
+ case InputOutput: class = "InputOutput"; break;
+ case InputOnly: class = "InputOnly"; break;
+ default: class = dclass; snprintf (dclass, 10, "0x%x", stuff->class); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s depth(%d) visual_ID(%s) class(%s)\n",
+ " ",
+ stuff->depth,
+ visual,
+ class);
+
+ \r REPLY ("%67s mask", " ");
+ \r REPLY ("(");
+ reply = _getWindowAttributeMask(stuff->mask, reply, len);
+ \r REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_ChangeWindowAttributes:
+ {
+ xChangeWindowAttributesReq *stuff = (xChangeWindowAttributesReq *)req;
+ REPLY (": XID(0x%x)", (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ \r REPLY (" detail");
+ \r REPLY ("(");
+ reply = _getWindowAttributeMask(stuff->valueMask, reply, len);
+ if (stuff->valueMask == CWEventMask)
+
+ REPLY (", mask(%x)", (unsigned int)*((XID *)&stuff[1]));
+ \r REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_ChangeSaveSet:
+ {
+ xChangeSaveSetReq *stuff = (xChangeSaveSetReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *mode;
+ char dmode[10];
+
+ switch (stuff->mode)
+ {
+ case SetModeInsert: mode = "SetModeInsert"; break;
+ case SetModeDelete: mode = "SetModeDelete"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ REPLY (" mode(%s)",
+ mode);
+ }
+
+ return reply;
+ }
+
+ case X_ReparentWindow:
+ {
+ xReparentWindowReq *stuff = (xReparentWindowReq *)req;
+ REPLY (": Window(0x%x) Parent(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->parent,
+ stuff->x,
+ stuff->y);
+
+ return reply;
+ }
+
+ case X_ConfigureWindow:
+ {
+ xConfigureWindowReq *stuff = (xConfigureWindowReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" mask");
+ REPLY ("(");
+ reply = _getConfigureWindowMask(stuff->mask, reply, len, (XID *)&stuff[1]);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_CirculateWindow:
+ {
+ xCirculateWindowReq *stuff = (xCirculateWindowReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *direction;
+ char ddirection[10];
+
+ switch (stuff->direction)
+ {
+ case RaiseLowest: direction = "RaiseLowest"; break;
+ case LowerHighest: direction = "LowerHighest"; break;
+ default: direction = ddirection; snprintf (ddirection, 10, "%d", stuff->direction); break;
+ }
+
+ REPLY (" direction(%s)",
+ direction);
+ }
+
+ return reply;
+ }
+
+ case X_ChangeProperty:
+ {
+ xChangePropertyReq *stuff = (xChangePropertyReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *mode;
+ char dmode[10];
+
+ switch (stuff->mode)
+ {
+ case PropModeReplace: mode = "PropModeReplace"; break;
+ case PropModePrepend: mode = "PropModePrepend"; break;
+ case PropModeAppend: mode = "PropModeAppend"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s mode(%s) format(%d) nUnits(%ld)",
+ " ",
+ mode,
+ stuff->format,
+ (long int)stuff->nUnits);
+ }
+
+ return reply;
+ }
+
+ case X_DeleteProperty:
+ {
+ xDeletePropertyReq *stuff = (xDeletePropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case X_GetProperty:
+ {
+ xGetPropertyReq *stuff = (xGetPropertyReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s delete(%s) longOffset(%ld) longLength(%ld)",
+ " ",
+ stuff->delete ? "YES" : "NO",
+ (long int)stuff->longOffset,
+ (long int)stuff->longLength);
+ }
+
+ return reply;
+ }
+
+ case X_SetSelectionOwner:
+ {
+ xSetSelectionOwnerReq *stuff = (xSetSelectionOwnerReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ REPLY (" Selection");
+ reply = xDbgGetAtom(stuff->selection, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_ConvertSelection:
+ {
+ xConvertSelectionReq *stuff = (xConvertSelectionReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->requestor);
+
+ REPLY (" Selection");
+ reply = xDbgGetAtom(stuff->selection, evinfo, reply, len);
+ REPLY (" Target");
+ reply = xDbgGetAtom(stuff->target, evinfo, reply, len);
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_SendEvent:
+ {
+ xSendEventReq *stuff = (xSendEventReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->destination);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" propagate(%s)",
+ stuff->propagate ? "YES" : "NO");
+
+ REPLY (" event_mask");
+ REPLY ("(");
+ reply = _getEventMask(stuff->eventMask, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_GrabPointer:
+ {
+ xGrabPointerReq *stuff = (xGrabPointerReq *)req;
+
+ REPLY (": XID(0x%x) ConfineTo(0x%x) Cursor(0x%x)",
+ (unsigned int)stuff->grabWindow,
+ (unsigned int)stuff->confineTo,
+ (unsigned int)stuff->cursor);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *pointer_mode, *keyboard_mode;
+ char dpointer_mode[10], dkeyboard_mode[10];
+
+ switch (stuff->pointerMode)
+ {
+ case GrabModeSync: pointer_mode = "GrabModeSync"; break;
+ case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
+ default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
+ }
+
+ switch (stuff->keyboardMode)
+ {
+ case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
+ case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
+ default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
+ }
+
+ REPLY (" pointer_mode(%s) keyboard_mode(%s) time(%lums)\n",
+ pointer_mode,
+ keyboard_mode,
+ (unsigned long)stuff->time);
+
+ REPLY (" event_mask");
+ REPLY ("(");
+ reply = _getEventMask(stuff->eventMask, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_GrabButton:
+ {
+ xGrabButtonReq *stuff = (xGrabButtonReq *)req;
+
+ REPLY (": XID(0x%x) ConfineTo(0x%x) Cursor(0x%x)",
+ (unsigned int)stuff->grabWindow,
+ (unsigned int)stuff->confineTo,
+ (unsigned int)stuff->cursor);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *pointer_mode, *keyboard_mode, *button;
+ char dpointer_mode[10], dkeyboard_mode[10], dbutton[10];
+
+ switch (stuff->pointerMode)
+ {
+ case GrabModeSync: pointer_mode = "GrabModeSync"; break;
+ case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
+ default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
+ }
+
+ switch (stuff->keyboardMode)
+ {
+ case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
+ case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
+ default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
+ }
+
+ switch (stuff->button)
+ {
+ case Button1: button = "Button1"; break;
+ case Button2: button = "Button2"; break;
+ case Button3: button = "Button3"; break;
+ case Button4: button = "Button4"; break;
+ case Button5: button = "Button5"; break;
+ default: button = dbutton; snprintf (dbutton, 10, "%d", stuff->button); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s event_mask(0x%x) pointer_mode(%s) keyboard_mode(%s) button(%s)",
+ " ",
+ stuff->eventMask,
+ pointer_mode,
+ keyboard_mode,
+ button);
+
+ REPLY (" modifiers");
+ REPLY ("(");
+ reply = _getKeyMask(stuff->modifiers, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_UngrabButton:
+ {
+ xUngrabButtonReq *stuff = (xUngrabButtonReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" modifiers");
+ REPLY ("(");
+ reply = _getKeyMask(stuff->modifiers, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_ChangeActivePointerGrab:
+ {
+ xChangeActivePointerGrabReq *stuff = (xChangeActivePointerGrabReq *)req;
+ REPLY (": Cursor(0x%x)",
+ (unsigned int)stuff->cursor);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+
+ REPLY (" event_mask");
+ REPLY ("(");
+ reply = _getEventMask(stuff->eventMask, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_GrabKeyboard:
+ {
+ xGrabKeyboardReq *stuff = (xGrabKeyboardReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *pointer_mode, *keyboard_mode;
+ char dpointer_mode[10], dkeyboard_mode[10];
+
+ switch (stuff->pointerMode)
+ {
+ case GrabModeSync: pointer_mode = "GrabModeSync"; break;
+ case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
+ default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
+ }
+
+ switch (stuff->keyboardMode)
+ {
+ case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
+ case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
+ default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
+ }
+
+ REPLY (" owner_events(%s) pointer_mode(%s) keyboard_mode(%s)",
+ stuff->ownerEvents ? "YES" : "NO",
+ pointer_mode,
+ keyboard_mode);
+ }
+
+ return reply;
+ }
+
+ case X_GrabKey:
+ {
+ xGrabKeyReq *stuff = (xGrabKeyReq *)req;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *pointer_mode, *keyboard_mode;
+ char dpointer_mode[10], dkeyboard_mode[10];
+
+ switch (stuff->pointerMode)
+ {
+ case GrabModeSync: pointer_mode = "GrabModeSync"; break;
+ case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
+ default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
+ }
+
+ switch (stuff->keyboardMode)
+ {
+ case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
+ case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
+ default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
+ }
+
+ REPLY (" key(%d) pointer_mode(%s) keyboard_mode(%s)\n",
+ stuff->key,
+ pointer_mode,
+ keyboard_mode);
+
+ REPLY (" modifiers");
+ REPLY ("(");
+ reply = _getKeyMask(stuff->modifiers, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_UngrabKey:
+ {
+ xUngrabKeyReq *stuff = (xUngrabKeyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" key(%d)",
+ stuff->key);
+
+ REPLY (" modifiers");
+ REPLY ("(");
+ reply = _getKeyMask(stuff->modifiers, reply, len);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_SetInputFocus:
+ {
+ xSetInputFocusReq *stuff = (xSetInputFocusReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->focus);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" reverTo(%d) time(%lums)",
+ stuff->revertTo,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_CreatePixmap:
+ {
+ xCreatePixmapReq *stuff = (xCreatePixmapReq *)req;
+ REPLY (": Pixmap(0x%x) Drawable(0x%x) size(%dx%d)",
+ (unsigned int)stuff->pid,
+ (unsigned int)stuff->drawable,
+ stuff->width,
+ stuff->height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" depth(%d)",
+ stuff->depth);
+ }
+
+ return reply;
+ }
+
+ case X_CreateGC:
+ {
+ xCreateGCReq *stuff = (xCreateGCReq *)req;
+ REPLY (": Gc(0x%x) Drawable(0x%x)",
+ (unsigned int)stuff->gc,
+ (unsigned int)stuff->drawable);
+
+ return reply;
+ }
+
+ case X_ClearArea:
+ {
+ xClearAreaReq *stuff = (xClearAreaReq *)req;
+ REPLY (": XID(0x%x) area(%d,%d %dx%d)",
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ stuff->width,
+ stuff->height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" exposures(%s)",
+ stuff->exposures ? "YES" : "NO");
+ }
+
+ \r return reply;
+ }
+
+ case X_CopyArea:
+ {
+ xCopyAreaReq *stuff = (xCopyAreaReq *)req;
+ REPLY (": srcXID(0x%x) dstXID(0x%x) gc(0x%x) size(%dx%d) src(%d,%d) dst(%d,%d)",
+ (unsigned int)stuff->srcDrawable,
+ (unsigned int)stuff->dstDrawable,
+ (unsigned int)stuff->gc,
+ stuff->width,
+ stuff->height,
+ stuff->srcX,
+ stuff->srcY,
+ stuff->dstX,
+ stuff->dstY);
+
+ return reply;
+ }
+
+ case X_CopyPlane:
+ {
+ xCopyPlaneReq *stuff = (xCopyPlaneReq *)req;
+ REPLY (": srcXID(0x%x) dstXID(0x%x) gc(0x%x) size(%dx%d) src(%d,%d) dst(%d,%d)",
+ (unsigned int)stuff->srcDrawable,
+ (unsigned int)stuff->dstDrawable,
+ (unsigned int)stuff->gc,
+ stuff->width,
+ stuff->height,
+ stuff->srcX,
+ stuff->srcY,
+ stuff->dstX,
+ stuff->dstY);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" bit_plane(0x%x)",
+ (unsigned int)stuff->bitPlane);
+ }
+
+ return reply;
+ }
+
+ case X_PolyPoint:
+ {
+ xPolyPointReq *stuff = (xPolyPointReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *coord_mode;
+ char dcoord_mode[10];
+
+ switch (stuff->coordMode)
+ {
+ case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
+ case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
+ default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
+ }
+
+ REPLY (" coord_mode(%s)",
+ coord_mode);
+ }
+
+ return reply;
+ }
+
+ case X_PolyLine:
+ {
+ xPolyLineReq *stuff = (xPolyLineReq *)req;
+ REPLY (": XID(0x%x gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *coord_mode;
+ char dcoord_mode[10];
+
+ switch (stuff->coordMode)
+ {
+ case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
+ case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
+ default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
+ }
+
+ REPLY (" coord_mode(%s)",
+ coord_mode);
+ }
+
+ return reply;
+ }
+
+ case X_PolySegment:
+ {
+ xPolySegmentReq *stuff = (xPolySegmentReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ return reply;
+ }
+
+ case X_PolyRectangle:
+ {
+ xPolyRectangleReq *stuff = (xPolyRectangleReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ return reply;
+ }
+
+ case X_PolyArc:
+ {
+ xPolyArcReq *stuff = (xPolyArcReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ return reply;
+ }
+
+ case X_FillPoly:
+ {
+ xFillPolyReq *stuff = (xFillPolyReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *shape, *coord_mode;
+ char dshape[10], dcoord_mode[10];
+
+ switch (stuff->shape)
+ {
+ case Complex: shape = "Complex"; break;
+ case Nonconvex: shape = "Nonconvex"; break;
+ case Convex: shape = "Convex"; break;
+ default: shape = dshape; snprintf (dshape, 10, "%d", stuff->shape); break;
+ }
+
+ switch (stuff->coordMode)
+ {
+ case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
+ case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
+ default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
+ }
+
+ REPLY (" shape(%s) coord_mode(%s)",
+ shape,
+ coord_mode);
+ }
+
+ return reply;
+ }
+
+ case X_PolyFillRectangle:
+ {
+ xPolyFillRectangleReq *stuff = (xPolyFillRectangleReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ return reply;
+ }
+
+ case X_PolyFillArc:
+ {
+ xPolyFillArcReq *stuff = (xPolyFillArcReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc);
+
+ return reply;
+ }
+
+ case X_PutImage:
+ {
+ xPutImageReq *stuff = (xPutImageReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x) size(%dx%d) dst(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->width,
+ stuff->height,
+ stuff->dstX,
+ stuff->dstY);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *format;
+ char dformat[10];
+
+ switch (stuff->format)
+ {
+ case XYBitmap: format = "XYBitmap"; break;
+ case XYPixmap: format = "XYPixmap"; break;
+ case ZPixmap: format = "ZPixmap"; break;
+ default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
+ }
+
+ REPLY (" format(%s) depth(%d)",
+ format,
+ stuff->depth);
+ }
+
+ return reply;
+ }
+
+ case X_GetImage:
+ {
+ xGetImageReq *stuff = (xGetImageReq *)req;
+ REPLY (": XID(0x%x) size(%dx%d) dst(%d,%d)",
+ (unsigned int)stuff->drawable,
+ stuff->width,
+ stuff->height,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *format;
+ char dformat[10];
+
+ switch (stuff->format)
+ {
+ case XYBitmap: format = "XYBitmap"; break;
+ case XYPixmap: format = "XYPixmap"; break;
+ case ZPixmap: format = "ZPixmap"; break;
+ default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
+ }
+
+ REPLY (" format(%s) plane_mask(0x%x)",
+ format,
+ (unsigned int)stuff->planeMask);
+ }
+
+ return reply;
+ }
+
+ case X_PolyText8:
+ {
+ xPolyText8Req *stuff = (xPolyText8Req *)req;
+ REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->x,
+ stuff->y);
+
+ return reply;
+ }
+
+ case X_PolyText16:
+ {
+ xPolyText16Req *stuff = (xPolyText16Req *)req;
+ REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->x,
+ stuff->y);
+
+ return reply;
+ }
+
+ case X_ImageText8:
+ {
+ xImageText8Req *stuff = (xImageText8Req *)req;
+ REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" nchars(%d)",
+ stuff->nChars);
+ }
+
+ return reply;
+ }
+
+ case X_ImageText16:
+ {
+ xImageText16Req *stuff = (xImageText16Req *)req;
+ REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" nchars(%d)",
+ stuff->nChars);
+ }
+
+ return reply;
+ }
+
+ case X_ChangeKeyboardMapping:
+ {
+ xChangeKeyboardMappingReq *stuff = (xChangeKeyboardMappingReq *)req;
+ REPLY (": first_key_code(%d) key_syms_per_key_code(%d)",
+ stuff->firstKeyCode,
+ stuff->keySymsPerKeyCode);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" key_codes(%d)",
+ stuff->keyCodes);
+ }
+
+ return reply;
+ }
+
+ case X_GetKeyboardMapping:
+ {
+ xGetKeyboardMappingReq *stuff = (xGetKeyboardMappingReq *)req;
+ REPLY (": first_key_code(%d)",
+ stuff->firstKeyCode);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" count(%d)",
+ stuff->count);
+ }
+
+ return reply;
+ }
+
+ case X_ChangePointerControl:
+ {
+ xChangePointerControlReq *stuff = (xChangePointerControlReq *)req;
+ REPLY (": accelNum(%d) accelDenum(%d) threshold(%d)",
+ stuff->accelNum,
+ stuff->accelDenum,
+ stuff->threshold);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" do_accel(%s) do_thresh(%s)",
+ stuff->doAccel ? "YES" : "NO",
+ stuff->doThresh ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_SetPointerMapping:
+ {
+ xSetPointerMappingReq *stuff = (xSetPointerMappingReq *)req;
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (": Elts(%d)",
+ stuff->nElts);
+ }
+
+ return reply;
+ }
+
+ case X_SetModifierMapping:
+ {
+ xSetModifierMappingReq *stuff =(xSetModifierMappingReq *)req;
+ REPLY (": num_key_per_modifier(%d)",
+ stuff->numKeyPerModifier);
+
+ return reply;
+ }
+
+ case X_ListProperties:
+ case X_DestroyWindow:
+ case X_DestroySubwindows:
+ case X_MapWindow:
+ case X_MapSubwindows:
+ case X_UnmapWindow:
+ case X_UnmapSubwindows:
+ case X_GetGeometry:
+ case X_QueryTree:
+ case X_UngrabPointer:
+ case X_UngrabKeyboard:
+ case X_FreePixmap:
+ case X_KillClient:
+ case X_FreeGC:
+ {
+ xResourceReq *stuff = (xResourceReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->id);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+char * xDbgEvlogEventCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch (evt->u.u.type & 0x7F)
+ {
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ {
+ REPLY (": Root(0x%x %d,%d) Event(0x%x %d,%d) Child(0x%x)",
+ (unsigned int)evt->u.keyButtonPointer.root,
+ evt->u.keyButtonPointer.rootX,
+ evt->u.keyButtonPointer.rootY,
+ (unsigned int)evt->u.keyButtonPointer.event,
+ evt->u.keyButtonPointer.eventX,
+ evt->u.keyButtonPointer.eventY,
+ (unsigned int)evt->u.keyButtonPointer.child);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s state(0x%x) same_screen(%s)",
+ " ",
+ evt->u.keyButtonPointer.state,
+ evt->u.keyButtonPointer.sameScreen ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ REPLY (": Root(0x%x %d,%d) Event(0x%x %d,%d) Child(0x%x)",
+ (unsigned int)evt->u.enterLeave.root,
+ evt->u.enterLeave.rootX,
+ evt->u.enterLeave.rootY,
+ (unsigned int)evt->u.enterLeave.event,
+ evt->u.enterLeave.eventX,
+ evt->u.enterLeave.eventY,
+ (unsigned int)evt->u.enterLeave.child);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(0x%x) same_screen(%s) focus(%s)",
+ " ",
+ (unsigned long)evt->u.enterLeave.time,
+ evt->u.enterLeave.state,
+ evt->u.enterLeave.flags & ELFlagSameScreen ? "YES" : "NO",
+ evt->u.enterLeave.flags & ELFlagFocus ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case FocusIn:
+ case FocusOut:
+ case KeymapNotify:
+ {
+ REPLY (": XID(0x%x)",
+ (unsigned int)evt->u.focus.window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char* mode;
+ char dmode[10];
+
+ switch (evt->u.focus.mode)
+ {
+ case NotifyNormal: mode = "NotifyNormal"; break;
+ case NotifyGrab: mode = "NotifyGrab"; break;
+ case NotifyUngrab: mode = "NotifyUngrab"; break;
+ case NotifyWhileGrabbed: mode = "NotifyWhileGrabbed"; break;
+ default: mode = dmode, snprintf (dmode, 10, "%u", evt->u.focus.mode); break;
+ }
+
+ REPLY (" mode(%s)",
+ mode);
+ }
+
+ return reply;
+ }
+
+ case Expose:
+ {
+ REPLY (": XID(0x%x) size(%dx%d) coord(%d,%d)",
+ (unsigned int)evt->u.expose.window,
+ evt->u.expose.width,
+ evt->u.expose.height,
+ evt->u.expose.x,
+ evt->u.expose.y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" count(%d)",
+ evt->u.expose.count);
+ }
+
+ return reply;
+ }
+
+ case GraphicsExpose:
+ {
+ REPLY (": XID(0x%x) size(%dx%d) coord(%d,%d)",
+ (unsigned int)evt->u.graphicsExposure.drawable,
+ evt->u.graphicsExposure.width,
+ evt->u.graphicsExposure.height,
+ evt->u.graphicsExposure.x,
+ evt->u.graphicsExposure.y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *major;
+ char dmajor[10];
+
+ switch (evt->u.graphicsExposure.majorEvent)
+ {
+ case X_CopyArea: major = "CopyArea"; break;
+ case X_CopyPlane: major = "CopyPlane"; break;
+ default: major = dmajor; snprintf (dmajor, 10, "%d", evt->u.graphicsExposure.majorEvent); break;
+ }
+
+ REPLY (" major_event(%s) minor_event(%d) count(%d)",
+ major,
+ evt->u.graphicsExposure.minorEvent,
+ evt->u.graphicsExposure.count);
+ }
+
+ return reply;
+ }
+
+ case NoExpose:
+ {
+ REPLY (": XID(0x%x)",
+ (unsigned int)evt->u.noExposure.drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *major;
+ char dmajor[10];
+
+ switch (evt->u.noExposure.majorEvent)
+ {
+ case X_CopyArea: major = "CopyArea"; break;
+ case X_CopyPlane: major = "CopyPlane"; break;
+ default: major = dmajor; snprintf (dmajor, 10, "%d", evt->u.noExposure.majorEvent); break;
+ }
+
+ REPLY (" major_event(%s) minor_event(%d)",
+ major,
+ evt->u.noExposure.minorEvent);
+ }
+
+ return reply;
+ }
+
+ case VisibilityNotify:
+ {
+ REPLY (": XID(0x%x)",
+ (unsigned int)evt->u.visibility.window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *state;
+ char dstate[10];
+
+ switch (evt->u.visibility.state)
+ {
+ case VisibilityUnobscured: state = "VisibilityUnobscured"; break;
+ case VisibilityPartiallyObscured: state = "VisibilityPartiallyObscured"; break;
+ case VisibilityFullyObscured: state = "VisibilityFullyObscured"; break;
+ default: state = dstate; snprintf (dstate, 10, "%d", evt->u.visibility.state); break;
+ }
+
+ REPLY (" state(%s)",
+ state);
+ }
+
+ return reply;
+ }
+
+ case CreateNotify:
+ {
+ REPLY (": Window(0x%x) Parent(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
+ (unsigned int)evt->u.createNotify.window,
+ (unsigned int)evt->u.createNotify.parent,
+ evt->u.createNotify.width,
+ evt->u.createNotify.height,
+ evt->u.createNotify.x,
+ evt->u.createNotify.y,
+ evt->u.createNotify.borderWidth);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" override(%s)",
+ evt->u.createNotify.override ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case DestroyNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x)",
+ (unsigned int)evt->u.destroyNotify.window,
+ (unsigned int)evt->u.destroyNotify.event);
+
+ return reply;
+ }
+
+ case UnmapNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x)",
+ (unsigned int)evt->u.unmapNotify.window,
+ (unsigned int)evt->u.unmapNotify.event);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" from_Configure(%s)",
+ evt->u.unmapNotify.fromConfigure ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case MapNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x)",
+ (unsigned int)evt->u.mapNotify.window,
+ (unsigned int)evt->u.mapNotify.event);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" override(%s)",
+ evt->u.mapNotify.override ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case MapRequest:
+ {
+ REPLY (": Window(0x%x) Parent(0x%x)",
+ (unsigned int)evt->u.mapRequest.window,
+ (unsigned int)evt->u.mapRequest.parent);
+
+ return reply;
+ }
+
+ case ReparentNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x) Parent(0x%x) coord(%d,%d)",
+ (unsigned int)evt->u.reparent.window,
+ (unsigned int)evt->u.reparent.event,
+ (unsigned int)evt->u.reparent.parent,
+ evt->u.reparent.x,
+ evt->u.reparent.y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" override(%s)",
+ evt->u.reparent.override ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case ConfigureNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x) AboveSibling(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
+ (unsigned int)evt->u.configureNotify.window,
+ (unsigned int)evt->u.configureNotify.event,
+ (unsigned int)evt->u.configureNotify.aboveSibling,
+ evt->u.configureNotify.width,
+ evt->u.configureNotify.height,
+ evt->u.configureNotify.x,
+ evt->u.configureNotify.y,
+ evt->u.configureNotify.borderWidth);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" override(%s)",
+ evt->u.configureNotify.override ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case ConfigureRequest:
+ {
+ REPLY (": Window(0x%x) Parent(0x%x) Sibling(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
+ (unsigned int)evt->u.configureRequest.window,
+ (unsigned int)evt->u.configureRequest.parent,
+ (unsigned int)evt->u.configureRequest.sibling,
+ evt->u.configureRequest.width,
+ evt->u.configureRequest.height,
+ evt->u.configureRequest.x,
+ evt->u.configureRequest.y,
+ evt->u.configureRequest.borderWidth);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s value_mask",
+ " ");
+ REPLY ("(");
+ reply = _getConfigureWindowMask(evt->u.configureRequest.valueMask, reply, len, NULL);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case GravityNotify:
+ {
+ REPLY (": Window(0x%x) Event(0x%x) coord(%d,%d)",
+ (unsigned int)evt->u.gravity.window,
+ (unsigned int)evt->u.gravity.event,
+ evt->u.gravity.x,
+ evt->u.gravity.y);
+
+ return reply;
+ }
+
+ case ResizeRequest:
+ {
+ REPLY (": Window(0x%x) size(%dx%d)",
+ (unsigned int)evt->u.resizeRequest.window,
+ evt->u.resizeRequest.width,
+ evt->u.resizeRequest.height);
+
+ return reply;
+ }
+
+ case CirculateNotify:
+ case CirculateRequest:
+ {
+ REPLY (": Window(0x%x) Event(0x%x) parent(0x%x)",
+ (unsigned int)evt->u.circulate.window,
+ (unsigned int)evt->u.circulate.event,
+ (unsigned int)evt->u.circulate.parent);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *place;
+ char dplace[10];
+
+ switch (evt->u.circulate.place)
+ {
+ case PlaceOnTop: place = "PlaceOnTop"; break;
+ case PlaceOnBottom: place = "PlaceOnBottom"; break;
+ default: place = dplace; snprintf (dplace, 10, "%d", evt->u.circulate.place); break;
+ }
+
+ REPLY (" place(%s)",
+ place);
+ }
+
+ return reply;
+ }
+
+ case PropertyNotify:
+ {
+ REPLY (": Window(0x%x)",
+ (unsigned int)evt->u.property.window);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(evt->u.property.atom, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *state;
+ char dstate[10];
+
+ switch (evt->u.property.state)
+ {
+ case PropertyNewValue: state = "PropertyNewValue"; break;
+ case PropertyDelete: state = "PropertyDelete"; break;
+ default: state = dstate; snprintf (dstate, 10, "%d", evt->u.property.state); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%s)",
+ " ",
+ (unsigned long)evt->u.property.time,
+ state);
+ }
+
+ return reply;
+ }
+
+ case SelectionClear:
+ {
+ REPLY (": Window(0x%x)",
+ (unsigned int)evt->u.selectionClear.window);
+
+ REPLY (" Atom");
+ reply = xDbgGetAtom(evt->u.selectionClear.atom, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)evt->u.selectionClear.time);
+ }
+
+ return reply;
+ }
+
+ case SelectionRequest:
+ {
+ REPLY (": Owner(0x%x) Requestor(0x%x)",
+ (unsigned int)evt->u.selectionRequest.owner,
+ (unsigned int)evt->u.selectionRequest.requestor);
+
+ REPLY (" selection");
+ reply = xDbgGetAtom(evt->u.selectionRequest.selection, evinfo, reply, len);
+ REPLY (" Target");
+ reply = xDbgGetAtom(evt->u.selectionRequest.target, evinfo, reply, len);
+ REPLY (" Property");
+ reply = xDbgGetAtom(evt->u.selectionRequest.property, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)evt->u.selectionRequest.time);
+ }
+
+ return reply;
+ }
+
+ case SelectionNotify:
+ {
+ REPLY (": Requestor(0x%x)",
+ (unsigned int)evt->u.selectionNotify.requestor);
+
+ REPLY (" selection");
+ reply = xDbgGetAtom(evt->u.selectionNotify.selection, evinfo, reply, len);
+ REPLY (" Target");
+ reply = xDbgGetAtom(evt->u.selectionNotify.target, evinfo, reply, len);
+ REPLY (" Property");
+ reply = xDbgGetAtom(evt->u.selectionNotify.property, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)evt->u.selectionNotify.time);
+ }
+
+ return reply;
+ }
+
+ case ColormapNotify:
+ {
+ REPLY (": XID(0x%x) Colormap(0x%x)",
+ (unsigned int)evt->u.colormap.window,
+ (unsigned int)evt->u.colormap.colormap);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *state;
+ char dstate[10];
+
+ switch (evt->u.colormap.state)
+ {
+ case ColormapInstalled: state = "ColormapInstalled"; break;
+ case ColormapUninstalled: state = "ColormapUninstalled"; break;
+ default: state = dstate; snprintf (dstate, 10, "%d", evt->u.colormap.state); break;
+ }
+
+ REPLY (" new(%s) state(%s)",
+ evt->u.colormap.new ? "YES" : "NO",
+ state);
+ }
+
+ return reply;
+ }
+
+ case ClientMessage:
+ {
+ REPLY (": XID(0x%x)",
+ (unsigned int)evt->u.clientMessage.window);
+
+ REPLY (" Type");
+ reply = xDbgGetAtom(evt->u.clientMessage.u.b.type, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case MappingNotify:
+ case GenericEvent:
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+char * xDbgEvlogReplyCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqType)
+ {
+ case X_GetGeometry:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetGeometryReply *stuff = (xGetGeometryReply *)rep;
+
+ REPLY (": XID(0x%x) coord(%d,%d %dx%d) borderWidth(%d)",
+ (unsigned int)stuff->root,
+ stuff->x,
+ stuff->y,
+ stuff->width,
+ stuff->height,
+ stuff->borderWidth);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_QueryTree:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xQueryTreeReply *stuff = (xQueryTreeReply *)rep;
+
+ REPLY (": XID(0x%x) Parent(0x%x) ChildrenNum(%d)",
+ (unsigned int)stuff->root,
+ (unsigned int)stuff->parent,
+ stuff->nChildren);
+ }
+ else
+ {
+ Window *stuff = (Window *)rep;
+ int i;
+
+ REPLY ("childIDs");
+ REPLY ("(");
+ for (i = 0 ; i < evinfo->rep.size / sizeof(Window) ; i++)
+ {
+ REPLY("0x%x", (unsigned int)stuff[i]);
+ if(i != evinfo->rep.size / sizeof(Window) - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_GetProperty:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetPropertyReply *stuff = (xGetPropertyReply *)rep;
+
+ REPLY (": PropertyType");
+ reply = xDbgGetAtom(stuff->propertyType, evinfo, reply, len);
+
+ REPLY (" bytesAfter(0x%x) format(%d) ItemNum(%ld)",
+ (unsigned int)stuff->bytesAfter,
+ stuff->format,
+ (long int)stuff->nItems);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_ListProperties:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xListPropertiesReply *stuff = (xListPropertiesReply *)rep;
+
+ REPLY (" PropertieNum(%d)",
+ stuff->nProperties);
+ }
+ else
+ {
+ Atom *stuff = (Atom *)rep;
+ int i;
+
+ REPLY ("Properties");
+ REPLY ("(");
+ for (i = 0 ; i < evinfo->rep.size / sizeof(Atom) ; i ++)
+ {
+ reply = xDbgGetAtom(stuff[i], evinfo, reply, len);
+ if(i != evinfo->rep.size / sizeof(Atom) - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_GetImage:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetImageReply *stuff = (xGetImageReply *)rep;
+
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->visual);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_GetKeyboardControl:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetKeyboardControlReply *stuff = (xGetKeyboardControlReply *)rep;
+
+ REPLY (": keyClickPercent(%d) bellPercent(%d), bellPitch(%d) bellDuration(%d)",
+ stuff->keyClickPercent,
+ stuff->bellPercent,
+ stuff->bellPitch,
+ stuff->bellDuration);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_GetPointerControl:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetPointerControlReply *stuff = (xGetPointerControlReply *)rep;
+
+ REPLY (": accelNumerator(%d) accelDenominator(%d), threshold(%d)",
+ stuff->accelNumerator,
+ stuff->accelDenominator,
+ stuff->threshold);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_CORE_H__
+#define __XDBG_EVLOG_CORE_H__
+
+#include "xdbg_types.h"
+
+char * xDbgEvlogRequestCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+char * xDbgEvlogReplyCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+char * xDbgEvlogEventCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/damageproto.h>
+
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_damage.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestDamage(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_DamageCreate:
+ {
+ xDamageCreateReq *stuff = (xDamageCreateReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x)",
+ (unsigned int)stuff->damage,
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *level;
+ char dlevel[10];
+
+ switch (stuff->level)
+ {
+ case XDamageReportRawRectangles: level = "DamageReportRawRegion"; break;
+ case XDamageReportDeltaRectangles: level = "DamageReportDeltaRegion"; break;
+ case XDamageReportBoundingBox: level = "DamageReportBoundingBox"; break;
+ case XDamageReportNonEmpty: level = "DamageReportNonEmpty"; break;
+ default: level = dlevel; snprintf (dlevel, 10, "%d", stuff->level); break;
+ }
+
+ REPLY (" level(%s)",
+ level);
+ }
+
+ return reply;
+ }
+
+ case X_DamageDestroy:
+ {
+ xDamageDestroyReq *stuff = (xDamageDestroyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->damage);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char*
+_EvlogEventDamage (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case XDamageNotify:
+ {
+ xDamageNotifyEvent *stuff = (xDamageNotifyEvent*)evt;
+ REPLY (": XID(0x%x) Damage(0x%x) area(%d,%d %dx%d) geo(%d,%d %dx%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->damage,
+ stuff->area.x,
+ stuff->area.y,
+ stuff->area.width,
+ stuff->area.height,
+ stuff->geometry.x,
+ stuff->geometry.y,
+ stuff->geometry.width,
+ stuff->geometry.height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) level(%d) sequence_num(%d)",
+ " ",
+ (unsigned long)stuff->timestamp,
+ stuff->level,
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyDamage (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+#if 0
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+
+ default:
+ break;
+ }
+#endif
+ return reply;
+}
+
+void
+xDbgEvlogDamageGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestDamage;
+ extinfo->evt_func = _EvlogEventDamage;
+ extinfo->rep_func = _EvlogReplyDamage;
+#else
+ ExtensionEntry *xext = CheckExtension (DAMAGE_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestDamage;
+ extinfo->evt_func = _EvlogEventDamage;
+ extinfo->rep_func = _EvlogReplyDamage;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_DAMAGE_H__
+#define __XDBG_EVLOG_DAMAGE_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogDamageGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <dri2/dri2.h>
+#include <X11/extensions/dri2proto.h>
+
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_dri2.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestDri2 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_DRI2CreateDrawable:
+ {
+ xDRI2CreateDrawableReq *stuff = (xDRI2CreateDrawableReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ return reply;
+ }
+
+ case X_DRI2DestroyDrawable:
+ {
+ xDRI2DestroyDrawableReq *stuff = (xDRI2DestroyDrawableReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ return reply;
+ }
+
+ case X_DRI2GetBuffers:
+ {
+ xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" count(%ld)",
+ (long int)stuff->count);
+ }
+
+ return reply;
+ }
+
+ case X_DRI2CopyRegion:
+ {
+ xDRI2CopyRegionReq *stuff = (xDRI2CopyRegionReq *)req;
+ REPLY (": XID(0x%x) src(0x%x) dst(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->src,
+ (unsigned int)stuff->dest);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" Region");
+ reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
+ }
+
+ return reply;
+ }
+
+ case X_DRI2GetBuffersWithFormat:
+ {
+ xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" count(%ld)",
+ (long int)stuff->count);
+ }
+
+ return reply;
+ }
+
+
+ case X_DRI2SwapBuffers:
+ {
+ xDRI2SwapBuffersReq *stuff = (xDRI2SwapBuffersReq *)req;
+ REPLY (": XID(0x%x) msc(0x%x/0x%x) divisor(0x%x/0x%x) remainder(0x%x/0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->target_msc_hi,
+ (unsigned int)stuff->target_msc_lo,
+ (unsigned int)stuff->divisor_hi,
+ (unsigned int)stuff->divisor_lo,
+ (unsigned int)stuff->remainder_hi,
+ (unsigned int)stuff->remainder_lo);
+
+ return reply;
+ }
+
+ case X_DRI2SwapInterval:
+ {
+ xDRI2SwapIntervalReq *stuff = (xDRI2SwapIntervalReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" interval(%ld)",
+ (long int)stuff->interval);
+ }
+
+ return reply;
+ }
+
+ case X_DRI2SwapBuffersWithRegion:
+ {
+ xDRI2SwapBuffersWithRegionReq *stuff = (xDRI2SwapBuffersWithRegionReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" Region");
+ reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogEventDri2 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case DRI2_BufferSwapComplete:
+ {
+ xDRI2BufferSwapComplete *stuff = (xDRI2BufferSwapComplete *) evt;
+ REPLY (": XID(0x%x) ust(0x%x/0x%x) msc(0x%x/0x%x) sbc(0x%x/0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->ust_hi,
+ (unsigned int)stuff->ust_lo,
+ (unsigned int)stuff->msc_hi,
+ (unsigned int)stuff->msc_lo,
+ (unsigned int)stuff->sbc_hi,
+ (unsigned int)stuff->sbc_lo);
+
+ evinfo->evt.size = sizeof (xDRI2BufferSwapComplete);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s sequence_num(%d) event_type(%d)",
+ " ",
+ stuff->sequenceNumber,
+ stuff->event_type);
+ }
+
+ return reply;
+ }
+
+ case DRI2_InvalidateBuffers:
+ {
+ xDRI2InvalidateBuffers *stuff = (xDRI2InvalidateBuffers *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyDri2 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_DRI2GetBuffers:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xDRI2GetBuffersReply *stuff = (xDRI2GetBuffersReply *)rep;
+ REPLY (": size(%ldx%ld) count(%ld)",
+ (long int)stuff->width,
+ (long int)stuff->height,
+ (long int)stuff->count);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+ }
+ }
+ else
+ {
+ xDRI2Buffer *stuff = (xDRI2Buffer *)rep;
+
+ REPLY ("attachment(0x%x) Name(0x%x) pitch(0x%x) cpp(0x%x) flags(0x%x)",
+ (unsigned int)stuff->attachment,
+ (unsigned int)stuff->name,
+ (unsigned int)stuff->pitch,
+ (unsigned int)stuff->cpp,
+ (unsigned int)stuff->flags);
+ }
+
+ return reply;
+ }
+
+ case X_DRI2SwapBuffers:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xDRI2SwapBuffersReply *stuff = (xDRI2SwapBuffersReply *)rep;
+ REPLY (": swap(%ld/%ld)",
+ (long int)stuff->swap_hi,
+ (long int)stuff->swap_lo);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+ }
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogDri2GetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestDri2;
+ extinfo->evt_func = _EvlogEventDri2;
+ extinfo->rep_func = _EvlogReplyDri2;
+#else
+ ExtensionEntry *xext = CheckExtension (DRI2_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestDri2;
+ extinfo->evt_func = _EvlogEventDri2;
+ extinfo->rep_func = _EvlogReplyDri2;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_DRI2_H__
+#define __XDBG_EVLOG_DRI2_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogDri2GetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog.h"
+#include "xdbg_evlog_event.h"
+
+
+#define UNKNOWN_EVENT "<unknown>"
+
+
+char *
+xDbgEvlogEvent (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ extern ExtensionInfo* Sorted_Evlog_extensions;
+ extern int Extensions_size;
+ EvlogEvent ev;
+ xEvent *xEvt = NULL;
+ int type;
+
+ RETURN_VAL_IF_FAIL (evinfo != NULL, reply);
+ RETURN_VAL_IF_FAIL (evinfo->type == EVENT, reply);
+
+ ev = evinfo->evt;
+ xEvt = ev.ptr;
+ type = xEvt->u.u.type;
+
+ REPLY ("%s", ev.name);
+
+ if (type > 0x7F)
+ REPLY ("(U)");
+ else
+ REPLY ("(S)");
+
+ type &= 0x7F;
+
+ if (type < EXTENSION_EVENT_BASE)
+ {
+ return xDbgEvlogEventCore (evinfo, detail_level, reply, len);
+ }
+ else
+ {
+ int i;
+
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ if (Sorted_Evlog_extensions[i].evt_base == 0)
+ continue;
+
+ if (i != Extensions_size - 1)
+ {
+ if (type >= Sorted_Evlog_extensions[i].evt_base &&
+ type < Sorted_Evlog_extensions[i+1].evt_base)
+ {
+ return Sorted_Evlog_extensions[i].evt_func (evinfo, Sorted_Evlog_extensions[i].evt_base, detail_level, reply, len);
+ }
+ continue;
+ }
+
+ return Sorted_Evlog_extensions[i].evt_func (evinfo, Sorted_Evlog_extensions[i].evt_base, detail_level, reply, len);
+ }
+
+ }
+
+ return reply;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_EVENT_H__
+#define __XDBG_EVLOG_EVENT_H__
+
+#include "xdbg_types.h"
+
+char * xDbgEvlogEvent (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <X11/extensions/gesture.h>
+#include <X11/extensions/gestureproto.h>
+
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_gesture.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestGesture(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_GestureSelectEvents:
+ {
+ xGestureSelectEventsReq *stuff = (xGestureSelectEventsReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" mask(0x%x)",
+ (unsigned int)stuff->mask);
+ }
+
+ return reply;
+ }
+
+ case X_GestureGetSelectedEvents:
+ {
+ xGestureGetSelectedEventsReq *stuff = (xGestureGetSelectedEventsReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_GestureGrabEvent:
+ {
+ xGestureGrabEventReq *stuff = (xGestureGrabEventReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *event_type;
+ char devent_type[10];
+
+ switch (stuff->eventType)
+ {
+ case GestureNotifyFlick: event_type = "GestureNotifyFlick"; break;
+ case GestureNotifyPan: event_type = "GestureNotifyPan"; break;
+ case GestureNotifyPinchRotation: event_type = "GestureNotifyPinchRotation"; break;
+ case GestureNotifyTap: event_type = "GestureNotifyTap"; break;
+ case GestureNotifyTapNHold: event_type = "GestureNotifyTapNHold"; break;
+ case GestureNotifyHold: event_type = "GestureNotifyHold"; break;
+ case GestureNotifyGroup: event_type = "GestureNotifyGroup"; break;
+ default: event_type = devent_type; sprintf (devent_type, "%ld", (long int)stuff->eventType); break;
+ }
+
+ REPLY (" event_type(%s) num_finger(%d) time(%lums)",
+ event_type,
+ stuff->num_finger,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_GestureUngrabEvent:
+ {
+ xGestureUngrabEventReq *stuff = (xGestureUngrabEventReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *event_type;
+ char devent_type[10];
+
+ switch (stuff->eventType)
+ {
+ case GestureNotifyFlick: event_type = "GestureNotifyFlick"; break;
+ case GestureNotifyPan: event_type = "GestureNotifyPan"; break;
+ case GestureNotifyPinchRotation: event_type = "GestureNotifyPinchRotation"; break;
+ case GestureNotifyTap: event_type = "GestureNotifyTap"; break;
+ case GestureNotifyTapNHold: event_type = "GestureNotifyTapNHold"; break;
+ case GestureNotifyHold: event_type = "GestureNotifyHold"; break;
+ case GestureNotifyGroup: event_type = "GestureNotifyGroup"; break;
+ default: event_type = devent_type; sprintf (devent_type, "%ld", (long int)stuff->eventType); break;
+ }
+
+ REPLY (" event_type(%s) num_finger(%d) time(%lums)",
+ event_type,
+ stuff->num_finger,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventGesture (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case GestureNotifyFlick:
+ {
+ xGestureNotifyFlickEvent *stuff = (xGestureNotifyFlickEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) time(%lums) num_finger(%d) direction(%d) distance(%d)",
+ kind,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->direction,
+ stuff->distance);
+
+ REPLY ("\n");
+ REPLY ("%67s duration(%lums) angle(%ld)",
+ " ",
+ (unsigned long)stuff->duration,
+ (long int)stuff->angle);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyPan:
+ {
+ xGestureNotifyPanEvent *stuff = (xGestureNotifyPanEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) sequence_num(%d) time(%lums) num_finger(%d) direction(%d) ",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->direction);
+
+ REPLY ("\n");
+ REPLY ("%67s distance(%d) duration(%ldms) coord(%d,%d)",
+ " ",
+ stuff->distance,
+ (long int)stuff->duration,
+ stuff->dx,
+ stuff->dy);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyPinchRotation:
+ {
+ xGestureNotifyPinchRotationEvent *stuff = (xGestureNotifyPinchRotationEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) sequence_num(%d) time(%lums) num_finger(%d) distance(%d)",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->distance);
+
+ REPLY ("\n");
+ REPLY ("%67s coord(%d,%d) zoom(%ld) angle(%ld)",
+ " ",
+ stuff->cx,
+ stuff->cy,
+ (long int)stuff->zoom,
+ (long int)stuff->angle);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyTap:
+ {
+ xGestureNotifyTapEvent *stuff = (xGestureNotifyTapEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) sequence_num(%d) time(%lums) num_finger(%d) coord(%d,%d)",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->cx,
+ stuff->cy);
+
+ REPLY ("\n");
+ REPLY ("%67s tap_repeat(%d) interval(%lums)",
+ " ",
+ stuff->tap_repeat,
+ (unsigned long)stuff->interval);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyTapNHold:
+ {
+ xGestureNotifyTapNHoldEvent *stuff = (xGestureNotifyTapNHoldEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) sequence_num(%d) time(%lums) num_finger(%d) coord(%d,%d)",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->cx,
+ stuff->cy);
+
+ REPLY ("\n");
+ REPLY ("%67s interval(%lums) hold_time(%lums)",
+ " ",
+ (unsigned long)stuff->interval,
+ (unsigned long)stuff->holdtime);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyHold:
+ {
+ xGestureNotifyHoldEvent *stuff = (xGestureNotifyHoldEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureEnd: kind = "GestureEnd"; break;
+ case GestureBegin: kind = "GestureBegin"; break;
+ case GestureUpdate: kind = "GestureUpdate"; break;
+ case GestureDone: kind = "GestureDone"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s) sequence_num(%d) time(%lums) num_finger(%d) coord(%d,%d) ",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->num_finger,
+ stuff->cx,
+ stuff->cy);
+
+ REPLY ("\n");
+ REPLY ("%67s hold_time(%lums)",
+ " ",
+ (unsigned long)stuff->holdtime);
+ }
+
+ return reply;
+ }
+
+ case GestureNotifyGroup:
+ {
+ xGestureNotifyGroupEvent *stuff = (xGestureNotifyGroupEvent *) evt;
+ REPLY (": XID(0x%x) groupID(%d) groupNum(%d)",
+ (unsigned int)stuff->window,
+ stuff->groupid,
+ stuff->num_group);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case GestureGroupRemoved: kind = "GestureGroupRemoved"; break;
+ case GestureGroupAdded: kind = "GestureGroupAdded"; break;
+ case GestureGroupCurrent: kind = "GestureGroupCurrent"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s kind(%s) sequence_num(%d) time(%lums) group_id(%d) num_group(%d)",
+ " ",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->groupid,
+ stuff->num_group);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyGesture (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+#if 0
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+
+ default:
+ break;
+ }
+#endif
+ return reply;
+}
+
+void
+xDbgEvlogGestureGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestGesture;
+ extinfo->evt_func = _EvlogEventGesture;
+ extinfo->rep_func = _EvlogReplyGesture;
+#else
+ ExtensionEntry *xext = CheckExtension (GESTURE_EXT_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestGesture;
+ extinfo->evt_func = _EvlogEventGesture;
+ extinfo->rep_func = _EvlogReplyGesture;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_GESTURE_H__
+#define __XDBG_EVLOG_GESTURE_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogGestureGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <X11/extensions/hwcproto.h>
+#include <X11/extensions/hwc.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_hwc.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestHwc (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+ int i;
+ CARD32 *p;
+
+ switch (req->data)
+ {
+ case X_HWCOpen:
+ {
+ xHWCOpenReq *stuff = (xHWCOpenReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_HWCSetDrawables:
+ {
+ xHWCSetDrawablesReq *stuff = (xHWCSetDrawablesReq *)req;
+ REPLY (": XID(0x%x) count(%ld)",
+ (unsigned int)stuff->window, stuff->count);
+
+ p = (CARD32 *) & req[3];
+ REPLY (" Drawables(");
+ for (i = 0; i < stuff->count; i++)
+ REPLY (" 0x%x", (unsigned int)p[i]);
+ REPLY (" )");
+
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogEventHwc (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xGenericEvent *evt = (xGenericEvent *)evinfo->evt.ptr;
+
+ switch (evt->evtype)
+ {
+ case HWCConfigureNotify:
+ {
+ xHWCConfigureNotify *stuff = (xHWCConfigureNotify *) evt;
+ REPLY (": maxLayer(%d)",
+ (unsigned int)stuff->maxLayer);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyHwc (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_HWCOpen:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xHWCOpenReply *stuff = (xHWCOpenReply *)rep;
+ REPLY (": maxLayers(%d)",
+ (unsigned int)stuff->maxLayer);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogHwcGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestHwc;
+ extinfo->evt_func = _EvlogEventHwc;
+ extinfo->rep_func = _EvlogReplyHwc;
+#else
+ ExtensionEntry *xext = CheckExtension (HWC_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestHwc;
+ extinfo->evt_func = _EvlogEventHwc;
+ extinfo->rep_func = _EvlogReplyHwc;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_HWC_H__
+#define __XDBG_EVLOG_HWC_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogHwcGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+
+#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/randrproto.h>
+
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_randr.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestRandr (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_RRGetScreenSizeRange:
+ {
+ xRRGetScreenSizeRangeReq *stuff = (xRRGetScreenSizeRangeReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_RRSetScreenSize:
+ {
+ xRRSetScreenSizeReq *stuff = (xRRSetScreenSizeReq *)req;
+ REPLY (": XID(0x%x) size(%dx%d)",
+ (unsigned int)stuff->window,
+ stuff->width,
+ stuff->height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" milliSize(%ldx%ld)",
+ (long int)stuff->widthInMillimeters,
+ (long int)stuff->heightInMillimeters);
+ }
+
+ return reply;
+ }
+
+ case X_RRGetScreenResources:
+ {
+ xRRGetScreenResourcesReq *stuff = (xRRGetScreenResourcesReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_RRGetOutputInfo:
+ {
+ xRRGetOutputInfoReq *stuff = (xRRGetOutputInfoReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" config_timestamp(%lums)",
+ (unsigned long)stuff->configTimestamp);
+ }
+
+ return reply;
+ }
+
+ case X_RRListOutputProperties:
+ {
+ xRRListOutputPropertiesReq *stuff = (xRRListOutputPropertiesReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ return reply;
+ }
+
+ case X_RRQueryOutputProperty:
+ {
+ xRRQueryOutputPropertyReq *stuff = (xRRQueryOutputPropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case X_RRConfigureOutputProperty:
+ {
+ xRRConfigureOutputPropertyReq *stuff = (xRRConfigureOutputPropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" pending(%s) range(%s)",
+ stuff->pending ? "YES" : "NO",
+ stuff->range ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_RRChangeOutputProperty:
+ {
+ xRRChangeOutputPropertyReq *stuff = (xRRChangeOutputPropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *mode;
+ char dmode[10];
+
+ switch (stuff->mode)
+ {
+ case PropModeReplace: mode = "PropModeReplace"; break;
+ case PropModePrepend: mode = "PropModePrepend"; break;
+ case PropModeAppend: mode = "PropModeAppend"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s mode(%s) format(%d) nUnits(%ld)",
+ " ",
+ mode,
+ stuff->format,
+ (long int)stuff->nUnits);
+ }
+
+ return reply;
+ }
+
+ case X_RRDeleteOutputProperty:
+ {
+ xRRDeleteOutputPropertyReq *stuff = (xRRDeleteOutputPropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case X_RRGetOutputProperty:
+ {
+ xRRGetOutputPropertyReq *stuff = (xRRGetOutputPropertyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" longOffset(%ld) longLength(%ld)",
+ (long int)stuff->longOffset,
+ (long int)stuff->longLength);
+ }
+
+ return reply;
+ }
+
+ case X_RRGetCrtcInfo:
+ {
+ xRRGetCrtcInfoReq *stuff = (xRRGetCrtcInfoReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->crtc);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" config_timestamp(%lums)",
+ (unsigned long)stuff->configTimestamp);
+ }
+
+ return reply;
+ }
+
+ case X_RRSetCrtcConfig:
+ {
+ xRRSetCrtcConfigReq *stuff = (xRRSetCrtcConfigReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d) ",
+ (unsigned int)stuff->crtc,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *rotation;
+
+ switch (stuff->rotation & 0xf)
+ {
+ case RR_Rotate_0: rotation = "RR_Rotate_0"; break;
+ case RR_Rotate_90: rotation = "RR_Rotate_90"; break;
+ case RR_Rotate_180: rotation = "RR_Rotate_180"; break;
+ case RR_Rotate_270: rotation = "RR_Rotate_270"; break;
+ default: rotation = "Invaild Rotation"; break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s timestamp(%lums) config_timestamp(%lums) RRmode(0x%x) rotation(%s)",
+ " ",
+ (unsigned long)stuff->timestamp,
+ (unsigned long)stuff->configTimestamp,
+ (unsigned int)stuff->mode,
+ rotation);
+ }
+
+ return reply;
+ }
+
+ case X_RRGetScreenResourcesCurrent:
+ {
+ xRRGetScreenResourcesCurrentReq *stuff = (xRRGetScreenResourcesCurrentReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogEventRandr (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case RRScreenChangeNotify:
+ {
+ xRRScreenChangeNotifyEvent *stuff = (xRRScreenChangeNotifyEvent *) evt;
+ REPLY (": Root(0x%x) Window(0x%x)",
+ (unsigned int)stuff->root,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *rotation;
+
+ switch (stuff->rotation & 0xf)
+ {
+ case RR_Rotate_0: rotation = "RR_Rotate_0"; break;
+ case RR_Rotate_90: rotation = "RR_Rotate_90"; break;
+ case RR_Rotate_180: rotation = "RR_Rotate_180"; break;
+ case RR_Rotate_270: rotation = "RR_Rotate_270"; break;
+ default: rotation = "Invaild Rotation"; break;
+ }
+
+ REPLY (" sizeID(%d) subPixel(%d) Pixel(%d,%d) Milli(%d,%d)",
+ stuff->sizeID,
+ stuff->subpixelOrder,
+ stuff->widthInPixels,
+ stuff->heightInPixels,
+ stuff->widthInMillimeters,
+ stuff->heightInMillimeters);
+
+ REPLY ("\n");
+ REPLY ("%67s rotation(%s) sequence_num(%d) timestamp(%lums) config_timestamp(%lums)",
+ " ",
+ rotation,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp,
+ (unsigned long)stuff->configTimestamp);
+ }
+
+ return reply;
+ }
+
+ case RRNotify:
+ {
+ switch(evt->u.u.detail)
+ {
+ case RRNotify_CrtcChange:
+ {
+ xRRCrtcChangeNotifyEvent *stuff = (xRRCrtcChangeNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Crtc(0x%x) RRmode(0x%x) new_size(%udx%ud) new_coord(%d,%d)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->crtc,
+ (unsigned int)stuff->mode,
+ stuff->width,
+ stuff->height,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *rotation;
+
+ switch (stuff->rotation & 0xf)
+ {
+ case RR_Rotate_0: rotation = "RR_Rotate_0"; break;
+ case RR_Rotate_90: rotation = "RR_Rotate_90"; break;
+ case RR_Rotate_180: rotation = "RR_Rotate_180"; break;
+ case RR_Rotate_270: rotation = "RR_Rotate_270"; break;
+ default: rotation = "Invaild Rotation"; break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s rotation(%s) sequence_num(%d) timestamp(%lums)",
+ " ",
+ rotation,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp);
+ }
+
+ return reply;
+ }
+
+ case RRNotify_OutputChange:
+ {
+ xRROutputChangeNotifyEvent *stuff = (xRROutputChangeNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Output(0x%x) Crtc(0x%x) RRmode(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->output,
+ (unsigned int)stuff->crtc,
+ (unsigned int)stuff->mode);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *rotation, *connection, *subpixelOrder;
+ char dconnection[10], dsubpixelOrder[10];
+
+ switch (stuff->rotation & 0xf)
+ {
+ case RR_Rotate_0: rotation = "RR_Rotate_0"; break;
+ case RR_Rotate_90: rotation = "RR_Rotate_90"; break;
+ case RR_Rotate_180: rotation = "RR_Rotate_180"; break;
+ case RR_Rotate_270: rotation = "RR_Rotate_270"; break;
+ default: rotation = "Invaild Rotation"; break;
+ }
+
+ switch (stuff->connection)
+ {
+ case RR_Connected: connection = "RR_Connected"; break;
+ case RR_Disconnected: connection = "RR_Disconnected"; break;
+ case RR_UnknownConnection: connection = "RR_UnknownConnection"; break;
+ default: connection = dconnection; snprintf (dconnection, 10, "%d", stuff->connection); break;
+ }
+
+ switch (stuff->subpixelOrder)
+ {
+ case SubPixelUnknown: subpixelOrder = "SubPixelUnknown"; break;
+ case SubPixelHorizontalRGB: subpixelOrder = "SubPixelHorizontalRGB"; break;
+ case SubPixelHorizontalBGR: subpixelOrder = "SubPixelHorizontalBGR"; break;
+ case SubPixelVerticalRGB: subpixelOrder = "SubPixelVerticalRGB"; break;
+ case SubPixelVerticalBGR: subpixelOrder = "SubPixelVerticalBGR"; break;
+ case SubPixelNone: subpixelOrder = "SubPixelNone"; break;
+ default: subpixelOrder = dsubpixelOrder; snprintf (dsubpixelOrder, 10, "%d", stuff->connection); break;
+ }
+
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+
+ REPLY ("\n");
+ REPLY ("%67s timestamp(%lums) config_timestamp(%lums) rotation(%s) connection(%s) subpixel_order(%s)",
+ " ",
+ (unsigned long)stuff->timestamp,
+ (unsigned long)stuff->configTimestamp,
+ rotation,
+ connection,
+ subpixelOrder);
+ }
+
+ return reply;
+ }
+
+ case RRNotify_OutputProperty:
+ {
+ xRROutputPropertyNotifyEvent *stuff = (xRROutputPropertyNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Output(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->output);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->atom, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *state;
+ char dstate[10];
+
+ switch (stuff->state)
+ {
+ case PropertyNewValue: state = "PropertyNewValue"; break;
+ case PropertyDelete: state = "PropertyDelete"; break;
+ default: state = dstate; snprintf (dstate, 10, "%d", stuff->state); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s sequence_num(%d) timestamp(%lums) state(%s)",
+ " ",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp,
+ state);
+ }
+
+ return reply;
+ }
+
+ case RRNotify_ProviderChange:
+ {
+ xRRProviderChangeNotifyEvent *stuff = (xRRProviderChangeNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Provider(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->provider);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d) timestamp(%lums)",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp);
+ }
+
+ return reply;
+ }
+
+ case RRNotify_ProviderProperty:
+ {
+ xRRProviderPropertyNotifyEvent *stuff = (xRRProviderPropertyNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Provider(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->provider);
+
+ REPLY (" Atom");
+ reply = xDbgGetAtom(stuff->atom, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *state;
+ char dstate[10];
+
+ switch (stuff->state)
+ {
+ case PropertyNewValue: state = "PropertyNewValue"; break;
+ case PropertyDelete: state = "PropertyDelete"; break;
+ default: state = dstate; snprintf (dstate, 10, "%d", stuff->state); break;
+ }
+
+ REPLY (" sequence_num(%d) timestamp(%lums) state(%s)",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp,
+ state);
+ }
+
+ return reply;
+ }
+
+ case RRNotify_ResourceChange:
+ {
+ xRRResourceChangeNotifyEvent *stuff = (xRRResourceChangeNotifyEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d) timestamp(%lums)",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->timestamp);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyRandr (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_RRGetScreenSizeRange:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xRRGetScreenSizeRangeReply *stuff = (xRRGetScreenSizeRangeReply *)rep;
+ REPLY (": minSize(%dx%d) maxSize(%dx%d)",
+ stuff->minWidth,
+ stuff->minHeight,
+ stuff->maxWidth,
+ stuff->maxHeight);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_RRGetScreenResources:
+ {
+ static int nCrtcs, nOutputs, nModes, nbytesNames;
+
+ if (evinfo->rep.isStart)
+ {
+ xRRGetScreenResourcesReply *stuff = (xRRGetScreenResourcesReply *)rep;
+ REPLY (": Timestamp(%ldms) ConfigTimestamp(%ldms) nCrtcs(%d) nOutputs(%d) nModes(%d) nbytesNames(%d)",
+ (long int)stuff->timestamp,
+ (long int)stuff->configTimestamp,
+ stuff->nCrtcs,
+ stuff->nOutputs,
+ stuff->nModes,
+ stuff->nbytesNames);
+
+ nCrtcs = stuff->nCrtcs;
+ nOutputs = stuff->nOutputs;
+ nModes = stuff->nModes;
+ nbytesNames = stuff->nbytesNames;
+ }
+ else
+ {
+ RRCrtc *crtcs = (RRCrtc *)rep;
+ RROutput *outputs = (RROutput *)(crtcs + nCrtcs);
+ xRRModeInfo *modeinfos = (xRRModeInfo *)(outputs + nOutputs);
+ CARD8 *names = (CARD8 *)(modeinfos + nModes);
+ char temp[64] = {0, };
+ int i;
+
+ names[nbytesNames] = '\0';
+
+ REPLY ("Crtcs");
+ REPLY ("(");
+ for (i = 0 ; i < nCrtcs ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)crtcs[i]);
+ if(i != nCrtcs - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Outputs");
+ REPLY ("(");
+ for (i = 0 ; i < nOutputs ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)outputs[i]);
+ if(i != nOutputs - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Modes");
+ REPLY ("(");
+ for (i = 0 ; i < nModes ; i++)
+ {
+ REPLY ("0x%x %dx%d", (unsigned int)modeinfos[i].id, modeinfos[i].width, modeinfos[i].height);
+ if(i != nModes - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Names");
+
+ int min = MIN (sizeof (temp) - 1, nbytesNames);
+ strncpy (temp, (char *)names, min);
+ temp[min] = '\0';
+
+ REPLY ("(");
+ REPLY ("%s", temp);
+ REPLY (")");
+
+ }
+
+ return reply;
+ }
+
+ case X_RRGetOutputInfo:
+ {
+ static int nCrtcs, nModes, nClones, namelength;
+ if (evinfo->rep.isStart)
+ {
+ xRRGetOutputInfoReply *stuff = (xRRGetOutputInfoReply *)rep;
+ REPLY (": Timestamp(%ldms) Crtc(0x%x) mmSize(%ldx%ld) nCrtcs(%d) nModes(%d) nPreferred(%d) nClones(%d)",
+ (long int)stuff->timestamp,
+ (unsigned int)stuff->crtc,
+ (long int)stuff->mmWidth,
+ (long int)stuff->mmHeight,
+ stuff->nCrtcs,
+ stuff->nModes,
+ stuff->nPreferred,
+ stuff->nClones);
+
+ nCrtcs = stuff->nCrtcs;
+ nModes = stuff->nModes;
+ nClones = stuff->nClones;
+ namelength = stuff->nameLength;
+ }
+ else
+ {
+ RRCrtc *crtcs = (RRCrtc *) rep;
+ RRMode *modes = (RRMode *) (crtcs + nCrtcs);
+ RROutput *clones = (RROutput *) (modes + nModes);
+ char *name = (char *) (clones + nClones);
+ int i;
+
+ name[namelength] = '\0';
+
+ REPLY ("Crtcs");
+ REPLY ("(");
+ for (i = 0 ; i < nCrtcs ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)crtcs[i]);
+ if(i != nCrtcs - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Modes");
+ REPLY ("(");
+ for (i = 0 ; i < nModes ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)modes[i]);
+ if(i != nModes - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Clone");
+ REPLY ("(");
+ for (i = 0 ; i < nClones ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)clones[i]);
+ if(i != nClones - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Name");
+ REPLY ("(");
+ REPLY ("%s", name);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_RRListOutputProperties:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xRRListOutputPropertiesReply *stuff = (xRRListOutputPropertiesReply *)rep;
+ REPLY (": nAtoms(%d)",
+ stuff->nAtoms);
+ }
+ else
+ {
+ Atom *stuff = (Atom *)rep;
+ int i;
+
+ REPLY ("Properties:");
+ for (i = 0 ; i < evinfo->rep.size / sizeof(Atom) ; i++)
+ {
+ reply = xDbgGetAtom(stuff[i], evinfo, reply, len);
+ if(i != evinfo->rep.size / sizeof(Atom) - 1)
+ REPLY (", ");
+ }
+ }
+
+ return reply;
+ }
+
+ case X_RRGetOutputProperty:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xRRGetOutputPropertyReply *stuff = (xRRGetOutputPropertyReply *)rep;
+ REPLY (": Atoms");
+ reply = xDbgGetAtom(stuff->propertyType, evinfo, reply, len);
+
+ REPLY (" bytesAfter(%ld) nItems(%ld)",
+ (long int)stuff->bytesAfter,
+ (long int)stuff->nItems);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_RRGetCrtcInfo:
+ {
+ static int nOutput, nPossibleOutput;
+
+ if (evinfo->rep.isStart)
+ {
+ xRRGetCrtcInfoReply *stuff = (xRRGetCrtcInfoReply *)rep;
+ REPLY (" Timestamp(%ldms) coord(%d,%d %dx%d) RRmode(0x%x) rot(%d) rots(%d) nOutput(%d) nPossibleOutput(%d)",
+ (long int)stuff->timestamp,
+ stuff->x,
+ stuff->y,
+ stuff->width,
+ stuff->height,
+ (unsigned int)stuff->mode,
+ stuff->rotation,
+ stuff->rotations,
+ stuff->nOutput,
+ stuff->nPossibleOutput);
+
+ nOutput = stuff->nOutput;
+ nPossibleOutput = stuff->nPossibleOutput;
+ }
+ else
+ {
+ RROutput *outputs = (RROutput *) rep;
+ RROutput *possible = (RROutput *) (outputs + nOutput);
+ int i;
+
+ REPLY ("Outputs");
+ REPLY ("(");
+ for (i = 0 ; i < nOutput ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)outputs[i]);
+ if(i != nOutput - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Possible");
+ REPLY ("(");
+ for (i = 0 ; i < nPossibleOutput ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)possible[i]);
+ if(i != nPossibleOutput - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_RRSetCrtcConfig:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xRRSetCrtcConfigReply *stuff = (xRRSetCrtcConfigReply *)rep;
+
+ REPLY (" newTimestamp(%ldms)",
+ (long int)stuff->newTimestamp);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_RRGetScreenResourcesCurrent:
+ {
+ static int nCrtcs, nOutputs, nModes, nbytesNames;
+
+ if (evinfo->rep.isStart)
+ {
+ xRRGetScreenResourcesReply *stuff = (xRRGetScreenResourcesReply *)rep;
+
+ REPLY (" Timestamp(%ldms) ConfigTimestamp(%ldms) nCrtcs(%d) nOutputs(%d) nModes(%d) nbytesNames(%d)",
+ (long int)stuff->timestamp,
+ (long int)stuff->configTimestamp,
+ stuff->nCrtcs,
+ stuff->nOutputs,
+ stuff->nModes,
+ stuff->nbytesNames);
+
+ nCrtcs = stuff->nCrtcs;
+ nOutputs = stuff->nOutputs;
+ nModes = stuff->nModes;
+ nbytesNames = stuff->nbytesNames;
+ }
+ else
+ {
+ RRCrtc *crtcs = (RRCrtc *)rep;
+ RROutput *outputs = (RROutput *)(crtcs + nCrtcs);
+ xRRModeInfo *modeinfos = (xRRModeInfo *)(outputs + nOutputs);
+ CARD8 *names = (CARD8 *)(modeinfos + nModes);
+ char temp[64] = {0, };
+ int i;
+
+ REPLY ("Crtcs");
+ REPLY ("(");
+ for (i = 0 ; i < nCrtcs ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)crtcs[i]);
+ if(i != nCrtcs - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Outputs");
+ REPLY ("(");
+ for (i = 0 ; i < nOutputs ; i++)
+ {
+ REPLY ("0x%x", (unsigned int)outputs[i]);
+ if(i != nOutputs - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Modes");
+ REPLY ("(");
+ for (i = 0 ; i < nModes ; i++)
+ {
+ REPLY ("0x%x %dx%d", (unsigned int)modeinfos[i].id, modeinfos[i].width, modeinfos[i].height);
+ if(i != nModes - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ REPLY (" Names");
+
+ int min = MIN (sizeof (temp) - 1, nbytesNames);
+ strncpy (temp, (char *)names, min);
+ temp[min] = '\0';
+
+ REPLY ("(");
+ REPLY ("%s", temp);
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogRandrGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestRandr;
+ extinfo->evt_func = _EvlogEventRandr;
+ extinfo->rep_func = _EvlogReplyRandr;
+#else
+ ExtensionEntry *xext = CheckExtension (RANDR_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestRandr;
+ extinfo->evt_func = _EvlogEventRandr;
+ extinfo->rep_func = _EvlogReplyRandr;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_RANDR_H__
+#define __XDBG_EVLOG_RANDR_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogRandrGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <sys/shm.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog.h"
+#include "xdbg_evlog_reply.h"
+
+#define UNKNOWN_EVENT "<unknown>"
+
+char *
+xDbgEvlogReply (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ extern ExtensionInfo Evlog_extensions[];
+ extern int Extensions_size;
+ EvlogReply rep;
+ int i;
+
+ RETURN_VAL_IF_FAIL (evinfo != NULL, reply);
+ RETURN_VAL_IF_FAIL (evinfo->type == REPLY, reply);
+
+ rep = evinfo->rep;
+
+ if (rep.isStart)
+ REPLY ("%s", evinfo->rep.name);
+
+ if (rep.reqType < EXTENSION_BASE)
+ {
+ return xDbgEvlogReplyCore (evinfo, detail_level, reply, len);
+ }
+ else
+ {
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ if (rep.reqType == Evlog_extensions[i].opcode)
+ {
+ return Evlog_extensions[i].rep_func (evinfo, detail_level, reply, len);
+ }
+ }
+ }
+
+ return reply;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_REPLY_H__
+#define __XDBG_EVLOG_REPLY_H__
+
+#include "xdbg_types.h"
+
+char * xDbgEvlogReply (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+#include <sys/shm.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog.h"
+#include "xdbg_evlog_request.h"
+
+#define UNKNOWN_EVENT "<unknown>"
+
+char *conn[] = {"Initial Connect", "Establich Connect"};
+
+char *
+xDbgEvlogReqeust (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ extern ExtensionInfo Evlog_extensions[];
+ extern int Extensions_size;
+ EvlogRequest req;
+ xReq *xReq = NULL;
+ int i;
+
+ RETURN_VAL_IF_FAIL (evinfo != NULL, reply);
+ RETURN_VAL_IF_FAIL (evinfo->type == REQUEST, reply);
+
+ req = evinfo->req;
+ xReq = req.ptr;
+
+ REPLY ("%s", evinfo->req.name);
+
+ for (i = 0 ; i < sizeof(conn) / sizeof(char *) ; i++)
+ if (!strcmp(evinfo->req.name, conn[i]))
+ return reply;
+
+ if (xReq->reqType < EXTENSION_BASE)
+ {
+ return xDbgEvlogRequestCore (evinfo, detail_level, reply, len);
+ }
+ else
+ {
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ if (xReq->reqType == Evlog_extensions[i].opcode)
+ {
+ return Evlog_extensions[i].req_func (evinfo, detail_level, reply, len);
+ }
+ }
+ }
+
+ return reply;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_REQUEST_H__
+#define __XDBG_EVLOG_REQUEST_H__
+
+#include "xdbg_types.h"
+
+char * xDbgEvlogReqeust (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/dpms.h>
+#include <X11/extensions/sync.h>
+#include <X11/extensions/xtestext1.h>
+#include <X11/extensions/XTest.h>
+#include <X11/Xlibint.h>
+
+#include <X11/extensions/dpmsproto.h>
+#include <X11/extensions/shmproto.h>
+#include <X11/extensions/syncproto.h>
+#include <X11/extensions/xtestext1proto.h>
+#include <X11/extensions/xtestproto.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_xext.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestXextDpms(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_DPMSSetTimeouts:
+ {
+ xDPMSSetTimeoutsReq *stuff = (xDPMSSetTimeoutsReq *)req;
+ REPLY (": Standby(%d) Suspend(%d) off(%d)",
+ stuff->standby,
+ stuff->suspend,
+ stuff->off);
+
+ return reply;
+ }
+
+ case X_DPMSForceLevel:
+ {
+ xDPMSForceLevelReq *stuff = (xDPMSForceLevelReq *)req;
+ REPLY (": Level(%d)",
+ stuff->level);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogRequestXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_ShmPutImage:
+ {
+ xShmPutImageReq *stuff = (xShmPutImageReq *)req;
+ REPLY (": XID(0x%x) gc(0x%x) size(%dx%d) src(%d,%d %dx%d) dst(%d,%d)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->totalWidth,
+ stuff->totalHeight,
+ stuff->srcX,
+ stuff->srcY,
+ stuff->srcWidth,
+ stuff->srcHeight,
+ stuff->dstX,
+ stuff->dstY);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *format;
+ char dformat[10];
+
+ switch (stuff->format)
+ {
+ case XYBitmap: format = "XYBitmap"; break;
+ case XYPixmap: format = "XYPixmap"; break;
+ case ZPixmap: format = "ZPixmap"; break;
+ default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s depth(%d) format(%s) send_event(%s) shmseg(0x%x) offset(%ld)",
+ " ",
+ stuff->depth,
+ format,
+ stuff->sendEvent ? "YES" : "NO",
+ (unsigned int)stuff->shmseg,
+ (long int)stuff->offset);
+ }
+
+ return reply;
+ }
+
+ case X_ShmGetImage:
+ {
+ xShmGetImageReq *stuff = (xShmGetImageReq *)req;
+ REPLY (": XID(0x%x) size(%dx%d) coord(%d,%d)",
+ (unsigned int)stuff->drawable,
+ stuff->width,
+ stuff->height,
+ stuff->x,
+ stuff->y);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *format;
+ char dformat[10];
+
+ switch (stuff->format)
+ {
+ case XYBitmap: format = "XYBitmap"; break;
+ case XYPixmap: format = "XYPixmap"; break;
+ case ZPixmap: format = "ZPixmap"; break;
+ default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
+ }
+
+ REPLY ("\n");
+ REPLY ("%67s format(%s) plain_mask(0x%x) shmseg(0x%x) offset(%ld)",
+ " ",
+ format,
+ (unsigned int)stuff->planeMask,
+ (unsigned int)stuff->shmseg,
+ (long int)stuff->offset);
+ }
+
+ return reply;
+ }
+
+ case X_ShmCreatePixmap:
+ {
+ xShmCreatePixmapReq *stuff = (xShmCreatePixmapReq *)req;
+ REPLY (": Pixmap(0x%x) Drawable(0x%x) size(%dx%d)",
+ (unsigned int)stuff->pid,
+ (unsigned int)stuff->drawable,
+ stuff->width,
+ stuff->height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s depth(%d) shmseg(0x%x) offset(%ld)",
+ " ",
+ stuff->depth,
+ (unsigned int)stuff->shmseg,
+ (long int)stuff->offset);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogRequestXextSync(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_SyncCreateCounter:
+ {
+ xSyncCreateCounterReq *stuff = (xSyncCreateCounterReq *)req;
+ REPLY (": XID(0x%x) initValue(%ld/%ld)",
+ (unsigned int)stuff->cid,
+ (long int)stuff->initial_value_hi,
+ (long int)stuff->initial_value_lo);
+
+ return reply;
+ }
+
+ case X_SyncSetCounter:
+ {
+ xSyncSetCounterReq *stuff = (xSyncSetCounterReq *)req;
+ REPLY (": XID(0x%x) Value(%ld/%ld)",
+ (unsigned int)stuff->cid,
+ (long int)stuff->value_hi,
+ (long int)stuff->value_lo);
+
+ return reply;
+ }
+
+ case X_SyncChangeCounter:
+ {
+ xSyncChangeCounterReq *stuff = (xSyncChangeCounterReq *)req;
+ REPLY (": XID(0x%x) Value(%ld/%ld)",
+ (unsigned int)stuff->cid,
+ (long int)stuff->value_hi,
+ (long int)stuff->value_lo);
+
+ return reply;
+ }
+
+ case X_SyncQueryCounter:
+ {
+ xSyncQueryCounterReq *stuff = (xSyncQueryCounterReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->counter);
+
+ return reply;
+ }
+
+ case X_SyncDestroyCounter:
+ {
+ xSyncDestroyCounterReq *stuff = (xSyncDestroyCounterReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->counter);
+
+ return reply;
+ }
+
+ case X_SyncAwait:
+ {
+ xSyncAwaitReq *stuff = (xSyncAwaitReq*)req;
+ xSyncWaitCondition *pProtocolWaitConds;
+
+ pProtocolWaitConds = (xSyncWaitCondition *) &stuff[1];
+ REPLY (": XID(0x%x) VType:%d TType:%d Value(%d/%d)",
+ (unsigned int)pProtocolWaitConds->counter,
+ (unsigned int)pProtocolWaitConds->value_type,
+ (unsigned int)pProtocolWaitConds->test_type,
+ (unsigned int)pProtocolWaitConds->wait_value_hi,
+ (unsigned int)pProtocolWaitConds->wait_value_lo);
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogRequestXextXtestExt1(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_TestFakeInput:
+ {
+ xTestFakeInputReq *stuff = (xTestFakeInputReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->ack);
+
+ return reply;
+ }
+
+ case X_TestGetInput:
+ {
+ xTestGetInputReq *stuff = (xTestGetInputReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->mode);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogRequestXextXtest(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_XTestGetVersion:
+ {
+ xXTestGetVersionReq *stuff = (xXTestGetVersionReq *)req;
+ REPLY (": MajorVersion(%d) MinorVersion(%d)",
+ stuff->majorVersion,
+ stuff->minorVersion);
+
+ return reply;
+ }
+
+ case X_XTestCompareCursor:
+ {
+ xXTestCompareCursorReq *stuff = (xXTestCompareCursorReq *)req;
+ REPLY (": XID(0x%x) Cursor(0x%x)",
+ (unsigned int)stuff->window,
+ (unsigned int)stuff->cursor);
+
+ return reply;
+ }
+
+ case X_XTestFakeInput:
+ {
+ xXTestFakeInputReq *stuff = (xXTestFakeInputReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->root,
+ stuff->rootX,
+ stuff->rootY);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" type(%d) detail(%d) time(%lums) device_id(%d)",
+ stuff->type,
+ stuff->detail,
+ (unsigned long)stuff->time,
+ stuff->deviceid);
+ }
+
+ return reply;
+ }
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogRequestXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_ShapeRectangles:
+ {
+ xShapeRectanglesReq *stuff = (xShapeRectanglesReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->dest,
+ stuff->xOff,
+ stuff->yOff);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ int i;
+ int nrect;
+ xRectangle *prect;
+ const char *destKind, *ordering;
+ char ddestKind[10], dordering[10];
+
+ switch (stuff->destKind)
+ {
+ case ShapeBounding: destKind = "ShapeBounding"; break;
+ case ShapeClip: destKind = "ShapeClip"; break;
+ case ShapeInput: destKind = "ShapeInput"; break;
+ default: destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
+ }
+
+ switch (stuff->ordering)
+ {
+ case Unsorted: ordering = "Unsorted"; break;
+ case YSorted: ordering = "YSorted"; break;
+ case YXSorted: ordering = "YXSorted"; break;
+ case YXBanded: ordering = "YXBanded"; break;
+ default: ordering = dordering; snprintf (dordering, 10, "%d", stuff->ordering); break;
+ }
+
+ nrect = ((stuff->length * 4) - sizeof(xShapeRectanglesReq)) / sizeof(xRectangle);
+ prect = (xRectangle *) &stuff[1];
+
+ REPLY (" op(%d) destKind(%s) ordering(%s) nrect(%d)",
+ stuff->op,
+ destKind,
+ ordering,
+ nrect);
+
+ REPLY ("\n");
+ REPLY ("%67s Region", " ");
+ REPLY ("(");
+
+ for (i = 0 ; i < nrect ; i++)
+ {
+ REPLY("[%d,%d %dx%d]",
+ prect[i].x,
+ prect[i].y,
+ prect[i].width,
+ prect[i].height);
+
+ if(i != nrect - 1)
+ REPLY (", ");
+ }
+
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_ShapeMask:
+ {
+ xShapeMaskReq *stuff = (xShapeMaskReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d) src(0x%x)",
+ (unsigned int)stuff->dest,
+ stuff->xOff,
+ stuff->yOff,
+ (unsigned int)stuff->src);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *destKind;
+ char ddestKind[10];
+
+ switch (stuff->destKind)
+ {
+ case ShapeBounding: destKind = "ShapeBounding"; break;
+ case ShapeClip: destKind = "ShapeClip"; break;
+ case ShapeInput: destKind = "ShapeInput"; break;
+ default: destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
+ }
+
+ REPLY (" op(%d) destKind(%s)",
+ stuff->op,
+ destKind);
+ }
+
+ return reply;
+ }
+
+ case X_ShapeCombine:
+ {
+ xShapeCombineReq *stuff = (xShapeCombineReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d) src(0x%x)",
+ (unsigned int)stuff->dest,
+ stuff->xOff,
+ stuff->yOff,
+ (unsigned int)stuff->src);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *destKind, *srcKind;
+ char ddestKind[10], dsrcKind[10];
+
+ switch (stuff->destKind)
+ {
+ case ShapeBounding: destKind = "ShapeBounding"; break;
+ case ShapeClip: destKind = "ShapeClip"; break;
+ case ShapeInput: destKind = "ShapeInput"; break;
+ default: destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
+ }
+
+ switch (stuff->srcKind)
+ {
+ case ShapeBounding: srcKind = "ShapeBounding"; break;
+ case ShapeClip: srcKind = "ShapeClip"; break;
+ case ShapeInput: srcKind = "ShapeInput"; break;
+ default: srcKind = dsrcKind; snprintf (dsrcKind, 10, "%d", stuff->srcKind); break;
+ }
+
+ REPLY (" op(%d) destKind(%s) srcKind(%s)",
+ stuff->op,
+ destKind,
+ srcKind);
+ }
+
+ return reply;
+ }
+
+ case X_ShapeOffset:
+ {
+ xShapeOffsetReq *stuff = (xShapeOffsetReq *)req;
+ REPLY (": XID(0x%x) coord(%d,%d)",
+ (unsigned int)stuff->dest,
+ stuff->xOff,
+ stuff->yOff);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *destKind;
+ char ddestKind[10];
+
+ switch (stuff->destKind)
+ {
+ case ShapeBounding: destKind = "ShapeBounding"; break;
+ case ShapeClip: destKind = "ShapeClip"; break;
+ case ShapeInput: destKind = "ShapeInput"; break;
+ default: destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
+ }
+
+ REPLY (" destKind(%s)",
+ destKind);
+ }
+
+ return reply;
+ }
+
+ case X_ShapeQueryExtents:
+ {
+ xShapeQueryExtentsReq *stuff = (xShapeQueryExtentsReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_ShapeSelectInput:
+ {
+ xShapeSelectInputReq *stuff = (xShapeSelectInputReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" enable(%s)",
+ stuff->enable ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_ShapeInputSelected:
+ {
+ xShapeInputSelectedReq *stuff = (xShapeInputSelectedReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ return reply;
+ }
+
+ case X_ShapeGetRectangles:
+ {
+ xShapeGetRectanglesReq *stuff = (xShapeGetRectanglesReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case ShapeBounding: kind = "ShapeBounding"; break;
+ case ShapeClip: kind = "ShapeClip"; break;
+ case ShapeInput: kind = "ShapeInput"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+ REPLY (" kind(%s)",
+ kind);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventXextDpms (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+#if 0
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+
+ default:
+ break;
+ }
+#endif
+ return reply;
+}
+
+
+static char *
+_EvlogEventXextShm (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case ShmCompletion:
+ {
+ xShmCompletionEvent *stuff = (xShmCompletionEvent *) evt;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d) major_event(%d) minor_event(%d) shmseg(0x%x) offset(%ld)",
+ stuff->sequenceNumber,
+ stuff->majorEvent,
+ stuff->minorEvent,
+ (unsigned int)stuff->shmseg,
+ (long int)stuff->offset);
+ }
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogEventXextSync (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case XSyncCounterNotify:
+ {
+ xSyncCounterNotifyEvent *stuff = (xSyncCounterNotifyEvent *) evt;
+ REPLY (": XID(0x%x) WaitValue(0x%x/0x%x) CounterValue(0x%x/0x%x)",
+ (unsigned int)stuff->counter,
+ (unsigned int)stuff->wait_value_hi,
+ (unsigned int)stuff->wait_value_lo,
+ (unsigned int)stuff->counter_value_hi,
+ (unsigned int)stuff->counter_value_lo);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s sequence_num(%d) time(%lums) count(%d) destroyed(%s)",
+ " ",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->count,
+ stuff->destroyed ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case XSyncAlarmNotify:
+ {
+ xSyncAlarmNotifyEvent *stuff = (xSyncAlarmNotifyEvent *) evt;
+ REPLY (": XID(0x%x) CounterValue(0x%x/0x%x) AlarmValue(0x%x/0x%x)",
+ (unsigned int)stuff->alarm,
+ (unsigned int)stuff->counter_value_hi,
+ (unsigned int)stuff->counter_value_lo,
+ (unsigned int)stuff->alarm_value_hi,
+ (unsigned int)stuff->alarm_value_lo);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s sequence_num(%d) time(%lums) state(%d)",
+ " ",
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->state);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+
+static char *
+_EvlogEventXextXtestExt1 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventXextXtest (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventXextShape (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case ShapeNotify:
+ {
+ xShapeNotifyEvent *stuff = (xShapeNotifyEvent *) evt;
+ REPLY (": XID(0x%x) coord(%d,%d %dx%d)",
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ stuff->width,
+ stuff->height);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *kind;
+ char dkind[10];
+
+ switch (stuff->kind)
+ {
+ case ShapeBounding: kind = "ShapeBounding"; break;
+ case ShapeClip: kind = "ShapeClip"; break;
+ case ShapeInput: kind = "ShapeInput"; break;
+ default: kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
+ }
+
+
+ REPLY ("\n");
+ REPLY ("%67s kind(%s) sequence_num(%d) time(%lums) shaped(%s)",
+ " ",
+ kind,
+ stuff->sequenceNumber,
+ (unsigned long)stuff->time,
+ stuff->shaped ? "EXIST" : "NON_EXIST");
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextDpms (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_DPMSSetTimeouts:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xDPMSGetTimeoutsReply *stuff = (xDPMSGetTimeoutsReply *)rep;
+ REPLY (": Standby(%usec) Suspend(%usec) off(%usec) sequence_num(%d)",
+ stuff->standby,
+ stuff->suspend,
+ stuff->off,
+ stuff->sequenceNumber);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_ShmGetImage:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xShmGetImageReply *stuff = (xShmGetImageReply *)rep;
+ REPLY (": Visual(0x%x) size(%ld) sequence_num(%d)",
+ (unsigned int)stuff->visual,
+ (long int)stuff->size,
+ stuff->sequenceNumber);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextSync (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_SyncQueryCounter:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xSyncQueryCounterReply *stuff = (xSyncQueryCounterReply *)rep;
+ REPLY (": Value(%ld/%ld) sequence_num(%d)",
+ (long int)stuff->value_hi,
+ (long int)stuff->value_lo,
+ stuff->sequenceNumber);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextXtestExt1 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_TestQueryInputSize:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xTestQueryInputSizeReply *stuff = (xTestQueryInputSizeReply *)rep;
+ REPLY (": sizeReturn(0x%x) sequence_num(%d)",
+ (unsigned int)stuff->size_return,
+ stuff->sequenceNumber);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextXtest (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_XTestGetVersion:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXTestGetVersionReply *stuff = (xXTestGetVersionReply *)rep;
+ REPLY (": MinorVersion(%d) sequence_num(%d)",
+ stuff->minorVersion,
+ stuff->sequenceNumber);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_ShapeQueryVersion:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xShapeQueryVersionReply *stuff = (xShapeQueryVersionReply *)rep;
+ REPLY (": MajorVersion(%d) MinorVersion(%d)",
+ stuff->majorVersion,
+ stuff->minorVersion);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_ShapeQueryExtents:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xShapeQueryExtentsReply *stuff = (xShapeQueryExtentsReply *)rep;
+
+ REPLY (": bounding_shaped(%s)",
+ stuff->boundingShaped ? "YES" : "NO");
+
+ if (stuff->boundingShaped)
+ REPLY (" bounding(%d,%d %dx%d)",
+ stuff->xClipShape,
+ stuff->yClipShape,
+ stuff->widthClipShape,
+ stuff->heightClipShape);
+ else
+ REPLY (" bounding(None)");
+
+
+ REPLY (" clip_shaped(%s)",
+ stuff->clipShaped ? "YES" : "NO");
+
+ if (stuff->boundingShaped)
+ REPLY (" clip(%d,%d %dx%d)",
+ stuff->xBoundingShape,
+ stuff->yBoundingShape,
+ stuff->widthBoundingShape,
+ stuff->heightBoundingShape);
+ else
+ REPLY (" clip(None)");
+
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_ShapeInputSelected:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xShapeInputSelectedReply *stuff = (xShapeInputSelectedReply *)rep;
+
+ REPLY (" enable(%s)",
+ stuff->enabled ? "YES" : "NO");
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_ShapeGetRectangles:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xShapeGetRectanglesReply *stuff = (xShapeGetRectanglesReply *)rep;
+
+ const char *ordering;
+ char dordering[10];
+
+ switch (stuff->ordering)
+ {
+ case Unsorted: ordering = "Unsorted"; break;
+ case YSorted: ordering = "YSorted"; break;
+ case YXSorted: ordering = "YXSorted"; break;
+ case YXBanded: ordering = "YXBanded"; break;
+ default: ordering = dordering; snprintf (dordering, 10, "%d", stuff->ordering); break;
+ }
+ REPLY (": ordering(%s) nrects(%ld)",
+ ordering,
+ (long int)stuff->nrects);
+ }
+ else
+ {
+ xRectangle *stuff = (xRectangle *)rep;
+ int i;
+
+ REPLY ("Region");
+ REPLY ("(");
+ for (i = 0 ; i < evinfo->rep.size / sizeof(xRectangle) ; i ++)
+ {
+ REPLY ("[%d,%d %dx%d]",
+ stuff->x,
+ stuff->y,
+ stuff->width,
+ stuff->height);
+
+ if(i != evinfo->rep.size / sizeof(xRectangle) - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogXextDpmsGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextDpms;
+ extinfo->evt_func = _EvlogEventXextDpms;
+ extinfo->rep_func = _EvlogReplyXextDpms;
+#else
+ ExtensionEntry *xext = CheckExtension (DPMSExtensionName);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextDpms;
+ extinfo->evt_func = _EvlogEventXextDpms;
+ extinfo->rep_func = _EvlogReplyXextDpms;
+#endif
+}
+
+
+void
+xDbgEvlogXextShmGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextShm;
+ extinfo->evt_func = _EvlogEventXextShm;
+ extinfo->rep_func = _EvlogReplyXextShm;
+#else
+ ExtensionEntry *xext = CheckExtension (SHMNAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextShm;
+ extinfo->evt_func = _EvlogEventXextShm;
+ extinfo->rep_func = _EvlogReplyXextShm;
+#endif
+}
+
+
+void
+xDbgEvlogXextSyncGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextSync;
+ extinfo->evt_func = _EvlogEventXextSync;
+ extinfo->rep_func = _EvlogReplyXextSync;
+#else
+ ExtensionEntry *xext = CheckExtension (SYNC_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextSync;
+ extinfo->evt_func = _EvlogEventXextSync;
+ extinfo->rep_func = _EvlogReplyXextSync;
+#endif
+
+}
+
+
+void
+xDbgEvlogXextXtestExt1GetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextXtestExt1;
+ extinfo->evt_func = _EvlogEventXextXtestExt1;
+ extinfo->rep_func = _EvlogReplyXextXtestExt1;
+#else
+ ExtensionEntry *xext = CheckExtension (XTestEXTENSION_NAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextXtestExt1;
+ extinfo->evt_func = _EvlogEventXextXtestExt1;
+ extinfo->rep_func = _EvlogReplyXextXtestExt1;
+#endif
+
+}
+
+
+void
+xDbgEvlogXextXtestGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextXtest;
+ extinfo->evt_func = _EvlogEventXextXtest;
+ extinfo->rep_func = _EvlogReplyXextXtest;
+#else
+ ExtensionEntry *xext = CheckExtension (XTestExtensionName);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextXtest;
+ extinfo->evt_func = _EvlogEventXextXtest;
+ extinfo->rep_func = _EvlogReplyXextXtest;
+#endif
+}
+
+void
+xDbgEvlogXextShapeGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXextShape;
+ extinfo->evt_func = _EvlogEventXextShape;
+ extinfo->rep_func = _EvlogReplyXextShape;
+#else
+ ExtensionEntry *xext = CheckExtension (SHAPENAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXextShape;
+ extinfo->evt_func = _EvlogEventXextShape;
+ extinfo->rep_func = _EvlogReplyXextShape;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_XEXT_H__
+#define __XDBG_EVLOG_XEXT_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogXextDpmsGetBase (ExtensionInfo *extinfo);
+void xDbgEvlogXextShmGetBase (ExtensionInfo *extinfo);
+void xDbgEvlogXextSyncGetBase (ExtensionInfo *extinfo);
+void xDbgEvlogXextXtestExt1GetBase (ExtensionInfo *extinfo);
+void xDbgEvlogXextXtestGetBase (ExtensionInfo *extinfo);
+void xDbgEvlogXextShapeGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XInput.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/extensions/XI2proto.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_xinput.h"
+#include "xdbg_evlog.h"
+
+static char *
+_getMode(CARD8 mode, char *reply, int *len)
+{
+ const char* buf;
+ char dbuf[10];
+
+ switch (mode)
+ {
+ case XIGrabModeSync: buf = "XIGrabModeSync"; break;
+ case XIGrabModeAsync: buf = "XIGrabModeAsync"; break;
+ case XIGrabModeTouch: buf = "XIGrabModeTouch"; break;
+ default: buf = dbuf; snprintf (dbuf, 10, "%d", mode); break;
+ }
+
+ REPLY ("%s", buf);
+
+ return reply;
+}
+
+static char *
+_EvlogRequestXinput (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case X_GrabDevice:
+ {
+ xGrabDeviceReq *stuff = (xGrabDeviceReq *)req;
+ REPLY (": XID(0x%x) device_ID(%d)",
+ (unsigned int)stuff->grabWindow,
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" this_dev_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->this_device_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" other_dev_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->other_devices_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" time(%lums) evt_cnt(%d) owner_events(%s)",
+ (unsigned long)stuff->time,
+ stuff->event_count,
+ stuff->ownerEvents ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_UngrabDevice:
+ {
+ xUngrabDeviceReq *stuff = (xUngrabDeviceReq *)req;
+ REPLY (": device_ID(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_GrabDeviceKey:
+ {
+ xGrabDeviceKeyReq *stuff = (xGrabDeviceKeyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" evt_cnt(%d) modifiers(%d) mod_dev(%d) grab_dev(%d) key(%d)",
+ stuff->event_count,
+ stuff->modifiers,
+ stuff->modifier_device,
+ stuff->grabbed_device,
+ stuff->key);
+
+ REPLY ("\n");
+ REPLY ("%67s this_dev_mode",
+ " ");
+
+ REPLY ("(");
+ reply = _getMode(stuff->this_device_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" other_dev_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->other_devices_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" owner_events(%s)",
+ stuff->ownerEvents ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_UngrabDeviceKey:
+ {
+ xUngrabDeviceKeyReq *stuff = (xUngrabDeviceKeyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" modifiers(%d) mod_dev(%d) grab_dev(%d) key(%d)",
+ stuff->modifiers,
+ stuff->modifier_device,
+ stuff->grabbed_device,
+ stuff->key);
+ }
+
+ return reply;
+ }
+
+ case X_GrabDeviceButton:
+ {
+ xGrabDeviceButtonReq *stuff = (xGrabDeviceButtonReq *)req;
+ REPLY (": XID(0x%x))",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" grab_dev(%d) mod_dev(%d) evt_cnt(%d) modifiers(%d) button(%d)",
+ stuff->grabbed_device,
+ stuff->modifier_device,
+ stuff->event_count,
+ stuff->modifiers,
+ stuff->button);
+
+ REPLY ("\n");
+ REPLY ("%67s this_dev_mode",
+ " ");
+ REPLY ("(");
+ reply = _getMode(stuff->this_device_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" other_dev_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->other_devices_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" owner_events(%s)",
+ stuff->ownerEvents ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_UngrabDeviceButton:
+ {
+ xUngrabDeviceButtonReq *stuff = (xUngrabDeviceButtonReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->grabWindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" modifiers(%d) modDev(%d) grabDev(%d) button(%d)",
+ stuff->modifiers,
+ stuff->modifier_device,
+ stuff->grabbed_device,
+ stuff->button);
+ }
+
+ return reply;
+ }
+
+ case X_AllowDeviceEvents:
+ {
+ xAllowDeviceEventsReq *stuff = (xAllowDeviceEventsReq *)req;
+ REPLY (": device_ID(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums) mode(%d)",
+ (unsigned long)stuff->time,
+ stuff->mode);
+ }
+
+ return reply;
+ }
+
+ case X_GetDeviceFocus:
+ {
+ xGetDeviceFocusReq *stuff = (xGetDeviceFocusReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_SetDeviceFocus:
+ {
+ xSetDeviceFocusReq *stuff = (xSetDeviceFocusReq *)req;
+ REPLY (": XID(0x%x) dev_ID(%d)",
+ (unsigned int)stuff->focus,
+ stuff->device);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums) revertTo(%d)",
+ (unsigned long)stuff->time,
+ stuff->revertTo);
+ }
+
+ return reply;
+ }
+
+ case X_XIQueryPointer:
+ {
+ xXIQueryPointerReq *stuff = (xXIQueryPointerReq *)req;
+ REPLY (": XID(0x%x) devID(%d)",
+ stuff->win,
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIWarpPointer:
+ {
+ xXIWarpPointerReq *stuff = (xXIWarpPointerReq *)req;
+ REPLY (": srcWIN(0x%x) dstWin(0x%x) src(%d,%d %dx%d) dst(%d,%d) device_ID(%d)",
+ stuff->src_win,
+ stuff->dst_win,
+ stuff->src_x,
+ stuff->src_y,
+ stuff->src_width,
+ stuff->src_height,
+ stuff->dst_x,
+ stuff->dst_y,
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIChangeCursor:
+ {
+ xXIChangeCursorReq *stuff = (xXIChangeCursorReq *)req;
+ REPLY (": XID(0x%x) Cursor(0x%x) devID(%d)",
+ stuff->win,
+ stuff->cursor,
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIChangeHierarchy:
+ {
+ xXIChangeHierarchyReq *stuff = (xXIChangeHierarchyReq *)req;
+ REPLY (": numChange(%d)",
+ stuff->num_changes);
+
+ return reply;
+ }
+
+ case X_XISetClientPointer:
+ {
+ xXISetClientPointerReq *stuff = (xXISetClientPointerReq *)req;
+ REPLY (": XID(0x%x) device_ID(%d)",
+ stuff->win,
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIGetClientPointer:
+ {
+ xXIGetClientPointerReq *stuff = (xXIGetClientPointerReq *)req;
+ REPLY (": XID(0x%x)",
+ stuff->win);
+
+ return reply;
+ }
+
+ case X_XISelectEvents:
+ {
+ xXISelectEventsReq *stuff = (xXISelectEventsReq *)req;
+ REPLY (": XID(0x%x)",
+ stuff->win);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" num_masks(%d)",
+ stuff->num_masks);
+ }
+
+ return reply;
+ }
+
+ case X_XIQueryVersion:
+ {
+ xXIQueryVersionReq *stuff = (xXIQueryVersionReq *)req;
+ REPLY (": major_vesion(%d) minor_vesion(%d)",
+ stuff->major_version,
+ stuff->minor_version);
+
+ return reply;
+ }
+
+ case X_XIQueryDevice:
+ {
+ xXIQueryDeviceReq *stuff = (xXIQueryDeviceReq *)req;
+ REPLY (": device_ID(%d)",
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XISetFocus:
+ {
+ xXISetFocusReq *stuff = (xXISetFocusReq *)req;
+ REPLY (": XID(0x%x) device_ID(%d)",
+ stuff->focus,
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%ums)",
+ stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_XIGetFocus:
+ {
+ xXIGetFocusReq *stuff = (xXIGetFocusReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIGrabDevice:
+ {
+ xXIGrabDeviceReq *stuff = (xXIGrabDeviceReq *)req;
+ REPLY (": XID(0x%x) Cursor(0x%x) device_ID(%d)",
+ stuff->grab_window,
+ stuff->cursor,
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s grab_mode",
+ " ");
+ REPLY ("(");
+ reply = _getMode(stuff->grab_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" paired_device_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->paired_device_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" time(%ums) owner_events(%s)",
+ stuff->time,
+ stuff->owner_events ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ case X_XIUngrabDevice:
+ {
+ xXIUngrabDeviceReq *stuff = (xXIUngrabDeviceReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%ums)",
+ stuff->time);
+ }
+
+ return reply;
+ }
+
+ case X_XIAllowEvents:
+ {
+ xXIAllowEventsReq *stuff = (xXIAllowEventsReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%ums) mode(%d)",
+ stuff->time,
+ stuff->mode);
+ }
+
+ return reply;
+ }
+
+ case X_XIPassiveGrabDevice:
+ {
+ xXIPassiveGrabDeviceReq *stuff = (xXIPassiveGrabDeviceReq *)req;
+ REPLY (": XID(0x%x) Cursor(0x%x) device_ID(%d)",
+ stuff->grab_window,
+ stuff->cursor,
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char * type;
+ char dtype[10];
+
+ switch(stuff->grab_type)
+ {
+ case XIGrabtypeButton: type = "XIGrabtypeButton"; break;
+ case XIGrabtypeKeycode: type = "XIGrabtypeKeycode"; break;
+ case XIGrabtypeEnter: type = "XIGrabtypeEnter"; break;
+ case XIGrabtypeFocusIn: type = "XIGrabtypeFocusIn"; break;
+ case XIGrabtypeTouchBegin: type = "XIGrabtypeTouchBegin"; break;
+ default: type = dtype; snprintf (dtype, 10, "%d", stuff->grab_type); break;
+ }
+
+ REPLY (" time(%ums) detail(%d) grab_type(%s)",
+ stuff->time,
+ stuff->detail,
+ type);
+
+ REPLY ("\n");
+ REPLY ("%67s", " ");
+
+ REPLY (" grab_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->grab_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" paired_device_mode");
+ REPLY ("(");
+ reply = _getMode(stuff->paired_device_mode, reply, len);
+ REPLY (")");
+
+ REPLY (" num_modifier(%d) owner_events(%s)",
+ stuff->num_modifiers,
+ stuff->owner_events ? "YES" : "NO");
+
+ }
+
+ return reply;
+ }
+
+ case X_XIPassiveUngrabDevice:
+ {
+ xXIPassiveUngrabDeviceReq *stuff = (xXIPassiveUngrabDeviceReq *)req;
+ REPLY (": XID(0x%x) device_ID(%d)",
+ stuff->grab_window,
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char * type;
+ char dtype[10];
+
+ switch(stuff->grab_type)
+ {
+ case XIGrabtypeButton: type = "XIGrabtypeButton"; break;
+ case XIGrabtypeKeycode: type = "XIGrabtypeKeycode"; break;
+ case XIGrabtypeEnter: type = "XIGrabtypeEnter"; break;
+ case XIGrabtypeFocusIn: type = "XIGrabtypeFocusIn"; break;
+ case XIGrabtypeTouchBegin: type = "XIGrabtypeTouchBegin"; break;
+ default: type = dtype; snprintf (dtype, 10, "%d", stuff->grab_type); break;
+ }
+
+ REPLY (" detail(%d) grab_type(%s) num_modifiers(%d)",
+ stuff->detail,
+ type,
+ stuff->num_modifiers);
+ }
+
+ return reply;
+ }
+
+ case X_XIListProperties:
+ {
+ xXIListPropertiesReq *stuff = (xXIListPropertiesReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ return reply;
+ }
+
+ case X_XIChangeProperty:
+ {
+ xXIChangePropertyReq *stuff = (xXIChangePropertyReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char * mode;
+ char dmode[10];
+
+ switch(stuff->mode)
+ {
+ case XIPropModeReplace: mode = "XIPropModeReplace"; break;
+ case XIPropModePrepend: mode = "XIPropModePrepend"; break;
+ case XIPropModeAppend: mode = "XIPropModeAppend"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ REPLY (" mode(%s) format(%d) num_items(%d)",
+ mode,
+ stuff->format,
+ stuff->num_items);
+ }
+
+ return reply;
+ }
+
+ case X_XIDeleteProperty:
+ {
+ xXIDeletePropertyReq *stuff = (xXIDeletePropertyReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case X_XIGetProperty:
+ {
+ xXIGetPropertyReq *stuff = (xXIGetPropertyReq *)req;
+ REPLY (": devID(%d)",
+ stuff->deviceid);
+
+ REPLY (" Property");
+ reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
+ REPLY (" Type");
+ reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" delete(%s) offset(%u) length(%u)",
+ stuff->delete ? "YES" : "NO",
+ stuff->offset,
+ stuff->len);
+ }
+
+ return reply;
+ }
+
+ case X_XIGetSelectedEvents:
+ {
+ xXIGetSelectedEventsReq *stuff = (xXIGetSelectedEventsReq *)req;
+ REPLY (": XID(0x%x)",
+ stuff->win);
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventXinput (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case XI_DeviceValuator:
+ {
+ deviceValuator *stuff = (deviceValuator *) evt;
+ REPLY (": device_ID(%d) numValuator(%d) fstnumValuator(%d)",
+ stuff->deviceid,
+ stuff->num_valuators,
+ stuff->first_valuator);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ int i;
+
+ REPLY (" sequence_num(%d) device_state(0x%x)\n",
+ stuff->sequenceNumber,
+ stuff->device_state);
+
+ REPLY ("%67s", " ");
+ for (i = 0 ; i < stuff->num_valuators ; i++)
+ {
+ REPLY (" valuator%d(%ld)",
+ i,
+ (long int)*(&stuff->valuator0 + i));
+ }
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceKeyPress:
+ {
+ XDeviceKeyPressedEvent *stuff = (XDeviceKeyPressedEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) key_code(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->keycode,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceKeyRelease:
+ {
+ XDeviceKeyReleasedEvent *stuff = (XDeviceKeyReleasedEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) key_code(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->keycode,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceButtonPress:
+ {
+ XDeviceButtonPressedEvent *stuff = (XDeviceButtonPressedEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) button(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->button,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceButtonRelease:
+ {
+ XDeviceButtonReleasedEvent *stuff = (XDeviceButtonReleasedEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) button(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->button,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceMotionNotify:
+ {
+ XDeviceMotionEvent *stuff = (XDeviceMotionEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) is_hint(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->is_hint,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceFocusIn:
+ {
+ XDeviceFocusInEvent *stuff = (XDeviceFocusInEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *mode, *detail;
+ char dmode[10], ddetail[10];
+
+ switch(stuff->mode)
+ {
+ case NotifyNormal: mode = "NotifyNormal"; break;
+ case NotifyGrab: mode = "NotifyGrab"; break;
+ case NotifyUngrab: mode = "NotifyUngrab"; break;
+ case NotifyWhileGrabbed: mode = "NotifyWhileGrabbed"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ switch(stuff->detail)
+ {
+ case NotifyAncestor: detail = "NotifyAncestor"; break;
+ case NotifyVirtual: detail = "NotifyVirtual"; break;
+ case NotifyInferior: detail = "NotifyInferior"; break;
+ case NotifyNonlinear: detail = "NotifyNonlinear"; break;
+ case NotifyNonlinearVirtual: detail = "NotifyNonlinearVirtual"; break;
+ case NotifyPointer: detail = "NotifyPointer"; break;
+ case NotifyPointerRoot: detail = "NotifyPointerRoot"; break;
+ case NotifyDetailNone: detail = "NotifyDetailNone"; break;
+ default: detail = ddetail; snprintf (ddetail, 10, "%d", stuff->detail); break;
+ }
+
+ REPLY (" mode(%s) detail(%s) time(%lums)",
+ mode,
+ detail,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceFocusOut:
+ {
+ XDeviceFocusOutEvent *stuff = (XDeviceFocusOutEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *mode, *detail;
+ char dmode[10], ddetail[10];
+
+ switch(stuff->mode)
+ {
+ case NotifyNormal: mode = "NotifyNormal"; break;
+ case NotifyGrab: mode = "NotifyGrab"; break;
+ case NotifyUngrab: mode = "NotifyUngrab"; break;
+ case NotifyWhileGrabbed: mode = "NotifyWhileGrabbed"; break;
+ default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
+ }
+
+ switch(stuff->detail)
+ {
+ case NotifyAncestor: detail = "NotifyAncestor"; break;
+ case NotifyVirtual: detail = "NotifyVirtual"; break;
+ case NotifyInferior: detail = "NotifyInferior"; break;
+ case NotifyNonlinear: detail = "NotifyNonlinear"; break;
+ case NotifyNonlinearVirtual: detail = "NotifyNonlinearVirtual"; break;
+ case NotifyPointer: detail = "NotifyPointer"; break;
+ case NotifyPointerRoot: detail = "NotifyPointerRoot"; break;
+ case NotifyDetailNone: detail = "NotifyDetailNone"; break;
+ default: detail = ddetail; snprintf (ddetail, 10, "%d", stuff->detail); break;
+ }
+
+ REPLY (" mode(%s) detail(%s) time(%lums)",
+ mode,
+ detail,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case XI_ProximityIn:
+ {
+ XProximityInEvent *stuff = (XProximityInEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_ProximityOut:
+ {
+ XProximityOutEvent *stuff = (XProximityOutEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x %d,%d) Root(0x%x %d,%d) subWindow(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window,
+ stuff->x,
+ stuff->y,
+ (unsigned int)stuff->root,
+ stuff->x_root,
+ stuff->y_root,
+ (unsigned int)stuff->subwindow);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s time(%lums) state(%d) same_screen(%s) device_state(%d) first_axis(%d)",
+ " ",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->same_screen ? "YES" : "NO",
+ stuff->device_state,
+ stuff->first_axis);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceStateNotify:
+ {
+ XDeviceStateNotifyEvent *stuff = (XDeviceStateNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums) num_classes(%d)",
+ (unsigned long)stuff->time,
+ stuff->num_classes);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceMappingNotify:
+ {
+ XDeviceMappingEvent *stuff = (XDeviceMappingEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *request;
+ char drequest[10];
+
+ switch(stuff->request)
+ {
+ case MappingModifier: request = "MappingModifier"; break;
+ case MappingKeyboard: request = "MappingKeyboard"; break;
+ case MappingPointer: request = "MappingPointer"; break;
+ default: request = drequest; snprintf (drequest, 10, "%d", stuff->request); break;
+ }
+
+ REPLY (" time(%lums) request(%s) first_keycode(%d) count(%d)",
+ (unsigned long)stuff->time,
+ request,
+ stuff->first_keycode,
+ stuff->count);
+ }
+
+ return reply;
+ }
+
+ case XI_ChangeDeviceNotify:
+ {
+ XChangeDeviceNotifyEvent *stuff = (XChangeDeviceNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Window(0x%x)",
+ (unsigned int)stuff->deviceid,
+ (unsigned int)stuff->window);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ const char *request;
+ char drequest[10];
+
+ switch(stuff->request)
+ {
+ case NewPointer: request = "NewPointer"; break;
+ case NewKeyboard: request = "NewKeyboard"; break;
+ default: request = drequest; snprintf (drequest, 10, "%d", stuff->request); break;
+ }
+
+ REPLY (" time(%lums) request(%s)",
+ (unsigned long)stuff->time,
+ request);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceKeystateNotify:
+ {
+ deviceKeyStateNotify *stuff = (deviceKeyStateNotify *) evt;
+ REPLY (": deviceid(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ case XI_DeviceButtonstateNotify:
+ {
+ deviceButtonStateNotify *stuff = (deviceButtonStateNotify *) evt;
+ REPLY (": deviceid(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" sequence_num(%d)",
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ case XI_DevicePresenceNotify:
+ {
+ devicePresenceNotify *stuff = (devicePresenceNotify *) evt;
+ REPLY (": deviceid(%d)",
+ stuff->deviceid);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums) device_change(%d) control(%d) sequence_num(%d)",
+ (unsigned long)stuff->time,
+ stuff->devchange,
+ stuff->control,
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ case XI_DevicePropertyNotify:
+ {
+ devicePropertyNotify *stuff = (devicePropertyNotify *) evt;
+ REPLY (": deviceid(%d)",
+ stuff->deviceid);
+
+ REPLY (" Atom");
+ reply = xDbgGetAtom(stuff->atom, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums) state(%d) sequence_num(%d)",
+ (unsigned long)stuff->time,
+ stuff->state,
+ stuff->sequenceNumber);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXinput (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case X_ListInputDevices:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xListInputDevicesReply *stuff = (xListInputDevicesReply *) rep;
+ REPLY (": nDevices(%d)",
+ stuff->ndevices);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_GrabDevice:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGrabDeviceReply *stuff = (xGrabDeviceReply *) rep;
+ REPLY (": status(%d)",
+ stuff->status);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_GetDeviceFocus:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xGetDeviceFocusReply *stuff = (xGetDeviceFocusReply *) rep;
+ REPLY (": XID(0x%x) Time(0x%x)",
+ (unsigned int)stuff->focus,
+ (unsigned int)stuff->time);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIQueryVersion:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIQueryVersionReply *stuff = (xXIQueryVersionReply *) rep;
+ REPLY (": majorVersion(%d) minorVersion(%d)",
+ stuff->major_version,
+ stuff->minor_version);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIQueryDevice:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIQueryDeviceReply *stuff = (xXIQueryDeviceReply *) rep;
+ REPLY (": numDevices(%d)",
+ stuff->num_devices);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIGetSelectedEvents:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIGetSelectedEventsReply *stuff = (xXIGetSelectedEventsReply *) rep;
+ REPLY (": numMasks(%d)",
+ stuff->num_masks);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIQueryPointer:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIQueryPointerReply *stuff = (xXIQueryPointerReply *) rep;
+ REPLY (": XID(0x%x) Child(0x%x) root(%d,%d) win(%d,%d)",
+ stuff->root,
+ stuff->child,
+ stuff->root_x,
+ stuff->root_y,
+ stuff->win_x,
+ stuff->win_y);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIGetClientPointer:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIGetClientPointerReply *stuff = (xXIGetClientPointerReply *) rep;
+ REPLY (": Set(%s) deviceid(%d)",
+ (stuff->set) ? "true":"false",
+ stuff->deviceid);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIGetFocus:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIGetFocusReply *stuff = (xXIGetFocusReply *) rep;
+ REPLY (": XID(0x%x)",
+ stuff->focus);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIGrabDevice:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIGrabDeviceReply *stuff = (xXIGrabDeviceReply *) rep;
+ REPLY (": status(%d)",
+ stuff->status);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIPassiveGrabDevice:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIPassiveGrabDeviceReply *stuff = (xXIPassiveGrabDeviceReply *) rep;
+ REPLY (": numModifiers(%d)",
+ stuff->num_modifiers);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ case X_XIListProperties:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIListPropertiesReply *stuff = (xXIListPropertiesReply *) rep;
+ REPLY (": numProperties(%d)",
+ stuff->num_properties);
+ }
+ else
+ {
+ Atom *stuff = (Atom *)rep;
+ int i;
+
+ REPLY ("Properties(");
+ for (i = 0 ; i < evinfo->rep.size / sizeof(Atom) ; i ++)
+ {
+ reply = xDbgGetAtom(stuff[i], evinfo, reply, len);
+ if(i != evinfo->rep.size / sizeof(Atom) - 1)
+ REPLY (", ");
+ }
+ REPLY (")");
+ }
+
+ return reply;
+ }
+
+ case X_XIGetProperty:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xXIGetPropertyReply *stuff = (xXIGetPropertyReply *) rep;
+
+ REPLY (": Type");
+ xDbgGetAtom(stuff->type, evinfo, reply, len);
+
+ REPLY (" numItems(%d) format(%d)",
+ stuff->num_items,
+ stuff->format);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogXinputGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXinput;
+ extinfo->evt_func = _EvlogEventXinput;
+ extinfo->rep_func = _EvlogReplyXinput;
+#else
+ ExtensionEntry *xext = CheckExtension (INAME);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXinput;
+ extinfo->evt_func = _EvlogEventXinput;
+ extinfo->rep_func = _EvlogReplyXinput;
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_XINPUT_H__
+#define __XDBG_EVLOG_XINPUT_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogXinputGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dix.h>
+#define XREGISTRY
+#include <registry.h>
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <windowstr.h>
+
+#include <X11/extensions/Xvlib.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+#include "xdbg_types.h"
+#include "xdbg_evlog_xv.h"
+#include "xdbg_evlog.h"
+
+static char *
+_EvlogRequestXv(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xReq *req = evinfo->req.ptr;
+
+ switch (req->data)
+ {
+ case xv_GrabPort:
+ {
+ xvGrabPortReq *stuff = (xvGrabPortReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->port);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case xv_UngrabPort:
+ {
+ xvUngrabPortReq *stuff = (xvUngrabPortReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->port);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" time(%lums)",
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case xv_PutStill:
+ {
+ xvPutStillReq *stuff = (xvPutStillReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) Vid(%d,%d %dx%d) Drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->vid_x,
+ stuff->vid_y,
+ stuff->vid_w,
+ stuff->vid_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ return reply;
+ }
+
+ case xv_GetStill:
+ {
+ xvGetStillReq *stuff = (xvGetStillReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) Vid(%d,%d %dx%d) Drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->vid_x,
+ stuff->vid_y,
+ stuff->vid_w,
+ stuff->vid_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ return reply;
+ }
+
+ case xv_PutVideo:
+ {
+ xvPutVideoReq *stuff = (xvPutVideoReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) Vid(%d,%d %dx%d) Drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->vid_x,
+ stuff->vid_y,
+ stuff->vid_w,
+ stuff->vid_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ return reply;
+ }
+
+ case xv_GetVideo:
+ {
+ xvGetVideoReq *stuff = (xvGetVideoReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) Vid(%d,%d %dx%d) Drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ stuff->vid_x,
+ stuff->vid_y,
+ stuff->vid_w,
+ stuff->vid_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ return reply;
+ }
+
+ case xv_StopVideo:
+ {
+ xvStopVideoReq *stuff = (xvStopVideoReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable);
+
+ return reply;
+ }
+
+ case xv_SelectVideoNotify:
+ {
+ xvSelectVideoNotifyReq *stuff = (xvSelectVideoNotifyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->drawable);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" On/Off(%s)",
+ stuff->onoff ? "ON" : "OFF");
+ }
+
+ return reply;
+ }
+
+ case xv_SelectPortNotify:
+ {
+ xvSelectPortNotifyReq *stuff = (xvSelectPortNotifyReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->port);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" On/Off(%s)",
+ stuff->onoff ? "ON" : "OFF");
+ }
+
+ return reply;
+ }
+
+ case xv_QueryBestSize:
+ {
+ xvQueryBestSizeReq *stuff = (xvQueryBestSizeReq *)req;
+ REPLY (": XID(0x%x) VidSize(%dx%d) DrwSize(%dx%d)",
+ (unsigned int)stuff->port,
+ stuff->vid_w,
+ stuff->vid_h,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" motion(%d)",
+ stuff->motion);
+ }
+
+ return reply;
+ }
+
+ case xv_SetPortAttribute:
+ {
+ xvSetPortAttributeReq *stuff = (xvSetPortAttributeReq *)req;
+ REPLY (": XID(0x%x) ",
+ (unsigned int)stuff->port);
+
+ REPLY (" Attribute");
+ reply = xDbgGetAtom(stuff->attribute, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" value(%ld)",
+ (long int)stuff->value);
+ }
+
+ return reply;
+ }
+
+ case xv_GetPortAttribute:
+ {
+ xvGetPortAttributeReq *stuff = (xvGetPortAttributeReq *)req;
+ REPLY (": XID(0x%x)",
+ (unsigned int)stuff->port);
+
+ REPLY (" Attribute");
+ reply = xDbgGetAtom(stuff->attribute, evinfo, reply, len);
+
+ return reply;
+ }
+
+ case xv_PutImage:
+ {
+ xvPutImageReq *stuff = (xvPutImageReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) ID(%x) buf(%dx%d) src(%d,%d %dx%d) drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ (unsigned int)stuff->id,
+ stuff->width,
+ stuff->height,
+ stuff->src_x,
+ stuff->src_y,
+ stuff->src_w,
+ stuff->src_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ return reply;
+ }
+
+ case xv_ShmPutImage:
+ {
+ xvShmPutImageReq *stuff = (xvShmPutImageReq *)req;
+ REPLY (": XID(0x%x) Drawable(0x%x) GC(0x%x) ID(%x) buf(%dx%d) src(%d,%d %dx%d) drw(%d,%d %dx%d)",
+ (unsigned int)stuff->port,
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->gc,
+ (unsigned int)stuff->id,
+ stuff->width,
+ stuff->height,
+ stuff->src_x,
+ stuff->src_y,
+ stuff->src_w,
+ stuff->src_h,
+ stuff->drw_x,
+ stuff->drw_y,
+ stuff->drw_w,
+ stuff->drw_h);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY ("\n");
+ REPLY ("%67s shmseg(0x%x) offset(%ld) send_event(%s)",
+ " ",
+ (unsigned int)stuff->shmseg,
+ (long int)stuff->offset,
+ stuff->send_event ? "YES" : "NO");
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogEventXv (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
+{
+ xEvent *evt = evinfo->evt.ptr;
+
+ switch ((evt->u.u.type & 0x7F) - first_base)
+ {
+ case XvVideoNotify:
+ {
+ XvVideoNotifyEvent *stuff = (XvVideoNotifyEvent *) evt;
+ REPLY (": XID(0x%x) portID(0x%x)",
+ (unsigned int)stuff->drawable,
+ (unsigned int)stuff->port_id);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" serial(%lu) reason(%lu) time(%lums)",
+ (unsigned long)stuff->serial,
+ (unsigned long)stuff->reason,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ case XvPortNotify:
+ {
+ XvPortNotifyEvent *stuff = (XvPortNotifyEvent *) evt;
+ REPLY (": XID(0x%x) Value(%ld)",
+ (unsigned int)stuff->port_id,
+ (long int)stuff->value);
+
+ REPLY (" Attribute");
+ reply = xDbgGetAtom(stuff->attribute, evinfo, reply, len);
+
+ if (detail_level >= EVLOG_PRINT_DETAIL)
+ {
+ REPLY (" serial(%lu) value(%ld) time(%lums)",
+ (unsigned long)stuff->serial,
+ (long int)stuff->value,
+ (unsigned long)stuff->time);
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+static char *
+_EvlogReplyXv (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
+{
+ xGenericReply *rep = evinfo->rep.ptr;
+
+ switch (evinfo->rep.reqData)
+ {
+ case xv_QueryBestSize:
+ {
+ if (evinfo->rep.isStart)
+ {
+ xvQueryBestSizeReply *stuff = (xvQueryBestSizeReply *)rep;
+ REPLY (": actualSize(%dx%d)",
+ stuff->actual_width,
+ stuff->actual_height);
+ }
+ else
+ {
+ return reply;
+ }
+
+ return reply;
+ }
+
+ default:
+ break;
+ }
+
+ return reply;
+}
+
+void
+xDbgEvlogXvGetBase (ExtensionInfo *extinfo)
+{
+#ifdef XDBG_CLIENT
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->req_func = _EvlogRequestXv;
+ extinfo->evt_func = _EvlogEventXv;
+ extinfo->rep_func = _EvlogReplyXv;
+#else
+ ExtensionEntry *xext = CheckExtension (XvName);
+ RETURN_IF_FAIL (xext != NULL);
+ RETURN_IF_FAIL (extinfo != NULL);
+
+ extinfo->opcode = xext->base;
+ extinfo->evt_base = xext->eventBase;
+ extinfo->err_base = xext->errorBase;
+ extinfo->req_func = _EvlogRequestXv;
+ extinfo->evt_func = _EvlogEventXv;
+ extinfo->rep_func = _EvlogReplyXv;
+
+#endif
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_EVLOG_XV_H__
+#define __XDBG_EVLOG_XV_H__
+
+#include "xdbg_types.h"
+
+void xDbgEvlogXvGetBase (ExtensionInfo *extinfo);
+
+#endif
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_TYPES_H__
+#define __XDBG_TYPES_H__
+
+#include <config.h>
+
+#include <xf86.h>
+#include <X11/Xdefs.h> /* for Bool */
+#include <X11/Xlib.h>
+#include <X11/extensions/Xfixes.h>
+#include <list.h>
+
+
+#define XDBG_PATH_MAX 1024
+#define XDBG_BUF_SIZE 64
+
+#ifdef PATH_MAX
+#undef PATH_MAX
+#endif //PATH_MAX
+#define PATH_MAX XDBG_PATH_MAX
+
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define SWAP(a, b) ({int t; t = a; a = b; b = t;})
+
+#define WARNING_IF_FAIL(cond) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond);}}
+#define RETURN_IF_FAIL(cond) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); return; }}
+#define RETURN_VAL_IF_FAIL(cond, val) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); return val; }}
+#define RETURN_VAL_IF_ERRNO(cond, val, errno) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); return val; }}
+#define GOTO_IF_FAIL(cond, dst) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); goto dst; }}
+#define GOTO_IF_ERRNO(cond, dst, errno) \
+ {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); goto dst; }}
+
+#define XDBG_LOG(fmt, ARG...) { fprintf (stderr, fmt, ##ARG); }
+
+#define REPLY(fmt, ARG...) \
+ do { \
+ if (reply && len && *len > 0) \
+ { \
+ int s = snprintf (reply, *len, fmt, ##ARG); \
+ reply += s; \
+ *len -= s; \
+ } \
+ } while (0)
+
+#define UNKNOWN_EVENT "<unknown>"
+
+typedef enum
+{
+ EVENT,
+ REQUEST,
+ REPLY,
+ FLUSH,
+ ERROR
+} EvlogType;
+
+#define EVLOG_MASK_CLIENT (1<<0)
+#define EVLOG_MASK_REQUEST (1<<1)
+#define EVLOG_MASK_EVENT (1<<2)
+#define EVLOG_MASK_REPLY (1<<3)
+#define EVLOG_MASK_ERROR (1<<4)
+#define EVLOG_MASK_ATOM (1<<5)
+#define EVLOG_MASK_REGION (1<<6)
+
+#define EVLOG_PRINT_DEFAULT 0
+#define EVLOG_PRINT_DETAIL 1
+#define EVLOG_PRINT_REPLY_DETAIL 2
+
+
+typedef struct _EvlogTable
+{
+ CARD32 xid;
+ char buf[XDBG_BUF_SIZE];
+ struct xorg_list link;
+} EvlogAtomTable, EvlogRegionTable;
+
+typedef struct _EvlogList
+{
+ struct xorg_list list;
+ int init;
+ int size;
+} EvlogAtom, EvlogRegion;
+
+typedef struct _EvlogClient
+{
+ int index;
+ int pid;
+ int gid;
+ int uid;
+ char command[PATH_MAX+1];
+ void* pClient;
+} EvlogClient;
+
+typedef struct _EvlogRequest
+{
+ int id;
+ CARD32 length;
+ xReq *ptr;
+ char name[PATH_MAX+1];
+} EvlogRequest;
+
+typedef struct _EvlogEvent
+{
+ xEvent *ptr;
+ int size;
+ char name[PATH_MAX+1];
+} EvlogEvent;
+
+typedef struct _EvlogReply
+{
+ xGenericReply *ptr;
+ int size;
+ char name[PATH_MAX+1];
+ int reqType;
+ int reqData;
+ Bool isStart;
+} EvlogReply;
+
+typedef struct _EvlogError
+{
+ BYTE errorCode;
+ CARD32 resourceID;
+ CARD16 minorCode;
+ CARD8 majorCode;
+} EvlogError;
+
+typedef struct _EvlogInfo
+{
+ EvlogType type;
+
+ int mask;
+ EvlogClient client;
+ EvlogRequest req;
+ EvlogEvent evt;
+ EvlogReply rep;
+ EvlogError err;
+ EvlogAtom evatom;
+ EvlogRegion evregion;
+
+ CARD32 time;
+} EvlogInfo;
+
+
+typedef struct _ExtensionInfo ExtensionInfo;
+
+struct _ExtensionInfo
+{
+ void (*get_base_func) (ExtensionInfo *extinfo);
+ int opcode;
+ int evt_base;
+ int err_base;
+ char* (*req_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+ char* (*evt_func) (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len);
+ char* (*rep_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
+};
+
+#endif
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+AC_PREREQ(2.57)
+AC_INIT([xdbg], [0.1.0], [https://])
+AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE()
+
+AM_MAINTAINER_MODE
+
+# Require xorg-macros: XORG_DEFAULT_OPTIONS
+m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.3)
+AM_CONFIG_HEADER([config.h])
+
+# Checks for programs.
+AC_PROG_LIBTOOL
+AC_PROG_CC
+XORG_DEFAULT_OPTIONS
+
+AH_TOP([#include "xorg-server.h"])
+
+AC_ARG_WITH(xorg-module-dir,
+ AC_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+AC_ARG_ENABLE(secure-log,
+ AS_HELP_STRING([--enable-secure-log],
+ [Enable secure log (default: disabled)]),
+ [SECURELOG=$enableval], [SECURELOG=no])
+
+# Checks for pkg-config packages
+PKG_CHECK_MODULES(XDBG, dlog xorg-server x11 xdamage xext dbus-1 bigreqsproto compositeproto damageproto dri2proto fixesproto fontsproto gestureproto inputproto kbproto randrproto recordproto renderproto resourceproto videoproto xcmiscproto xextproto xf86vidmodeproto xproto libdrm xcomposite libdri2 xgesture xtst xrandr xi xv)
+
+PKG_CHECK_MODULES(HWC, libhwc hwcproto,
+ [SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $HWC_CFLAGS"
+ AC_CHECK_HEADERS([X11/extensions/hwc.h],[have_hwc_h="yes"],[have_hwc_h="no"])
+ CPPFLAGS="$SAVE_CPPFLAGS"],[echo "not found"])
+
+AM_CONDITIONAL(HAVE_HWC, [test "x$have_hwc_h" = xyes])
+if test "x$have_hwc_h" = xyes; then
+ AC_DEFINE(HAVE_HWC, 1, [Have libhwc])
+ XDBG_CFLAGS="$XDBG_CFLAGS $HWC_CFLAGS"
+ XDBG_LIBS="$XDBG_LIBS $HWC_LIBS"
+fi
+
+AC_SUBST([XDBG_CFLAGS])
+AC_SUBST([XDBG_LIBS])
+
+XDBG_CLIENT_CFLAGS="${XDBG_CFLAGS} -DXDBG_CLIENT"
+XDBG_CLIENT_LIBS="${XDBG_LIBS}"
+AC_SUBST([XDBG_CLIENT_CFLAGS])
+AC_SUBST([XDBG_CLIENT_LIBS])
+
+# Checks for header files.
+AC_HEADER_STDC
+
+MODULE_NAME=xdbg
+AC_SUBST([MODULE_NAME])
+AC_SUBST([moduledir])
+
+AC_DEFINE_UNQUOTED(MODULE_NAME, "$MODULE_NAME", [module name])
+
+TIZEN_ENGINEER_MODE=0
+if test "x$SECURELOG" = xyes; then
+ TIZEN_ENGINEER_MODE=1
+ AC_SUBST([TIZEN_ENGINEER_MODE])
+fi
+
+AC_OUTPUT([Makefile
+ common/Makefile
+ bin/Makefile
+ bin/xdbg/Makefile
+ bin/xevlog_analyze/Makefile
+ lib/Makefile
+ lib/xdbg_log_secure.h
+ lib/xdbg.pc
+ module/Makefile])
+
+echo "CFLAGS : $CFLAGS"
+echo "LDFLAGS : $LDFLAGS"
+echo "XDBG_CFLAGS: $XDBG_CFLAGS"
+echo "XDBG_LIBS : $XDBG_LIBS"
+echo "XDBG_CLIENT_CFLAGS: $XDBG_CLIENT_CFLAGS"
+echo "XDBG_CLIENT_LIBS : $XDBG_CLIENT_LIBS"
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+libxdbg_lib_la_LTLIBRARIES = libxdbg-lib.la
+libxdbg_lib_ladir = $(libdir)
+libxdbg_lib_la_LIBADD = @XDBG_LIBS@
+libxdbg_lib_la_LDFLAGS = ${LDFLAGS}
+libxdbg_lib_la_CFLAGS = \
+ ${CFLAGS} \
+ @XDBG_CFLAGS@ \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/common
+
+libxdbg_lib_la_SOURCES = \
+ xdbg_log.c \
+ xdbg_log_klog.c \
+ xdbg_log_dlog.c \
+ xdbg_log_drmevent.c \
+ xdbg_log_plist.c \
+ xdbg_log_fpsdebug.c \
+ xdbg_dump.c
+
+xdbgincludedir = $(includedir)/xdbg
+xdbginclude_HEADERS = \
+ xdbg.h \
+ xdbg_log.h \
+ xdbg_log_drmevent.h \
+ xdbg_log_secure.h \
+ xdbg_log_plist.h \
+ xdbg_log_fpsdebug.h \
+ xdbg_dump.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xdbg.pc
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_H__
+#define __XDBG_H__
+
+/* include only headers */
+#include <xdbg_log.h>
+#include <xdbg_log_drmevent.h>
+#include <xdbg_log_plist.h>
+#include <xdbg_log_fpsdebug.h>
+#include <xdbg_dump.h>
+
+#endif /* __XDBG_H__ */
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: xdbg
+Description: The X debug Library
+Version: @PACKAGE_VERSION@
+Requires.private: xorg-server x11 dlog
+Cflags: -I${includedir}/xdbg
+Libs: -L${libdir} -lxdbg-lib
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include "xdbg_log.h"
+#include "xdbg_dump.h"
+#include "xdbg_dump_module.h"
+#include <list.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define DUMP_BUFCNT 50
+#define DUMP_DIR "/tmp/xdump"
+#define DUMP_SCALE_RATIO 2
+
+typedef struct
+{
+ int index;
+
+ void *bo; /* buffer object */
+ int bo_size;
+
+ char file[128];
+ union {
+ struct {
+ int dump_w;
+ int dump_h;
+ xRectangle dump_rect;
+ } a;
+ int dump_size;
+ } u;
+ Bool is_dirty;
+ Bool is_bmp;
+
+ struct xorg_list link;
+} xDbgDumpBuffer;
+
+typedef struct
+{
+ Bool init;
+
+ char *type_str;
+ char *file_str;
+ char *count_str;
+ char *crop_str;
+
+ xDbgDumpBufferFunc func;
+ int bo_size;
+
+ struct xorg_list *cursor;
+ struct xorg_list buffers;
+
+ int type;
+ int count;
+ xRectangle *crop;
+} xDbgDumpInfo;
+
+static xDbgDumpInfo xdbg_dump_info;
+
+static int
+_parse_int (char *s)
+{
+ char *fmt = "%lu";
+ int retval = 0;
+ int thesign = 1;
+
+ if (s && s[0])
+ {
+ char temp[12];
+ snprintf (temp, sizeof (temp), "%s", s);
+ s = temp;
+
+ if (s[0] == '-')
+ s++, thesign = -1;
+ if (s[0] == '0')
+ s++, fmt = "%o";
+ if (s[0] == 'x' || s[0] == 'X')
+ s++, fmt = "%x";
+ (void) sscanf (s, fmt, &retval);
+ }
+ return (thesign * retval);
+}
+
+static Bool
+_xDbgDumpEnsureDir (void)
+{
+ char *dir = DUMP_DIR;
+ DIR *dp;
+ int ret;
+
+ if (!(dp = opendir (dir)))
+ {
+ ret = mkdir (dir, 0755);
+ if (ret < 0)
+ {
+ XDBG_ERROR (MXDBG, "fail: mkdir '%s'\n", DUMP_DIR);
+ return FALSE;
+ }
+ }
+ else
+ closedir (dp);
+
+ return TRUE;
+}
+
+static void
+_xDbgDumpSetOptions (void)
+{
+ char options[256];
+ int tempsize = sizeof (options);
+ char *reply = options;
+ int *len = &tempsize;
+
+ options[0] = '\0';
+
+ /* type */
+ if (xdbg_dump_info.type_str)
+ {
+ char *c = xdbg_dump_info.type_str;
+ if (!strcmp (c, "drawable"))
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_DRAWABLE;
+ else if (!strcmp (c, "fb"))
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_FB;
+ else if (!strcmp (c, "ui"))
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_UI;
+ else if (!strcmp (c, "video"))
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_VIDEO;
+ else
+ xdbg_dump_info.type = _parse_int (c);
+ }
+ else
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_UI;
+ XDBG_REPLY ("type(0x%x) ", xdbg_dump_info.type);
+
+ /* count */
+ if (xdbg_dump_info.count_str)
+ xdbg_dump_info.count = atoi (xdbg_dump_info.count_str);
+ else
+ xdbg_dump_info.count = DUMP_BUFCNT;
+ XDBG_REPLY ("count(%d) ", xdbg_dump_info.count);
+
+ /* file */
+ if (xdbg_dump_info.file_str)
+ XDBG_REPLY ("file(%s) ", xdbg_dump_info.file_str);
+
+ /* crop */
+ if (xdbg_dump_info.crop_str)
+ {
+ int i;
+ char temp[64];
+ char *c;
+ int nums[4];
+
+ if (xdbg_dump_info.crop)
+ {
+ free (xdbg_dump_info.crop);
+ xdbg_dump_info.crop = NULL;
+ }
+
+ snprintf (temp, sizeof (temp), "%s", xdbg_dump_info.crop_str);
+
+ c = strtok (temp, ",");
+ i = 0;
+ while (c != NULL)
+ {
+ nums[i++] = atoi(c);
+ c = strtok (NULL, ",");
+ if (i == 4)
+ break;
+ }
+
+ if (i == 4)
+ {
+ xdbg_dump_info.crop = calloc (1, sizeof (xRectangle));
+ XDBG_RETURN_IF_FAIL (xdbg_dump_info.crop != NULL);
+
+ xdbg_dump_info.crop->x = nums[0];
+ xdbg_dump_info.crop->y = nums[1];
+ xdbg_dump_info.crop->width = nums[2];
+ xdbg_dump_info.crop->height = nums[3];
+
+ XDBG_REPLY ("crop(%d,%d %dx%d) ",
+ nums[0], nums[1], nums[2], nums[3]);
+ }
+ }
+
+ XDBG_DEBUG (MXDBG, "%s\n", options);
+}
+
+static void
+_xDbgDumpInit (void)
+{
+ if (xdbg_dump_info.init)
+ return;
+
+ xdbg_dump_info.init = TRUE;
+ xdbg_dump_info.cursor = NULL;
+ xorg_list_init (&xdbg_dump_info.buffers);
+}
+
+static int
+_xDbgDumpBmp (const char * file, const void * data, int width, int height)
+{
+ int i;
+
+ struct
+ {
+ unsigned char magic[2];
+ } bmpfile_magic = { {'B', 'M'} };
+
+ struct
+ {
+ unsigned int filesz;
+ unsigned short creator1;
+ unsigned short creator2;
+ unsigned int bmp_offset;
+ } bmpfile_header = { 0, 0, 0, 0x36 };
+
+ struct
+ {
+ unsigned int header_sz;
+ unsigned int width;
+ unsigned int height;
+ unsigned short nplanes;
+ unsigned short bitspp;
+ unsigned int compress_type;
+ unsigned int bmp_bytesz;
+ unsigned int hres;
+ unsigned int vres;
+ unsigned int ncolors;
+ unsigned int nimpcolors;
+ } bmp_dib_v3_header_t = { 0x28, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0 };
+ unsigned int * blocks;
+
+ XDBG_RETURN_VAL_IF_FAIL (file != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (data != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (width > 0, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (height > 0, FALSE);
+
+ FILE * fp = fopen (file, "w+");
+ XDBG_RETURN_VAL_IF_FAIL (fp != NULL, FALSE);
+
+ bmpfile_header.filesz = sizeof (bmpfile_magic) + sizeof (bmpfile_header) +
+ sizeof (bmp_dib_v3_header_t) + width * height * 3;
+ bmp_dib_v3_header_t.header_sz = sizeof (bmp_dib_v3_header_t);
+ bmp_dib_v3_header_t.width = width;
+ bmp_dib_v3_header_t.height = -height;
+ bmp_dib_v3_header_t.nplanes = 1;
+ bmp_dib_v3_header_t.bmp_bytesz = width * height * 3;
+
+ fwrite (&bmpfile_magic, sizeof (bmpfile_magic), 1, fp);
+ fwrite (&bmpfile_header, sizeof (bmpfile_header), 1, fp);
+ fwrite (&bmp_dib_v3_header_t, sizeof (bmp_dib_v3_header_t), 1, fp);
+
+ blocks = (unsigned int*)data;
+ for (i=0; i<height * width; i++)
+ fwrite (&blocks[i], 3, 1, fp);
+
+ fclose (fp);
+
+ XDBG_TRACE (MXDBG, "%s saved\n", file);
+
+ return TRUE;
+}
+
+static Bool
+_xDbgDumpRaw (const char * file, const void * data, int size)
+{
+ XDBG_RETURN_VAL_IF_FAIL (file != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (data != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (size > 0, FALSE);
+
+ FILE * fp = fopen (file, "w+");
+ XDBG_RETURN_VAL_IF_FAIL (fp != NULL, FALSE);
+
+ unsigned int *blocks = (unsigned int*)data;
+ fwrite (blocks, 1, size, fp);
+ fclose (fp);
+
+ XDBG_TRACE (MXDBG, "%s saved\n", file);
+
+ return TRUE;
+}
+
+API Bool
+xDbgDumpSetType (char *type_str)
+{
+ XDBG_RETURN_VAL_IF_FAIL (type_str != NULL, FALSE);
+
+ _xDbgDumpInit ();
+
+ if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_ERROR (MXDBG, "can't set.\n");
+ return FALSE;
+ }
+
+ if (xdbg_dump_info.type_str)
+ free (xdbg_dump_info.type_str);
+
+ xdbg_dump_info.type_str = strdup (type_str);
+ XDBG_DEBUG (MXDBG, "type_str: %s\n", xdbg_dump_info.type_str);
+
+ return TRUE;
+}
+
+API Bool
+xDbgDumpSetFile (char *file_str)
+{
+ XDBG_RETURN_VAL_IF_FAIL (file_str != NULL, FALSE);
+
+ _xDbgDumpInit ();
+
+ if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_ERROR (MXDBG, "can't set.\n");
+ return FALSE;
+ }
+
+ if (xdbg_dump_info.file_str)
+ free (xdbg_dump_info.file_str);
+
+ xdbg_dump_info.file_str = strdup (file_str);
+ XDBG_DEBUG (MXDBG, "file_str: %s\n", xdbg_dump_info.file_str);
+
+ return TRUE;
+}
+
+API Bool
+xDbgDumpSetCount (char *count_str)
+{
+ XDBG_RETURN_VAL_IF_FAIL (count_str != NULL, FALSE);
+
+ _xDbgDumpInit ();
+
+ if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_ERROR (MXDBG, "can't set.\n");
+ return FALSE;
+ }
+
+ if (xdbg_dump_info.count_str)
+ free (xdbg_dump_info.count_str);
+
+ xdbg_dump_info.count_str = strdup (count_str);
+ XDBG_DEBUG (MXDBG, "count_str: %s\n", xdbg_dump_info.count_str);
+
+ return TRUE;
+}
+
+API Bool
+xDbgDumpSetCrop (char *crop_str)
+{
+ XDBG_RETURN_VAL_IF_FAIL (crop_str != NULL, FALSE);
+
+ _xDbgDumpInit ();
+
+ if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_ERROR (MXDBG, "can't set.\n");
+ return FALSE;
+ }
+
+ if (xdbg_dump_info.crop_str)
+ free (xdbg_dump_info.crop_str);
+
+ xdbg_dump_info.crop_str = strdup (crop_str);
+ XDBG_DEBUG (MXDBG, "crop_str: %s\n", xdbg_dump_info.crop_str);
+
+ return TRUE;
+}
+
+API char*
+xDbgDumpGetType (void)
+{
+ return xdbg_dump_info.type_str;
+}
+
+API char*
+xDbgDumpGetFile (void)
+{
+ return xdbg_dump_info.file_str;
+}
+
+API char*
+xDbgDumpGetCount (void)
+{
+ return xdbg_dump_info.count_str;
+}
+
+API char*
+xDbgDumpGetCrop (void)
+{
+ return xdbg_dump_info.crop_str;
+}
+
+API Bool
+xDbgDumpPrepare (void)
+{
+ int i;
+
+ _xDbgDumpInit ();
+
+ if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
+ return TRUE;
+
+ _xDbgDumpSetOptions ();
+
+ for (i = 0; i < xdbg_dump_info.count; i++)
+ {
+ xDbgDumpBuffer *dumpbuf = calloc (1, sizeof (xDbgDumpBuffer));
+ XDBG_GOTO_IF_FAIL (dumpbuf != NULL, fail);
+
+ xorg_list_add (&dumpbuf->link, &xdbg_dump_info.buffers);
+ dumpbuf->index = i;
+ dumpbuf->bo_size = xdbg_dump_info.bo_size;
+ if (xdbg_dump_info.func.alloc)
+ {
+ dumpbuf->bo = xdbg_dump_info.func.alloc (dumpbuf->bo_size);
+ XDBG_GOTO_IF_FAIL (dumpbuf->bo != NULL, fail);
+ }
+ }
+
+ xdbg_dump_info.cursor = &xdbg_dump_info.buffers;
+
+ return TRUE;
+fail:
+ xDbgDumpClear ();
+ return FALSE;
+}
+
+API void
+xDbgDumpSave (void)
+{
+ xDbgDumpBuffer *cur = NULL, *next = NULL;
+
+ _xDbgDumpInit ();
+
+ if (!_xDbgDumpEnsureDir ())
+ return;
+
+ xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
+ {
+ char file[128];
+ void *ptr;
+
+ if (!cur->is_dirty)
+ continue;
+
+ if (xdbg_dump_info.func.map)
+ ptr = xdbg_dump_info.func.map (cur->bo);
+ else
+ ptr = cur->bo;
+ XDBG_GOTO_IF_FAIL (ptr != NULL, reset_dump);
+
+ snprintf (file, sizeof(file), "%s/%s", DUMP_DIR, cur->file);
+
+ if (cur->is_bmp)
+ {
+ unsigned int *p = (unsigned int*)ptr;
+ int i, j;
+
+ /* fill magenta color(#FF00FF) for background */
+ for (j = 0; j < cur->u.a.dump_h; j++)
+ for (i = 0; i < cur->u.a.dump_w ; i++)
+ {
+ if (i >= cur->u.a.dump_rect.x && i < (cur->u.a.dump_rect.x + cur->u.a.dump_rect.width))
+ if (j >= cur->u.a.dump_rect.y && j < (cur->u.a.dump_rect.y + cur->u.a.dump_rect.height))
+ continue;
+ p[i + j * cur->u.a.dump_w] = 0xFFFF00FF;
+ }
+
+ _xDbgDumpBmp (file, ptr, cur->u.a.dump_w, cur->u.a.dump_h);
+
+ if (xdbg_dump_info.file_str && !strcmp (xdbg_dump_info.file_str, "raw"))
+ {
+ snprintf (file, sizeof(file), "%s/%s.raw", DUMP_DIR, cur->file);
+ _xDbgDumpRaw (file, ptr, cur->u.a.dump_w*cur->u.a.dump_h*4);
+ }
+ }
+ else
+ {
+ _xDbgDumpRaw (file, ptr, cur->u.dump_size);
+ }
+
+ if (xdbg_dump_info.func.unmap)
+ xdbg_dump_info.func.unmap (cur->bo);
+
+reset_dump:
+ cur->file[0] = '\0';
+ memset (&cur->u, 0, sizeof (cur->u));
+ cur->is_dirty = FALSE;
+ cur->is_bmp = FALSE;
+ }
+}
+
+API void
+xDbgDumpClear (void)
+{
+ xDbgDumpBuffer *cur = NULL, *next = NULL;
+
+ _xDbgDumpInit ();
+
+ xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
+ {
+ if (xdbg_dump_info.func.free)
+ xdbg_dump_info.func.free (cur->bo);
+ xorg_list_del (&cur->link);
+ free (cur);
+ }
+
+ xdbg_dump_info.cursor = NULL;
+
+ xdbg_dump_info.type = XDBG_DUMP_TYPE_NONE;
+ xdbg_dump_info.count = 0;
+ if (xdbg_dump_info.crop)
+ {
+ free (xdbg_dump_info.crop);
+ xdbg_dump_info.crop = NULL;
+ }
+
+ XDBG_DEBUG (MXDBG, "\n");
+}
+
+API Bool
+xDbgDumpSetBufferFunc (xDbgDumpBufferFunc *func, int bo_size)
+{
+ XDBG_RETURN_VAL_IF_FAIL (bo_size > 0, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (func != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (func->alloc != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (func->free != NULL, FALSE);
+ if (func->map)
+ XDBG_RETURN_VAL_IF_FAIL (func->unmap != NULL, FALSE);
+
+ _xDbgDumpInit ();
+
+ xdbg_dump_info.func = *func;
+ xdbg_dump_info.bo_size = bo_size;
+
+ XDBG_INFO (MXDBG, "\n");
+
+ return TRUE;
+}
+
+API Bool
+xDbgDumpIsEnable (xDbgDumpType type)
+{
+ return (xdbg_dump_info.type & type) ? TRUE : FALSE;
+}
+
+API void
+xDbgDumpRaw (void *data, xDbgDumpType type, void *var_buf, const char *file)
+{
+ xDbgDumpBuffer *dumpbuf;
+ struct xorg_list *next_cursor;
+
+ XDBG_RETURN_IF_FAIL (type > 0);
+ XDBG_RETURN_IF_FAIL (var_buf != NULL);
+ XDBG_RETURN_IF_FAIL (file != NULL);
+
+ _xDbgDumpInit ();
+ if (xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_WARNING (MXDBG, "not ready to dump\n");
+ return;
+ }
+
+ next_cursor = xdbg_dump_info.cursor->next;
+ XDBG_RETURN_IF_FAIL (next_cursor != NULL);
+
+ if (next_cursor == &xdbg_dump_info.buffers)
+ {
+ next_cursor = next_cursor->next;
+ XDBG_RETURN_IF_FAIL (next_cursor != NULL);
+ }
+
+ dumpbuf = xorg_list_entry (next_cursor, xDbgDumpBuffer, link);
+ XDBG_RETURN_IF_FAIL (dumpbuf != NULL);
+
+ if (xdbg_dump_info.func.dumpRaw)
+ {
+ Bool ret;
+ int dump_size = 0;
+
+ ret = xdbg_dump_info.func.dumpRaw (data, type,
+ var_buf, dumpbuf->bo, dumpbuf->bo_size,
+ &dump_size);
+ XDBG_RETURN_IF_FAIL (ret == TRUE);
+ XDBG_RETURN_IF_FAIL (dump_size > 0);
+ XDBG_RETURN_IF_FAIL (dump_size <= dumpbuf->bo_size);
+
+ snprintf (dumpbuf->file, sizeof (dumpbuf->file), "%.3f_%s", GetTimeInMillis()/1000.0, file);
+ dumpbuf->u.dump_size = dump_size;
+ dumpbuf->is_dirty = TRUE;
+ dumpbuf->is_bmp = FALSE;
+
+ xdbg_dump_info.cursor = next_cursor;
+ }
+
+ XDBG_DEBUG (MXDBG, "type:0x%x file: %s\n", type, file);
+}
+
+API void
+xDbgDumpBmp (void *data, xDbgDumpType type, void *var_buf, const char *file)
+{
+ xDbgDumpBuffer *dumpbuf;
+ struct xorg_list *next_cursor;
+
+ XDBG_RETURN_IF_FAIL (type > 0);
+ XDBG_RETURN_IF_FAIL (var_buf != NULL);
+ XDBG_RETURN_IF_FAIL (file != NULL);
+
+ _xDbgDumpInit ();
+ if (xorg_list_is_empty (&xdbg_dump_info.buffers))
+ {
+ XDBG_WARNING (MXDBG, "not ready to dump\n");
+ return;
+ }
+
+ next_cursor = xdbg_dump_info.cursor->next;
+ XDBG_RETURN_IF_FAIL (next_cursor != NULL);
+
+ if (next_cursor == &xdbg_dump_info.buffers)
+ {
+ next_cursor = next_cursor->next;
+ XDBG_RETURN_IF_FAIL (next_cursor != NULL);
+ }
+
+ dumpbuf = xorg_list_entry (next_cursor, xDbgDumpBuffer, link);
+ XDBG_RETURN_IF_FAIL (dumpbuf != NULL);
+
+ if (xdbg_dump_info.func.dumpBmp)
+ {
+ Bool ret;
+ int dump_w = 0, dump_h = 0;
+ xRectangle dump_rect = {0,};
+
+ ret = xdbg_dump_info.func.dumpBmp (data, type,
+ var_buf, dumpbuf->bo, dumpbuf->bo_size,
+ &dump_w, &dump_h, &dump_rect);
+ XDBG_RETURN_IF_FAIL (ret == TRUE);
+ XDBG_RETURN_IF_FAIL (dump_w > 0);
+ XDBG_RETURN_IF_FAIL (dump_h > 0);
+ XDBG_RETURN_IF_FAIL (dump_rect.width > 0);
+ XDBG_RETURN_IF_FAIL (dump_rect.height > 0);
+
+ snprintf (dumpbuf->file, sizeof (dumpbuf->file), "%.3f_%s", GetTimeInMillis()/1000.0, file);
+ dumpbuf->u.a.dump_w = dump_w;
+ dumpbuf->u.a.dump_h = dump_h;
+ dumpbuf->u.a.dump_rect = dump_rect;
+ dumpbuf->is_dirty = TRUE;
+ dumpbuf->is_bmp = TRUE;
+
+ xdbg_dump_info.cursor = next_cursor;
+ }
+
+ XDBG_DEBUG (MXDBG, "type:0x%x file: %s\n", type, file);
+}
+
+API Bool
+xDbgDumpReplaceBuffer (void *old_dump_buf, void *new_dump_buf, int new_dump_buf_size)
+{
+ xDbgDumpBuffer *cur = NULL, *next = NULL;
+
+ XDBG_RETURN_VAL_IF_FAIL (new_dump_buf != NULL, FALSE);
+ XDBG_RETURN_VAL_IF_FAIL (new_dump_buf_size > 0, FALSE);
+
+ _xDbgDumpInit ();
+
+ xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
+ {
+ if (cur->bo == old_dump_buf)
+ {
+ if (xdbg_dump_info.func.free)
+ xdbg_dump_info.func.free (cur->bo);
+
+ cur->bo = new_dump_buf;
+ cur->bo_size = new_dump_buf_size;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_DUMP_H__
+#define __XDBG_DUMP_H__
+
+#include <X11/Xdefs.h>
+#include <X11/Xprotostr.h>
+
+/* "xdbg dump" is designed for "x video driver" to dump various buffers without
+ * losing performance. When it starts, it allocates 50 dump-buffers by default.
+ * You can change the count of dump-buffers with "-count" option. After starting,
+ * various buffers will be copied into dump-buffers. Finally when it stops,
+ * all copied buffers will be saved into "/tmp/xdump" directory.
+ * You can use "-type" option to distinguish the type of various buffers inside of
+ * x video driver.
+ *
+ * # xdbg dump on //begin
+ * # xdbg dump off //off with saving
+ * # xdbg dump clear //off without saving
+ * # xdbg dump -count [n]
+ * # xdbg dump -type [drawable|fb|ui|video]
+ * # xdbg dump on -type ui -count 100
+ * # xdbg dump -type 0x2000 //user-defined type(number only)
+ * # xdbg dump -crop 10,10,200,200 //dump only (10,10 200x200) area
+ */
+typedef enum
+{
+ XDBG_DUMP_TYPE_NONE = 0x00000000,
+ XDBG_DUMP_TYPE_DRAWABLE = 0x00000001,
+ XDBG_DUMP_TYPE_FB = 0x00000010,
+ XDBG_DUMP_TYPE_UI = 0x00000011,
+ XDBG_DUMP_TYPE_VIDEO = 0x00000100,
+} xDbgDumpType;
+
+/* "xDbgDumpBufferFunc" should be implemented in "x video driver". */
+typedef struct
+{
+ /* [in ] dump_buf_size: size of dump-buffer
+ * [out] a newly-allocated dump-buffer
+ */
+ void* (*alloc) (int dump_buf_size);
+
+ /* map() should return virtual address of dump-buffer. If alloc() returns
+ * virtual address, map() and unmap() can be NULL. Don't need to implement.
+ * [in ] dump_buf: a dump-buffer
+ * [out] virtual address of a dump-buffer
+ */
+ void* (*map) (void *dump_buf);
+ void (*unmap) (void *dump_buf);
+ void (*free) (void *dump_buf);
+
+ /* xDbgDumpBmp() calls dumpBum(). Returned dump_w, dump_h and dump_rect will
+ * be used when a dump-buffer is saved to a bmp file.
+ * If you don't call xDbgDumpBmp(), dumpBmp() can be NULL.
+ * [in ] data: user-data
+ * [in ] type: dump-type
+ * [in ] var_buf: various buffer
+ * [in ] dump_buf: a dump-buffer
+ * [in ] dump_buf_size: size of dump-buffer
+ * [out] dump_w: a dump-buffer's width
+ * [out] dump_h a dump-buffer's height
+ * [out] dump_rect: rect which contains copied-image within a dump-buffer
+ * [out] TRUE if success to copy, FALSE if fail
+ */
+ Bool (*dumpBmp) (void *data, xDbgDumpType type,
+ void *var_buf, void *dump_buf, int dump_buf_size,
+ int *dump_w, int *dump_h, xRectangle *dump_rect);
+
+ /* xDbgDumpRaw() calls dumpRaw(). Returned dump_size will be used when a
+ * dump-buffer is saved to a raw file.
+ * If you don't call xDbgDumpRaw(), dumpRaw() can be NULL.
+ * [in ] data: user-data
+ * [in ] type: dump-type
+ * [in ] var_buf: various buffer
+ * [in ] dump_buf: a dump-buffer
+ * [in ] dump_buf_size: size of dump-buffer
+ * [out] dump_size: size which contains copied-image in a dump-buffer
+ * [out] TRUE if success to copy, FALSE if fail
+ */
+ Bool (*dumpRaw) (void *data, xDbgDumpType type,
+ void *var_buf, void *dump_buf, int dump_buf_size,
+ int *dump_size);
+
+ void (*reserved1) (void);
+ void (*reserved2) (void);
+ void (*reserved3) (void);
+ void (*reserved4) (void);
+} xDbgDumpBufferFunc;
+
+/* Register dump-buffer-functions and set max-size of a dump-buffer.
+ * [in ] func: dump-buffer-functions
+ * [in ] dump_buf_size: dump-buffer size. alloc() receives this size.
+ * [out] TRUE if success, FALSE if fail
+ */
+Bool xDbgDumpSetBufferFunc (xDbgDumpBufferFunc *func, int dump_buf_size);
+
+/* Check if "xdbg dump" is on.
+ * [in ] type: dump-type
+ * [out] TRUE if on, FALSE if off
+ *
+ * Sample:
+ * if (xDbgDumpIsEnable (XDBG_DUMP_TYPE_UI))
+ * xDbgDumpBmp (scrn, XDBG_DUMP_TYPE_UI, pPixmap, "drawable_1.bmp");
+ *
+ * if (xDbgDumpIsEnable (XDBG_DUMP_TYPE_VIDEO))
+ * xDbgDumpRaw (scrn, XDBG_DUMP_TYPE_VIDEO, yuv_buffer, "video_1.yuv");
+ */
+Bool xDbgDumpIsEnable (xDbgDumpType type);
+
+/* Dump various buffer as raw file
+ * [in ] data: user-data
+ * [in ] type: dump-type
+ * [in ] var_buf: various buffer
+ * [in ] file: filename to save
+ */
+void xDbgDumpRaw (void *data, xDbgDumpType type, void *var_buf, const char *file);
+
+/* Dump various buffer as bmp file
+ * [in ] data: user-data
+ * [in ] type: dump-type
+ * [in ] var_buf: various buffer
+ * [in ] file: filename to save
+ */
+void xDbgDumpBmp (void *data, xDbgDumpType type, void *var_buf, const char *file);
+
+/* Replace a old dump-buffer to a new dump-buffer.
+ * [in ] old_dump_buf: old dump-buffer
+ * [in ] new_dump_buf: new dump-buffer
+ * [in ] new_dump_buf_size: new dump-buffer's size
+ * [out] TRUE if success, FALSE if fail
+ */
+Bool xDbgDumpReplaceBuffer (void *old_dump_buf, void *new_dump_buf, int new_dump_buf_size);
+
+#endif /* __XDBG_DUMP_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_DUMP_MODULE_H__
+#define __XDBG_DUMP_MODULE_H__
+
+#include <X11/Xdefs.h>
+#include <X11/Xprotostr.h>
+#include "xdbg_dump.h"
+
+Bool xDbgDumpSetType (char *type_str);
+Bool xDbgDumpSetFile (char *file_str);
+Bool xDbgDumpSetCount (char *count_str);
+Bool xDbgDumpSetCrop (char *crop_str);
+char* xDbgDumpGetType (void);
+char* xDbgDumpGetFile (void);
+char* xDbgDumpGetCount (void);
+char* xDbgDumpGetCrop (void);
+
+Bool xDbgDumpPrepare (void);
+void xDbgDumpSave (void);
+void xDbgDumpClear (void);
+
+#endif /* __XDBG_DUMP_MODULE_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <stdarg.h>
+#include <dlog.h>
+#include "xdbg_log.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#define MAX_MODULE_NAME 4
+#define MAX_MODULE_CNT 256
+#define BUF_LEN 1024
+#define MAX_MONTH 12
+
+typedef struct
+{
+ unsigned int module;
+ char *name;
+ int loglevel;
+} ModuleInfo;
+
+static ModuleInfo modules[MAX_MODULE_CNT];
+static int module_cnt = 0;
+static int default_level = XLOG_LEVEL_DEFAULT;
+static char *st_month[MAX_MONTH] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+
+static Bool dlog_enable;
+
+extern void dLogWrapper (int loglevel, int is_module, const char * file, int line, const char * f, va_list args);
+extern void kLogWrapper (int loglevel, int is_module, const char * file, int line, const char * f, va_list args);
+static char* _LogGetName (unsigned int module);
+
+static void*
+_LogInitModule (unsigned int module, int loglevel)
+{
+ if (module_cnt >= MAX_MODULE_CNT)
+ return NULL;
+
+ modules[module_cnt].module = module;
+ modules[module_cnt].name = _LogGetName (module);
+ modules[module_cnt].loglevel = loglevel;
+ module_cnt++;
+
+ return &modules[module_cnt-1];
+}
+
+static void
+_LogModule (void * handle, int logoption, const char * file, int line, const char * f, va_list args)
+{
+ ModuleInfo *h = (ModuleInfo*)handle;
+ char *ostr[XLOG_LEVEL_MAX] = {"DD", "TT", "II", "WW", "EE"};
+ char tmpBuf[BUF_LEN];
+ int loglevel = logoption & XLOG_MASK_LOGLEVEL;
+ const char *name;
+ struct timeval tv;
+ struct tm *tm=NULL;
+
+ if (!h)
+ return;
+
+ name = h->name;
+
+ if (logoption & XLOG_OPTION_KLOG)
+ {
+ snprintf(tmpBuf, BUF_LEN, "[%s]%s", (name)?name:"", f);
+ kLogWrapper (loglevel, logoption, file, line, tmpBuf, args);
+ }
+ else if (loglevel >= XLOG_LEVEL_INFO)
+ {
+ if( !dlog_enable )
+ {
+ /* get local time from tv */
+ gettimeofday(&tv, NULL);
+ tm = localtime(&tv.tv_sec);
+
+ /* write to file */
+ if (tm)
+ {
+ if (logoption & XLOG_OPTION_SECURE)
+ snprintf(tmpBuf, BUF_LEN, "[%s %d %02d:%02d:%02d:%03ld] (%s) > [SECURE_LOG] [%s]%s", st_month[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec/1000, ostr[loglevel], (name)?name:"", f);
+ else
+ snprintf(tmpBuf, BUF_LEN, "[%s %d %02d:%02d:%02d:%03ld] (%s) [%s]%s", st_month[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec/1000, ostr[loglevel], (name)?name:"", f);
+ }
+ else
+ snprintf(tmpBuf, BUF_LEN, "[failed to get local time] (%s) [%s]%s", ostr[loglevel], (name)?name:"", f);
+
+ LogVWrite (1, tmpBuf, args);
+ }
+ else
+ {
+ /* dlog already supports localtime stamp. So we just add clock time! */
+ /* write to file */
+ if (logoption & XLOG_OPTION_SECURE)
+ snprintf(tmpBuf, BUF_LEN, "[%10.3f] (%s) > [SECURE_LOG] [%s]%s", GetTimeInMillis()/1000.0, ostr[loglevel], (name)?name:"", f);
+ else
+ snprintf(tmpBuf, BUF_LEN, "[%10.3f] (%s) [%s]%s", GetTimeInMillis()/1000.0, ostr[loglevel], (name)?name:"", f);
+
+ dLogWrapper (loglevel, logoption, file, line, tmpBuf, args);
+ }
+ }
+
+ /* write to console */
+ if (loglevel >= h->loglevel)
+ {
+ char *buf = tmpBuf;
+ int remain = BUF_LEN;
+ int len = 0;
+ unsigned int tv_ms;
+
+ if( tm == NULL )
+ {
+ gettimeofday(&tv, NULL);
+ tm = localtime(&tv.tv_sec);
+ }
+
+ tv_ms = tv.tv_usec/1000;
+ if (tm)
+ len = snprintf (buf, remain, "[%10.3f] [%s %d %02d:%02d:%02d:%03d] (%s) [%s]", GetTimeInMillis()/1000.0, st_month[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tv_ms, ostr[loglevel], name?name:"");
+ else
+ len = snprintf (buf, remain, "[%10.3f] [Failed to get current time:%03d] (%s) [%s]", GetTimeInMillis()/1000.0, tv_ms, ostr[loglevel], name?name:"");
+ buf += len;
+ remain -= len;
+
+ len += vsnprintf (buf, remain, f, args);
+
+ fwrite(tmpBuf, len, 1, stderr);
+ }
+}
+
+API int
+xDbgLogSetLevel (unsigned int module, int level)
+{
+ int i;
+ ModuleInfo * h;
+
+ if (level < XLOG_LEVEL_0 || level > XLOG_LEVEL_4)
+ return FALSE;
+
+ if (module == XDBG_ALL_MODULE)
+ {
+ default_level = level;
+ for (i = 0; i < module_cnt; i++)
+ modules[i].loglevel = level;
+
+ return TRUE;
+ }
+
+ for (i = 0; i < module_cnt; i++)
+ {
+ if (module == modules[i].module)
+ {
+ modules[i].loglevel = level;
+ return TRUE;
+ }
+ }
+
+ h = _LogInitModule (module, level);
+ if (h == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
+API void
+xDbgLogEnableDlog (Bool enable)
+{
+ dlog_enable = (enable > 0) ? TRUE:FALSE;
+}
+
+API Bool
+xDbgGetLogEnableDlog ()
+{
+ return dlog_enable;
+}
+
+API void*
+xDbgLog (unsigned int module, int logoption, const char * file, int line, const char * f, ...)
+{
+ int loglevel = logoption & XLOG_MASK_LOGLEVEL;
+ ModuleInfo *h;
+ va_list args;
+ int i;
+
+ if (module == 0)
+ return NULL;
+
+ if (loglevel < XLOG_LEVEL_0 || loglevel > XLOG_LEVEL_4)
+ return NULL;
+
+ for (i = 0; i < module_cnt; i++)
+ {
+ h = &modules[i];
+ if (module == h->module)
+ goto check_level;
+ }
+
+ h= (ModuleInfo *)_LogInitModule (module, default_level);
+ if(h == NULL)
+ return NULL;
+
+check_level:
+ if (loglevel < XLOG_LEVEL_INFO && loglevel < h->loglevel)
+ return h;
+
+ va_start (args, f);
+ _LogModule (h, logoption, file, line, f, args);
+ va_end (args);
+
+ return h;
+}
+
+API int
+xDbgLogEnumModules (LOG_ENUM_MODE mode, char *buf, int *remain)
+{
+ int i, len;
+ char *p = buf;
+
+ switch (mode)
+ {
+ case MODE_NAME_ONLY:
+ for (i = 0; i < module_cnt && *remain > 0; i++)
+ {
+ len = snprintf (p, *remain, "%s", modules[i].name);
+ p += len;
+ *remain -= len;
+
+ if (i != module_cnt - 1 && *remain > 0)
+ {
+ len = snprintf (p, *remain, "/");
+ p += len;
+ *remain -= len;
+ }
+ }
+ break;
+ case MODE_WITH_STATUS:
+ for (i = 0; i < module_cnt && *remain > 0; i++)
+ {
+ len = snprintf (p, *remain, " %12s:%d\n", modules[i].name, modules[i].loglevel);
+ p += len;
+ *remain -= len;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ return p - buf;
+}
+
+static char*
+_LogGetName (unsigned int module)
+{
+ char *name = malloc (MAX_MODULE_NAME+1);
+ char *p = name;
+ int i;
+
+ if (!name)
+ return NULL;
+
+ name[0] = '\0';
+
+ for (i = 0; i < MAX_MODULE_NAME; i++)
+ {
+ if (!_C(module, (i<<3)))
+ break;
+
+ *p = _C(module, (i<<3));
+ p++;
+ }
+
+ *p = '\0';
+
+ return name;
+}
+
+API unsigned int
+xDbgLogGetModule (char *name)
+{
+ unsigned int module = 0;
+ int i, len;
+
+ if (!name)
+ return 0;
+
+ if (!strcasecmp (name, "all"))
+ return XDBG_ALL_MODULE;
+
+ len = strlen (name);
+ for (i = 0; i < len; i++)
+ {
+ module |= _B(*name, (i<<3));
+ name++;
+ }
+
+ return module;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_LOG_H__
+#define __XDBG_LOG_H__
+
+#include <errno.h>
+#include <stdlib.h>
+#include <os.h>
+#include <xdbg_log_secure.h>
+
+unsigned int xDbgLogGetModule (char *name);
+Bool xDbgGetLogEnableDlog ();
+
+#define _C(b,s) (((b) >> (s)) & 0xFF)
+#define _B(c,s) ((((unsigned int)(c)) & 0xff) << (s))
+#define XDBG_M(a,b,c,d) (_B(d,24)|_B(c,16)|_B(b,8)|_B(a,0))
+
+/* debug module for XDBG */
+#define MXDBG XDBG_M('X','D','B','G')
+
+// Masks
+#define XLOG_MASK_LOGLEVEL 0x000000FF
+#define XLOG_MASK_OPTIONS 0xFFFFFF00
+
+// LogLevels
+enum
+{
+ XLOG_LEVEL_0,
+ XLOG_LEVEL_1,
+ XLOG_LEVEL_2,
+ XLOG_LEVEL_3,
+ XLOG_LEVEL_4,
+ XLOG_LEVEL_MAX,
+ XLOG_LEVEL_DEFAULT = XLOG_LEVEL_MAX,
+};
+
+#define XDBG_ALL_MODULE 0xFFFFFFFF
+
+#define XLOG_LEVEL_DEBUG XLOG_LEVEL_0 /* console */
+#define XLOG_LEVEL_TRACE XLOG_LEVEL_1 /* console */
+#define XLOG_LEVEL_INFO XLOG_LEVEL_2 /* Xorg.0.log or dlog */
+#define XLOG_LEVEL_WARNING XLOG_LEVEL_3 /* Xorg.0.log and dlog */
+#define XLOG_LEVEL_ERROR XLOG_LEVEL_4 /* Xorg.0.log and dlog */
+
+#define XLOG_OPTION_KLOG (1 << 8) /* LV:WARNING and /dev/kmsg */
+#define XLOG_OPTION_SECURE (1 << 12) /* LV:INFO. Disable when released */
+
+typedef enum
+{
+ MODE_NAME_ONLY,
+ MODE_WITH_STATUS
+} LOG_ENUM_MODE;
+
+int xDbgLogEnumModules (LOG_ENUM_MODE mode, char *buf, int *remain);
+int xDbgLogSetLevel (unsigned int module, int level);
+void xDbgLogEnableDlog (Bool enable);
+void* xDbgLog (unsigned int module, int logoption, const char *file, int line, const char *f, ...);
+
+// defines
+#define XLOG_DEBUG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_DEBUG, __FILE__, __LINE__, ##ARG)
+#define XLOG_TRACE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_TRACE, __FILE__, __LINE__, ##ARG)
+#define XLOG_INFO(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO, __FILE__, __LINE__, ##ARG)
+#define XLOG_WARNING(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_WARNING, __FILE__, __LINE__, ##ARG)
+#define XLOG_ERROR(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_ERROR, __FILE__, __LINE__, ##ARG)
+#define XLOG_KLOG(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_WARNING|XLOG_OPTION_KLOG, __FILE__, __LINE__, ##ARG)
+#define XLOG_SECURE(mod, ARG...) xDbgLog(mod, XLOG_LEVEL_INFO|XLOG_OPTION_SECURE, __FILE__, __LINE__, ##ARG)
+
+#define XDBG_DEBUG(mod, fmt, ARG...) XLOG_DEBUG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#define XDBG_TRACE(mod, fmt, ARG...) XLOG_TRACE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#define XDBG_INFO(mod, fmt, ARG...) XLOG_INFO(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#define XDBG_WARNING(mod, fmt, ARG...) XLOG_WARNING(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#define XDBG_ERROR(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#define XDBG_ERRNO(mod, fmt, ARG...) XLOG_ERROR(mod, "[%s](err=%s(%d)) "fmt, __FUNCTION__, strerror(errno), errno, ##ARG)
+#define XDBG_KLOG(mod, fmt, ARG...) XLOG_KLOG(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+
+#if TIZEN_ENGINEER_MODE
+#define XDBG_SECURE(mod, fmt, ARG...) XLOG_SECURE(mod, "[%s] "fmt, __FUNCTION__, ##ARG)
+#else
+#define XDBG_SECURE(mod, fmt, ARG...) do { } while(0)
+#endif
+
+#define XDBG_NEVER_GET_HERE(mod) XLOG_ERROR(mod, "[%s:%d] ** NEVER GET HERE **\n", __FUNCTION__,__LINE__)
+
+#define XDBG_WARNING_IF_FAIL(cond) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond);}}
+#define XDBG_RETURN_IF_FAIL(cond) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); return; }}
+#define XDBG_RETURN_VAL_IF_FAIL(cond, val) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); return val; }}
+#define XDBG_RETURN_VAL_IF_ERRNO(cond, val, errno) {if (!(cond)) { XDBG_ERRNO (MXDBG, "'%s' failed.\n", #cond); return val; }}
+#define XDBG_GOTO_IF_FAIL(cond, dst) {if (!(cond)) { XDBG_ERROR (MXDBG, "'%s' failed.\n", #cond); goto dst; }}
+#define XDBG_GOTO_IF_ERRNO(cond, dst, errno) {if (!(cond)) { XDBG_ERRNO (MXDBG, "'%s' failed.\n", #cond); goto dst; }}
+
+#define XDBG_REPLY(fmt, ARG...) \
+ do { \
+ if (reply && len && *len > 0) \
+ { \
+ int s = snprintf (reply, *len, fmt, ##ARG); \
+ reply += s; \
+ *len -= s; \
+ } \
+ } while (0)
+
+#endif /* __XDBG_LOG_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdarg.h>
+#include <dlog.h>
+
+#include "xdbg_log.h"
+
+void dLogWrapper (int loglevel, int module, const char * file, int line, const char * f, va_list args)
+{
+ const char * tag = "Xorg";
+
+ switch (loglevel)
+ {
+ case XLOG_LEVEL_DEBUG:
+ SLOG_VA (LOG_DEBUG, tag, f, args);
+ break;
+ case XLOG_LEVEL_TRACE:
+ SLOG_VA (LOG_DEBUG, tag, f, args);
+ break;
+ case XLOG_LEVEL_INFO:
+ SLOG_VA (LOG_INFO, tag, f, args);
+ break;
+ case XLOG_LEVEL_WARNING:
+ SLOG_VA (LOG_WARN, tag, f, args);
+ break;
+ case XLOG_LEVEL_ERROR:
+ SLOG_VA (LOG_ERROR, tag, f, args);
+ break;
+ default:
+ return;
+ }
+}
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include <list.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+typedef struct _xdbgVblankInfo
+{
+ int crtc_pipe;
+ unsigned int client_idx;
+ unsigned int draw_id;
+ int flag;
+ unsigned long time;
+ struct xorg_list link;
+} XDbgVblankInfo, *XDbgVblankInfoPtr;
+
+typedef struct _xdbgPageFlipInfo
+{
+ int crtc_pipe;
+ unsigned int client_idx;
+ unsigned int draw_id;
+ unsigned long time;
+ struct xorg_list link;
+} XDbgPageFlipInfo, *XDbgPageFlipInfoPtr;
+
+static int init_drmevent = 0;
+static struct xorg_list vblank_event_list;
+static struct xorg_list pageflip_event_list;
+
+API void
+xDbgLogDrmEventInit ()
+{
+ init_drmevent = 1;
+
+ xorg_list_init (&vblank_event_list);
+ xorg_list_init (&pageflip_event_list);
+}
+
+API void
+xDbgLogDrmEventDeInit ()
+{
+ /* TODO: delete all link(xorg_list_del) in the two list */
+}
+
+API void *
+xDbgLogDrmEventAddVblank ( int crtc_pipe, unsigned int client_idx, unsigned int draw_id, int flag)
+{
+ XDbgVblankInfoPtr pVblankInfo = NULL;
+
+ pVblankInfo = calloc (1, sizeof (XDbgVblankInfo));
+ if (!pVblankInfo)
+ return NULL;
+
+ pVblankInfo->crtc_pipe = crtc_pipe;
+ pVblankInfo->client_idx = client_idx;
+ pVblankInfo->draw_id = draw_id;
+ pVblankInfo->flag = flag;
+ pVblankInfo->time =GetTimeInMillis();
+
+ xorg_list_init(&pVblankInfo->link);
+ xorg_list_add(&pVblankInfo->link, &vblank_event_list);
+
+ return (void *)pVblankInfo;
+}
+
+API void
+xDbgLogDrmEventRemoveVblank (void *vblank_data)
+{
+ XDbgVblankInfoPtr pVblankInfo = (XDbgVblankInfoPtr) vblank_data;
+
+ xorg_list_del (&pVblankInfo->link);
+ free (pVblankInfo);
+ pVblankInfo = NULL;
+}
+
+API void *
+xDbgLogDrmEventAddPageflip (int crtc_pipe, unsigned int client_idx, unsigned int draw_id)
+{
+ XDbgPageFlipInfoPtr pPageFlipInfo = NULL;
+
+ pPageFlipInfo = calloc (1, sizeof (XDbgPageFlipInfo));
+ if (!pPageFlipInfo)
+ return NULL;
+
+ pPageFlipInfo->crtc_pipe = crtc_pipe;
+ pPageFlipInfo->client_idx = client_idx;
+ pPageFlipInfo->draw_id = draw_id;
+ pPageFlipInfo->time =GetTimeInMillis();
+
+ xorg_list_init(&pPageFlipInfo->link);
+ xorg_list_add(&pPageFlipInfo->link, &pageflip_event_list);
+
+ return (void *)pPageFlipInfo;
+}
+
+API void
+xDbgLogDrmEventRemovePageflip (void *pageflip_data)
+{
+ XDbgPageFlipInfoPtr pPageFlipInfo = (XDbgPageFlipInfoPtr) pageflip_data;
+
+ xorg_list_del (&pPageFlipInfo->link);
+ free (pPageFlipInfo);
+ pPageFlipInfo = NULL;
+}
+
+API void
+xDbgLogDrmEventPendingLists ( char *reply, int *len)
+{
+ XDbgVblankInfoPtr vblank_ref = NULL;
+ XDbgVblankInfoPtr vblank_next = NULL;
+ XDbgPageFlipInfoPtr flip_ref = NULL;
+ XDbgPageFlipInfoPtr flip_next = NULL;
+ Bool check_flip = FALSE;
+ Bool check_vblank = FALSE;
+
+ if (!init_drmevent)
+ {
+ XDBG_REPLY ("drmevent_pending is not supported.\n");
+ return;
+ }
+
+
+ XDBG_REPLY ("[vblank event pending]\n");
+ xorg_list_for_each_entry_safe (vblank_ref, vblank_next, &vblank_event_list, link)
+ {
+ check_vblank = TRUE;
+
+ if (vblank_ref->flag > -1)
+ {
+ XDBG_REPLY ("req_time client_id draw_id crtc_pipe vblank_type\n");
+ XDBG_REPLY ("[%10.3f] %5d 0x%x %5d %5d\n",
+ (double)vblank_ref->time/1000.0,
+ (unsigned int)vblank_ref->client_idx,
+ (unsigned int)vblank_ref->draw_id, vblank_ref->crtc_pipe, vblank_ref->flag);
+ }
+ else
+ {
+ XDBG_REPLY ("req_time vblank_type\n");
+ XDBG_REPLY ("[%10.3f] %d\n", (double)vblank_ref->time/1000.0, vblank_ref->flag);
+ }
+ }
+ if (!check_vblank)
+ XDBG_REPLY ("\t no pending events\n");
+
+ XDBG_REPLY ("[flip event pending]\n");
+ xorg_list_for_each_entry_safe (flip_ref, flip_next, &pageflip_event_list, link)
+ {
+ check_flip = TRUE;
+
+ XDBG_REPLY ("req_time client_id draw_id crtc_pipe\n");
+ XDBG_REPLY ("[%10.3f] %5d 0x%x %4d\n",
+ (double)flip_ref->time/1000.0, (unsigned int)flip_ref->client_idx,
+ (unsigned int)flip_ref->draw_id, flip_ref->crtc_pipe);
+ }
+ if (!check_flip)
+ XDBG_REPLY ("\t no pending events\n");
+}
+
+
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_LOG_DRMEVENT_H__
+#define __XDBG_LOG_DRMEVENT_H__
+
+void xDbgLogDrmEventInit (void);
+void xDbgLogDrmEventDeInit (void);
+
+void * xDbgLogDrmEventAddVblank ( int crtc_pipe, unsigned int client_idx, unsigned int draw_id, int flag);
+void xDbgLogDrmEventRemoveVblank (void *vblank_data);
+
+void *xDbgLogDrmEventAddPageflip (int crtc_pipe, unsigned int client_idx, unsigned int draw_id);
+void xDbgLogDrmEventRemovePageflip (void *pageflip_data);
+
+#endif /* __XDBG_LOG_DRMEVENT_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <xf86drm.h>
+#include "xorg-server.h"
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include "xdbg_log_fpsdebug.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define FPS_DEBUG_TIMER_INTERVAL 500
+
+static int init_fpsdebug = 0;
+static Bool g_on = FALSE;
+
+struct _fpsDebug
+{
+ int nPanCount;
+ CARD32 tStart, tCur, tLast;
+ OsTimerPtr fpsTimer;
+ int connector_type;
+ int cid;
+};
+
+static struct
+{
+ int type;
+ const char *name;
+} connector_list[] =
+{
+ { DRM_MODE_CONNECTOR_Unknown, "unknown" },
+ { DRM_MODE_CONNECTOR_VGA, "VGA" },
+ { DRM_MODE_CONNECTOR_DVII, "DVI-I" },
+ { DRM_MODE_CONNECTOR_DVID, "DVI-D" },
+ { DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
+ { DRM_MODE_CONNECTOR_Composite, "composite" },
+ { DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
+ { DRM_MODE_CONNECTOR_LVDS, "LVDS" },
+ { DRM_MODE_CONNECTOR_Component, "component" },
+ { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
+ { DRM_MODE_CONNECTOR_DisplayPort, "displayport" },
+ { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
+ { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
+ { DRM_MODE_CONNECTOR_TV, "TV" },
+ { DRM_MODE_CONNECTOR_eDP, "embedded displayport" },
+ { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
+};
+
+static int
+_get_connector_id (int connector_type)
+{
+ int num = sizeof (connector_list) / sizeof (connector_list[0]);
+ int i;
+ int cid = 0;
+
+ for (i = 0; i < num; i++)
+ {
+ if (connector_type == connector_list[i].type)
+ {
+ cid = i;
+ break;
+ }
+ }
+
+ return cid;
+}
+
+
+static int
+_fps_print_fps (FpsDebugPtr pFpsDebug, int isTimeOut)
+{
+ double sec;
+
+ sec = (double) (pFpsDebug->tLast - pFpsDebug->tStart) /1000.0;
+ ErrorF ("[Xorg..V][%s][FB:(%3dframes %3.1ffps)] Dur:%3.3f...%s\n",
+ connector_list[pFpsDebug->cid].name, pFpsDebug->nPanCount, pFpsDebug->nPanCount / sec,
+ sec, isTimeOut ? "[TimeOut]" : "");
+ pFpsDebug->nPanCount = 0;
+
+ return 0;
+}
+
+static CARD32
+_fps_frame_timeout (OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ _fps_print_fps (arg, TRUE);
+
+ return 0;
+}
+
+
+API FpsDebugPtr
+xDbgLogFpsDebugCreate ()
+{
+ FpsDebugPtr pFpsDebug = NULL;
+
+ init_fpsdebug = 1;
+
+ pFpsDebug = calloc (1, sizeof (struct _fpsDebug));
+ if (!pFpsDebug)
+ {
+ XDBG_ERROR (MXDBG, "fail to allocate the FpsDebug\n");
+ return NULL;
+ }
+
+ return pFpsDebug;
+}
+
+API void
+xDbgLogFpsDebugDestroy (FpsDebugPtr pFpsDebug)
+{
+ if (!pFpsDebug)
+ return;
+
+ free (pFpsDebug);
+ pFpsDebug = NULL;
+}
+
+API void
+xDbgLogFpsDebugCount (FpsDebugPtr pFpsDebug, int connector_type)
+{
+ /* if fpsdebug is off, do not count fps */
+ if (!g_on)
+ return;
+
+ if (connector_type != pFpsDebug->connector_type)
+ {
+ pFpsDebug->connector_type = connector_type;
+ pFpsDebug->cid = _get_connector_id (connector_type);
+ }
+
+ pFpsDebug->tCur = GetTimeInMillis();
+ if (pFpsDebug->nPanCount && pFpsDebug->tStart + FPS_DEBUG_TIMER_INTERVAL <= pFpsDebug->tCur)
+ _fps_print_fps (pFpsDebug, FALSE);
+
+ if (pFpsDebug->nPanCount == 0)
+ pFpsDebug->tStart = pFpsDebug->tLast;
+
+ pFpsDebug->nPanCount++;
+ pFpsDebug->tLast = pFpsDebug->tCur;
+ pFpsDebug->fpsTimer = TimerSet (pFpsDebug->fpsTimer
+ , 0, FPS_DEBUG_TIMER_INTERVAL
+ , _fps_frame_timeout, pFpsDebug);
+}
+
+API void
+xDbgLogFpsDebug (char *reply, int *len, int on)
+{
+ if (!init_fpsdebug)
+ {
+ XDBG_REPLY ("fps_debug is not supported.\n");
+ return;
+ }
+
+ if (g_on != on)
+ g_on = on;
+}
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_LOG_FPSDEBUG_H__
+#define __XDBG_LOG_FPSDEBUG_H__
+
+typedef struct _fpsDebug *FpsDebugPtr;
+
+FpsDebugPtr xDbgLogFpsDebugCreate (void);
+void xDbgLogFpsDebugDestroy (FpsDebugPtr pFpsDebug);
+void xDbgLogFpsDebugCount (FpsDebugPtr pFpsDebug, int connector_type);
+
+#endif /* __XDBG_LOG_FPSDEBUG_H__ */
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_LOG_INT_H__
+#define __XDBG_LOG_INT_H__
+
+void xDbgLogDrmEventPendingLists ( char *reply, int *len);
+void xDbgLogFpsDebug (char *reply, int *len, int on);
+void xDbgLogPList (char *reply, int *len);
+
+#endif /* __XDBG_LOG_INT_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <stdarg.h>
+#include <stdio.h>
+
+void kLogWrapper (int loglevel, int module, const char * file, int line, const char * f, va_list args)
+{
+ static FILE* fp = NULL;
+ static char init = 0;
+
+ if(!init && !fp)
+ {
+ fp = fopen("/dev/kmsg", "wt");
+ init = 1;
+ }
+
+ if(!fp) return;
+
+ vfprintf(fp, f, args);
+ fflush(fp);
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include "xorg-server.h"
+#include "xf86.h"
+#include <scrnintstr.h>
+#include <resource.h>
+#include <windowstr.h>
+#include <pixmap.h>
+#include <list.h>
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include "xdbg_log_plist.h"
+
+/* for debug message */
+#define MMEM XDBG_M('M','E','M',0)
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+/*=========================================================================*/
+/* trace the usage of the pixmaps in xserver */
+/*=========================================================================*/
+
+#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
+#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
+#define MAX_HISTORY 10
+
+typedef struct {
+ PixmapPtr pPixmap;
+ unsigned int size;
+ unsigned int refs;
+ char *hint;
+ XID refHistorys[MAX_HISTORY];
+ int numHistory;
+ struct xorg_list link;
+} XDbgPixmap;
+
+typedef struct {
+ PixmapPtr pPixmap;
+ struct xorg_list link;
+} XDbgRefPixmap;
+
+typedef struct {
+ DrawablePtr pDraw;
+ XDbgRefPixmap *pRefPixmap;
+ struct xorg_list link;
+ struct xorg_list refPixmaps;
+} XDbgDrawable;
+
+static int init_plist = 0;
+static struct xorg_list xdbgPixmaps;
+static struct xorg_list xdbgDrawables;
+static PixmapPtr pPixRoot = NULL;
+unsigned int total_size = 0;
+unsigned int peek_size = 0;
+
+const struct {
+ unsigned int hint;
+ char* str;
+} pixmap_hint[] = {
+ {CREATE_PIXMAP_USAGE_SCRATCH, "scratch"},
+ {CREATE_PIXMAP_USAGE_BACKING_PIXMAP, "backing_pixmap"},
+ {CREATE_PIXMAP_USAGE_GLYPH_PICTURE, "glyph_picture"},
+ {CREATE_PIXMAP_USAGE_SHARED, "shared"},
+ {CREATE_PIXMAP_USAGE_OVERLAY, "overlay"},
+ {CREATE_PIXMAP_USAGE_DRI2_FLIP_BACK, "dri2_flip_back"},
+ {CREATE_PIXMAP_USAGE_FB, "fb"},
+ {CREATE_PIXMAP_USAGE_SUB_FB, "sub_fb"},
+ {CREATE_PIXMAP_USAGE_DRI2_BACK, "dri2_back"},
+ /******END********/
+ {0, "normal"}
+};
+
+static char *
+_get_pixmap_hint_name (signed int usage_hint)
+{
+ int i = 0;
+
+ while (pixmap_hint[i].hint)
+ {
+ if (pixmap_hint[i].hint == usage_hint)
+ return pixmap_hint[i].str;
+ i++;
+ }
+ return NULL;
+}
+
+static XDbgPixmap *
+_findXDbgPixmap (PixmapPtr pPixmap)
+{
+ XDbgPixmap *cur = NULL, *tmp = NULL;
+
+ xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
+ {
+ if (cur->pPixmap == pPixmap)
+ return cur;
+ }
+
+ return NULL;
+}
+
+static XDbgDrawable *
+_findXDbgDrawable (DrawablePtr pDraw)
+{
+ XDbgDrawable *cur = NULL, *tmp = NULL;
+
+ xorg_list_for_each_entry_safe (cur, tmp, &xdbgDrawables, link)
+ {
+ if (cur->pDraw == pDraw)
+ return cur;
+ }
+
+ return NULL;
+}
+
+static XDbgRefPixmap*
+_findXDbgRefPixmap (XDbgDrawable* pXDbgDrawable, PixmapPtr pPixmap)
+{
+ XDbgRefPixmap *cur = NULL, *tmp = NULL;
+
+ xorg_list_for_each_entry_safe (cur, tmp, &pXDbgDrawable->refPixmaps, link)
+ {
+ if (cur->pPixmap == pPixmap)
+ return cur;
+ }
+
+ return NULL;
+}
+
+static void
+_addXDbgPixmap (PixmapPtr pPixmap)
+{
+ XDbgPixmap *cur = NULL;
+ unsigned int size;
+
+ cur = _findXDbgPixmap (pPixmap);
+ if (cur)
+ {
+ size = pPixmap->devKind * pPixmap->drawable.height;
+ if (size == cur->size)
+ return;
+
+ XDBG_TRACE (MMEM, " Change pixmap(%p) size(%d -> %d)\n",
+ cur->pPixmap, cur->size, size);
+
+ total_size -= cur->size;
+ cur->size = size;
+ cur->hint = _get_pixmap_hint_name (pPixmap->usage_hint);
+ }
+ else
+ {
+ cur = calloc (1, sizeof (XDbgPixmap));
+ if (!cur) return;
+
+ cur->pPixmap = pPixmap;
+ cur->size = pPixmap->devKind*pPixmap->drawable.height;
+ cur->hint = _get_pixmap_hint_name (pPixmap->usage_hint);
+ xorg_list_add (&cur->link, &xdbgPixmaps);
+ }
+
+ /* caculate the total_size of pixmaps */
+ total_size += cur->size;
+ if (total_size > peek_size)
+ peek_size = total_size;
+
+ if (pPixmap->usage_hint == CREATE_PIXMAP_USAGE_FB)
+ pPixRoot = pPixmap;
+
+ XDBG_TRACE (MMEM, "Add pixmap(%p) size:%d, hint:%s\n",
+ cur->pPixmap, cur->size, cur->hint);
+}
+
+static void
+_removeXDbgPixmap (PixmapPtr pPixmap)
+{
+ XDbgPixmap *cur = NULL;
+
+ cur = _findXDbgPixmap (pPixmap);
+ if (!cur)
+ {
+ XDBG_WARNING (MMEM, "Unknown pixmap XID:0x%x, pPix:%p\n",
+ (unsigned int)pPixmap->drawable.id, pPixmap);
+ return;
+ }
+
+ if (cur->refs > 0)
+ XDBG_TRACE (MMEM,"Pixmap(%p) refs:%d\n", cur->pPixmap, cur->refs);
+
+ /* caculate the total_size of pixmaps */
+ total_size -= cur->size;
+
+ XDBG_TRACE (MMEM, " Remove pixmap(%p) size:%d, hint:%s\n",
+ cur->pPixmap, cur->size, cur->hint);
+
+ xorg_list_del(&cur->link);
+ free(cur);
+}
+
+#if 0
+static void
+_dumpDraws (char *reply, int *len)
+{
+ XDbgDrawable *cur = NULL, *tmp = NULL;
+ XDbgRefPixmap *p = NULL, *ptmp = NULL;
+ XDbgPixmap *dp = NULL;
+
+ xorg_list_for_each_entry_safe (cur, tmp, &xdbgDrawables, link)
+ {
+ XDBG_REPLY ("[%d] XID:0x%x type:%s %dx%d+%d+%d\n",
+ CLIENT_ID(cur->pDraw->id),
+ (unsigned int)cur->pDraw->id,
+ (cur->pDraw->type == DRAWABLE_WINDOW ? "window":"pixmap"),
+ cur->pDraw->width, cur->pDraw->height, cur->pDraw->x, cur->pDraw->y);
+
+ xorg_list_for_each_entry_safe (p, ptmp, &cur->refPixmaps, link)
+ {
+ dp = _findXDbgPixmap (p->pPixmap);
+ if(!dp)
+ {
+ XDBG_REPLY ("\t***[REF_Pixmap] unknown pixmap(%p)\n", p->pPixmap);
+ continue;
+ }
+
+ XDBG_REPLY ("\t[REF_Pixmap] %p, hint:%s, size:%d\n",
+ dp->pPixmap, dp->hint, (unsigned int)dp->size/1024);
+ }
+ }
+}
+
+static void
+_dumpPixmaps (char *reply, int *len)
+{
+ XDbgPixmap *cur = NULL, *tmp = NULL;
+ int client_id;
+ int i;
+
+ if (pPixRoot)
+ {
+ cur = _findXDbgPixmap (pPixRoot);
+ XDBG_RETURN_IF_FAIL (cur != NULL);
+ XDBG_REPLY ("ROOT_Pixmap XID:0x%x pixmap(%p) hint:%s(0x%x) size:%d\n",
+ (unsigned int)cur->pPixmap->drawable.id, pPixRoot,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024);
+ }
+
+ xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
+ {
+ if (cur->pPixmap == pPixRoot)
+ continue;
+
+ if (cur->pPixmap->drawable.id || cur->refs == 0)
+ {
+ client_id = CLIENT_ID(cur->pPixmap->drawable.id);
+ if (cur->pPixmap->drawable.id)
+ {
+ XDBG_REPLY ("[%d] XID:0x%x %dx%d hint:%s(0x%x) size:%d refs:%d\n",
+ client_id, (unsigned int)cur->pPixmap->drawable.id,
+ cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024, cur->refs);
+ }
+ else
+ {
+ XDBG_REPLY ("[%d] Pixmap:%p %dx%d hint:%s(0x%x) size:%d refs:%d\n",
+ client_id, cur->pPixmap,
+ cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024, cur->refs);
+ }
+
+ if (cur->numHistory)
+ {
+ XDBG_REPLY ("\t[RefHistory] ");
+ for (i = 0; i < cur->numHistory; i++)
+ {
+ XDBG_REPLY ("0x%x ", (unsigned int)cur->refHistorys[i]);
+ }
+ XDBG_REPLY ("\n");
+ }
+ }
+ }
+}
+#endif
+
+CreatePixmapProcPtr fnCreatePixmap;
+DestroyPixmapProcPtr fnDestroyPixmap;
+ModifyPixmapHeaderProcPtr fnModifyPixmap;
+SetWindowPixmapProcPtr fnSetWindowPixmap;
+DestroyWindowProcPtr fnDestroyWindow;
+
+static PixmapPtr
+XDbgLogCreatePixmap (ScreenPtr pScreen, int width, int height,
+ int depth, unsigned usage_hint)
+{
+ PixmapPtr pPixmap = NULL;
+
+ pScreen->CreatePixmap = fnCreatePixmap;
+ pPixmap = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
+ pScreen->CreatePixmap = XDbgLogCreatePixmap;
+
+ if(pPixmap)
+ _addXDbgPixmap (pPixmap);
+
+ return pPixmap;
+}
+
+static Bool
+XDbgLogModifyPixmapHeader (PixmapPtr pPixmap, int width, int height,
+ int depth, int bitsPerPixel, int devKind, pointer pPixData)
+{
+ Bool ret;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ pScreen->ModifyPixmapHeader = fnModifyPixmap;
+ ret = pScreen->ModifyPixmapHeader (pPixmap, width, height,
+ depth, bitsPerPixel, devKind, pPixData);
+ pScreen->ModifyPixmapHeader = XDbgLogModifyPixmapHeader;
+
+ _addXDbgPixmap (pPixmap);
+
+ return ret;
+}
+
+static Bool
+XDbgLogDestroyPixmap (PixmapPtr pPixmap)
+{
+ Bool ret;
+
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+
+ if (pPixmap->refcnt == 1)
+ _removeXDbgPixmap (pPixmap);
+
+ pScreen->DestroyPixmap = fnDestroyPixmap;
+ ret = pScreen->DestroyPixmap(pPixmap);
+ pScreen->DestroyPixmap = XDbgLogDestroyPixmap;
+
+ return ret;
+}
+
+static void
+XDbgLogSetWindowPixmap (WindowPtr pWin, PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = (ScreenPtr) pWin->drawable.pScreen;
+ WindowPtr pParent = pWin->parent;
+ XDbgDrawable *d = NULL;
+ XDbgPixmap *p = NULL;
+ XDbgRefPixmap *p_ref = NULL;
+
+ pScreen->SetWindowPixmap = fnSetWindowPixmap;
+ pScreen->SetWindowPixmap (pWin, pPixmap);
+ pScreen->SetWindowPixmap = XDbgLogSetWindowPixmap;
+
+ if (pPixmap != pScreen->GetWindowPixmap(pParent))
+ {
+ //Add to window list
+ p = _findXDbgPixmap (pPixmap);
+ if (!p)
+ {
+ XDBG_WARNING (MMEM, "Unknown pixmap(%p) hint:%s\n",
+ pPixmap, _get_pixmap_hint_name(pPixmap->usage_hint));
+ return;
+ }
+
+ d = _findXDbgDrawable (&pWin->drawable);
+ if (!d)
+ {
+ d = calloc (1, sizeof(XDbgDrawable));
+ if (!d)
+ {
+ XDBG_WARNING (MMEM, "%s:%d: Failed to allocate memory\n",
+ __FUNCTION__, __LINE__);
+ return;
+ }
+ d->pDraw = &pWin->drawable;
+ xorg_list_init (&d->refPixmaps);
+ xorg_list_add (&d->link, &xdbgDrawables);
+ XDBG_TRACE (MMEM, " Add window(0x%x)\n", (unsigned int)pWin->drawable.id);
+ }
+
+ if (d->pRefPixmap)
+ {
+ XDBG_TRACE (MMEM, " Unset WinPixmap win(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pWin->drawable.id, p->pPixmap, p->hint);
+ xorg_list_del (&d->pRefPixmap->link);
+ free (d->pRefPixmap);
+ d->pRefPixmap = NULL;
+ }
+
+ p_ref = calloc (1, sizeof(XDbgRefPixmap));
+ if (!p_ref)
+ {
+ XDBG_WARNING (MMEM, "%s:%d: Failed to allocate memory to pixmap\n",
+ __FUNCTION__, __LINE__);
+ return;
+ }
+
+ p_ref->pPixmap = pPixmap;
+ xorg_list_init (&p_ref->link);
+ xorg_list_add (&p_ref->link, &d->refPixmaps);
+ d->pRefPixmap = p_ref;
+
+ p->refs++;
+ p->refHistorys[p->numHistory++] = pWin->drawable.id;
+
+ XDBG_TRACE (MMEM, " Set WinPixmap win(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pWin->drawable.id, p->pPixmap, p->hint);
+ }
+ else
+ {
+ //find window
+ d = _findXDbgDrawable (&pWin->drawable);
+
+ //remove window
+ if (d && d->pRefPixmap)
+ {
+ p = _findXDbgPixmap (d->pRefPixmap->pPixmap);
+ if (p)
+ {
+ if (p->refs > 0)
+ p->refs--;
+ else
+ XDBG_WARNING (MMEM, "pixmap(%p), refs(%d)\n",
+ __FUNCTION__, __LINE__, p->pPixmap, p->refs);
+ }
+
+ XDBG_TRACE (MMEM,"Unset WinPixmap win(0x%x): pixmap(%p) to NULL\n",
+ (unsigned int)pWin->drawable.id, d->pRefPixmap->pPixmap);
+
+ p_ref = _findXDbgRefPixmap (d, d->pRefPixmap->pPixmap);
+ if(p_ref)
+ {
+ xorg_list_del (&d->pRefPixmap->link);
+ free (d->pRefPixmap);
+ }
+ else
+ XDBG_WARNING (MMEM, "Unknown refpixmap : WinPixmap win(0x%x) pixmap(%p) \n",
+ (unsigned int)pWin->drawable.id, d->pRefPixmap->pPixmap);
+
+ d->pRefPixmap = NULL;
+
+ if (xorg_list_is_empty (&d->refPixmaps))
+ {
+ xorg_list_del (&d->link);
+ free(d);
+ }
+ }
+ }
+}
+
+static Bool
+XDbgLogDestroyWindow (WindowPtr pWindow)
+{
+ Bool ret;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ XDbgDrawable *d = NULL;
+ XDbgPixmap *p = NULL;
+ XDbgRefPixmap *pos = NULL, *tmp = NULL;
+
+ pScreen->DestroyWindow = fnDestroyWindow;
+ ret = pScreen->DestroyWindow (pWindow);
+ pScreen->DestroyWindow = XDbgLogDestroyWindow;
+
+ d = _findXDbgDrawable (&pWindow->drawable);
+ if (d)
+ {
+ XDBG_TRACE (MMEM, "Remove drawable(0x%x)\n",
+ (unsigned int)pWindow->drawable.id);
+
+ xorg_list_for_each_entry_safe (pos, tmp, &d->refPixmaps, link)
+ {
+ p = _findXDbgPixmap (pos->pPixmap);
+ if(p)
+ p->refs--;
+
+ XDBG_TRACE (MMEM, "Remove ref_pixmap(%p), dbgPixmap(%p)\n",
+ pos->pPixmap, p);
+
+ xorg_list_del (&pos->link);
+ free (pos);
+ }
+
+ xorg_list_del (&d->link);
+ free (d);
+ }
+
+ return ret;
+}
+
+API void
+xDbgLogPListInit (ScreenPtr pScreen)
+{
+ init_plist = 1;
+
+ xorg_list_init (&xdbgPixmaps);
+ xorg_list_init (&xdbgDrawables);
+
+ fnSetWindowPixmap = pScreen->SetWindowPixmap;
+ fnDestroyWindow = pScreen->DestroyWindow;
+ fnCreatePixmap = pScreen->CreatePixmap;
+ fnModifyPixmap = pScreen->ModifyPixmapHeader;
+ fnDestroyPixmap = pScreen->DestroyPixmap;
+
+ pScreen->CreatePixmap = XDbgLogCreatePixmap;
+ pScreen->DestroyPixmap = XDbgLogDestroyPixmap;
+ pScreen->ModifyPixmapHeader = XDbgLogModifyPixmapHeader;
+ pScreen->SetWindowPixmap = XDbgLogSetWindowPixmap;
+ pScreen->DestroyWindow = XDbgLogDestroyWindow;
+}
+
+API void
+xDbgLogPListDeinit (ScreenPtr pScreen)
+{}
+
+
+API void
+xDbgLogPListDrawAddRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap)
+{
+ XDbgDrawable *d = NULL;
+ XDbgPixmap *p = NULL;
+ XDbgRefPixmap *p_ref = NULL;
+
+ XDBG_RETURN_IF_FAIL (pDraw != NULL);
+ XDBG_RETURN_IF_FAIL (pRefPixmap != NULL);
+
+ d = _findXDbgDrawable (pDraw);
+ p = _findXDbgPixmap (pRefPixmap);
+ if(!p)
+ {
+ XDBG_WARNING (MMEM, "%s:%d : Unknown pixmap XID:0x%x, pPix:%p\n",
+ __FUNCTION__, __LINE__,
+ (unsigned int)pRefPixmap->drawable.id, pRefPixmap);
+ return;
+ }
+
+ if (!d)
+ {
+ d = calloc (1, sizeof(XDbgDrawable));
+ if (!d)
+ {
+ XDBG_WARNING (MMEM, "%s:%d: Failed to allocate memory\n",
+ __FUNCTION__, __LINE__);
+ return;
+ }
+ d->pDraw = pDraw;
+ xorg_list_init (&d->refPixmaps);
+ xorg_list_add (&d->link, &xdbgDrawables);
+
+ XDBG_TRACE (MMEM, " Add window(0x%x)\n", (unsigned int)pDraw->id);
+ }
+
+ p_ref =_findXDbgRefPixmap (d, pRefPixmap);
+ if(p_ref)
+ return;
+
+ p_ref = calloc (1, sizeof(XDbgRefPixmap));
+ if (!p_ref)
+ {
+ XDBG_WARNING (MMEM, "%s:%d: Failed to allocate memory\n",
+ __FUNCTION__, __LINE__);
+ return;
+ }
+ p_ref->pPixmap = pRefPixmap;
+ xorg_list_init (&p_ref->link);
+ xorg_list_add (&p_ref->link, &d->refPixmaps);
+
+ p->refs++;
+ if (p->numHistory < (MAX_HISTORY-1))
+ p->refHistorys[p->numHistory++] = pDraw->id;
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ XDBG_TRACE (MMEM, " Add RefPixmap win(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pDraw->id, p->pPixmap, p->hint);
+ else
+ XDBG_TRACE (MMEM, " Add RefPixmap pix(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pDraw->id, p->pPixmap, p->hint);
+}
+
+API void
+xDbgLogPListDrawRemoveRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap)
+{
+ XDbgDrawable *d = NULL;
+ XDbgRefPixmap *p_ref = NULL;
+ XDbgPixmap *p = NULL;
+
+ p = _findXDbgPixmap (pRefPixmap);
+ if (pDraw == NULL)
+ {
+ if (p && p->refs > 0)
+ {
+ XDBG_ERROR (MMEM, "Error:%s:%d null draw pixmap(%p)\n",
+ __FUNCTION__, __LINE__, pRefPixmap);
+ }
+ return;
+ }
+
+ d = _findXDbgDrawable (pDraw);
+ if (!d)
+ {
+ XDBG_WARNING (MMEM, "%s:%d : Unknown drawable XID:0x%x, pPix:%p\n",
+ __FUNCTION__, __LINE__, (unsigned int)pDraw->id, pRefPixmap);
+ return;
+ }
+
+ p_ref = _findXDbgRefPixmap (d, pRefPixmap);
+ if(!p_ref)
+ {
+ XDBG_WARNING (MMEM, "%s:%d : Unknown refpixmap XID:0x%x, pPix:%p\n",
+ __FUNCTION__, __LINE__, (unsigned int)pDraw->id, pRefPixmap);
+ return;
+ }
+
+ xorg_list_del (&p_ref->link);
+ free (p_ref);
+ if (p)
+ p->refs--;
+
+ if (xorg_list_is_empty (&d->refPixmaps))
+ {
+ xorg_list_del(&d->link);
+ free(d);
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ XDBG_TRACE (MMEM, " Remove RefPixmap win(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pDraw->id, pRefPixmap,
+ _get_pixmap_hint_name(pRefPixmap->usage_hint));
+ else
+ XDBG_TRACE (MMEM, " Remove RefPixmap pix(0x%x), pixmap(%p) hint:%s\n",
+ (unsigned int)pDraw->id, pRefPixmap,
+ _get_pixmap_hint_name(pRefPixmap->usage_hint));
+}
+
+
+API void
+xDbgLogPList (char *reply, int *len)
+{
+ if (!init_plist)
+ {
+ XDBG_REPLY ("plist is not supported.\n");
+ return;
+ }
+
+ XDBG_REPLY ("\n\n====================================\n");
+ XDBG_REPLY (" Total:%d, Peek:%d\n", (unsigned int)total_size/1024, (unsigned int)peek_size/1024);
+ XDBG_REPLY ( "====================================\n");
+
+ XDBG_REPLY ("== WINDOWS ==\n");
+ XDbgDrawable *dd = NULL, *ddtmp = NULL;
+ XDbgRefPixmap *rp = NULL, *rptmp = NULL;
+ XDbgPixmap *dp = NULL;
+
+ xorg_list_for_each_entry_safe (dd, ddtmp, &xdbgDrawables, link)
+ {
+ XDBG_REPLY ("[%d] XID:0x%x type:%s %dx%d+%d+%d\n",
+ CLIENT_ID(dd->pDraw->id),
+ (unsigned int)dd->pDraw->id,
+ (dd->pDraw->type == DRAWABLE_WINDOW ? "window":"pixmap"),
+ dd->pDraw->width, dd->pDraw->height, dd->pDraw->x, dd->pDraw->y);
+
+ xorg_list_for_each_entry_safe (rp, rptmp, &dd->refPixmaps, link)
+ {
+ dp = _findXDbgPixmap (rp->pPixmap);
+ if(!dp)
+ {
+ XDBG_REPLY ("\t***[REF_Pixmap] unknown pixmap(%p)\n", rp->pPixmap);
+ continue;
+ }
+
+ XDBG_REPLY ("\t[REF_Pixmap] %p, hint:%s, size:%d\n",
+ dp->pPixmap, dp->hint, (unsigned int)dp->size/1024);
+ }
+ }
+ XDBG_REPLY ("\n");
+
+
+ XDBG_REPLY ( "== PIXMAPS ==\n");
+ XDbgPixmap *cur = NULL, *tmp = NULL;
+ int client_id;
+ int i;
+
+ if (pPixRoot)
+ {
+ cur = _findXDbgPixmap (pPixRoot);
+ XDBG_RETURN_IF_FAIL (cur != NULL);
+ XDBG_REPLY ("ROOT_Pixmap XID:0x%x pixmap(%p) hint:%s(0x%x) size:%d\n",
+ (unsigned int)cur->pPixmap->drawable.id, pPixRoot,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024);
+ }
+
+ xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
+ {
+ if (cur->pPixmap == pPixRoot)
+ continue;
+
+ if (cur->pPixmap->drawable.id || cur->refs == 0)
+ {
+ client_id = CLIENT_ID(cur->pPixmap->drawable.id);
+ if (cur->pPixmap->drawable.id)
+ {
+ XDBG_REPLY ("[%d] XID:0x%x %dx%d hint:%s(0x%x) size:%d refs:%d\n",
+ client_id, (unsigned int)cur->pPixmap->drawable.id,
+ cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024, cur->refs);
+ }
+ else
+ {
+ XDBG_REPLY ("[%d] Pixmap:%p %dx%d hint:%s(0x%x) size:%d refs:%d\n",
+ client_id, cur->pPixmap,
+ cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
+ cur->hint, cur->pPixmap->usage_hint,
+ (unsigned int)cur->size/1024, cur->refs);
+ }
+
+ if (cur->numHistory)
+ {
+ XDBG_REPLY ("\t[RefHistory] ");
+ for (i = 0; i < cur->numHistory; i++)
+ {
+ XDBG_REPLY ("0x%x ", (unsigned int)cur->refHistorys[i]);
+ }
+ XDBG_REPLY ("\n");
+ }
+ }
+ }
+ XDBG_REPLY ("\n");
+}
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_LOG_PLIST_H__
+#define __XDBG_LOG_PLIST_H__
+
+#include <pixmap.h>
+
+/* pixmap usage_hint stands for back-flipbuffer pixmap */
+#ifndef CREATE_PIXMAP_USAGE_DRI2_FLIP_BACK
+#define CREATE_PIXMAP_USAGE_DRI2_FLIP_BACK 0x100
+#endif
+
+/* pixmap usage_hint stands for framebuffer pixmap */
+#ifndef CREATE_PIXMAP_USAGE_FB
+#define CREATE_PIXMAP_USAGE_FB 0x101
+#endif
+
+/* pixmap usage_hint stands for sub-framebuffer pixmap */
+#ifndef CREATE_PIXMAP_USAGE_SUB_FB
+#define CREATE_PIXMAP_USAGE_SUB_FB 0x202
+#endif
+
+/* pixmap usage_hint stands for backbuffer pixmap */
+#ifndef CREATE_PIXMAP_USAGE_DRI2_BACK
+#define CREATE_PIXMAP_USAGE_DRI2_BACK 0x404
+#endif
+
+void xDbgLogPListInit (ScreenPtr pScreen);
+void xDbgLogPListDeInit (ScreenPtr pScreen);
+
+void xDbgLogPListDrawAddRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap);
+void xDbgLogPListDrawRemoveRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap);
+
+#endif /* __XDBG_LOG_PLIST_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#if defined(XDBG_CLIENT)
+#error "This header is not for client."
+#endif
+
+#ifndef __XDBG_LOG_SECURE_H__
+#define __XDBG_LOG_SECURE_H__
+
+#define TIZEN_ENGINEER_MODE @TIZEN_ENGINEER_MODE@
+
+#endif /* __XDBG_LOG_SECURE_H__ */
--- /dev/null
+# Copyright 2013 Samsung Electronics co., Ltd. All Rights Reserved.
+#
+# Contact: Boram Park <boram1288.park@samsung.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+libxdbg_la_LTLIBRARIES = libxdbg.la
+libxdbg_ladir = @moduledir@
+libxdbg_la_LIBADD = @XDBG_LIBS@ ../common/libcommon-server.la ../lib/libxdbg-lib.la
+libxdbg_la_LDFLAGS = -module -avoid-version ${LDFLAGS}
+libxdbg_la_CFLAGS = \
+ ${CFLAGS} \
+ @XDBG_CFLAGS@ \
+ -I$(top_srcdir)/common \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/module
+
+libxdbg_la_SOURCES = \
+ xdbg_module.c \
+ xdbg_module_main.c \
+ xdbg_module_options.c \
+ xdbg_module_command.c \
+ xdbg_module_clist.c \
+ xdbg_module_plist.c \
+ xdbg_module_fpsdebug.c \
+ xdbg_module_evlog.c \
+ xdbg_module_drmevent.c
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <xf86.h>
+
+#include "xdbg_module_main.h"
+#include "xdbg_module_options.h"
+
+MODULESETUPPROTO (xDbgModuleSetup);
+MODULETEARDOWNPROTO (xDbgModuleTearDown);
+
+static XF86ModuleVersionInfo ModuleVersRec =
+{
+ MODULE_NAME,
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ PACKAGE_VERSION_MAJOR,
+ PACKAGE_VERSION_MINOR,
+ PACKAGE_VERSION_PATCHLEVEL,
+ ABI_CLASS_NONE,
+ SET_ABI_VERSION (0,1),
+ NULL,
+ {0,0,0,0}
+};
+
+_X_EXPORT XF86ModuleData xdbgModuleData =
+{
+ &ModuleVersRec,
+ xDbgModuleSetup,
+ xDbgModuleTearDown
+};
+
+static XDbgModule module_xdbg;
+
+static void
+_xDbgModuleBlockHandler (pointer data, OSTimePtr pTimeout, pointer pRead)
+{
+ /* _xDbgModuleBlockHandler called only at the first. */
+ RemoveBlockAndWakeupHandlers(_xDbgModuleBlockHandler,
+ (WakeupHandlerProcPtr)NoopDDA,
+ NULL);
+
+ /* main */
+ xDbgModuleMain (&module_xdbg);
+}
+
+pointer
+xDbgModuleSetup (pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ XF86OptionPtr pOpt = (XF86OptionPtr)opts;
+ static Bool setupDone = FALSE;
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+
+ /* Parse Options */
+ xDbgModuleParseOptions (&module_xdbg, pOpt);
+
+ /* Register block handler */
+ RegisterBlockAndWakeupHandlers (_xDbgModuleBlockHandler,
+ (WakeupHandlerProcPtr)NoopDDA,
+ NULL);
+ return (pointer) 1;
+ }
+ else
+ {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+
+ return NULL;
+ }
+}
+
+void
+xDbgModuleTearDown (pointer module)
+{
+ xDbgModuleMainExit (module);
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_H__
+#define __XDBG_MODULE_H__
+
+#include <xf86.h>
+#include <X11/Xdefs.h> /* for Bool */
+#include "xdbg_types.h"
+
+typedef struct _ModuleClientInfo
+{
+ int index;
+ int pid;
+ int gid;
+ int uid;
+ int conn_fd;
+ char command[PATH_MAX+1];
+} ModuleClientInfo;
+
+typedef struct _XDbgModule
+{
+ Bool dlog;
+ char *log_path;
+ char *evlog_path;
+ char *evlog_rule_path;
+ char *cwd;
+} XDbgModule;
+
+extern DevPrivateKeyRec debug_client_key;
+#define DebugClientKey (&debug_client_key)
+#define GetClientInfo(pClient) ((ModuleClientInfo*)dixLookupPrivate(&(pClient)->devPrivates, DebugClientKey))
+
+#endif /* __XDBG_MODULE_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "xdbg.h"
+#include "xdbg_types.h"
+#include "xdbg_module.h"
+
+
+void
+xDbgModuleCList (XDbgModule *pMod, char *reply, int *len)
+{
+ int i;
+
+ XDBG_REPLY ("%6s %6s %s %s\n", "INDEX", "PID", "BLOCKED", "NAME");
+
+ for (i = 1; i < currentMaxClients && (0 < *len); i++)
+ {
+ ClientPtr pClient = clients[i];
+ ModuleClientInfo *info;
+
+ if (!pClient)
+ continue;
+
+ info = GetClientInfo (pClient);
+ if (!info)
+ continue;
+
+ XDBG_REPLY ("%6d %6d %4d %9s\n",
+ info->index, info->pid, pClient->ignoreCount, info->command);
+ }
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_CLIST_H__
+#define __XDBG_MODULE_CLIST_H__
+
+#include "xdbg_module.h"
+
+void xDbgModuleCList (XDbgModule *pMod, char *reply, int *len);
+
+#endif /* __XDBG_MODULE_CLIST_H__ */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <windowstr.h>
+#include <xacestr.h>
+#include <xdbg.h>
+#include "xdbg_types.h"
+#include <xf86Priv.h>
+#include "xdbg_dump_module.h"
+#include "xdbg_module.h"
+#include "xdbg_module_clist.h"
+#include "xdbg_module_plist.h"
+#include "xdbg_module_evlog.h"
+#include "xdbg_module_drmevent.h"
+#include "xdbg_module_fpsdebug.h"
+#include "xdbg_module_command.h"
+
+static void
+_CommandDLog (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ int on;
+
+ if (argc != 3)
+ {
+ XDBG_REPLY ("DLog level: %d\n", xDbgGetLogEnableDlog() ? 1 : 0);
+ return;
+ }
+
+ on = atoi (argv[2]);
+
+ xDbgLogEnableDlog (on);
+
+ XDBG_REPLY ("Success\n");
+}
+
+static Bool
+_CommandSetLogFile (int pid, char *path, char *reply, int *len, XDbgModule *pMod)
+{
+ static int old_stderr = -1;
+ char fd_name[XDBG_PATH_MAX];
+ int log_fd = -1;
+ FILE *log_fl;
+
+ if (!path || strlen (path) <= 0)
+ {
+ XDBG_REPLY ("failed: logpath is invalid\n");
+ return FALSE;
+ }
+
+ if (old_stderr == -1)
+ old_stderr = dup (STDERR_FILENO);
+
+ if (!strcmp (path, "console"))
+ snprintf (fd_name, XDBG_PATH_MAX, "/proc/%d/fd/1", pid);
+ else
+ {
+ if (path[0] == '/')
+ snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
+ else
+ {
+ if (pMod->cwd)
+ snprintf (fd_name, XDBG_PATH_MAX, "%s/%s", pMod->cwd, path);
+ else
+ snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
+ }
+ }
+
+ log_fl = fopen (fd_name, "a");
+ if (!log_fl)
+ {
+ XDBG_REPLY ("failed: open file(%s)\n", fd_name);
+ return FALSE;
+ }
+
+ fflush (stderr);
+ close (STDERR_FILENO);
+
+ setvbuf (log_fl, NULL, _IOLBF, 512);
+ log_fd = fileno (log_fl);
+
+ dup2 (log_fd, STDERR_FILENO);
+ fclose (log_fl);
+
+ if (pMod->log_path)
+ free (pMod->log_path);
+
+ pMod->log_path = strdup (fd_name);
+ XDBG_RETURN_VAL_IF_FAIL (pMod->log_path != NULL, FALSE);
+
+ XDBG_REPLY ("log path: %s\n", pMod->log_path);
+
+ return TRUE;
+}
+
+
+static void
+_CommandLogPath (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc != 3)
+ {
+ XDBG_REPLY ("log path: %s\n", (pMod->log_path)?pMod->log_path:"stderr");
+ return;
+ }
+
+ _CommandSetLogFile (pid, argv[2], reply, len, pMod);
+}
+
+static void
+_CommandSetLogLevel (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ Bool ret;
+ char *module_name;
+ int level;
+
+ if (argc < 4)
+ {
+ xDbgLogEnumModules (MODE_WITH_STATUS, reply, len);
+ return;
+ }
+
+ module_name = argv[2];
+ level = atoi (argv[3]);
+
+ if (level < 0 || level >= 5)
+ {
+ XDBG_REPLY ("Error : Not valid log level %d.\n", level);
+ return;
+ }
+
+ ret = xDbgLogSetLevel (xDbgLogGetModule (module_name), level);
+
+ if (ret)
+ XDBG_REPLY ("Log level for module %s was successfully set to %d\n",
+ module_name, level);
+ else
+ XDBG_REPLY ("Error : An error was occured during log level setting\n");
+}
+
+static void
+_CommandClientList (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc != 2)
+ {
+ XDBG_REPLY ("Error : too few arguments\n");
+ return;
+ }
+
+ xDbgModuleCList (pMod, reply, len);
+}
+
+static void
+_CommandPixmapList (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc != 2)
+ {
+ XDBG_REPLY ("Error : too few arguments\n");
+ return;
+ }
+
+ xDbgModulePList (pMod, reply, len);
+}
+
+static void
+_CommandEvlog (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ int on;
+ extern Bool xev_trace_on;
+
+ if (argc != 3)
+ {
+ XDBG_REPLY ("Evlog level: %d\n", xev_trace_on ? 1 : 0);
+ return;
+ }
+
+ on = atoi (argv[2]);
+
+ xDbgModuleEvlogPrintEvents (pMod, on, argv[0], reply, len);
+
+ XDBG_REPLY ("Success\n");
+}
+
+static void
+_CommandEvlogDetail (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ int level;
+ extern int xev_trace_detail_level;
+
+ if (argc != 3)
+ {
+ XDBG_REPLY ("Detail Level: %d\n", xev_trace_detail_level);
+ return;
+ }
+
+ level = atoi(argv[2]);
+
+ xDbgModuleEvlogDetail (pMod, level, reply, len);
+ XDBG_REPLY ("Success\n");
+}
+
+static void
+_CommandSetEvlogRule (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc < 2)
+ {
+ XDBG_REPLY ("Error : invalid number of arguments.\n");
+ return;
+ }
+
+ if (argc > 2 && argv[2] && !strcmp (argv[2], "file"))
+ {
+ if (argc < 4 || !argv[3])
+ {
+ XDBG_REPLY ("Error : no evlog rule file.\n");
+ return;
+ }
+
+ if (pMod->evlog_rule_path)
+ free (pMod->evlog_rule_path);
+
+ pMod->evlog_rule_path = strdup (argv[3]);
+ }
+
+ xDbgModuleEvlogInfoSetRule (pMod, argc - 2, (const char**)&(argv[2]), reply, len);
+}
+
+static void
+_CommandSetEvlogPath (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc != 3)
+ {
+ XDBG_REPLY ("evlog path: %s\n", (pMod->evlog_path)?pMod->evlog_path:"none");
+ return;
+ }
+
+ if (!argv[2] || strlen (argv[2]) <= 0)
+ {
+ XDBG_REPLY ("invalid option\n");
+ return;
+ }
+
+ if (pMod->evlog_path)
+ {
+ free (pMod->evlog_path);
+ pMod->evlog_path=NULL;
+ }
+
+ if (!xDbgModuleEvlogSetEvlogPath (pMod, pid, argv[2], reply, len))
+ {
+ XDBG_REPLY ("Error: evlog path(%s)\n", argv[2]);
+ return;
+ }
+
+ pMod->evlog_path = strdup (argv[2]);
+ if (!pMod->evlog_path) {
+ XDBG_REPLY ("Failed to allocate memory to evlog_path\n");
+ return;
+ }
+
+ if (!strcmp (pMod->evlog_path, "console"))
+ XDBG_REPLY ("/proc/%d/fd/1", pid);
+ else if (pMod->evlog_path[0] == '/')
+ XDBG_REPLY ("evlog path: %s\n", pMod->evlog_path);
+ else
+ XDBG_REPLY ("evlog path: %s/%s\n", pMod->cwd, pMod->evlog_path);
+}
+
+static void
+_CommandDrmEventPending (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ if (argc != 2)
+ {
+ XDBG_REPLY ("Error : too few arguments\n");
+ return;
+ }
+
+ xDbgModuleDrmEventPending (pMod, reply, len);
+}
+
+static void
+_CommandFpsDebug (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ int on;
+
+ if (argc != 3)
+ {
+ XDBG_REPLY ("Error : too few arguments\n");
+ return;
+ }
+
+ on = atoi (argv[2]);
+
+ xDbgModuleFpsDebug (pMod, on, reply, len);
+
+ XDBG_REPLY ("Success\n");
+}
+
+static char *
+_printDumpOption (char *reply, int *len)
+{
+ if (xDbgDumpGetType ())
+ XDBG_REPLY ("type:%s ", xDbgDumpGetType ());
+ if (xDbgDumpGetCount ())
+ XDBG_REPLY ("count:%s ", xDbgDumpGetCount ());
+ if (xDbgDumpGetFile ())
+ XDBG_REPLY ("file:%s ", xDbgDumpGetFile ());
+ if (xDbgDumpGetCrop ())
+ XDBG_REPLY ("crop:%s ", xDbgDumpGetCrop ());
+
+ return reply;
+}
+
+static void
+_CommandDump (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod)
+{
+ int i;
+ char *c;
+
+ if (argc < 3)
+ {
+ reply = _printDumpOption (reply, len);
+ XDBG_REPLY("\n");
+ return;
+ }
+
+ for (i = 0; i < argc; i++)
+ {
+ char *c = argv[i];
+ if (*c != '-')
+ continue;
+
+ if (!strcmp (c, "-type"))
+ {
+ c = argv[++i];
+ if (!xDbgDumpSetType (c))
+ {
+ XDBG_REPLY ("fail: set '%s' (already running)\n", c);
+ return;
+ }
+ }
+ else if (!strcmp (c, "-count"))
+ {
+ c = argv[++i];
+ if (!xDbgDumpSetCount (c))
+ {
+ XDBG_REPLY ("fail: set '%s' (already running)\n", c);
+ return;
+ }
+ }
+ else if (!strcmp (c, "-file"))
+ {
+ c = argv[++i];
+ if (!xDbgDumpSetFile (c))
+ {
+ XDBG_REPLY ("fail: set '%s' (already running)\n", c);
+ return;
+ }
+ }
+ else if (!strcmp (c, "-crop"))
+ {
+ c = argv[++i];
+ if (!xDbgDumpSetCrop (c))
+ {
+ XDBG_REPLY ("fail: set '%s' (already running)\n", c);
+ return;
+ }
+ }
+ }
+
+ c = argv[2];
+ if (!strcmp (c, "on"))
+ {
+ xDbgDumpPrepare ();
+ XDBG_REPLY ("'%s'", c);
+ reply = _printDumpOption (reply, len);
+ }
+ else if (!strcmp (c, "off"))
+ {
+ xDbgDumpSave ();
+ xDbgDumpClear ();
+ XDBG_REPLY ("'%s' ", c);
+ }
+ else if (!strcmp (c, "clear"))
+ {
+ xDbgDumpClear ();
+ XDBG_REPLY ("'%s' ", c);
+ }
+ else if (*c != '-')
+ {
+ XDBG_REPLY ("unknown option '%s'\n", c);
+ return;
+ }
+
+ XDBG_REPLY ("success\n");
+}
+
+static struct
+{
+ const char *Cmd;
+ const char *Description;
+ const char *Options;
+
+ int (*DynamicUsage) (int, char*, int *);
+ const char *DetailedUsage;
+
+ void (*func) (int pid, int argc, char **argv, char *reply, int *len, XDbgModule *pMod);
+} command_proc[] =
+{
+ {
+ "dlog", "to enable dlog", "[0-1]",
+ NULL, "[OFF:0/ON:1]",
+ _CommandDLog
+ },
+
+ {
+ "log_path", "to set log path", "[console/filepath]",
+ NULL, "[console/filepath]",
+ _CommandLogPath
+ },
+
+ {
+ "log", "to set loglevel", "[MODULE] [0-4]",
+ (int(*)(int, char*, int*))xDbgLogEnumModules, "[DEBUG:0/TRACE:1/INFO:2/WARNING:3/ERROR:4]",
+ _CommandSetLogLevel
+ },
+
+ {
+ "clist", "to print clients", "",
+ NULL, "",
+ _CommandClientList
+ },
+
+ {
+ "plist", "to print pixmap list", "",
+ NULL, "",
+ _CommandPixmapList
+ },
+
+ {
+ "evlog", "to print x events", "[0-1]",
+ NULL, "[OFF:0/ON:1]",
+ _CommandEvlog
+ },
+
+ {
+ "evlog_detail", "to set printing detail log level", "[0-2]",
+ NULL, "[Primary logs:0/ More detail logs:1/ Supplementary Reply logs:2]",
+ _CommandEvlogDetail
+ },
+
+ {
+ "evlog_rule", "to set evlog rules", "[add/remove/file/print/help]",
+ NULL, "[add allow/deny rules / remove (index) / file(file_name) / print / help]",
+ _CommandSetEvlogRule
+ },
+
+ {
+ "evlog_path", "to set filepath of evlog", "[console/filepath]",
+ NULL, "[console/filepath]",
+ _CommandSetEvlogPath
+ },
+
+ {
+ "drmevent_pending", "to print pending drmvents", "",
+ NULL, "",
+ _CommandDrmEventPending
+ },
+
+ {
+ "fpsdebug", "to print fps", "[0-1]",
+ NULL, "[OFF:0/ON:1]",
+ _CommandFpsDebug
+ },
+
+ {
+ "dump", "to dump buffers", "[on,off,clear]",
+ NULL, "[on,off,clear] -type [ui,drawable,fb,video] -count [n] -file [bmp,raw]",
+ _CommandDump
+ },
+};
+
+static void _CommandPrintUsage (char *reply, int *len, const char * exec)
+{
+ int option_cnt = sizeof (command_proc) / sizeof (command_proc[0]);
+ int i;
+
+ XDBG_REPLY ("Usage : %s [cmd] [options]\n", exec);
+ XDBG_REPLY (" ex)\n");
+
+ for (i=0; i<option_cnt; i++)
+ XDBG_REPLY (" %s %s %s\n", exec, command_proc[i].Cmd, command_proc[i].Options);
+
+ XDBG_REPLY (" options :\n");
+
+ for (i=0; i<option_cnt; i++)
+ {
+ if (command_proc[i].Cmd && command_proc[i].Description)
+ XDBG_REPLY (" %s (%s)\n", command_proc[i].Cmd, command_proc[i].Description);
+ else
+ XDBG_REPLY (" Cmd(%p) or Descriptiont(%p).\n", command_proc[i].Cmd, command_proc[i].Description);
+
+ if (command_proc[i].DynamicUsage)
+ {
+ char dyn[1024];
+ int dynlen = sizeof (dyn);
+ command_proc[i].DynamicUsage (MODE_NAME_ONLY, dyn, &dynlen);
+ XDBG_REPLY (" [MODULE:%s]\n", dyn);
+ }
+
+ if (command_proc[i].DetailedUsage)
+ XDBG_REPLY (" %s\n", command_proc[i].DetailedUsage);
+ else
+ XDBG_REPLY (" DetailedUsage(%p).\n", command_proc[i].DetailedUsage);
+ }
+}
+
+void
+xDbgModuleCommand (void *data, int argc, char **argv, char *reply, int *len)
+{
+ XDbgModule *pMod = (XDbgModule*)data;
+ int nproc = sizeof (command_proc) / sizeof (command_proc[0]);
+ int i, pid, new_argc;
+ char **new_argv;
+
+ pid = atoi (argv[0]);
+ pMod->cwd = strdup (argv[1]);
+
+ new_argc = argc - 2;
+ new_argv = (char**)malloc (new_argc * sizeof (char*));
+ if (!new_argv)
+ {
+ XDBG_REPLY ("Error : malloc new_argv\n");
+ return;
+ }
+
+ for (i = 0; i < new_argc; i++)
+ new_argv[i] = argv[i+2];
+
+ if (argc < 4)
+ {
+ _CommandPrintUsage (reply, len, new_argv[0]);
+ free (new_argv);
+ return;
+ }
+
+ for (i = 0; i < nproc; i++)
+ {
+ if (!strcmp (new_argv[1], command_proc[i].Cmd) ||
+ (new_argv[1][0] == '-' && !strcmp (1 + new_argv[1], command_proc[i].Cmd)))
+ {
+ command_proc[i].func (pid, new_argc, new_argv, reply, len, pMod);
+ free (new_argv);
+ return;
+ }
+ }
+
+ _CommandPrintUsage (reply, len, new_argv[0]);
+
+ free (new_argv);
+}
+
+Bool
+xDbgModuleCommandInitLogPath (XDbgModule *pMod, char *log_path)
+{
+ char reply[1024];
+ int len = sizeof (reply);
+
+ if (log_path && strlen (log_path) > 0)
+ {
+ char newname[XDBG_PATH_MAX];
+ char filename[XDBG_PATH_MAX];
+ char *p = NULL, *last = NULL;
+ int i;
+
+ snprintf (newname, XDBG_PATH_MAX, "%s", log_path);
+
+ for (i = 0; i < strlen (newname); i++)
+ {
+ p = newname + i;
+ if (*p == '/')
+ last = p;
+ }
+
+ snprintf (filename, XDBG_PATH_MAX, "%s", last + 1);
+ snprintf (last, XDBG_PATH_MAX - (last - newname), "/prev.%s", filename);
+
+ if (rename (log_path, newname))
+ {
+ if (errno != ENOENT)
+ {
+ XDBG_ERROR (MXDBG, "Failed: rename %s -> %s\n", log_path, newname);
+ return FALSE;
+ }
+ }
+
+ _CommandSetLogFile (0, log_path, reply, &len, pMod);
+ }
+ else
+ _CommandSetLogFile (0, "console", reply, &len, pMod);
+
+ return TRUE;
+}
+
+Bool
+xDbgModuleCommandInitEvlogRulePath (XDbgModule *pMod, char *evlog_rule_path)
+{
+ char reply[4096];
+ int len = sizeof (reply);
+ char *argv[4];
+ int argc = 4;
+
+ if (!evlog_rule_path || strlen (evlog_rule_path) <= 0)
+ return TRUE;
+
+ argv[0] = "unknown";
+ argv[1] = "evlog_rule";
+ argv[2] = "file";
+ argv[3] = evlog_rule_path;
+
+ _CommandSetEvlogRule (0, argc, argv, reply, &len, pMod);
+
+ xDbgModuleEvlogPrintEvents (pMod, TRUE, "", reply, &len);
+
+ return TRUE;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_COMMAND_H__
+#define __XDBG_MODULE_COMMAND_H__
+
+#include "xdbg_module.h"
+
+void xDbgModuleCommand (void *data, int argc, char **argv, char *reply, int *len);
+Bool xDbgModuleCommandInitLogPath (XDbgModule *pMod, char *log_path);
+Bool xDbgModuleCommandInitEvlogRulePath (XDbgModule *pMod, char *evlog_rule_path);
+
+#endif /* __XDBG_MODULE_COMMAND_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include "xdbg_module.h"
+
+
+void
+xDbgModuleDrmEventPending (XDbgModule *pMod, char *reply, int *remain)
+{
+ xDbgLogDrmEventPendingLists (reply, remain);
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_DRMEVENT_H__
+#define __XDBG_MODULE_DRMEVENT_H__
+
+#include "xdbg_module.h"
+
+void xDbgModuleDrmEventPending (XDbgModule *pMod, char *reply, int *remain);
+
+#endif /* __XDBG_MODULE_DRMEVENT_H__ */
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+
+#define __USE_GNU
+#include <sys/socket.h>
+#include <linux/socket.h>
+
+#ifdef HAS_GETPEERUCRED
+# include <ucred.h>
+#endif
+
+#include <xace.h>
+#include <xacestr.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/XI2proto.h>
+#include <windowstr.h>
+
+#include <xdbg.h>
+#include "xdbg_types.h"
+#include "xdbg_module.h"
+#include "xdbg_module_evlog.h"
+#include "xdbg_evlog.h"
+
+#define XREGISTRY
+#include "registry.h"
+
+#define FP1616toDBL(x) ((x) * 1.0 / (1 << 16))
+
+Bool xev_trace_on = FALSE;
+int xev_trace_detail_level = EVLOG_PRINT_DEFAULT;
+static int xev_trace_fd = -1;
+static int xev_trace_record_fd = -1;
+static Atom atom_client_pid = None;
+static int init = 0;
+
+static void evtRecord (int fd, EvlogInfo *evinfo)
+{
+ extern ExtensionInfo Evlog_extensions[];
+ extern int Extensions_size;
+ int write_len = 0;
+ int i;
+
+ XDBG_RETURN_IF_FAIL (fd >= 0)
+ XDBG_RETURN_IF_FAIL (evinfo != NULL);
+
+ write_len = sizeof (int) +
+ sizeof (EvlogType) +
+ sizeof (int) +
+ sizeof (CARD32);
+
+ if (evinfo->mask & EVLOG_MASK_CLIENT)
+ write_len += sizeof (EvlogClient);
+
+ if (evinfo->mask & EVLOG_MASK_REQUEST)
+ write_len += (sizeof (EvlogRequest) + (evinfo->req.length * 4));
+
+ if (evinfo->mask & EVLOG_MASK_EVENT)
+ write_len += (sizeof (EvlogEvent) + evinfo->evt.size);
+
+ if (evinfo->mask & EVLOG_MASK_REPLY)
+ write_len += (sizeof (EvlogReply) + evinfo->rep.size);
+
+ if (evinfo->mask & EVLOG_MASK_ERROR)
+ write_len += (sizeof (EvlogError));
+
+ if (evinfo->mask & EVLOG_MASK_ATOM)
+ write_len += (sizeof (int) +
+ (sizeof (EvlogAtomTable) * evinfo->evatom.size));
+
+ if (evinfo->mask & EVLOG_MASK_REGION)
+ write_len += (sizeof (int) +
+ (sizeof (EvlogRegionTable) * evinfo->evregion.size));
+
+ if (!init)
+ write_len += (sizeof (int) +
+ ((sizeof (int) * 3) * Extensions_size));
+
+ if (write (fd, &write_len, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write write_len\n");
+ return;
+ }
+
+ if (!init)
+ {
+ if (write (fd, &Extensions_size, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write Extensions_size\n");
+ return;
+ }
+
+ for (i = 0 ; i < Extensions_size ; i++)
+ {
+ if (write (fd, &Evlog_extensions[i].opcode, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] opcode\n", i);
+ return;
+ }
+ if (write (fd, &Evlog_extensions[i].evt_base, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] evt_base\n", i);
+ return;
+ }
+ if (write (fd, &Evlog_extensions[i].err_base, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] err_base\n", i);
+ return;
+ }
+ }
+
+ init = 1;
+ }
+
+ if (write (fd, &evinfo->time, sizeof(CARD32)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write msec\n");
+ return;
+ }
+ if (write (fd, &evinfo->type, sizeof(EvlogType)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write type\n");
+ return;
+ }
+ if (write (fd, &evinfo->mask, sizeof(int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write mask\n");
+ return;
+ }
+
+ if (evinfo->mask & EVLOG_MASK_CLIENT)
+ if (write (fd, &evinfo->client, sizeof (EvlogClient)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write client\n");
+ return;
+ }
+
+ if (evinfo->mask & EVLOG_MASK_REQUEST)
+ {
+ if (write (fd, &evinfo->req, sizeof (EvlogRequest)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write request\n");
+ return;
+ }
+ if (write (fd, evinfo->req.ptr, (evinfo->req.length * 4)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write request\n");
+ return;
+ }
+ }
+ if (evinfo->mask & EVLOG_MASK_EVENT)
+ {
+ if (write (fd, &evinfo->evt, sizeof (EvlogEvent)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write event\n");
+ return;
+ }
+
+ XDBG_WARNING_IF_FAIL (evinfo->evt.size > 0);
+ if (write (fd, evinfo->evt.ptr, evinfo->evt.size) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write event\n");
+ return;
+ }
+ }
+ if (evinfo->mask & EVLOG_MASK_REPLY)
+ {
+ if (write (fd, &evinfo->rep, sizeof (EvlogReply)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write reply\n");
+ return;
+ }
+
+ XDBG_WARNING_IF_FAIL (evinfo->rep.size > 0);
+ if (write (fd, evinfo->rep.ptr, evinfo->rep.size) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write reply\n");
+ return;
+ }
+ }
+ if (evinfo->mask & EVLOG_MASK_ERROR)
+ {
+ if (write (fd, &evinfo->err, sizeof (EvlogError)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write reply\n");
+ return;
+ }
+ }
+
+ if (evinfo->mask & EVLOG_MASK_ATOM)
+ {
+ EvlogAtomTable *table = NULL;
+
+ if (write (fd, &evinfo->evatom.size, sizeof (int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write atom size\n");
+ return;
+ }
+ xorg_list_for_each_entry(table, &evinfo->evatom.list, link)
+ if (write (fd, table, sizeof (EvlogAtomTable)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write atom table\n");
+ return;
+ }
+ }
+
+ if (evinfo->mask & EVLOG_MASK_REGION)
+ {
+ EvlogRegionTable *table = NULL;
+
+ if (write (fd, &evinfo->evregion.size, sizeof (int)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write region size\n");
+ return;
+ }
+ xorg_list_for_each_entry(table, &evinfo->evregion.list, link)
+ if (write (fd, table, sizeof (EvlogRegionTable)) == -1)
+ {
+ XDBG_ERROR (MXDBG, "failed: write region table\n");
+ return;
+ }
+ }
+}
+
+static void evtPrintF (int fd, EvlogInfo *evinfo, char *log)
+{
+ if (fd < 0)
+ ErrorF ("%s", log);
+ else
+ dprintf (fd, "%s", log);
+}
+
+static void evtPrint (EvlogType type, ClientPtr client, xEvent *ev, ReplyInfoRec *rep)
+{
+ EvlogInfo evinfo = {0,};
+ static int EntryInit = 0;
+
+ /* evinfo.type */
+ evinfo.type = type;
+
+ /* evinfo.client */
+ if (client)
+ {
+ ModuleClientInfo *info = GetClientInfo (client);
+ XDBG_RETURN_IF_FAIL (info != NULL);
+ int min;
+
+ evinfo.mask |= EVLOG_MASK_CLIENT;
+ evinfo.client.index = info->index;
+ evinfo.client.pid = info->pid;
+ evinfo.client.gid = info->gid;
+ evinfo.client.uid = info->uid;
+
+ min = MIN (sizeof (evinfo.client.command) - 1, strlen (info->command));
+ strncpy (evinfo.client.command, info->command, min);
+ evinfo.client.command[min] = '\0';
+
+ evinfo.client.pClient = (void*)client;
+
+ /* evinfo.req */
+ if (type == REQUEST)
+ {
+ extern char *conn[];
+
+ REQUEST (xReq);
+
+ evinfo.mask |= EVLOG_MASK_REQUEST;
+ evinfo.req.id = stuff->reqType;
+ evinfo.req.length = client->req_len;
+ evinfo.req.ptr = client->requestBuffer;
+
+ if (client->requestVector == InitialVector && stuff->reqType == 1)
+ snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s", conn[0]);
+ else if (client->requestVector == InitialVector && stuff->reqType == 2)
+ snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s", conn[1]);
+ else
+ {
+ if (stuff->reqType < EXTENSION_BASE)
+ snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s",
+ LookupRequestName (stuff->reqType, 0));
+ else
+ snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s",
+ LookupRequestName (stuff->reqType, stuff->data));
+ }
+ }
+
+ /* evinfo.rep */
+ if (type == REPLY)
+ {
+ REQUEST (xReq);
+
+ evinfo.mask |= EVLOG_MASK_REPLY;
+ evinfo.rep.reqType = stuff->reqType;
+ evinfo.rep.reqData = stuff->data;
+ evinfo.rep.ptr = (xGenericReply*)rep->replyData;
+ evinfo.rep.size = rep->dataLenBytes - rep->padBytes;
+ evinfo.rep.isStart = rep->startOfReply;
+
+ if (stuff->reqType < EXTENSION_BASE)
+ snprintf (evinfo.rep.name, sizeof (evinfo.rep.name), "%s",
+ LookupRequestName (stuff->reqType, 0));
+ else
+ snprintf (evinfo.rep.name, sizeof (evinfo.rep.name), "%s",
+ LookupRequestName (stuff->reqType, stuff->data));
+ }
+
+ if (type == ERROR)
+ {
+ xError* err = NULL;
+
+ if (ev)
+ err = (xError *) ev;
+ else if (rep)
+ err = (xError *) rep->replyData;
+
+ if (err)
+ {
+ evinfo.mask |= EVLOG_MASK_ERROR;
+ evinfo.err.errorCode = err->errorCode;
+ evinfo.err.resourceID = err->resourceID;
+ evinfo.err.minorCode = err->minorCode;
+ evinfo.err.majorCode = err->majorCode;
+ }
+ else
+ XDBG_NEVER_GET_HERE (MXDBG);
+ }
+ }
+
+ /* evinfo.evt */
+ if (ev)
+ {
+ if (type == EVENT)
+ {
+ evinfo.mask |= EVLOG_MASK_EVENT;
+ evinfo.evt.ptr = ev;
+ snprintf (evinfo.evt.name, sizeof (evinfo.evt.name), "%s",
+ LookupEventName ((int)(ev->u.u.type)));
+ }
+ }
+
+ /* evinfo.time */
+ evinfo.time = GetTimeInMillis ();
+
+ /* get extension entry */
+ if (!EntryInit && !xDbgEvlogGetExtensionEntry (NULL))
+ return;
+
+ EntryInit = 1;
+
+ if (!xDbgEvlogRuleValidate (&evinfo))
+ return;
+
+ if (xev_trace_record_fd >= 0)
+ {
+ if (xDbgEvlogFillLog (&evinfo, EVLOG_PRINT_REPLY_DETAIL, NULL, NULL))
+ evtRecord (xev_trace_record_fd, &evinfo);
+ }
+ else
+ {
+ char log[1024];
+ int size = sizeof (log);
+
+ if (xDbgEvlogFillLog (&evinfo, xev_trace_detail_level, log, &size))
+ evtPrintF (xev_trace_fd, &evinfo, log);
+ }
+
+ /* evatom initialize */
+ xDbgDistroyAtomList(&evinfo);
+ xDbgDistroyRegionList(&evinfo);
+}
+
+#if TIZEN_ENGINEER_MODE
+static const char*
+_traceGetWindowName (ClientPtr client, Window window)
+{
+ int rc;
+ WindowPtr pWin;
+ Mask win_mode = DixGetPropAccess, prop_mode = DixReadAccess;
+ Atom property;
+ PropertyPtr pProp;
+ static char winname[128];
+ int datalen;
+
+ rc = dixLookupWindow (&pWin, window, client, win_mode);
+ if (rc != Success)
+ return NULL;
+
+ property = MakeAtom ("WM_NAME", strlen ("WM_NAME"), TRUE);
+ while (pWin)
+ {
+ rc = dixLookupProperty (&pProp, pWin, property, client, prop_mode);
+ if (rc == Success && pProp->data)
+ {
+ datalen = (pProp->size>127) ?127:pProp->size;
+ strncpy (winname, pProp->data, datalen);
+ winname[datalen] = 0;
+
+ return winname;
+ }
+
+ pWin = pWin->parent;
+ }
+
+ return NULL;
+}
+#endif
+
+static void
+_traceFlush (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ if (xev_trace_on == FALSE)
+ return;
+
+ evtPrint (FLUSH, NULL, NULL, NULL);
+}
+
+static void
+_traceAReply (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ if (xev_trace_on == FALSE)
+ return;
+
+ ReplyInfoRec *pri = (ReplyInfoRec*)calldata;
+
+ evtPrint (REPLY, pri->client, NULL, pri);
+}
+
+static void
+_traceEvent (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
+{
+ EventInfoRec *pei = (EventInfoRec*)calldata;
+ ClientPtr pClient;
+ ModuleClientInfo *info;
+ int ev; /* event index */
+ static int xi2_opcode = -1;
+ xEvent *pev;
+
+#if TIZEN_ENGINEER_MODE
+ static char* ename[]=
+ {
+ "KeyPress",
+ "KeyRelease",
+ "ButtonPress",
+ "ButtonRelease",
+ };
+#endif
+
+ XDBG_RETURN_IF_FAIL (pei != NULL);
+
+ pClient = pei->client;
+ XDBG_RETURN_IF_FAIL (pClient != NULL);
+
+ pev = pei->events;
+ XDBG_RETURN_IF_FAIL (pev != NULL);
+
+ info = GetClientInfo (pClient);
+ XDBG_RETURN_IF_FAIL (info != NULL);
+
+ for (ev=0; ev < pei->count; ev++, pev++)
+ {
+ int type = pev->u.u.type & 0177;
+
+ if (type < LASTEvent)
+ {
+ switch (type)
+ {
+ case KeyPress:
+ case KeyRelease:
+ XDBG_SECURE (MXDBG, "%s(%d)_%d(%s.%d : %s.0x%x) root(%d,%d) win(%d,%d)\n"
+ , ename[type-KeyPress], pev->u.u.detail, pev->u.u.type
+ , info->command, info->pid
+ , _traceGetWindowName (pClient, pev->u.keyButtonPointer.event), (unsigned int)pev->u.keyButtonPointer.event
+ , pev->u.keyButtonPointer.rootX, pev->u.keyButtonPointer.rootY
+ , pev->u.keyButtonPointer.eventX, pev->u.keyButtonPointer.eventY);
+ break;
+
+ case ButtonPress:
+ case ButtonRelease:
+ XDBG_SECURE (MXDBG, "%s(%d)_%d(%s.%d : %s.0x%x) root(%d,%d) win(%d,%d)\n"
+ , ename[type-KeyPress], pev->u.u.detail, pev->u.u.type
+ , info->command, info->pid
+ , _traceGetWindowName (pClient, pev->u.keyButtonPointer.event), (unsigned int)pev->u.keyButtonPointer.event
+ , pev->u.keyButtonPointer.rootX, pev->u.keyButtonPointer.rootY
+ , pev->u.keyButtonPointer.eventX, pev->u.keyButtonPointer.eventY);
+ break;
+ case GenericEvent:
+ if(!xi2_opcode) break;
+ if(xi2_opcode < 0)
+ {
+ ExtensionEntry *pExt = CheckExtension("XInputExtension");
+ if(!pExt) xi2_opcode = 0;
+ else xi2_opcode = pExt->base;
+ }
+
+ if(((xGenericEvent*)pev)->extension != xi2_opcode) break;
+
+ xXIDeviceEvent *xidev = (xXIDeviceEvent *)pev;
+ if(xidev->deviceid==2) break;
+ if(xidev->evtype==XI_ButtonPress)
+ XDBG_TRACE (MXDBG, "XI_ButtonPress(%d) device(%d), event win(0x%x), child(0x%x), root(%.f,%.f), win(%.f, %.f)\n", XI_ButtonPress, xidev->deviceid, xidev->event, xidev->child, FP1616toDBL(xidev->root_x), FP1616toDBL(xidev->root_y), FP1616toDBL(xidev->event_x), FP1616toDBL(xidev->event_y));
+ else if(xidev->evtype==XI_ButtonRelease)
+ XDBG_TRACE (MXDBG, "XI_ButtonRelease(%d) device(%d), event win(0x%x), child(0x%x), root(%.f,%.f), win(%.f, %.f)\n", XI_ButtonRelease, xidev->deviceid, xidev->event, xidev->child, FP1616toDBL(xidev->root_x), FP1616toDBL(xidev->root_y), FP1616toDBL(xidev->event_x), FP1616toDBL(xidev->event_y));
+ else if(xidev->evtype==XI_Motion)
+ XDBG_TRACE (MXDBG, "XI_Motion(%d) device(%d), event win(0x%x), child(0x%x), root(%.f,%.f), win(%.f, %.f)\n", XI_Motion, xidev->deviceid, xidev->event, xidev->child, FP1616toDBL(xidev->root_x), FP1616toDBL(xidev->root_y), FP1616toDBL(xidev->event_x), FP1616toDBL(xidev->event_y));
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (type != X_Error && xev_trace_on)
+ evtPrint (EVENT, pClient, pev, NULL);
+ else if (type == X_Error && xev_trace_on)
+ evtPrint (ERROR, pClient, pev, NULL);
+ }
+}
+
+static void
+_traceACoreEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ if (xev_trace_on == FALSE)
+ return;
+
+ XaceCoreDispatchRec *rec = calldata;
+
+ XDBG_RETURN_IF_FAIL (rec != NULL);
+
+ evtPrint (REQUEST, rec->client, NULL, NULL);
+}
+
+static void
+_traceAExtEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ if (xev_trace_on == FALSE)
+ return;
+
+ XaceExtAccessRec *rec = calldata;
+
+ XDBG_RETURN_IF_FAIL (rec != NULL);
+
+ evtPrint (REQUEST, rec->client, NULL, NULL);
+}
+
+static void
+_traceAuditEndEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ return;
+}
+
+static void
+_traceProperty (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XacePropertyAccessRec *rec = calldata;
+ ModuleClientInfo *info = GetClientInfo (rec->client);
+ PropertyPtr pProp = *rec->ppProp;
+ Atom name = pProp->propertyName;
+
+ /* Don't care about the new content check */
+ if (rec->client == serverClient || rec->access_mode & DixPostAccess)
+ return;
+
+ if (name == atom_client_pid && (rec->access_mode & DixWriteAccess))
+ {
+ XDBG_WARNING (MXDBG, "Invalid access X_CLINET_PID pid:%d, uid:%d\n", info->pid, info->uid);
+ rec->status = BadAccess;
+ return;
+ }
+
+ rec->status = Success;
+ return;
+}
+
+static void
+_traceResource (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceResourceAccessRec *rec = calldata;
+ Mask access_mode = rec->access_mode;
+ ModuleClientInfo *info = GetClientInfo (rec->client);
+
+ /* Perform the background none check on windows */
+ if (access_mode & DixCreateAccess && rec->rtype == RT_WINDOW)
+ {
+ WindowPtr pWin = (WindowPtr) rec->res;
+ int rc;
+ int pid = info->pid;
+
+ rc = dixChangeWindowProperty (serverClient,
+ pWin, atom_client_pid, XA_CARDINAL, 32,
+ PropModeReplace, 1, &pid, FALSE);
+ if (rc != Success)
+ XDBG_ERROR (MXDBG, "failed : set X_CLIENT_PID to %d.\n", pid);
+ }
+}
+
+static void
+_traceReceive (CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceReceiveAccessRec *rec = calldata;
+
+ if (rec->events->u.u.type != VisibilityNotify)
+ return;
+
+ rec->status = BadAccess;
+}
+
+Bool
+xDbgModuleEvlogInstallHooks (XDbgModule *pMod)
+{
+ int ret = TRUE;
+
+ ret &= AddCallback (&EventCallback, _traceEvent, NULL);
+ ret &= XaceRegisterCallback (XACE_PROPERTY_ACCESS, _traceProperty, NULL);
+ ret &= XaceRegisterCallback (XACE_RESOURCE_ACCESS, _traceResource, NULL);
+
+ /*Disable Visibility Event*/
+ ret &= XaceRegisterCallback (XACE_RECEIVE_ACCESS, _traceReceive, NULL);
+
+ if (atom_client_pid == None)
+ atom_client_pid = MakeAtom ("X_CLIENT_PID", 12, TRUE);
+
+ if (!ret)
+ {
+ XDBG_ERROR (MXDBG, "failed: register one or more callbacks\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+xDbgModuleEvlogUninstallHooks (XDbgModule *pMod)
+{
+ DeleteCallback (&EventCallback, _traceEvent, NULL);
+ XaceDeleteCallback (XACE_PROPERTY_ACCESS, _traceProperty, NULL);
+ XaceDeleteCallback (XACE_RESOURCE_ACCESS, _traceResource, NULL);
+}
+
+void
+xDbgModuleEvlogPrintEvents (XDbgModule *pMod, Bool on, const char * client_name, char *reply, int *len)
+{
+ int ret = TRUE;
+
+ on = (on)?TRUE:FALSE;
+ if (xev_trace_on == on)
+ return;
+
+ xev_trace_on = on;
+
+ if (xev_trace_on)
+ {
+ int i;
+
+ //Find client's pid
+ for (i=1 ; i< currentMaxClients ; i++)
+ {
+ ClientPtr pClient;
+ ModuleClientInfo *info;
+
+ pClient = clients[i];
+ if (!pClient)
+ continue;
+
+ info = GetClientInfo (pClient);
+ if (!info)
+ continue;
+
+ if (strlen (info->command) > 0 && strstr (client_name, info->command))
+ {
+ char fd_name[256];
+
+ if (xev_trace_fd >= 0)
+ close (xev_trace_fd);
+
+ snprintf (fd_name, 256, "/proc/%d/fd/1", info->pid);
+ xev_trace_fd = open (fd_name, O_RDWR);
+ if (xev_trace_fd < 0)
+ XDBG_REPLY ("failed: open consol '%s'. (%s)\n", fd_name, strerror(errno));
+ }
+ }
+
+ ret &= AddCallback (&FlushCallback, _traceFlush, NULL);
+ ret &= AddCallback (&ReplyCallback, _traceAReply, NULL);
+ ret &= XaceRegisterCallback (XACE_CORE_DISPATCH, _traceACoreEvents, NULL);
+ ret &= XaceRegisterCallback (XACE_EXT_DISPATCH, _traceAExtEvents, NULL);
+ ret &= XaceRegisterCallback (XACE_AUDIT_END, _traceAuditEndEvents, NULL);
+
+ if (!ret)
+ {
+ XDBG_REPLY ("failed: register one or more callbacks.\n");
+ return;
+ }
+ }
+ else
+ {
+ DeleteCallback (&FlushCallback, _traceFlush, NULL);
+ DeleteCallback (&ReplyCallback, _traceAReply, NULL);
+ XaceDeleteCallback (XACE_CORE_DISPATCH, _traceACoreEvents, NULL);
+ XaceDeleteCallback (XACE_EXT_DISPATCH, _traceAExtEvents, NULL);
+ XaceDeleteCallback (XACE_AUDIT_END, _traceAuditEndEvents, NULL);
+ }
+
+ return;
+}
+
+void
+xDbgModuleEvlogDetail (XDbgModule *pMod, int level, char *reply, int *len)
+{
+ xev_trace_detail_level = level;
+}
+
+int
+xDbgModuleEvlogInfoSetRule (XDbgModule *pMod, const int argc, const char ** argv, char *reply, int *len)
+{
+ return xDbgEvlogRuleSet (argc, argv, reply, len);
+}
+
+Bool
+xDbgModuleEvlogSetEvlogPath (XDbgModule *pMod, int pid, char *path, char *reply, int *len)
+{
+ char fd_name[XDBG_PATH_MAX];
+ int fd_check = -1;
+
+ if (!path || strlen (path) <= 0)
+ return FALSE;
+
+ if (xev_trace_record_fd >= 0)
+ {
+ close (xev_trace_record_fd);
+ xev_trace_record_fd = -1;
+ }
+
+ if (pMod->log_path)
+ {
+ free (pMod->log_path);
+ pMod->log_path = NULL;
+ }
+
+ if (!strcmp (path, "console"))
+ {
+ if (pid > 0)
+ {
+ char fd_name[256];
+
+ if (xev_trace_fd >= 0)
+ close (xev_trace_fd);
+
+ snprintf (fd_name, sizeof (fd_name), "/proc/%d/fd/1", pid);
+
+ xev_trace_fd = open (fd_name, O_RDWR);
+ if (xev_trace_fd < 0)
+ XDBG_REPLY ("failed: open consol '%s'. (%s)\n", fd_name, strerror(errno));
+
+ pMod->evlog_path = strdup (fd_name);
+ }
+
+ return TRUE;
+ }
+
+ if (path[0] == '/')
+ snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
+ else
+ {
+ if (pMod->cwd)
+ snprintf (fd_name, XDBG_PATH_MAX, "%s/%s", pMod->cwd, path);
+ else
+ snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
+ }
+
+ pMod->evlog_path = strdup (fd_name);
+
+ fd_check = open (fd_name, O_RDONLY);
+ if(fd_check < 0)
+ init = 0;
+ else
+ close (fd_check);
+
+ xev_trace_record_fd = open (fd_name, O_CREAT|O_RDWR|O_APPEND, 0755);
+ if (xev_trace_record_fd < 0)
+ {
+ XDBG_REPLY ("failed: open file '%s'. (%s)\n", fd_name, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_EVLOG_H__
+#define __XDBG_MODULE_EVLOG_H__
+
+#include "xdbg_module.h"
+
+Bool xDbgModuleEvlogInstallHooks (XDbgModule *pMod);
+void xDbgModuleEvlogUninstallHooks (XDbgModule *pMod);
+
+void xDbgModuleEvlogPrintEvents (XDbgModule *pMod, Bool on, const char * client_name, char *reply, int *len);
+void xDbgModuleEvlogDetail (XDbgModule *pMod, int level, char *reply, int *len);
+int xDbgModuleEvlogInfoSetRule (XDbgModule *pMod, const int argc, const char ** argv, char *reply, int *len);
+
+Bool xDbgModuleEvlogSetEvlogPath (XDbgModule *pMod, int pid, char *path, char *reply, int *len);
+
+#endif /* __XDBG_MODULE_EVLOG_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include "xdbg_module.h"
+
+void
+xDbgModuleFpsDebug (XDbgModule *pMod, int on, char *reply, int *len)
+{
+ xDbgLogFpsDebug (reply, len, on);
+}
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_FPSDEBUG_H__
+#define __XDBG_MODULE_FPSDEBUG_H__
+
+#include "xdbg_module.h"
+
+void xDbgModuleFpsDebug (XDbgModule *pMod, int on, char *reply, int *len);
+
+
+#endif /* __XDBG_MODULE_FPSDEBUG_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <windowstr.h>
+#include <xacestr.h>
+#include <xdbg.h>
+
+#include "xdbg_dbus_server.h"
+#include "xdbg_module.h"
+#include "xdbg_module_command.h"
+#include "xdbg_module_evlog.h"
+
+#define __USE_GNU
+#include <sys/socket.h>
+
+DevPrivateKeyRec debug_client_key;
+
+static XDbgDbusServerMethod method;
+
+static void
+_debugClientInfo (ClientPtr client)
+{
+ int fd = XaceGetConnectionNumber (client);
+ ModuleClientInfo *info = GetClientInfo (client);
+
+ /* For local clients, try and determine the executable name */
+ if (XaceIsLocal (client))
+ {
+ struct ucred creds;
+ socklen_t len = sizeof (creds);
+ char path[PATH_MAX + 1] = {0,};
+ int bytes;
+
+ memset (&creds, 0, sizeof (creds));
+ if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &creds, &len) < 0)
+ goto finish;
+
+ snprintf (path, PATH_MAX + 1, "/proc/%d/cmdline", creds.pid);
+ fd = open (path, O_RDONLY);
+ if (fd < 0)
+ goto finish;
+
+ bytes = read (fd, path, PATH_MAX + 1);
+ close (fd);
+ if (bytes <= 0)
+ goto finish;
+
+ strncpy (info->command, path, PATH_MAX);
+ info->command[PATH_MAX] = '\0';
+
+ info->pid = creds.pid;
+ info->uid = creds.uid;
+ info->gid = creds.gid;
+ info->conn_fd = fd;
+ info->index = client->index;
+ }
+ else
+ {
+ info->pid = -1;
+ info->index = client->index;
+ strncpy (info->command, "REMOTE", PATH_MAX);
+ info->command[PATH_MAX] = '\0';
+ }
+
+ return;
+
+finish:
+ XDBG_ERROR (MXDBG, "Failed to make client info(index:%d)\n",
+ client->index);
+ return;
+}
+
+static void
+_traceClientState (CallbackListPtr *list, pointer closure, pointer calldata)
+{
+ NewClientInfoRec *clientinfo = (NewClientInfoRec*)calldata;
+ ClientPtr client = clientinfo->client;
+ ModuleClientInfo *info = GetClientInfo (client);
+ static char* clientState[]=
+ {
+ "ClientStateInitial",
+ "ClientStateAuthenticating",
+ "ClientStateRunning",
+ "ClientStateRetained",
+ "ClientStateGone",
+ "ClientStateCheckingDebug",
+ "ClientStateCheckedDebug"
+ };
+
+ if (!info)
+ return;
+
+ if ((client->clientState == ClientStateInitial) || (client->clientState == ClientStateGone))
+ {
+ if (client->clientState == ClientStateInitial)
+ _debugClientInfo (client);
+
+ XDBG_SECURE (MXDBG, "id:%d, conn_fd:%d, pid:%d, uid:%d, name:%s (%s)\n",
+ info->index, info->conn_fd, info->pid, info->uid, info->command,
+ clientState[client->clientState]);
+ return;
+ }
+
+ XDBG_DEBUG (MXDBG, "id:%d, conn_fd:%d, pid:%d, uid:%d, name:%s (%s)\n",
+ info->index, info->conn_fd, info->pid, info->uid, info->command,
+ clientState[client->clientState]);
+}
+
+Bool
+xDbgModuleMain (XDbgModule *pMod)
+{
+ Bool ret = TRUE;
+
+ if (!dixRegisterPrivateKey (DebugClientKey, PRIVATE_CLIENT, sizeof (ModuleClientInfo)))
+ {
+ XDBG_ERROR (MXDBG, "failed: dixRegisterPrivateKey\n");
+ return FALSE;
+ }
+
+ ret &= AddCallback (&ClientStateCallback, _traceClientState, pMod);
+
+ if (!ret)
+ {
+ XDBG_ERROR (MXDBG, "failed: AddCallback\n");
+ return FALSE;
+ }
+
+ xDbgModuleEvlogInstallHooks (pMod);
+
+ if (!xDbgDBusServerConnect ())
+ {
+ XDBG_ERROR (MXDBG, "failed: xDbgDBusServerConnect\n");
+ return FALSE;
+ }
+
+ snprintf (method.name, sizeof (method.name), "%s", XDBG_DBUS_METHOD);
+ method.func = xDbgModuleCommand;
+ method.data = pMod;
+
+ xDbgDBusServerAddMethod (&method);
+
+ return TRUE;
+}
+
+void
+xDbgModuleMainExit (XDbgModule *pMod)
+{
+ DeleteCallback (&ClientStateCallback, _traceClientState, pMod);
+
+ xDbgModuleEvlogUninstallHooks (pMod);
+
+ xDbgDBusServerRemoveMethod (&method);
+
+ xDbgDBusServerDisconnect ();
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_MAIN_H__
+#define __XDBG_MODULE_MAIN_H__
+
+#include "xdbg_module.h"
+
+Bool xDbgModuleMain (XDbgModule *pMod);
+void xDbgModuleMainExit (XDbgModule *pMod);
+
+#endif /* __XDBG_MODULE_MAIN_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <xdbg.h>
+
+#include "xdbg_module.h"
+#include "xdbg_module_command.h"
+#include "xdbg_module_evlog.h"
+
+/* Supported options */
+typedef enum
+{
+ OPTION_DLOG,
+ OPTION_LOG_PATH,
+ OPTION_LOG_LEVEL,
+ OPTION_EVLOG_PATH,
+ OPTION_EVLOG_RULE_PATH,
+} ModuleOption;
+
+static const OptionInfoRec module_options[] =
+{
+ { OPTION_DLOG, "dlog", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_LOG_PATH, "log_path", OPTV_STRING, {0}, FALSE },
+ { OPTION_LOG_LEVEL, "log_level", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_EVLOG_PATH, "evlog_path", OPTV_STRING, {0}, FALSE },
+ { OPTION_EVLOG_RULE_PATH, "evlog_rule_path", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xDbgModuleParseOptions (XDbgModule *pMod, XF86OptionPtr pOpt)
+{
+ OptionInfoPtr options = xnfalloc (sizeof (module_options));
+ const char *path;
+ char temp[256];
+ int log_level = XLOG_LEVEL_DEFAULT;
+
+ memcpy (options, module_options, sizeof(module_options));
+
+ xf86ProcessOptions (-1, pOpt, options);
+
+ /* dlog */
+ xf86GetOptValBool (options, OPTION_DLOG, &pMod->dlog);
+ XDBG_INFO (MXDBG, "dlog: \"%s\"\n", (pMod->dlog)?"on":"off");
+ xDbgLogEnableDlog (pMod->dlog);
+
+ /* log_path */
+ path = xf86GetOptValString (options, OPTION_LOG_PATH);
+ XDBG_INFO (MXDBG, "log path: \"%s\"\n", (path)?path:"none");
+ if (path)
+ {
+ snprintf (temp, sizeof(temp), "%s", path);
+ xDbgModuleCommandInitLogPath (pMod, temp);
+ }
+
+ /* log_level */
+ xf86GetOptValInteger (options, OPTION_LOG_LEVEL, &log_level);
+ XDBG_INFO (MXDBG, "log default level: %d\n", log_level);
+ xDbgLogSetLevel (XDBG_ALL_MODULE, log_level);
+
+ /* evlog_path */
+ path = xf86GetOptValString (options, OPTION_EVLOG_PATH);
+ XDBG_INFO (MXDBG, "evlog path: \"%s\"\n", (path)?path:"none");
+ if (path)
+ {
+ snprintf (temp, sizeof(temp), "%s", path);
+ xDbgModuleEvlogSetEvlogPath (pMod, -1, temp, NULL, NULL);
+ }
+
+ /* evlog_rule_path */
+ path = xf86GetOptValString (options, OPTION_EVLOG_RULE_PATH);
+ XDBG_INFO (MXDBG, "evlog rule path: \"%s\"\n", (path)?path:"none");
+ if (path)
+ {
+ snprintf (temp, sizeof(temp), "%s", path);
+ xDbgModuleCommandInitEvlogRulePath (pMod, temp);
+ }
+
+ free (options);
+}
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_OPTIONS_H__
+#define __XDBG_MODULE_OPTIONS_H__
+
+#include "xdbg_module.h"
+
+void xDbgModuleParseOptions (XDbgModule *pMod, XF86OptionPtr pOpt);
+
+#endif /* __XDBG_MODULE_OPTIONS_H__ */
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xdbg.h"
+#include "xdbg_log_int.h"
+#include "xdbg_types.h"
+#include "xdbg_module.h"
+
+
+void
+xDbgModulePList (XDbgModule *pMod, char *reply, int *len)
+{
+ xDbgLogPList (reply, len);
+}
+
--- /dev/null
+/**************************************************************************
+
+xdbg
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+
+Contact: Boram Park <boram1288.park@samsung.com>
+ Sangjin LEE <lsj119@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __XDBG_MODULE_PLIST_H__
+#define __XDBG_MODULE_PLIST_H__
+
+#include "xdbg_module.h"
+
+void xDbgModulePList (XDbgModule *pMod, char *reply, int *remain);
+
+#endif /* __XDBG_MODULE_PLIST_H__ */
\ No newline at end of file
--- /dev/null
+Name: xorg-x11-module-xdbg
+Summary: Xserver debug module
+Version: 0.1.47
+Release: 1
+VCS: adaptation/xorg/driver/xserver-xorg-module-xdbg#xorg-x11-module-xdbg-0.1.13-1-79-gfb1d23b62faa7f302ac1b19ff1d3f757c4745b13
+Group: System/Libraries
+License: MIT
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(xorg-server)
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(xext)
+BuildRequires: pkgconfig(xdamage)
+BuildRequires: pkgconfig(xorg-macros)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(bigreqsproto)
+BuildRequires: pkgconfig(xcomposite)
+BuildRequires: pkgconfig(compositeproto)
+BuildRequires: pkgconfig(damageproto)
+BuildRequires: pkgconfig(libdri2)
+BuildRequires: pkgconfig(dri2proto)
+BuildRequires: pkgconfig(fixesproto)
+BuildRequires: pkgconfig(fontsproto)
+BuildRequires: pkgconfig(xgesture)
+BuildRequires: pkgconfig(gestureproto)
+BuildRequires: pkgconfig(inputproto)
+BuildRequires: pkgconfig(kbproto)
+BuildRequires: pkgconfig(xrandr)
+BuildRequires: pkgconfig(randrproto)
+BuildRequires: pkgconfig(recordproto)
+BuildRequires: pkgconfig(renderproto)
+BuildRequires: pkgconfig(resourceproto)
+BuildRequires: pkgconfig(videoproto)
+BuildRequires: pkgconfig(xcmiscproto)
+BuildRequires: pkgconfig(xextproto)
+BuildRequires: pkgconfig(xf86vidmodeproto)
+BuildRequires: pkgconfig(xproto)
+BuildRequires: pkgconfig(libdrm)
+BuildRequires: pkgconfig(xtst)
+BuildRequires: pkgconfig(xi)
+BuildRequires: pkgconfig(xv)
+
+%description
+This package provides the runtime debug library and module for debug of inside X server.
+
+%package devel
+Summary: X server runtime debug library development package
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: pkgconfig(xorg-server)
+Requires: pkgconfig(x11)
+Requires: pkgconfig(xproto)
+Requires: pkgconfig(dlog)
+
+%description devel
+X server runtime debug library development package
+
+%prep
+%setup -q
+
+%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export XDBG_OPTIONS="--enable-secure-log"
+%endif
+%reconfigure --disable-static --prefix=/usr $XDBG_OPTIONS \
+ CFLAGS="$CFLAGS -Wall -Werror" \
+ LDFLAGS="$LDFLAGS -Wl,--hash-style=both -Wl,--as-needed"
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp -af COPYING %{buildroot}/usr/share/license/%{name}
+%make_install
+
+%remove_docs
+
+%files
+%manifest xorg-x11-module-xdbg.manifest
+%defattr(-,root,root,-)
+/usr/share/license/%{name}
+%{_bindir}/xdbg
+%{_bindir}/xevlog_analyze
+%{_libdir}/libxdbg-lib.so.*
+%{_libdir}/xorg/modules/libxdbg.so
+
+%files devel
+%dir %{_includedir}/xdbg/
+%{_includedir}/xdbg/*.h
+%{_libdir}/libxdbg-lib.so
+%{_libdir}/pkgconfig/xdbg.pc
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/*" label="_" exec_label="none" />
+ </assign>
+</manifest>
+