Module: xenomai-jki
Branch: forge-tracing
Commit: 1bf921fd6e339779b260c3d42028eac5c426001e
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=1bf921fd6e339779b260c3d42028eac5c426001e

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Oct 31 15:35:19 2013 +0100

cobalt/kernel: Instrument syscalls

---

 include/ftrace/xn_sys.h      | 1405 ++++++++++++++++++++++++++++++++++++++++++
 kernel/cobalt/posix/clock.c  |   13 +
 kernel/cobalt/posix/mutex.c  |    4 +
 kernel/cobalt/posix/nsem.c   |   10 +
 kernel/cobalt/posix/sem.c    |   26 +
 kernel/cobalt/posix/sem.h    |    1 +
 kernel/cobalt/posix/thread.c |   30 +
 kernel/cobalt/shadow.c       |    1 +
 8 files changed, 1490 insertions(+)

diff --git a/include/ftrace/xn_sys.h b/include/ftrace/xn_sys.h
new file mode 100644
index 0000000..c7cd09a
--- /dev/null
+++ b/include/ftrace/xn_sys.h
@@ -0,0 +1,1405 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xn_sys
+
+#if !defined(_TRACE_XN_SYS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_XN_SYS_H
+
+#include <linux/tracepoint.h>
+#include <cobalt/uapi/sched.h>
+#include <cobalt/uapi/thread.h>
+#include <cobalt/uapi/time.h>
+
+#include <../kernel/xenomai/posix/registry.h>
+#include <../kernel/xenomai/posix/sem.h>
+#include <../kernel/xenomai/posix/mutex.h>
+
+#define __timespec_fields(name)                                        \
+       __field(__kernel_time_t, tv_sec_##name)                 \
+       __field(long, tv_nsec_##name)
+
+#if 0
+#define __optional_timespec_fields(name)                       \
+       __field(int, using_##name)                              \
+       __timespec_fields(name)
+#endif
+
+#define __assign_timespec(to, from)                            \
+       do {                                                    \
+               __entry->tv_sec_##to = (from)->tv_sec;          \
+               __entry->tv_nsec_##to = (from)->tv_nsec;        \
+       } while (0)
+
+#if 0
+#define __assign_optional_timespec(to, from)                   \
+       do {                                                    \
+               __entry->using_##to = (from != NULL);           \
+               if (from)                                       \
+                       __assign_timespec(to, from);            \
+               else {                                          \
+                       __entry->tv_sec_##to = 0;               \
+                       __entry->tv_nsec_##to = 0;              \
+               }                                               \
+       } while (0)
+#endif
+
+#define __timespec_args(name)                                  \
+       __entry->tv_sec_##name, __entry->tv_nsec_##name
+
+#if 0
+#define __timespec_used(name)                                  \
+       __entry->using_##name ? "used" : "unused"
+#endif
+
+#define show_thread_mode(mode)                                 \
+       __print_flags(mode, "|",                                \
+                     {PTHREAD_WARNSW, "warnsw"},               \
+                     {PTHREAD_LOCK_SCHED, "lock"},             \
+                     {PTHREAD_DISABLE_LOCKBREAK, "nolockbreak"})
+
+#define __thread_mode_args(name)                               \
+        __entry->name, show_thread_mode(__entry->name)
+
+#define show_sched_policy(policy)                              \
+       __print_symbolic(policy,                                \
+                        {SCHED_NORMAL, "normal"},              \
+                        {SCHED_FIFO, "fifo"},                  \
+                        {SCHED_RR, "rr"},                      \
+                        {SCHED_SPORADIC, "sporadic"},          \
+                        {SCHED_COBALT, "cobalt"},              \
+                        {SCHED_WEAK, "weak"})
+
+#define __sched_policy_args(name)                              \
+        __entry->name, show_sched_policy(__entry->name)
+
+#if 0
+#define show_protocol(protocol)                                                
\
+       __print_symbolic(protocol,                                      \
+                        {PTHREAD_PRIO_NONE, "prio-none"},              \
+                        {PTHREAD_PRIO_INHERIT, "prio-inherit"},        \
+                        {PTHREAD_PRIO_PROTECT, "prio-protect"})
+
+#define __protocol_args()                                      \
+        __entry->protocol, show_protocol(__entry->protocol)
+
+#define show_type(type)                                                        
\
+       __print_symbolic(type,                                          \
+                        {PTHREAD_MUTEX_NORMAL, "normal"},              \
+                        {PTHREAD_MUTEX_RECURSIVE, "recursive"},        \
+                        {PTHREAD_MUTEX_ERRORCHECK, "errorcheck"})
+
+#define __type_args()                                          \
+        __entry->type, show_type(__entry->type)
+
+#define show_pshared(pshared)                                  \
+       __print_symbolic(pshared,                               \
+                        {PTHREAD_PROCESS_PRIVATE, "private"},  \
+                        {PTHREAD_PROCESS_SHARED, "shared"})
+
+#define __pshared_args()                                       \
+        __entry->pshared, show_pshared(__entry->pshared)
+
+#define show_sigev_notify(notify)                              \
+       __print_symbolic(notify,                                \
+                        {SIGEV_NONE, "none"},                  \
+                        {SIGEV_SIGNAL, "signal"})
+
+#define __sigev_notify_args()                                  \
+        __entry->notify, show_sigev_notify(__entry->notify)
+
+#define show_intr_mode(mode)                                   \
+       __print_flags(mode, "|",                                \
+                     {PTHREAD_INOAUTOENA, "inoautoena"},       \
+                     {PTHREAD_IPROPAGATE, "ipropagate"})
+
+#define __intr_mode_args()                                     \
+        __entry->mode, show_intr_mode(__entry->mode)
+
+#define show_intr_cmd(cmd)                                     \
+       __print_symbolic(cmd,                                   \
+                        {PTHREAD_IENABLE, "ienable"},          \
+                        {PTHREAD_IDISABLE, "idisable"})
+
+#define __intr_cmd_args()                                      \
+        __entry->cmd, show_intr_cmd(__entry->cmd)
+#endif
+
+#define show_oflags(flags)                                     \
+       __print_flags(flags,  "|",                              \
+                     {O_RDONLY, "rdonly"},                     \
+                     {O_WRONLY, "wronly"},                     \
+                     {O_RDWR, "rdwr"},                         \
+                     {O_CREAT, "creat"},                       \
+                     {O_EXCL, "excl"},                         \
+                     {O_DIRECT, "direct"},                     \
+                     {O_NONBLOCK, "nonblock"},                 \
+                     {O_TRUNC, "trunc"})
+
+#define __oflags_args(name)                                    \
+       __entry->name, show_oflags(__entry->name)
+
+#define show_sem_flags(flags)                                  \
+       __print_symbolic(flags,                                 \
+                        {SEM_FIFO, "fifo"},                    \
+                        {SEM_PULSE, "puls"},                   \
+                        {SEM_PSHARED, "pshared"},              \
+                        {SEM_REPORT, "report"},                \
+                        {SEM_WARNDEL, "warndel"},              \
+                        {SEM_RAWCLOCK, "rawclock"},            \
+                        {SEM_NOBUSYDEL, "nobusydel"})
+
+#define __sem_flags_args(name)                                 \
+        __entry->name, show_sem_flags(__entry->name)
+
+#define show_clock(clock_id)                                   \
+       __print_symbolic(clock_id,                              \
+                        {CLOCK_REALTIME, "realtime"},          \
+                        {CLOCK_MONOTONIC, "monotonic"},        \
+                        {CLOCK_MONOTONIC_RAW, "monotonic-raw"}, \
+                        {CLOCK_HOST_REALTIME, "host-realtime"})
+
+#define __clock_args(name)                                     \
+       __entry->name, show_clock(__entry->name)
+
+#define show_clock_mode(mode)                                  \
+       __print_symbolic(mode,                                  \
+                        {0, "reltime"},                        \
+                        {TIMER_ABSTIME, "abstime"})
+
+#define __clock_mode_args(name)                                        \
+        __entry->name, show_clock_mode(__entry->name)
+
+DECLARE_EVENT_CLASS(sys_void,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy),
+       TP_STRUCT__entry(
+               __array(char, dummy, 0)
+       ),
+       TP_fast_assign(
+               (void)dummy;
+       ),
+       TP_printk("%s", "")
+);
+
+DECLARE_EVENT_CLASS(sys_name,
+       TP_PROTO(char *name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(
+               __string(name, name)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+       ),
+       TP_printk("name=%s", __get_str(name))
+);
+
+#if 0
+DECLARE_EVENT_CLASS(posix_fd,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(
+               __field(int, fd)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+       ),
+       TP_printk("fd=%d", __entry->fd)
+);
+
+DECLARE_EVENT_CLASS(posix_timespec,
+       TP_PROTO(struct timespec *ts),
+       TP_ARGS(ts),
+       TP_STRUCT__entry(
+               __timespec_fields(ts)
+       ),
+       TP_fast_assign(
+               __assign_timespec(ts, ts);
+       ),
+       TP_printk("time={%ld.%09ld}", __timespec_args(ts))
+);
+#endif
+
+/*
+ * Threads management services.
+ */
+DECLARE_EVENT_CLASS(sys_thread_schedparam,
+       TP_PROTO(unsigned long pth, int policy, struct sched_param_ex *param),
+       TP_ARGS(pth, policy, param),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __field(int, policy)
+               __field(int, priority)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __entry->policy = policy;
+               __entry->priority = param->sched_priority;
+               /* TODO: trace policy-specific parameters */
+       ),
+       TP_printk("pth=%p policy=%d(%s) priority=%d",
+               (void *)__entry->pth, __sched_policy_args(policy),
+               __entry->priority)
+);
+
+DEFINE_EVENT(sys_thread_schedparam, xn_sys_thread_create,
+       TP_PROTO(unsigned long pth, int policy, struct sched_param_ex *param),
+       TP_ARGS(pth, policy, param)
+);
+
+DEFINE_EVENT(sys_thread_schedparam, xn_sys_thread_setschedparam,
+       TP_PROTO(unsigned long pth, int policy, struct sched_param_ex *param),
+       TP_ARGS(pth, policy, param)
+);
+
+DEFINE_EVENT(sys_thread_schedparam, xn_sys_thread_getschedparam,
+       TP_PROTO(unsigned long pth, int policy, struct sched_param_ex *param),
+       TP_ARGS(pth, policy, param)
+);
+
+DEFINE_EVENT(sys_void, xn_sys_sched_yield,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy)
+);
+
+TRACE_EVENT(xn_sys_thread_make_periodic_np,
+       TP_PROTO(unsigned long pth, struct timespec *start,
+               struct timespec *period),
+       TP_ARGS(pth, start, period),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __timespec_fields(start)
+               __timespec_fields(period)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __assign_timespec(start, start);
+               __assign_timespec(period, period);
+       ),
+       TP_printk("pth=%p date=%ld.%09ld period=%ld.%09ld",
+               (void *)__entry->pth, __timespec_args(start),
+               __timespec_args(period))
+);
+
+DEFINE_EVENT(sys_void, xn_sys_thread_wait_np,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy)
+);
+
+TRACE_EVENT(xn_sys_thread_wait_np_return,
+       TP_PROTO(unsigned long overruns),
+       TP_ARGS(overruns),
+       TP_STRUCT__entry(
+               __field(unsigned long, overruns)
+       ),
+       TP_fast_assign(
+               __entry->overruns = overruns;
+       ),
+       TP_printk("overruns=%ld", __entry->overruns)
+);
+
+TRACE_EVENT(xn_sys_thread_set_mode_np,
+       TP_PROTO(int clrmask, int setmask),
+       TP_ARGS(clrmask, setmask),
+       TP_STRUCT__entry(
+               __field(int, clrmask)
+               __field(int, setmask)
+       ),
+       TP_fast_assign(
+               __entry->clrmask = clrmask;
+               __entry->setmask = setmask;
+       ),
+       TP_printk("clrmask=%#x(%s) setmask=%#x(%s)",
+               __thread_mode_args(clrmask), __thread_mode_args(setmask))
+);
+
+TRACE_EVENT(xn_sys_thread_set_name_np,
+       TP_PROTO(unsigned long pth, char *name),
+       TP_ARGS(pth, name),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __string(name, name)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __assign_str(name, name);
+       ),
+       TP_printk("pth=%p name=%s", (void *)__entry->pth, __get_str(name))
+);
+
+DECLARE_EVENT_CLASS(sys_pid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(
+               __field(pid_t, pid)
+       ),
+       TP_fast_assign(
+               __entry->pid = pid;
+       ),
+       TP_printk("pid=%d", __entry->pid)
+);
+
+DEFINE_EVENT(sys_pid, xn_sys_thread_probe_np,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid)
+);
+
+TRACE_EVENT(xn_sys_thread_kill,
+       TP_PROTO(unsigned long pth, int sig),
+       TP_ARGS(pth, sig),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __field(int, sig)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __entry->sig = sig;
+       ),
+       TP_printk("pth=%p sig=%d", (void *)__entry->pth, __entry->sig)
+);
+
+TRACE_EVENT(xn_sys_thread_join,
+       TP_PROTO(unsigned long pth),
+       TP_ARGS(pth),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+       ),
+       TP_printk("pth=%p", (void *)__entry->pth)
+);
+
+DEFINE_EVENT(sys_pid, xn_sys_thread_stat,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid)
+);
+
+/*
+ * Semaphores services.
+ */
+DECLARE_EVENT_CLASS(sys_sem,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle),
+       TP_STRUCT__entry(
+               __field(xnhandle_t, handle)
+       ),
+       TP_fast_assign(
+               __entry->handle = handle;
+       ),
+       TP_printk("sem=%lx", __entry->handle)
+);
+
+TRACE_EVENT(xn_sys_sem_init,
+       TP_PROTO(int flags, unsigned value),
+       TP_ARGS(flags, value),
+       TP_STRUCT__entry(
+               __field(int, flags)
+               __field(unsigned int, value)
+       ),
+       TP_fast_assign(
+               __entry->flags = flags;
+               __entry->value = value;
+       ),
+       TP_printk("flags=%x(%s) value=%u",
+               __sem_flags_args(flags), __entry->value)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_init_return,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_destroy,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_post,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_wait,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+TRACE_EVENT(xn_sys_sem_timedwait,
+       TP_PROTO(xnhandle_t handle, const struct timespec __user *timeout),
+       TP_ARGS(handle, timeout),
+       TP_STRUCT__entry(
+               __field(xnhandle_t, handle)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->handle = handle;
+               __xn_safe_copy_from_user(&__entry->tv_sec_timeout,
+                       &timeout->tv_sec, sizeof(__entry->tv_sec_timeout));
+               __xn_safe_copy_from_user(&__entry->tv_nsec_timeout,
+                       &timeout->tv_nsec, sizeof(__entry->tv_nsec_timeout));
+       ),
+       TP_printk("sem=%lx timeout=%ld.%09ld", __entry->handle,
+               __timespec_args(timeout))
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_trywait,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_getvalue,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+TRACE_EVENT(xn_sys_sem_getvalue_return,
+       TP_PROTO(xnhandle_t handle, int value),
+       TP_ARGS(handle, value),
+       TP_STRUCT__entry(
+               __field(xnhandle_t, handle)
+               __field(int, value)
+       ),
+       TP_fast_assign(
+               __entry->handle = handle;
+               __entry->value = value;
+       ),
+       TP_printk("sem=%lx value=%d", __entry->handle, __entry->value)
+);
+
+TRACE_EVENT(xn_sys_sem_open,
+       TP_PROTO(const char *name, int oflags, mode_t mode,
+                unsigned int value),
+       TP_ARGS(name, oflags, mode, value),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(int, oflags)
+               __field(mode_t, mode)
+               __field(unsigned int, value)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->oflags = oflags;
+               if (oflags & O_CREAT) {
+                       __entry->mode = mode;
+                       __entry->value = value;
+               } else {
+                       __entry->mode = 0;
+                       __entry->value = 0;
+               }
+       ),
+       TP_printk("name=%s oflags=%#x(%s) mode=%o value=%u",
+               __get_str(name), __oflags_args(oflags), __entry->mode,
+               __entry->value)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_open_return,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_close,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(sys_name, xn_sys_sem_unlink,
+       TP_PROTO(char *name),
+       TP_ARGS(name)
+);
+
+DEFINE_EVENT(sys_sem, xn_sys_sem_broadcast_np,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+/*
+ * Clocks and timers services.
+ */
+DECLARE_EVENT_CLASS(sys_clock_timespec,
+       TP_PROTO(unsigned long clock_id, struct timespec *ts),
+       TP_ARGS(clock_id, ts),
+       TP_STRUCT__entry(
+               __field(unsigned long, clock_id)
+               __timespec_fields(ts)
+       ),
+       TP_fast_assign(
+               __entry->clock_id = clock_id;
+               __assign_timespec(ts, ts);
+       ),
+       TP_printk("clockid=%ld(%s) time=%ld.%09ld", __clock_args(clock_id),
+               __timespec_args(ts))
+);
+
+#if 0
+DECLARE_EVENT_CLASS(posix_timer,
+       TP_PROTO(unsigned long timer),
+       TP_ARGS(timer),
+       TP_STRUCT__entry(
+               __field(unsigned long, timer)
+       ),
+       TP_fast_assign(
+               __entry->timer = timer;
+       ),
+       TP_printk("timerid=%ld", __entry->timer)
+);
+
+DECLARE_EVENT_CLASS(posix_timer_timespec,
+       TP_PROTO(unsigned long timer, struct itimerspec *itimer),
+       TP_ARGS(timer, itimer),
+       TP_STRUCT__entry(
+               __field(unsigned long, timer)
+               __timespec_fields(interval)
+               __timespec_fields(value)
+       ),
+       TP_fast_assign(
+               __entry->timer = timer;
+               __assign_timespec(interval, &itimer->it_interval);
+               __assign_timespec(value, &itimer->it_value);
+       ),
+       TP_printk("timerid=%ld "
+               "itimer.interval=%ld.%09ld itimer.value=%ld.%09ld",
+               __entry->timer, __timespec_args(interval),
+               __timespec_args(value))
+);
+#endif
+
+DEFINE_EVENT(sys_clock_timespec, xn_sys_clock_getres,
+       TP_PROTO(unsigned long clock_id, struct timespec *ts),
+       TP_ARGS(clock_id, ts)
+);
+
+DEFINE_EVENT(sys_clock_timespec, xn_sys_clock_gettime,
+       TP_PROTO(unsigned long clock_id, struct timespec *ts),
+       TP_ARGS(clock_id, ts)
+);
+
+DEFINE_EVENT(sys_clock_timespec, xn_sys_clock_settime,
+       TP_PROTO(unsigned long clock_id, struct timespec *ts),
+       TP_ARGS(clock_id, ts)
+);
+
+TRACE_EVENT(xn_sys_clock_nanosleep,
+       TP_PROTO(unsigned long clock_id, int flags, struct timespec *ts),
+       TP_ARGS(clock_id, flags, ts),
+       TP_STRUCT__entry(
+               __field(unsigned long, clock_id)
+               __field(int, flags)
+               __timespec_fields(ts)
+       ),
+       TP_fast_assign(
+               __entry->clock_id = clock_id;
+               __entry->flags = flags;
+               __assign_timespec(ts, ts);
+       ),
+       TP_printk("clockid=%ld(%s) flags=%#x(%s) time=%ld.%09ld",
+               __clock_args(clock_id), __clock_mode_args(flags),
+               __timespec_args(ts))
+);
+
+DEFINE_EVENT(sys_clock_timespec, xn_sys_clock_nanosleep_return,
+       TP_PROTO(unsigned long clock_id, struct timespec *ts),
+       TP_ARGS(clock_id, ts)
+);
+
+#if 0
+/* int timer_create(clockid_t clockid, const struct sigevent *evp, timer_t 
*timerid)
+ */
+TRACE_EVENT(xn_posix_timer_create,
+       TP_PROTO(unsigned long clock_id, struct sigevent *evt),
+       TP_ARGS(clock_id, evt),
+       TP_STRUCT__entry(
+               __field(unsigned long, clock_id)
+               __field(int, sigev_signo)
+               __field(int, sigev_notify)
+       ),
+       TP_fast_assign(
+               __entry->clock_id = clock_id;
+               __entry->sigev_signo = evt->sigev_signo;
+               __entry->sigev_notify = evt->sigev_notify;
+       ),
+       TP_printk("clockid=%ld(%s) sigev-signo=%d sigev-notify=%d(%s)",
+               __clock_args(clock_id), __entry->sigev_signo,
+               __sigev_notify_args(sigev_notify))
+);
+
+DEFINE_EVENT(posix_timer, xn_posix_timer_create_return,
+       TP_PROTO(unsigned long timer),
+       TP_ARGS(timer)
+);
+
+/* int timer_delete(timer_t timerid)
+ */
+DEFINE_EVENT(posix_timer, xn_posix_timer_delete,
+       TP_PROTO(unsigned long timer),
+       TP_ARGS(timer)
+);
+
+/* int timer_settime(timer_t timerid, int flags, const struct itimerspec 
*value, struct itimerspec *ovalue)
+ */
+TRACE_EVENT(xn_posix_timer_settime,
+       TP_PROTO(unsigned long timer, int flags, struct itimerspec *itimer),
+       TP_ARGS(timer, flags, itimer),
+       TP_STRUCT__entry(
+               __field(unsigned long, timer)
+               __field(int, flags)
+               __timespec_fields(interval)
+               __timespec_fields(value)
+       ),
+       TP_fast_assign(
+               __entry->timer = timer;
+               __entry->flags = flags;
+               __assign_timespec(interval, &itimer->it_interval);
+               __assign_timespec(value, &itimer->it_value);
+       ),
+       TP_printk("timerid=%ld flags=%#x(%s) "
+               "itimer.interval=%ld.%09ld itimer.value=%ld.%09ld",
+               __entry->timer, __clock_mode_args(flags),
+               __timespec_args(interval), __timespec_args(value))
+);
+
+DEFINE_EVENT(posix_timer_timespec, xn_posix_timer_settime_return,
+       TP_PROTO(unsigned long timer, struct itimerspec *itimer),
+       TP_ARGS(timer, itimer)
+);
+
+/* int timer_gettime(timer_t timerid, struct itimerspec *value)
+ */
+DEFINE_EVENT(posix_timer_timespec, xn_posix_timer_gettime,
+       TP_PROTO(unsigned long timer, struct itimerspec *itimer),
+       TP_ARGS(timer, itimer)
+);
+
+/* int timer_getoverrun(timer_t timerid)
+ */
+DEFINE_EVENT(posix_timer, xn_posix_timer_getoverrun,
+       TP_PROTO(unsigned long timer),
+       TP_ARGS(timer)
+);
+
+/*
+ * Mutex services.
+ */
+DECLARE_EVENT_CLASS(posix_mutexattr,
+       TP_PROTO(pthread_mutexattr_t *attr),
+       TP_ARGS(attr),
+       TP_STRUCT__entry(
+               __field(pthread_mutexattr_t *, attr)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+       ),
+       TP_printk("mutexattr=%p", __entry->attr)
+);
+
+DECLARE_EVENT_CLASS(posix_mutexattr_type,
+       TP_PROTO(pthread_mutexattr_t *attr, int type),
+       TP_ARGS(attr, type),
+       TP_STRUCT__entry(
+               __field(pthread_mutexattr_t *, attr)
+               __field(int, type)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+               __entry->type = type;
+       ),
+       TP_printk("mutexattr=%p type=%d(%s)",
+               __entry->attr, __type_args(type))
+);
+
+DECLARE_EVENT_CLASS(posix_mutexattr_pshared,
+       TP_PROTO(pthread_mutexattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared),
+       TP_STRUCT__entry(
+               __field(pthread_mutexattr_t *, attr)
+               __field(int, pshared)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+               __entry->pshared = pshared;
+       ),
+       TP_printk("mutexattr=%p pshared=%d(%s)",
+               __entry->attr, __pshared_args(pshared))
+);
+
+DECLARE_EVENT_CLASS(posix_mutexattr_protocol,
+       TP_PROTO(pthread_mutexattr_t *attr, int protocol),
+       TP_ARGS(attr, protocol),
+       TP_STRUCT__entry(
+               __field(pthread_mutexattr_t *, attr)
+               __field(int, protocol)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+               __entry->protocol = protocol;
+       ),
+       TP_printk("mutexattr=%p protocol=%d(%s)",
+               __entry->attr, __protocol_args(protocol))
+);
+
+DECLARE_EVENT_CLASS(posix_mutex,
+       TP_PROTO(union __xeno_mutex *mutex),
+       TP_ARGS(mutex),
+       TP_STRUCT__entry(
+               __field(union __xeno_mutex *, mutex)
+       ),
+       TP_fast_assign(
+               __entry->mutex = mutex;
+       ),
+       TP_printk("mutex=%p", __entry->mutex)
+);
+
+/* int pthread_mutexattr_init(pthread_mutexattr_t *attr)
+ */
+DEFINE_EVENT(posix_mutexattr, xn_posix_mutexattr_init,
+       TP_PROTO(pthread_mutexattr_t *attr),
+       TP_ARGS(attr)
+);
+
+/* int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
+ */
+DEFINE_EVENT(posix_mutexattr, xn_posix_mutexattr_destroy,
+       TP_PROTO(pthread_mutexattr_t *attr),
+       TP_ARGS(attr)
+);
+
+/* int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type)
+ */
+DEFINE_EVENT(posix_mutexattr_type, xn_posix_mutexattr_gettype,
+       TP_PROTO(pthread_mutexattr_t *attr, int type),
+       TP_ARGS(attr, type)
+);
+
+/* int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
+ */
+DEFINE_EVENT(posix_mutexattr_type, xn_posix_mutexattr_settype,
+       TP_PROTO(pthread_mutexattr_t *attr, int type),
+       TP_ARGS(attr, type)
+);
+
+/* int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int 
*proto)
+ */
+DEFINE_EVENT(posix_mutexattr_protocol, xn_posix_mutexattr_getprotocol,
+       TP_PROTO(pthread_mutexattr_t *attr, int protocol),
+       TP_ARGS(attr, protocol)
+);
+
+/* int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int proto)
+ */
+DEFINE_EVENT(posix_mutexattr_protocol, xn_posix_mutexattr_setprotocol,
+       TP_PROTO(pthread_mutexattr_t *attr, int protocol),
+       TP_ARGS(attr, protocol)
+);
+
+/* int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int 
*pshared)
+ */
+DEFINE_EVENT(posix_mutexattr_pshared, xn_posix_mutexattr_getpshared,
+       TP_PROTO(pthread_mutexattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared)
+);
+
+/* int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
+ */
+DEFINE_EVENT(posix_mutexattr_pshared, xn_posix_mutexattr_setpshared,
+       TP_PROTO(pthread_mutexattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared)
+);
+#endif
+
+TRACE_EVENT(xn_sys_mutex_init,
+       TP_PROTO(struct cobalt_mutex *mutex, const pthread_mutexattr_t *attr),
+       TP_ARGS(mutex, attr),
+       TP_STRUCT__entry(
+               __field(struct cobalt_mutex *, mutex)
+               __field(unsigned int, type)
+               __field(unsigned int, protocol)
+               __field(unsigned int, pshared)
+       ),
+       TP_fast_assign(
+               __entry->mutex = mutex;
+               __entry->type = attr->type;
+               __entry->protocol = attr->protocol;
+               __entry->pshared = attr->pshared;
+       ),
+       TP_printk("mutex=%p type=%d protocol=%d pshared=%d",
+               __entry->mutex, __entry->type, __entry->protocol,
+               __entry->pshared)
+);
+
+#if 0
+/* int pthread_mutex_destroy(pthread_mutex_t *mx)
+ */
+DEFINE_EVENT(posix_mutex, xn_posix_mutex_destroy,
+       TP_PROTO(union __xeno_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+/* int pthread_mutex_trylock(pthread_mutex_t *mx)
+ */
+DEFINE_EVENT(posix_mutex, xn_posix_mutex_trylock,
+       TP_PROTO(union __xeno_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+/* int pthread_mutex_lock(pthread_mutex_t *mx)
+ */
+DEFINE_EVENT(posix_mutex, xn_posix_mutex_lock,
+       TP_PROTO(union __xeno_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+/* int pthread_mutex_timedlock(pthread_mutex_t *mx, const struct timespec *to)
+ */
+TRACE_EVENT(xn_posix_mutex_timedlock,
+       TP_PROTO(union __xeno_mutex * mutex, const struct timespec *timeout),
+       TP_ARGS(mutex, timeout),
+       TP_STRUCT__entry(
+               __field(union __xeno_mutex *, mutex)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->mutex = mutex;
+               __assign_timespec(timeout, timeout);
+       ),
+       TP_printk("mutex=%p timeout=%ld.%09ld", __entry->mutex,
+               __timespec_args(timeout))
+);
+
+/* int pthread_mutex_unlock(pthread_mutex_t *mx)
+ */
+DEFINE_EVENT(posix_mutex, xn_posix_mutex_unlock,
+       TP_PROTO(union __xeno_mutex *mutex),
+       TP_ARGS(mutex)
+);
+
+/*
+ * Condition variables services.
+ */
+DECLARE_EVENT_CLASS(posix_condattr,
+       TP_PROTO(pthread_condattr_t *attr),
+       TP_ARGS(attr),
+       TP_STRUCT__entry(
+               __field(pthread_condattr_t *, attr)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+       ),
+       TP_printk("condattr=%p", __entry->attr)
+);
+
+DECLARE_EVENT_CLASS(posix_condattr_pshared,
+       TP_PROTO(pthread_condattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared),
+       TP_STRUCT__entry(
+               __field(pthread_condattr_t *, attr)
+               __field(int, pshared)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+               __entry->pshared = pshared;
+       ),
+       TP_printk("condattr=%p pshared=%d(%s)",
+               __entry->attr, __pshared_args(pshared))
+);
+
+DECLARE_EVENT_CLASS(posix_condattr_clock,
+       TP_PROTO(pthread_condattr_t *attr, int clock_id),
+       TP_ARGS(attr, clock_id),
+       TP_STRUCT__entry(
+               __field(pthread_condattr_t *, attr)
+               __field(int, clock_id)
+       ),
+       TP_fast_assign(
+               __entry->attr = attr;
+               __entry->clock_id = clock_id;
+       ),
+       TP_printk("condattr=%p clockid=%d(%s)",
+               __entry->attr, __clock_args(clock_id))
+);
+
+DECLARE_EVENT_CLASS(posix_cond,
+       TP_PROTO(union __xeno_cond *cond),
+       TP_ARGS(cond),
+       TP_STRUCT__entry(
+               __field(union __xeno_cond *, cond)
+       ),
+       TP_fast_assign(
+               __entry->cond = cond;
+       ),
+       TP_printk("cond=%p", __entry->cond)
+);
+
+DECLARE_EVENT_CLASS(posix_cond_wait,
+       TP_PROTO(union __xeno_cond *cond, union __xeno_mutex *mutex),
+       TP_ARGS(cond, mutex),
+       TP_STRUCT__entry(
+               __field(union __xeno_cond*, cond)
+               __field(union __xeno_mutex*, mutex)
+       ),
+       TP_fast_assign(
+               __entry->cond = cond;
+               __entry->mutex = mutex;
+       ),
+       TP_printk("cond=%p mutex=%p", __entry->cond, __entry->mutex)
+);
+
+/* int pthread_condattr_init(pthread_condattr_t *attr)
+ */
+DEFINE_EVENT(posix_condattr, xn_posix_condattr_init,
+       TP_PROTO(pthread_condattr_t *attr),
+       TP_ARGS(attr)
+);
+
+/* int pthread_condattr_destroy(pthread_condattr_t *attr)
+ */
+DEFINE_EVENT(posix_condattr, xn_posix_condattr_destroy,
+       TP_PROTO(pthread_condattr_t *attr),
+       TP_ARGS(attr)
+);
+
+/* int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t 
*clk_id)
+ */
+DEFINE_EVENT(posix_condattr_clock, xn_posix_condattr_getclock,
+       TP_PROTO(pthread_condattr_t *attr, int clock_id),
+       TP_ARGS(attr, clock_id)
+);
+
+/* int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clk_id)
+ */
+DEFINE_EVENT(posix_condattr_clock, xn_posix_condattr_setclock,
+       TP_PROTO(pthread_condattr_t *attr, int clock_id),
+       TP_ARGS(attr, clock_id)
+);
+
+/* int pthread_condattr_getpshared(const pthread_condattr_t *attr, int 
*pshared)
+ */
+DEFINE_EVENT(posix_condattr_pshared, xn_posix_condattr_getpshared,
+       TP_PROTO(pthread_condattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared)
+);
+
+/* int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared)
+ */
+DEFINE_EVENT(posix_condattr_pshared, xn_posix_condattr_setpshared,
+       TP_PROTO(pthread_condattr_t *attr, int pshared),
+       TP_ARGS(attr, pshared)
+);
+
+/* int pthread_cond_init(pthread_cond_t *cnd, const pthread_condattr_t *attr)
+ */
+TRACE_EVENT(xn_posix_cond_init,
+       TP_PROTO(union __xeno_cond *cond, pthread_condattr_t *attr),
+       TP_ARGS(cond, attr),
+       TP_STRUCT__entry(
+               __field(union __xeno_cond *, cond)
+               __field(pthread_condattr_t *, attr)
+       ),
+       TP_fast_assign(
+               __entry->cond = cond;
+               __entry->attr = attr;
+       ),
+       TP_printk("cond=%p condattr=%p ",
+               __entry->cond, __entry->attr)
+);
+
+/* int pthread_cond_destroy(pthread_cond_t *cnd)
+ */
+DEFINE_EVENT(posix_cond, xn_posix_cond_destroy,
+       TP_PROTO(union __xeno_cond *cond),
+       TP_ARGS(cond)
+);
+
+/* int pthread_cond_wait(pthread_cond_t *cnd, pthread_mutex_t *mx)
+ */
+DEFINE_EVENT(posix_cond_wait, xn_posix_cond_wait,
+       TP_PROTO(union __xeno_cond *cond, union __xeno_mutex *mutex),
+       TP_ARGS(cond, mutex)
+);
+
+DEFINE_EVENT(posix_cond_wait, xn_posix_cond_wait_restart,
+       TP_PROTO(union __xeno_cond *cond, union __xeno_mutex *mutex),
+       TP_ARGS(cond, mutex)
+);
+
+/* int pthread_cond_timedwait(pthread_cond_t *cnd, pthread_mutex_t *mx, const 
struct timespec *abstime)
+ */
+TRACE_EVENT(xn_posix_cond_timedwait,
+       TP_PROTO(union __xeno_cond *cond, union __xeno_mutex *mutex,
+               const struct timespec *timeout),
+       TP_ARGS(cond, mutex, timeout),
+       TP_STRUCT__entry(
+               __field(union __xeno_cond*, cond)
+               __field(union __xeno_mutex*, mutex)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->cond = cond;
+               __entry->mutex = mutex;
+               __assign_timespec(timeout, timeout);
+       ),
+       TP_printk("cond=%p mutex=%p timeout=%ld.%09ld",
+               __entry->cond, __entry->mutex,
+               __timespec_args(timeout))
+);
+
+/* int pthread_cond_signal(pthread_cond_t *cnd)
+ */
+DEFINE_EVENT(posix_cond, xn_posix_cond_signal,
+       TP_PROTO(union __xeno_cond *cond),
+       TP_ARGS(cond)
+);
+
+/* int pthread_cond_broadcast(pthread_cond_t *cnd)
+ */
+DEFINE_EVENT(posix_cond, xn_posix_cond_broadcast,
+       TP_PROTO(union __xeno_cond *cond),
+       TP_ARGS(cond)
+);
+
+/*
+ * Message queues services.
+ */
+DECLARE_EVENT_CLASS(posix_mq_sendrecv,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio),
+       TP_ARGS(fd, buf, len, prio),
+       TP_STRUCT__entry(
+               __field(int, fd)
+               __field(char *, buf)
+               __field(size_t, len)
+               __field(unsigned, prio)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+               __entry->buf = buf;
+               __entry->len = len;
+               __entry->prio = prio;
+       ),
+       TP_printk("fd=%d buf=%p len=%zu prio=%d",
+               __entry->fd, __entry->buf,
+               __entry->len, __entry->prio)
+);
+
+DECLARE_EVENT_CLASS(posix_mq_sendrecv_timespec,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio,
+               struct timespec *timeout),
+       TP_ARGS(fd, buf, len, prio, timeout),
+       TP_STRUCT__entry(
+               __field(int, fd)
+               __field(char *, buf)
+               __field(size_t, len)
+               __field(unsigned, prio)
+               __optional_timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+               __entry->buf = buf;
+               __entry->len = len;
+               __entry->prio = prio;
+               __assign_optional_timespec(timeout, timeout);
+       ),
+       TP_printk("fd=%d buf=%p len=%zu prio=%d timeout(%s)=%ld.%09ld",
+               __entry->fd, __entry->buf, __entry->len, __entry->prio,
+               __timespec_used(timeout), __timespec_args(timeout))
+);
+
+/* mqd_t mq_open(const char *name, int oflags,...)
+ */
+TRACE_EVENT(xn_posix_mq_open,
+       TP_PROTO(int fd, char *name, int oflags, int mode,
+               struct mq_attr *attr),
+       TP_ARGS(fd, name, oflags, mode, attr),
+       TP_STRUCT__entry(
+               __field(int, fd)
+               __string(name, name)
+               __field(int, oflags)
+               __field(int, mode)
+               __field(struct mq_attr *, attr)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+               __assign_str(name, name);
+               __entry->oflags = oflags;
+               __entry->mode = mode;
+               __entry->attr = attr;
+       ),
+       TP_printk("fd=%d name=%s oflags=%#x(%s) mode=%04o attr=%p",
+               __entry->fd, __get_str(name), __oflags_args(oflags),
+               __entry->mode, __entry->attr)
+);
+
+/* int mq_close(mqd_t fd)
+ */
+DEFINE_EVENT(posix_fd, xn_posix_mq_close,
+       TP_PROTO(int fd),
+       TP_ARGS(fd)
+);
+
+/* int mq_unlink(const char *name)
+ */
+DEFINE_EVENT(posix_name, xn_posix_mq_unlink,
+       TP_PROTO(char *name),
+       TP_ARGS(name)
+);
+
+/* int mq_send(mqd_t fd, const char *buffer, size_t len, unsigned prio)
+ */
+DEFINE_EVENT(posix_mq_sendrecv, xn_posix_mq_send,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio),
+       TP_ARGS(fd, buf, len, prio)
+);
+
+/* int mq_timedsend(mqd_t fd, const char *buffer, size_t len, unsigned prio, 
const struct timespec *abs_timeout)
+ */
+DEFINE_EVENT(posix_mq_sendrecv_timespec, xn_posix_mq_timedsend,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio,
+               struct timespec *timeout),
+       TP_ARGS(fd, buf, len, prio, timeout)
+);
+
+/* ssize_t mq_receive(mqd_t fd, char *buffer, size_t len, unsigned *priop)
+ */
+DEFINE_EVENT(posix_mq_sendrecv, xn_posix_mq_receive,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio),
+       TP_ARGS(fd, buf, len, prio)
+);
+
+DEFINE_EVENT(posix_mq_sendrecv, xn_posix_mq_receive_return,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio),
+       TP_ARGS(fd, buf, len, prio)
+);
+
+/* ssize_t mq_timedreceive(mqd_t fd, char *buffer, size_t len, unsigned 
*priop, const struct timespec *abs_timeout)
+ */
+DEFINE_EVENT(posix_mq_sendrecv_timespec, xn_posix_mq_timedreceive,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio,
+               struct timespec *timeout),
+       TP_ARGS(fd, buf, len, prio, timeout)
+);
+
+DEFINE_EVENT(posix_mq_sendrecv, xn_posix_mq_timedreceive_return,
+       TP_PROTO(int fd, char *buf, size_t len, unsigned prio),
+       TP_ARGS(fd, buf, len, prio)
+);
+
+/* int mq_notify(mqd_t fd, const struct sigevent *evp)
+ * FIXME: add signal number
+ */
+DEFINE_EVENT(posix_fd, xn_posix_mq_notify,
+       TP_PROTO(int fd),
+       TP_ARGS(fd)
+);
+
+/*
+ * Interruptions management services.
+ */
+DECLARE_EVENT_CLASS(posix_intr,
+       TP_PROTO(pthread_intr_t intr),
+       TP_ARGS(intr),
+       TP_STRUCT__entry(
+               __field(pthread_intr_t, intr)
+       ),
+       TP_fast_assign(
+               __entry->intr = intr;
+       ),
+       TP_printk("intr=%p", __entry->intr)
+);
+
+/* int pthread_intr_attach_np(pthread_intr_t * intr, unsigned irq, int mode)
+ */
+TRACE_EVENT(xn_posix_intr_attach_np,
+       TP_PROTO(pthread_intr_t intr, int irq, int mode),
+       TP_ARGS(intr, irq, mode),
+       TP_STRUCT__entry(
+               __field(pthread_intr_t , intr)
+               __field(int, irq)
+               __field(int, mode)
+       ),
+       TP_fast_assign(
+               __entry->intr = intr;
+               __entry->irq = irq;
+               __entry->mode = mode;
+       ),
+       TP_printk("intr=%p irq=%d mode=%#x(%s)",
+                 __entry->intr, __entry->irq, __intr_mode_args(mode))
+);
+
+/* int pthread_intr_detach_np(pthread_intr_t intr)
+ */
+DEFINE_EVENT(posix_intr, xn_posix_intr_detach_np,
+       TP_PROTO(pthread_intr_t intr),
+       TP_ARGS(intr)
+);
+
+/*  int pthread_intr_wait_np(pthread_intr_t intr, const struct timespec *to)
+ */
+TRACE_EVENT(xn_posix_intr_wait_np,
+       TP_PROTO(pthread_intr_t intr, const struct timespec *timeout),
+       TP_ARGS(intr, timeout),
+       TP_STRUCT__entry(
+               __field(pthread_intr_t, intr)
+               __optional_timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->intr = intr;
+               __assign_optional_timespec(timeout, timeout);
+       ),
+       TP_printk("intr=%p timeout(%s)=%ld.%09ld", __entry->intr,
+               __timespec_used(timeout), __timespec_args(timeout))
+);
+
+/* int pthread_intr_control_np(pthread_intr_t intr, int cmd)
+ */
+TRACE_EVENT(xn_posix_intr_control_np,
+       TP_PROTO(pthread_intr_t intr, int cmd),
+       TP_ARGS(intr, cmd),
+       TP_STRUCT__entry(
+               __field(pthread_intr_t , intr)
+               __field(int, cmd)
+       ),
+       TP_fast_assign(
+               __entry->intr = intr;
+               __entry->cmd = cmd;
+       ),
+       TP_printk("intr=%p cmd=%#x(%s)",
+               __entry->intr, __intr_cmd_args(cmd))
+);
+
+/*
+ * Shared memory services.
+ */
+DECLARE_EVENT_CLASS(posix_map,
+       TP_PROTO(void *addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(
+               __field(void *, addr)
+               __field(int, len)
+       ),
+       TP_fast_assign(
+               __entry->addr = addr;
+               __entry->len = len;
+       ),
+       TP_printk("addr=%p len=%d", __entry->addr, __entry->len)
+);
+
+/* int shm_open(const char *name, int oflags, mode_t mode)
+ */
+TRACE_EVENT(xn_posix_shm_open,
+       TP_PROTO(int fd, char *name, int oflags, int mode),
+       TP_ARGS(fd, name, oflags, mode),
+       TP_STRUCT__entry(
+               __field(int, fd)
+               __string(name, name)
+               __field(int, oflags)
+               __field(int, mode)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+               __assign_str(name, name);
+               __entry->oflags = oflags;
+               __entry->mode = mode;
+       ),
+       TP_printk("fd=%d name=%s oflags=%#x(%s) mode=%04o",
+               __entry->fd, __get_str(name), __oflags_args(oflags),
+               __entry->mode)
+);
+
+/* int shm_close(int fd)
+ */
+DEFINE_EVENT(posix_fd, xn_posix_shm_close,
+       TP_PROTO(int fd),
+       TP_ARGS(fd)
+);
+
+/* int shm_unlink(const char *name)
+ */
+DEFINE_EVENT(posix_name, xn_posix_shm_unlink,
+       TP_PROTO(char *name),
+       TP_ARGS(name)
+);
+
+/* int ftruncate(int fd, off_t len)
+ */
+TRACE_EVENT(xn_posix_ftruncate,
+       TP_PROTO(int fd, off_t len),
+       TP_ARGS(fd, len),
+       TP_STRUCT__entry(
+               __field(int, fd)
+               __field(off_t, len)
+       ),
+       TP_fast_assign(
+               __entry->fd = fd;
+               __entry->len = len;
+       ),
+       TP_printk("fd=%d len=%ld", __entry->fd, __entry->len)
+);
+
+/* void * mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off)
+ */
+TRACE_EVENT(xn_posix_mmap,
+       TP_PROTO(size_t len, int fd, off_t off),
+       TP_ARGS(len, fd, off),
+       TP_STRUCT__entry(
+               __field(int, len)
+               __field(int, fd)
+               __field(off_t, off)
+       ),
+       TP_fast_assign(
+               __entry->len = len;
+               __entry->fd = fd;
+               __entry->off = off;
+       ),
+       TP_printk("len=%d fd=%d off=%ld",
+               __entry->len, __entry->fd, __entry->off)
+);
+
+DEFINE_EVENT(posix_map, xn_posix_mmap_return,
+       TP_PROTO(void *addr, size_t len),
+       TP_ARGS(addr, len)
+);
+
+/* int munmap(void *addr, size_t len)
+ */
+DEFINE_EVENT(posix_map, xn_posix_munmap,
+       TP_PROTO(void *addr, size_t len),
+       TP_ARGS(addr, len)
+);
+
+/*
+ * I/O multiplexing (select) services.
+ */
+
+/* int select(int, fd_set **, int, struct timeval *)
+ */
+TRACE_EVENT(xn_posix_select,
+       TP_PROTO(int nfds, fd_set **fds, int using_to, struct timeval *to),
+       TP_ARGS(nfds, fds, using_to, to),
+       TP_STRUCT__entry(
+               __field(int, nfds)
+               __field(unsigned long, in_fds)
+               __field(unsigned long, out_fds)
+               __field(unsigned long, exc_fds)
+               __optional_timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->nfds = nfds;
+               __entry->in_fds = fds[0] ? fds[0]->fds_bits[0] : 0;
+               __entry->out_fds = fds[1] ? fds[1]->fds_bits[0] : 0;
+               __entry->exc_fds = fds[2] ? fds[2]->fds_bits[0] : 0;
+               __entry->using_timeout = using_to;
+               if (using_to) {
+                       __entry->tv_sec_timeout = to->tv_sec;
+                       __entry->tv_nsec_timeout = to->tv_usec * 1000;
+               } else {
+                       __entry->tv_sec_timeout = 0;
+                       __entry->tv_nsec_timeout = 0;
+               }
+       ),
+       TP_printk("nfds=%d in=%lx... out=%lx... exc=%lx..."
+                 " timeout(%s)=%ld.%09ld", __entry->nfds, __entry->in_fds,
+                 __entry->out_fds, __entry->exc_fds,
+                 __timespec_used(timeout), __timespec_args(timeout))
+);
+#endif
+
+#endif /* _TRACE_XN_SYS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 1bf21da..941260c 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -61,6 +61,8 @@
 #include "thread.h"
 #include "clock.h"
 
+#include <trace/events/xn_sys.h>
+
 static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS];
 
 DECLARE_BITMAP(cobalt_clock_extids, COBALT_MAX_EXTCLOCKS);
@@ -174,6 +176,8 @@ int cobalt_clock_getres(clockid_t clock_id, struct timespec 
__user *u_ts)
                ns2ts(&ts, ns);
        }
 
+       trace_xn_sys_clock_getres(clock_id, &ts);
+
        if (u_ts && __xn_safe_copy_to_user(u_ts, &ts, sizeof(ts)))
                return -EFAULT;
 
@@ -205,6 +209,8 @@ int cobalt_clock_gettime(clockid_t clock_id, struct 
timespec __user *u_ts)
                ns2ts(&ts, ns);
        }
 
+       trace_xn_sys_clock_gettime(clock_id, &ts);
+
        if (__xn_safe_copy_to_user(u_ts, &ts, sizeof(*u_ts)))
                return -EFAULT;
 
@@ -224,6 +230,8 @@ int cobalt_clock_settime(clockid_t clock_id, const struct 
timespec __user *u_ts)
        if ((unsigned long)ts.tv_nsec >= ONE_BILLION)
                return -EINVAL;
 
+       trace_xn_sys_clock_settime(clock_id, &ts);
+
        switch (clock_id) {
        case CLOCK_REALTIME:
                xnlock_get_irqsave(&nklock, s);
@@ -267,6 +275,8 @@ int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
        if (flags & ~TIMER_ABSTIME)
                return -EINVAL;
 
+       trace_xn_sys_clock_nanosleep(clock_id, flags, &rqt);
+
        cur = xnsched_current_thread();
 
        xnlock_get_irqsave(&nklock, s);
@@ -279,6 +289,9 @@ int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
                        rem = xntimer_get_timeout_stopped(&cur->rtimer);
                        xnlock_put_irqrestore(&nklock, s);
                        ns2ts(rmtp, rem > 1 ? rem : 0);
+
+                       trace_xn_sys_clock_nanosleep_return(clock_id, rmtp);
+
                        if (__xn_safe_copy_to_user(u_rmt, rmtp, sizeof(*u_rmt)))
                                return -EFAULT;
                } else
diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c
index 78b6a2c..189c484 100644
--- a/kernel/cobalt/posix/mutex.c
+++ b/kernel/cobalt/posix/mutex.c
@@ -53,6 +53,8 @@
 #include "cond.h"
 #include "clock.h"
 
+#include <trace/events/xn_sys.h>
+
 static int cobalt_mutex_init_inner(struct cobalt_mutex_shadow *shadow,
                                   struct cobalt_mutex *mutex,
                                   struct mutex_dat *datp,
@@ -299,6 +301,8 @@ int cobalt_mutex_init(struct cobalt_mutex_shadow __user 
*u_mx,
        if (mutex == NULL)
                return -ENOMEM;
 
+       trace_xn_sys_mutex_init(mutex, attr);
+
        datp = xnheap_alloc(&xnsys_ppd_get(attr->pshared)->sem_heap,
                             sizeof(*datp));
        if (datp == NULL) {
diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c
index e719560..6077a95 100644
--- a/kernel/cobalt/posix/nsem.c
+++ b/kernel/cobalt/posix/nsem.c
@@ -25,6 +25,8 @@
 #include "internal.h"
 #include "sem.h"
 
+#include <trace/events/xn_sys.h>
+
 DEFINE_XNLOCK(nsem_lock);
 
 struct nsem {
@@ -56,6 +58,8 @@ nsem_open(struct cobalt_process *cc, struct cobalt_sem_shadow 
__user *ushadow,
        spl_t s;
        int rc;
 
+       trace_xn_sys_sem_open(name, oflags, mode, value);
+
        if (name[0] != '/' || name[1] == '\0')
                return ERR_PTR(-EINVAL);
 
@@ -142,6 +146,8 @@ nsem_open(struct cobalt_process *cc, struct 
cobalt_sem_shadow __user *ushadow,
                xnlock_put_irqrestore(&nsem_lock, s);
        }
 
+       trace_xn_sys_sem_open_return(handle);
+
        return u->usem;
 }
 
@@ -225,6 +231,8 @@ int cobalt_sem_close(struct cobalt_sem_shadow __user *usm)
 
        handle = cobalt_get_handle_from_user(&usm->handle);
 
+       trace_xn_sys_sem_close(handle);
+
        return nsem_close(cc, handle);
 }
 
@@ -241,6 +249,8 @@ int cobalt_sem_unlink(const char __user *u_name)
        if (len >= sizeof(name))
                return -ENAMETOOLONG;
 
+       trace_xn_sys_sem_unlink(name);
+
        if (name[0] != '/')
                return -EINVAL;
 
diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 98bb67e..876e3bf 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -38,6 +38,8 @@
 #include "clock.h"
 #include "sem.h"
 
+#include <trace/events/xn_sys.h>
+
 #define SEM_NAMED    0x80000000
 
 static inline struct cobalt_kqueues *sem_kqueue(struct cobalt_sem *sem)
@@ -661,6 +663,8 @@ int cobalt_sem_init(struct cobalt_sem_shadow __user *u_sem, 
int pshared, unsigne
        struct cobalt_sem_shadow sm;
        struct cobalt_sem *sem;
 
+       trace_xn_sys_sem_init(pshared ? SEM_PSHARED : 0, value);
+
        if (__xn_safe_copy_from_user(&sm, u_sem, sizeof(sm)))
                return -EFAULT;
 
@@ -668,6 +672,8 @@ int cobalt_sem_init(struct cobalt_sem_shadow __user *u_sem, 
int pshared, unsigne
        if (IS_ERR(sem))
                return PTR_ERR(sem);
 
+       trace_xn_sys_sem_init_return(sm.handle);
+
        return __xn_safe_copy_to_user(u_sem, &sm, sizeof(*u_sem));
 }
 
@@ -677,6 +683,8 @@ int cobalt_sem_post(struct cobalt_sem_shadow __user *u_sem)
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_post(handle);
+
        return sem_post(handle);
 }
 
@@ -686,6 +694,8 @@ int cobalt_sem_wait(struct cobalt_sem_shadow __user *u_sem)
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_wait(handle);
+
        return sem_wait(handle);
 }
 
@@ -696,6 +706,8 @@ int cobalt_sem_timedwait(struct cobalt_sem_shadow __user 
*u_sem,
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_timedwait(handle, u_ts);
+
        return sem_timedwait(handle, u_ts);
 }
 
@@ -705,6 +717,8 @@ int cobalt_sem_trywait(struct cobalt_sem_shadow __user 
*u_sem)
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_trywait(handle);
+
        return sem_trywait(handle);
 }
 
@@ -715,10 +729,14 @@ int cobalt_sem_getvalue(struct cobalt_sem_shadow __user 
*u_sem, int __user *u_sv
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_getvalue(handle);
+
        err = sem_getvalue(handle, &sval);
        if (err < 0)
                return err;
 
+       trace_xn_sys_sem_getvalue_return(handle, sval);
+
        return __xn_safe_copy_to_user(u_sval, &sval, sizeof(sval));
 }
 
@@ -730,6 +748,8 @@ int cobalt_sem_destroy(struct cobalt_sem_shadow __user 
*u_sem)
        if (__xn_safe_copy_from_user(&sm, u_sem, sizeof(sm)))
                return -EFAULT;
 
+       trace_xn_sys_sem_destroy(sm.handle);
+
        err = sem_destroy(&sm);
        if (err < 0)
                return err;
@@ -743,6 +763,8 @@ int cobalt_sem_init_np(struct cobalt_sem_shadow __user 
*u_sem,
        struct cobalt_sem_shadow sm;
        struct cobalt_sem *sem;
 
+       trace_xn_sys_sem_init(flags, value);
+
        if (__xn_safe_copy_from_user(&sm, u_sem, sizeof(sm)))
                return -EFAULT;
 
@@ -754,6 +776,8 @@ int cobalt_sem_init_np(struct cobalt_sem_shadow __user 
*u_sem,
        if (IS_ERR(sem))
                return PTR_ERR(sem);
 
+       trace_xn_sys_sem_init_return(sm.handle);
+
        return __xn_safe_copy_to_user(u_sem, &sm, sizeof(*u_sem));
 }
 
@@ -766,6 +790,8 @@ int cobalt_sem_broadcast_np(struct cobalt_sem_shadow __user 
*u_sem)
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
+       trace_xn_sys_sem_broadcast_np(handle);
+
        xnlock_get_irqsave(&nklock, s);
        sm = xnregistry_lookup(handle, NULL);
        err = sem_post_inner(sm, sm->owningq, 1);
diff --git a/kernel/cobalt/posix/sem.h b/kernel/cobalt/posix/sem.h
index 09a2e48..5ef2bd5 100644
--- a/kernel/cobalt/posix/sem.h
+++ b/kernel/cobalt/posix/sem.h
@@ -24,6 +24,7 @@
 #include <cobalt/kernel/registry.h>
 
 struct cobalt_process;
+struct cobalt_kqueues;
 
 struct cobalt_sem {
        unsigned int magic;
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index dbb1660..b5f5873 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -41,6 +41,8 @@
 #include "timer.h"
 #include "clock.h"
 
+#include <trace/events/xn_sys.h>
+
 xnticks_t cobalt_time_slice;
 
 #define PTHREAD_HSLOTS (1 << 8)        /* Must be a power of 2 */
@@ -824,6 +826,8 @@ int cobalt_thread_setschedparam_ex(unsigned long pth,
        if (__xn_safe_copy_from_user(&param, u_param, sizeof(param)))
                return -EFAULT;
 
+       trace_xn_sys_thread_setschedparam(pth, policy, &param);
+
        hkey.u_pth = pth;
        hkey.mm = current->mm;
        thread = thread_lookup(&hkey);
@@ -872,6 +876,8 @@ int cobalt_thread_getschedparam_ex(unsigned long pth,
        if (ret)
                return ret;
 
+       trace_xn_sys_thread_getschedparam(pth, policy, &param);
+
        if (__xn_safe_copy_to_user(u_policy, &policy, sizeof(int)))
                return -EFAULT;
 
@@ -910,6 +916,9 @@ int cobalt_thread_create(unsigned long pth, int policy,
 
        if (__xn_safe_copy_from_user(&param_ex, u_param, sizeof(param_ex)))
                return -EFAULT;
+
+       trace_xn_sys_thread_create(pth, policy, &param_ex);
+
        /*
         * We have been passed the pthread_t identifier the user-space
         * Cobalt library has assigned to our caller; we'll index our
@@ -994,6 +1003,8 @@ int cobalt_thread_make_periodic_np(unsigned long pth,
        if (__xn_safe_copy_from_user(&periodt, u_periodt, sizeof(periodt)))
                return -EFAULT;
 
+       trace_xn_sys_thread_make_periodic_np(pth, &startt, &periodt);
+
        return pthread_make_periodic_np(thread, clk_id, &startt, &periodt);
 }
 
@@ -1002,7 +1013,12 @@ int cobalt_thread_wait_np(unsigned long __user 
*u_overruns)
        unsigned long overruns;
        int ret;
 
+       trace_xn_sys_thread_wait_np(0);
+
        ret = xnthread_wait_period(&overruns);
+
+       trace_xn_sys_thread_wait_np_return(overruns);
+
        if (u_overruns && (ret == 0 || ret == -ETIMEDOUT))
                __xn_put_user(overruns, u_overruns);
 
@@ -1013,6 +1029,8 @@ int cobalt_thread_set_mode_np(int clrmask, int setmask, 
int __user *u_mode_r)
 {
        int ret, old;
 
+       trace_xn_sys_thread_set_mode_np(clrmask, setmask);
+
        ret = pthread_set_mode_np(clrmask, setmask, &old);
        if (ret)
                return ret;
@@ -1039,6 +1057,8 @@ int cobalt_thread_set_name_np(unsigned long pth, const 
char __user *u_name)
        hkey.u_pth = pth;
        hkey.mm = current->mm;
 
+       trace_xn_sys_thread_set_name_np(pth, name);
+
        xnlock_get_irqsave(&nklock, s);
 
        thread = thread_lookup(&hkey);
@@ -1068,6 +1088,8 @@ int cobalt_thread_probe_np(pid_t pid)
        int ret;
        spl_t s;
 
+       trace_xn_sys_thread_probe_np(pid);
+
        hash = jhash2((u32 *)&pid, sizeof(pid) / sizeof(u32), 0);
 
        xnlock_get_irqsave(&nklock, s);
@@ -1090,6 +1112,8 @@ int cobalt_thread_kill(unsigned long pth, int sig)
        int ret;
        spl_t s;
 
+       trace_xn_sys_thread_kill(pth, sig);
+
        xnlock_get_irqsave(&nklock, s);
 
        hkey.u_pth = pth;
@@ -1111,6 +1135,8 @@ int cobalt_thread_join(unsigned long pth)
        struct cobalt_thread *thread;
        spl_t s;
 
+       trace_xn_sys_thread_join(pth);
+
        xnlock_get_irqsave(&nklock, s);
        hkey.u_pth = pth;
        hkey.mm = current->mm;
@@ -1132,6 +1158,8 @@ int cobalt_thread_stat(pid_t pid,
        xnticks_t xtime;
        spl_t s;
 
+       trace_xn_sys_thread_stat(pid);
+
        if (pid == 0) {
                thread = xnshadow_current();
                if (thread == NULL)
@@ -1239,6 +1267,8 @@ int cobalt_sched_yield(void)
        struct cobalt_thread *curr = cobalt_current_thread();
        int ret;
 
+       trace_xn_sys_sched_yield(0);
+
        /* Maybe some extension wants to handle this. */
        if (cobalt_call_extension(sched_yield, &curr->extref, ret) && ret)
                return ret > 0 ? 0 : ret;
diff --git a/kernel/cobalt/shadow.c b/kernel/cobalt/shadow.c
index 0c62970..672fe4b 100644
--- a/kernel/cobalt/shadow.c
+++ b/kernel/cobalt/shadow.c
@@ -65,6 +65,7 @@
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/xn_cobalt.h>
+#include <trace/events/xn_sys.h>
 
 #define EVENT_PROPAGATE   0
 #define EVENT_STOP        1


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to