1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: Boram Park <boram1288.park@samsung.com>
8 Sangjin LEE <lsj119@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
48 #include <sys/socket.h>
49 #include <linux/socket.h>
51 #ifdef HAS_GETPEERUCRED
57 #include <X11/Xatom.h>
58 #include <X11/extensions/XI2proto.h>
59 #include <windowstr.h>
62 #include "xdbg_types.h"
63 #include "xdbg_module.h"
64 #include "xdbg_module_evlog.h"
65 #include "xdbg_evlog.h"
72 #define FP1616toDBL(x) ((x) * 1.0 / (1 << 16))
74 Bool xev_trace_on = FALSE;
75 int xev_trace_detail_level = EVLOG_PRINT_DEFAULT;
76 static int xev_trace_fd = -1;
77 static int xev_trace_record_fd = -1;
78 static Atom atom_client_pid = None;
80 static char *xerror_path = NULL;
83 xDbgModuleEvlogXErrorSetPath (char *path)
88 static void xErrorPrint (EvlogInfo *evinfo, const char *f, ...)
93 if (!strcmp (xerror_path, "dlog"))
95 const char * error_tag = "XERROR";
96 SLOG_VA (LOG_DEBUG, error_tag, f, args);
98 else if (!strcmp (xerror_path, "xorg"))
100 LogVWrite (1, f, args);
105 static void evtRecord (int fd, EvlogInfo *evinfo)
107 extern ExtensionInfo Evlog_extensions[];
108 extern int Extensions_size;
112 XDBG_RETURN_IF_FAIL (fd >= 0)
113 XDBG_RETURN_IF_FAIL (evinfo != NULL);
115 write_len = sizeof (int) +
120 if (evinfo->mask & EVLOG_MASK_CLIENT)
121 write_len += sizeof (EvlogClient);
123 if (evinfo->mask & EVLOG_MASK_REQUEST)
124 write_len += (sizeof (EvlogRequest) + (evinfo->req.length * 4));
126 if (evinfo->mask & EVLOG_MASK_EVENT)
127 write_len += (sizeof (EvlogEvent) + evinfo->evt.size);
129 if (evinfo->mask & EVLOG_MASK_REPLY)
130 write_len += (sizeof (EvlogReply) + evinfo->rep.size);
132 if (evinfo->mask & EVLOG_MASK_ERROR)
133 write_len += (sizeof (EvlogError));
135 if (evinfo->mask & EVLOG_MASK_ATOM)
136 write_len += (sizeof (int) +
137 (sizeof (EvlogAtomTable) * evinfo->evatom.size));
139 if (evinfo->mask & EVLOG_MASK_REGION)
140 write_len += (sizeof (int) +
141 (sizeof (EvlogRegionTable) * evinfo->evregion.size));
144 write_len += (sizeof (int) +
145 ((sizeof (int) * 3) * Extensions_size));
147 if (write (fd, &write_len, sizeof(int)) == -1)
149 XDBG_ERROR (MXDBG, "failed: write write_len\n");
155 if (write (fd, &Extensions_size, sizeof(int)) == -1)
157 XDBG_ERROR (MXDBG, "failed: write Extensions_size\n");
161 for (i = 0 ; i < Extensions_size ; i++)
163 if (write (fd, &Evlog_extensions[i].opcode, sizeof(int)) == -1)
165 XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] opcode\n", i);
168 if (write (fd, &Evlog_extensions[i].evt_base, sizeof(int)) == -1)
170 XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] evt_base\n", i);
173 if (write (fd, &Evlog_extensions[i].err_base, sizeof(int)) == -1)
175 XDBG_ERROR (MXDBG, "failed: write Evlog_extensions[%d] err_base\n", i);
183 if (write (fd, &evinfo->time, sizeof(CARD32)) == -1)
185 XDBG_ERROR (MXDBG, "failed: write msec\n");
188 if (write (fd, &evinfo->type, sizeof(EvlogType)) == -1)
190 XDBG_ERROR (MXDBG, "failed: write type\n");
193 if (write (fd, &evinfo->mask, sizeof(int)) == -1)
195 XDBG_ERROR (MXDBG, "failed: write mask\n");
199 if (evinfo->mask & EVLOG_MASK_CLIENT)
200 if (write (fd, &evinfo->client, sizeof (EvlogClient)) == -1)
202 XDBG_ERROR (MXDBG, "failed: write client\n");
206 if (evinfo->mask & EVLOG_MASK_REQUEST)
208 if (write (fd, &evinfo->req, sizeof (EvlogRequest)) == -1)
210 XDBG_ERROR (MXDBG, "failed: write request\n");
213 if (write (fd, evinfo->req.ptr, (evinfo->req.length * 4)) == -1)
215 XDBG_ERROR (MXDBG, "failed: write request\n");
219 if (evinfo->mask & EVLOG_MASK_EVENT)
221 if (write (fd, &evinfo->evt, sizeof (EvlogEvent)) == -1)
223 XDBG_ERROR (MXDBG, "failed: write event\n");
227 XDBG_WARNING_IF_FAIL (evinfo->evt.size > 0);
228 if (write (fd, evinfo->evt.ptr, evinfo->evt.size) == -1)
230 XDBG_ERROR (MXDBG, "failed: write event\n");
234 if (evinfo->mask & EVLOG_MASK_REPLY)
236 if (write (fd, &evinfo->rep, sizeof (EvlogReply)) == -1)
238 XDBG_ERROR (MXDBG, "failed: write reply\n");
242 XDBG_WARNING_IF_FAIL (evinfo->rep.size > 0);
243 if (write (fd, evinfo->rep.ptr, evinfo->rep.size) == -1)
245 XDBG_ERROR (MXDBG, "failed: write reply\n");
249 if (evinfo->mask & EVLOG_MASK_ERROR)
251 if (write (fd, &evinfo->err, sizeof (EvlogError)) == -1)
253 XDBG_ERROR (MXDBG, "failed: write reply\n");
258 if (evinfo->mask & EVLOG_MASK_ATOM)
260 EvlogAtomTable *table = NULL;
262 if (write (fd, &evinfo->evatom.size, sizeof (int)) == -1)
264 XDBG_ERROR (MXDBG, "failed: write atom size\n");
267 xorg_list_for_each_entry(table, &evinfo->evatom.list, link)
268 if (write (fd, table, sizeof (EvlogAtomTable)) == -1)
270 XDBG_ERROR (MXDBG, "failed: write atom table\n");
275 if (evinfo->mask & EVLOG_MASK_REGION)
277 EvlogRegionTable *table = NULL;
279 if (write (fd, &evinfo->evregion.size, sizeof (int)) == -1)
281 XDBG_ERROR (MXDBG, "failed: write region size\n");
284 xorg_list_for_each_entry(table, &evinfo->evregion.list, link)
285 if (write (fd, table, sizeof (EvlogRegionTable)) == -1)
287 XDBG_ERROR (MXDBG, "failed: write region table\n");
293 static void evtPrintF (int fd, EvlogInfo *evinfo, char *log)
298 dprintf (fd, "%s", log);
301 static void evtPrint (EvlogType type, ClientPtr client, xEvent *ev, ReplyInfoRec *rep)
303 EvlogInfo evinfo = {0,};
304 static int EntryInit = 0;
312 ModuleClientInfo *info = GetClientInfo (client);
313 XDBG_RETURN_IF_FAIL (info != NULL);
316 evinfo.mask |= EVLOG_MASK_CLIENT;
317 evinfo.client.index = info->index;
318 evinfo.client.pid = info->pid;
319 evinfo.client.gid = info->gid;
320 evinfo.client.uid = info->uid;
322 min = MIN (sizeof (evinfo.client.command) - 1, strlen (info->command));
323 strncpy (evinfo.client.command, info->command, min);
324 evinfo.client.command[min] = '\0';
326 evinfo.client.pClient = (void*)client;
335 evinfo.mask |= EVLOG_MASK_REQUEST;
336 evinfo.req.id = stuff->reqType;
337 evinfo.req.length = client->req_len;
338 evinfo.req.ptr = client->requestBuffer;
340 if (client->requestVector == InitialVector && stuff->reqType == 1)
341 snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s", conn[0]);
342 else if (client->requestVector == InitialVector && stuff->reqType == 2)
343 snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s", conn[1]);
346 if (stuff->reqType < EXTENSION_BASE)
347 snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s",
348 LookupRequestName (stuff->reqType, 0));
350 snprintf (evinfo.req.name, sizeof (evinfo.req.name), "%s",
351 LookupRequestName (stuff->reqType, stuff->data));
360 evinfo.mask |= EVLOG_MASK_REPLY;
361 evinfo.rep.reqType = stuff->reqType;
362 evinfo.rep.reqData = stuff->data;
363 evinfo.rep.ptr = (xGenericReply*)rep->replyData;
364 evinfo.rep.size = rep->dataLenBytes - rep->padBytes;
365 evinfo.rep.isStart = rep->startOfReply;
367 if (stuff->reqType < EXTENSION_BASE)
368 snprintf (evinfo.rep.name, sizeof (evinfo.rep.name), "%s",
369 LookupRequestName (stuff->reqType, 0));
371 snprintf (evinfo.rep.name, sizeof (evinfo.rep.name), "%s",
372 LookupRequestName (stuff->reqType, stuff->data));
375 if (type == ERROR || type == XERROR)
382 err = (xError *) rep->replyData;
386 evinfo.mask |= EVLOG_MASK_ERROR;
387 evinfo.err.errorCode = err->errorCode;
388 evinfo.err.resourceID = err->resourceID;
389 evinfo.err.minorCode = err->minorCode;
390 evinfo.err.majorCode = err->majorCode;
391 snprintf (evinfo.err.errorName, sizeof (evinfo.err.errorName), "%s",
392 LookupErrorName(err->errorCode));
393 snprintf (evinfo.err.majorName, sizeof (evinfo.err.majorName), "%s",
394 LookupMajorName(err->majorCode));
397 XDBG_NEVER_GET_HERE (MXDBG);
406 evinfo.mask |= EVLOG_MASK_EVENT;
408 snprintf (evinfo.evt.name, sizeof (evinfo.evt.name), "%s",
409 LookupEventName ((int)(ev->u.u.type)));
414 evinfo.time = GetTimeInMillis ();
416 /* get extension entry */
417 if (!EntryInit && !xDbgEvlogGetExtensionEntry ())
422 if (!xDbgEvlogRuleValidate (&evinfo))
428 int size = sizeof (log);
430 if (xDbgEvlogFillLog (&evinfo, xev_trace_detail_level, log, &size))
431 xErrorPrint (&evinfo, "%s", log);
433 else if (xev_trace_record_fd >= 0)
435 if (xDbgEvlogFillLog (&evinfo, EVLOG_PRINT_REPLY_DETAIL, NULL, NULL))
436 evtRecord (xev_trace_record_fd, &evinfo);
441 int size = sizeof (log);
443 if (xDbgEvlogFillLog (&evinfo, xev_trace_detail_level, log, &size))
444 evtPrintF (xev_trace_fd, &evinfo, log);
447 /* evatom initialize */
448 xDbgDistroyAtomList(&evinfo);
449 xDbgDistroyRegionList(&evinfo);
452 #if (TIZEN_ENGINEER_MODE || USE_NORMAL_LOG)
454 _traceGetWindowName (ClientPtr client, Window window)
458 Mask win_mode = DixGetPropAccess, prop_mode = DixReadAccess;
461 static char winname[128];
464 rc = dixLookupWindow (&pWin, window, client, win_mode);
468 property = MakeAtom ("WM_NAME", strlen ("WM_NAME"), TRUE);
471 rc = dixLookupProperty (&pProp, pWin, property, client, prop_mode);
472 if (rc == Success && pProp->data)
474 datalen = (pProp->size>127) ?127:pProp->size;
475 strncpy (winname, pProp->data, datalen);
476 winname[datalen] = 0;
489 _traceFlush (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
491 if (xev_trace_on == FALSE)
494 evtPrint (FLUSH, NULL, NULL, NULL);
498 _traceAReply (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
500 if (xev_trace_on == FALSE)
503 ReplyInfoRec *pri = (ReplyInfoRec*)calldata;
505 evtPrint (REPLY, pri->client, NULL, pri);
509 _traceEvent (CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
511 EventInfoRec *pei = (EventInfoRec*)calldata;
513 ModuleClientInfo *info;
514 int ev; /* event index */
515 static int xi2_opcode = -1;
518 #if (TIZEN_ENGINEER_MODE || USE_NORMAL_LOG)
519 static char* ename[]=
528 XDBG_RETURN_IF_FAIL (pei != NULL);
530 pClient = pei->client;
531 XDBG_RETURN_IF_FAIL (pClient != NULL);
534 XDBG_RETURN_IF_FAIL (pev != NULL);
536 info = GetClientInfo (pClient);
537 XDBG_RETURN_IF_FAIL (info != NULL);
539 for (ev=0; ev < pei->count; ev++, pev++)
541 int type = pev->u.u.type & 0177;
543 if (type < LASTEvent)
549 XDBG_SECURE (MXDBG, "%s(%d)_%d(%s.%d : %s.0x%x) root(%d,%d) win(%d,%d)\n"
550 , ename[type-KeyPress], pev->u.u.detail, pev->u.u.type
551 , info->command, info->pid
552 , _traceGetWindowName (pClient, pev->u.keyButtonPointer.event), (unsigned int)pev->u.keyButtonPointer.event
553 , pev->u.keyButtonPointer.rootX, pev->u.keyButtonPointer.rootY
554 , pev->u.keyButtonPointer.eventX, pev->u.keyButtonPointer.eventY);
559 XDBG_SECURE (MXDBG, "%s(%d)_%d(%s.%d : %s.0x%x) root(%d,%d) win(%d,%d)\n"
560 , ename[type-KeyPress], pev->u.u.detail, pev->u.u.type
561 , info->command, info->pid
562 , _traceGetWindowName (pClient, pev->u.keyButtonPointer.event), (unsigned int)pev->u.keyButtonPointer.event
563 , pev->u.keyButtonPointer.rootX, pev->u.keyButtonPointer.rootY
564 , pev->u.keyButtonPointer.eventX, pev->u.keyButtonPointer.eventY);
567 if(!xi2_opcode) break;
570 ExtensionEntry *pExt = CheckExtension("XInputExtension");
571 if(!pExt) xi2_opcode = 0;
572 else xi2_opcode = pExt->base;
575 if(((xGenericEvent*)pev)->extension != xi2_opcode) break;
577 xXIDeviceEvent *xidev = (xXIDeviceEvent *)pev;
578 if(xidev->deviceid==2) break;
579 if(xidev->evtype==XI_ButtonPress)
580 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));
581 else if(xidev->evtype==XI_ButtonRelease)
582 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));
583 else if(xidev->evtype==XI_Motion)
584 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));
591 if (type == X_Error && xerror_path)
592 evtPrint (XERROR, pClient, pev, NULL);
594 if (type != X_Error && xev_trace_on)
595 evtPrint (EVENT, pClient, pev, NULL);
596 else if (type == X_Error && xev_trace_on)
597 evtPrint (ERROR, pClient, pev, NULL);
603 _traceACoreEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
605 if (xev_trace_on == FALSE)
608 XaceCoreDispatchRec *rec = calldata;
610 XDBG_RETURN_IF_FAIL (rec != NULL);
612 evtPrint (REQUEST, rec->client, NULL, NULL);
616 _traceAExtEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
618 if (xev_trace_on == FALSE)
621 XaceExtAccessRec *rec = calldata;
623 XDBG_RETURN_IF_FAIL (rec != NULL);
625 evtPrint (REQUEST, rec->client, NULL, NULL);
629 _traceAuditEndEvents (CallbackListPtr *pcbl, pointer unused, pointer calldata)
635 _traceProperty (CallbackListPtr *pcbl, pointer unused, pointer calldata)
637 XacePropertyAccessRec *rec = calldata;
638 ModuleClientInfo *info = GetClientInfo (rec->client);
639 PropertyPtr pProp = *rec->ppProp;
640 Atom name = pProp->propertyName;
642 /* Don't care about the new content check */
643 if (rec->client == serverClient || rec->access_mode & DixPostAccess)
646 if (name == atom_client_pid && (rec->access_mode & DixWriteAccess))
648 XDBG_WARNING (MXDBG, "Invalid access X_CLINET_PID pid:%d, uid:%d\n", info->pid, info->uid);
649 rec->status = BadAccess;
653 rec->status = Success;
658 _traceResource (CallbackListPtr *pcbl, pointer unused, pointer calldata)
660 XaceResourceAccessRec *rec = calldata;
661 Mask access_mode = rec->access_mode;
662 ModuleClientInfo *info = GetClientInfo (rec->client);
664 /* Perform the background none check on windows */
665 if (access_mode & DixCreateAccess && rec->rtype == RT_WINDOW)
667 WindowPtr pWin = (WindowPtr) rec->res;
671 rc = dixChangeWindowProperty (serverClient,
672 pWin, atom_client_pid, XA_CARDINAL, 32,
673 PropModeReplace, 1, &pid, FALSE);
675 XDBG_ERROR (MXDBG, "failed : set X_CLIENT_PID to %d.\n", pid);
680 _traceReceive (CallbackListPtr *pcbl, pointer unused, pointer calldata)
682 XaceReceiveAccessRec *rec = calldata;
684 if (rec->events->u.u.type != VisibilityNotify)
687 rec->status = BadAccess;
691 xDbgModuleEvlogInstallHooks (XDbgModule *pMod)
695 ret &= AddCallback (&EventCallback, _traceEvent, NULL);
696 ret &= XaceRegisterCallback (XACE_PROPERTY_ACCESS, _traceProperty, NULL);
697 ret &= XaceRegisterCallback (XACE_RESOURCE_ACCESS, _traceResource, NULL);
699 /*Disable Visibility Event*/
700 ret &= XaceRegisterCallback (XACE_RECEIVE_ACCESS, _traceReceive, NULL);
702 if (atom_client_pid == None)
703 atom_client_pid = MakeAtom ("X_CLIENT_PID", 12, TRUE);
707 XDBG_ERROR (MXDBG, "failed: register one or more callbacks\n");
715 xDbgModuleEvlogUninstallHooks (XDbgModule *pMod)
717 DeleteCallback (&EventCallback, _traceEvent, NULL);
718 XaceDeleteCallback (XACE_PROPERTY_ACCESS, _traceProperty, NULL);
719 XaceDeleteCallback (XACE_RESOURCE_ACCESS, _traceResource, NULL);
723 xDbgModuleEvlogPrintEvents (XDbgModule *pMod, Bool on, const char * client_name, char *reply, int *len)
727 on = (on)?TRUE:FALSE;
728 if (xev_trace_on == on)
738 for (i=1 ; i< currentMaxClients ; i++)
741 ModuleClientInfo *info;
743 pClient = clients[i];
747 info = GetClientInfo (pClient);
751 if (strlen (info->command) > 0 && strstr (client_name, info->command))
755 if (xev_trace_fd >= 0)
756 close (xev_trace_fd);
758 snprintf (fd_name, 256, "/proc/%d/fd/1", info->pid);
759 xev_trace_fd = open (fd_name, O_RDWR);
760 if (xev_trace_fd < 0)
762 char err_buf[256] = {0,};
765 errp = (char *)strerror_r (errno, err_buf, sizeof(err_buf));
766 XDBG_REPLY ("failed: open consol '%s'. (%s)\n", fd_name, errp);
771 ret &= AddCallback (&FlushCallback, _traceFlush, NULL);
772 ret &= AddCallback (&ReplyCallback, _traceAReply, NULL);
773 ret &= XaceRegisterCallback (XACE_CORE_DISPATCH, _traceACoreEvents, NULL);
774 ret &= XaceRegisterCallback (XACE_EXT_DISPATCH, _traceAExtEvents, NULL);
775 ret &= XaceRegisterCallback (XACE_AUDIT_END, _traceAuditEndEvents, NULL);
779 XDBG_REPLY ("failed: register one or more callbacks.\n");
785 DeleteCallback (&FlushCallback, _traceFlush, NULL);
786 DeleteCallback (&ReplyCallback, _traceAReply, NULL);
787 XaceDeleteCallback (XACE_CORE_DISPATCH, _traceACoreEvents, NULL);
788 XaceDeleteCallback (XACE_EXT_DISPATCH, _traceAExtEvents, NULL);
789 XaceDeleteCallback (XACE_AUDIT_END, _traceAuditEndEvents, NULL);
796 xDbgModuleEvlogDetail (XDbgModule *pMod, int level, char *reply, int *len)
798 xev_trace_detail_level = level;
802 xDbgModuleEvlogInfoSetRule (XDbgModule *pMod, const int argc, const char ** argv, char *reply, int *len)
804 return xDbgEvlogRuleSet (argc, argv, reply, len);
808 xDbgModuleEvlogSetEvlogPath (XDbgModule *pMod, int pid, char *path, char *reply, int *len)
810 char fd_name[XDBG_PATH_MAX];
813 if (!path || strlen (path) <= 0)
816 if (xev_trace_record_fd >= 0)
818 close (xev_trace_record_fd);
819 xev_trace_record_fd = -1;
824 free (pMod->log_path);
825 pMod->log_path = NULL;
828 if (!strcmp (path, "console"))
834 if (xev_trace_fd >= 0)
835 close (xev_trace_fd);
837 snprintf (fd_name, sizeof (fd_name), "/proc/%d/fd/1", pid);
839 xev_trace_fd = open (fd_name, O_RDWR);
840 if (xev_trace_fd < 0)
842 char err_buf[256] = {0,};
845 errp = (char *)strerror_r (errno, err_buf, sizeof(err_buf));
846 XDBG_REPLY ("failed: open consol '%s'. (%s)\n", fd_name, errp);
849 pMod->evlog_path = strdup (fd_name);
856 snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
860 snprintf (fd_name, XDBG_PATH_MAX, "%s/%s", pMod->cwd, path);
862 snprintf (fd_name, XDBG_PATH_MAX, "%s", path);
865 pMod->evlog_path = strdup (fd_name);
867 fd_check = open (fd_name, O_RDONLY);
873 xev_trace_record_fd = open (fd_name, O_CREAT|O_RDWR|O_APPEND, 0755);
874 if (xev_trace_record_fd < 0)
876 char err_buf[256] = {0,};
879 errp = (char *)strerror_r (errno, err_buf, sizeof(err_buf));
880 XDBG_REPLY ("failed: open file '%s'. (%s)\n", fd_name, errp);