Support detailed syscalls with 0 arguments
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 17 Sep 2011 01:01:39 +0000 (21:01 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 17 Sep 2011 01:01:39 +0000 (21:01 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/syscalls/headers/x86-64-syscalls-3.0.4-integers.h
instrumentation/syscalls/lttng-syscalls-generate-headers.sh
ltt-events.h
ltt-probes.c
lttng-syscalls.c
probes/lttng-events-reset.h
probes/lttng-events.h

index 0d0c2c1a0c58cd9807fdff60bb359f83eeded309..1ed412cd73e921ee4e58bb9968357e275488a87f 100644 (file)
 #include <linux/tracepoint.h>
 #include <linux/syscalls.h>
 
+DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
 TRACE_EVENT(sys_close,
        TP_PROTO(unsigned int fd),
        TP_ARGS(fd),
@@ -536,79 +557,95 @@ TRACE_EVENT(sys_mmap,
 
 #else /* CREATE_SYSCALL_TABLE */
 
-TRACE_SYSCALL_TABLE(sys_close, 3, 1)
-TRACE_SYSCALL_TABLE(sys_brk, 12, 1)
-TRACE_SYSCALL_TABLE(sys_dup, 32, 1)
-TRACE_SYSCALL_TABLE(sys_alarm, 37, 1)
-TRACE_SYSCALL_TABLE(sys_exit, 60, 1)
-TRACE_SYSCALL_TABLE(sys_fsync, 74, 1)
-TRACE_SYSCALL_TABLE(sys_fdatasync, 75, 1)
-TRACE_SYSCALL_TABLE(sys_fchdir, 81, 1)
-TRACE_SYSCALL_TABLE(sys_umask, 95, 1)
-TRACE_SYSCALL_TABLE(sys_setuid, 105, 1)
-TRACE_SYSCALL_TABLE(sys_setgid, 106, 1)
-TRACE_SYSCALL_TABLE(sys_getpgid, 121, 1)
-TRACE_SYSCALL_TABLE(sys_setfsuid, 122, 1)
-TRACE_SYSCALL_TABLE(sys_setfsgid, 123, 1)
-TRACE_SYSCALL_TABLE(sys_getsid, 124, 1)
-TRACE_SYSCALL_TABLE(sys_personality, 135, 1)
-TRACE_SYSCALL_TABLE(sys_sched_getscheduler, 145, 1)
-TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, 146, 1)
-TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, 147, 1)
-TRACE_SYSCALL_TABLE(sys_mlockall, 151, 1)
-TRACE_SYSCALL_TABLE(sys_io_destroy, 207, 1)
-TRACE_SYSCALL_TABLE(sys_epoll_create, 213, 1)
-TRACE_SYSCALL_TABLE(sys_timer_getoverrun, 225, 1)
-TRACE_SYSCALL_TABLE(sys_timer_delete, 226, 1)
-TRACE_SYSCALL_TABLE(sys_exit_group, 231, 1)
-TRACE_SYSCALL_TABLE(sys_unshare, 272, 1)
-TRACE_SYSCALL_TABLE(sys_eventfd, 284, 1)
-TRACE_SYSCALL_TABLE(sys_epoll_create1, 291, 1)
-TRACE_SYSCALL_TABLE(sys_inotify_init1, 294, 1)
-TRACE_SYSCALL_TABLE(sys_syncfs, 306, 1)
-TRACE_SYSCALL_TABLE(sys_munmap, 11, 2)
-TRACE_SYSCALL_TABLE(sys_dup2, 33, 2)
-TRACE_SYSCALL_TABLE(sys_shutdown, 48, 2)
-TRACE_SYSCALL_TABLE(sys_listen, 50, 2)
-TRACE_SYSCALL_TABLE(sys_kill, 62, 2)
-TRACE_SYSCALL_TABLE(sys_msgget, 68, 2)
-TRACE_SYSCALL_TABLE(sys_flock, 73, 2)
-TRACE_SYSCALL_TABLE(sys_ftruncate, 77, 2)
-TRACE_SYSCALL_TABLE(sys_fchmod, 91, 2)
-TRACE_SYSCALL_TABLE(sys_setpgid, 109, 2)
-TRACE_SYSCALL_TABLE(sys_setreuid, 113, 2)
-TRACE_SYSCALL_TABLE(sys_setregid, 114, 2)
-TRACE_SYSCALL_TABLE(sys_getpriority, 140, 2)
-TRACE_SYSCALL_TABLE(sys_mlock, 149, 2)
-TRACE_SYSCALL_TABLE(sys_munlock, 150, 2)
-TRACE_SYSCALL_TABLE(sys_tkill, 200, 2)
-TRACE_SYSCALL_TABLE(sys_ioprio_get, 252, 2)
-TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, 255, 2)
-TRACE_SYSCALL_TABLE(sys_timerfd_create, 283, 2)
-TRACE_SYSCALL_TABLE(sys_eventfd2, 290, 2)
-TRACE_SYSCALL_TABLE(sys_setns, 308, 2)
-TRACE_SYSCALL_TABLE(sys_lseek, 8, 3)
-TRACE_SYSCALL_TABLE(sys_mprotect, 10, 3)
-TRACE_SYSCALL_TABLE(sys_ioctl, 16, 3)
-TRACE_SYSCALL_TABLE(sys_msync, 26, 3)
-TRACE_SYSCALL_TABLE(sys_madvise, 28, 3)
-TRACE_SYSCALL_TABLE(sys_shmget, 29, 3)
-TRACE_SYSCALL_TABLE(sys_socket, 41, 3)
-TRACE_SYSCALL_TABLE(sys_semget, 64, 3)
-TRACE_SYSCALL_TABLE(sys_fcntl, 72, 3)
-TRACE_SYSCALL_TABLE(sys_fchown, 93, 3)
-TRACE_SYSCALL_TABLE(sys_setresuid, 117, 3)
-TRACE_SYSCALL_TABLE(sys_setresgid, 119, 3)
-TRACE_SYSCALL_TABLE(sys_sysfs, 139, 3)
-TRACE_SYSCALL_TABLE(sys_setpriority, 141, 3)
-TRACE_SYSCALL_TABLE(sys_tgkill, 234, 3)
-TRACE_SYSCALL_TABLE(sys_ioprio_set, 251, 3)
-TRACE_SYSCALL_TABLE(sys_dup3, 292, 3)
-TRACE_SYSCALL_TABLE(sys_ptrace, 101, 4)
-TRACE_SYSCALL_TABLE(sys_tee, 276, 4)
-TRACE_SYSCALL_TABLE(sys_mremap, 25, 5)
-TRACE_SYSCALL_TABLE(sys_prctl, 157, 5)
-TRACE_SYSCALL_TABLE(sys_remap_file_pages, 216, 5)
-TRACE_SYSCALL_TABLE(sys_mmap, 9, 6)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 24, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 34, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 39, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 102, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 104, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 107, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 108, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 110, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 111, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 112, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 152, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 153, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 162, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 186, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 219, 0)
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 253, 0)
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 3, 1)
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 8, 3)
+TRACE_SYSCALL_TABLE(sys_mmap, sys_mmap, 9, 6)
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 10, 3)
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 11, 2)
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 12, 1)
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 16, 3)
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 25, 5)
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 26, 3)
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 28, 3)
+TRACE_SYSCALL_TABLE(sys_shmget, sys_shmget, 29, 3)
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 32, 1)
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 33, 2)
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 37, 1)
+TRACE_SYSCALL_TABLE(sys_socket, sys_socket, 41, 3)
+TRACE_SYSCALL_TABLE(sys_shutdown, sys_shutdown, 48, 2)
+TRACE_SYSCALL_TABLE(sys_listen, sys_listen, 50, 2)
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 60, 1)
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 62, 2)
+TRACE_SYSCALL_TABLE(sys_semget, sys_semget, 64, 3)
+TRACE_SYSCALL_TABLE(sys_msgget, sys_msgget, 68, 2)
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 72, 3)
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 73, 2)
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 74, 1)
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 75, 1)
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 77, 2)
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 81, 1)
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 91, 2)
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 93, 3)
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 95, 1)
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 101, 4)
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 105, 1)
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 106, 1)
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 109, 2)
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 113, 2)
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 114, 2)
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 117, 3)
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 119, 3)
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 121, 1)
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 122, 1)
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 123, 1)
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 124, 1)
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 135, 1)
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 139, 3)
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 140, 2)
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 141, 3)
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 145, 1)
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 146, 1)
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 147, 1)
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 149, 2)
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 150, 2)
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 151, 1)
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 157, 5)
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 200, 2)
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 207, 1)
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 213, 1)
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 216, 5)
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 225, 1)
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 226, 1)
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 231, 1)
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 234, 3)
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 251, 3)
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 252, 2)
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 255, 2)
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 272, 1)
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 276, 4)
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 283, 2)
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 284, 1)
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 290, 2)
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 291, 1)
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 292, 3)
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 294, 1)
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 306, 1)
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 308, 2)
 
 #endif /* CREATE_SYSCALL_TABLE */
index 87daf0fc1426af9c917a2d46d0a6b5da36dedd5e..91e282c4c9c1c62cb92b17d1efe894e4d548143a 100644 (file)
@@ -22,7 +22,7 @@ mv ${TMPFILE} ${SRCFILE}
 #Filter
 
 #select only syscalls we currently support
-#move non-pointers with arguments to a integer-only file.
+#move non-pointers with and without arguments to a integer-only file.
 CLASS=integers
 grep -v "\\*\|cap_user_header_t" ${SRCFILE} > ${TMPFILE}
 mv ${TMPFILE} ${SRCFILE}
@@ -33,12 +33,6 @@ mv ${TMPFILE} ${SRCFILE}
 #grep "\\*\|cap_#user_header_t" ${SRCFILE} > ${TMPFILE}
 #mv ${TMPFILE} ${SRCFILE}
 
-#TODO
-#move those without arguments to a separate file.
-#CLASS=noargs
-#grep "^syscall [^ ]* nr [^ ]* nbargs 0 " ${SRCFILE} > ${TMPFILE}
-#mv ${TMPFILE} ${SRCFILE}
-
 HEADER=headers/${INPUTFILE}-${CLASS}.h
 
 echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER}
@@ -56,7 +50,24 @@ echo \
 #include <linux/syscalls.h>
 " >> ${HEADER}
 
-#TODO 0
+NRARGS=0
+
+echo \
+'DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\
+'      TP_STRUCT__entry(),\n'\
+'      TP_fast_assign(),\n'\
+'      TP_printk()\n'\
+')'\
+       >> ${HEADER}
+
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+sed 's/^syscall \([^ ]*\) nr \([^ ]*\) nbargs \([^ ]*\) '\
+'types: (\([^)]*\)) '\
+'args: (\([^)]*\))/'\
+'DEFINE_EVENT_NOARGS(syscalls_noargs, sys_\1)'\
+'/g'\
+       ${TMPFILE} >> ${HEADER}
+
 
 # types: 4
 # args   5
@@ -165,7 +176,7 @@ sed 's/^syscall \([^ ]*\) nr \([^ ]*\) nbargs \([^ ]*\) '\
 # Macro for tracing syscall table
 
 rm -f ${TMPFILE}
-for NRARGS in $(seq 1 6); do
+for NRARGS in $(seq 0 6); do
        grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} >> ${TMPFILE}
 done
 
@@ -179,8 +190,19 @@ echo \
 #else /* CREATE_SYSCALL_TABLE */
 " >> ${HEADER}
 
+
+NRARGS=0
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+
+#noargs
+sed 's/^syscall \([^ ]*\) nr \([^ ]*\) nbargs \([^ ]*\) .*$/'\
+'TRACE_SYSCALL_TABLE(syscalls_noargs, sys_\1, \2, \3)/g'\
+       ${TMPFILE} >> ${HEADER}
+
+#others.
+grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
 sed 's/^syscall \([^ ]*\) nr \([^ ]*\) nbargs \([^ ]*\) .*$/'\
-'TRACE_SYSCALL_TABLE(sys_\1, \2, \3)/g'\
+'TRACE_SYSCALL_TABLE(sys_\1, sys_\1, \2, \3)/g'\
        ${TMPFILE} >> ${HEADER}
 
 echo -n \
index f3f5b8fde1a57355f4aeafab94e5691153c57c24..a556e5dfdb5a939d28cac269059329a010d3ed77 100644 (file)
@@ -158,7 +158,7 @@ struct lttng_event_desc {
 };
 
 struct lttng_probe_desc {
-       const struct lttng_event_desc *event_desc;
+       const struct lttng_event_desc **event_desc;
        unsigned int nr_events;
        struct list_head head;                  /* chain registered probes */
 };
index 668f6678ad3ec13c15cfb8518e8d20b32b5afa76..81dcbd715df08300b6bcfd9973418f853544e8d0 100644 (file)
@@ -26,8 +26,8 @@ const struct lttng_event_desc *find_event(const char *name)
 
        list_for_each_entry(probe_desc, &probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
-                       if (!strcmp(probe_desc->event_desc[i].name, name))
-                               return &probe_desc->event_desc[i];
+                       if (!strcmp(probe_desc->event_desc[i]->name, name))
+                               return probe_desc->event_desc[i];
                }
        }
        return NULL;
@@ -44,7 +44,7 @@ int ltt_probe_register(struct lttng_probe_desc *desc)
         * overhead becomes an issue.
         */
        for (i = 0; i < desc->nr_events; i++) {
-               if (find_event(desc->event_desc[i].name)) {
+               if (find_event(desc->event_desc[i]->name)) {
                        ret = -EEXIST;
                        goto end;
                }
@@ -96,7 +96,7 @@ void *tp_list_start(struct seq_file *m, loff_t *pos)
        list_for_each_entry(probe_desc, &probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
                        if (iter++ >= *pos)
-                               return (void *) &probe_desc->event_desc[i];
+                               return (void *) probe_desc->event_desc[i];
                }
        }
        /* End of list */
@@ -113,7 +113,7 @@ void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
        list_for_each_entry(probe_desc, &probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
                        if (iter++ >= *ppos)
-                               return (void *) &probe_desc->event_desc[i];
+                               return (void *) probe_desc->event_desc[i];
                }
        }
        /* End of list */
index 28348abe350a7e3de15f2d0824745d6a11e42963..09e48c4573c4727c11dba36e7f13c20366c45f41 100644 (file)
 
 static void syscall_entry_probe(void *__data, struct pt_regs *regs, long id);
 
+/*
+ * Take care of NOARGS not supported by mainline.
+ */
+#define DECLARE_EVENT_CLASS_NOARGS(name, tstruct, assign, print)
+#define DEFINE_EVENT_NOARGS(template, name)
+#define TRACE_EVENT_NOARGS(name, struct, assign, print)
+
 /*
  * Create LTTng tracepoint probes.
  */
@@ -38,7 +45,7 @@ static void syscall_entry_probe(void *__data, struct pt_regs *regs, long id);
 
 struct trace_syscall_entry {
        void *func;
-       const struct lttng_event_desc *desc;    /* Set dynamically */
+       const struct lttng_event_desc *desc;
        const struct lttng_event_field *fields;
        unsigned int nrargs;
 };
@@ -48,11 +55,12 @@ static int sc_table_desc_filled;
 #define CREATE_SYSCALL_TABLE
 
 #undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_name, _nr, _nrargs)               \
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
        [ _nr ] = {                                             \
-               .func = __event_probe__##_name,                 \
+               .func = __event_probe__##_template,             \
                .nrargs = (_nrargs),                            \
-               .fields = __event_fields___##_name,             \
+               .fields = __event_fields___##_template,         \
+               .desc = &__event_desc___##_name,                \
        },
 
 static struct trace_syscall_entry sc_table[] = {
@@ -163,47 +171,12 @@ static void syscall_entry_probe(void *__data, struct pt_regs *regs, long id)
        }
 }
 
-static const struct lttng_event_desc *find_syscall_desc(unsigned int id)
-{
-       unsigned int i;
-
-       for (i = 0; i < __probe_desc___syscalls.nr_events; i++) {
-               if (__probe_desc___syscalls.event_desc[i].fields
-                               == sc_table[id].fields)
-                       return &__probe_desc___syscalls.event_desc[i];
-       }
-       WARN_ON_ONCE(1);
-       return NULL;
-}
-
-static void fill_sc_table_desc(void)
-{
-       unsigned int i;
-
-       if (sc_table_desc_filled)
-               return;
-       /*
-        * This is O(n^2), but rare. Eventually get the TRACE_EVENT code
-        * to emit per-event symbols to skip this.
-        */
-       for (i = 0; i < ARRAY_SIZE(sc_table); i++) {
-               const struct lttng_event_desc **desc = &sc_table[i].desc;
-
-               if (!sc_table[i].func)
-                       continue;
-               (*desc) = find_syscall_desc(i);
-       }
-       sc_table_desc_filled = 1;
-}
-
-
 int lttng_syscalls_register(struct ltt_channel *chan, void *filter)
 {
        unsigned int i;
        int ret;
 
        wrapper_vmalloc_sync_all();
-       fill_sc_table_desc();
 
        if (!chan->sc_table) {
                /* create syscall table mapping syscall to events */
index 3157f1e48dd9f8b3ce8cf5a32ae3b3b389049de1..c8a1046d90b95bcd315903300e35301ca4c98995 100644 (file)
 #undef DECLARE_EVENT_CLASS
 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)
 
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)
+
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(_template, _name, _proto, _args)
 
+#undef DEFINE_EVENT_NOARGS
+#define DEFINE_EVENT_NOARGS(_template, _name)
+
 #undef TRACE_EVENT_FLAGS
 #define TRACE_EVENT_FLAGS(name, value)
index 925e12daaec0eb249a029abab1c57a577c221b6e..022b4a8312d2363e818ac7eb6628831d467e3e4a 100644 (file)
                             PARAMS(print))                    \
        DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args))
 
+#undef TRACE_EVENT_NOARGS
+#define TRACE_EVENT_NOARGS(name, tstruct, assign, print)       \
+       DECLARE_EVENT_CLASS_NOARGS(name,                       \
+                            PARAMS(tstruct),                  \
+                            PARAMS(assign),                   \
+                            PARAMS(print))                    \
+       DEFINE_EVENT_NOARGS(name, name)
+
+
 #undef DEFINE_EVENT_PRINT
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
        DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
 #define DEFINE_EVENT(_template, _name, _proto, _args)                  \
 void trace_##_name(_proto);
 
+#undef DEFINE_EVENT_NOARGS
+#define DEFINE_EVENT_NOARGS(_template, _name)                          \
+void trace_##_name(void *__data);
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 /*
@@ -174,12 +187,17 @@ void trace_##_name(_proto);
 #undef TP_STRUCT__entry
 #define TP_STRUCT__entry(args...) args /* Only one used in this phase */
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
        static const struct lttng_event_field __event_fields___##_name[] = { \
                _tstruct                                                     \
        };
 
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
+       DECLARE_EVENT_CLASS_NOARGS(_name, PARAMS(_tstruct), PARAMS(_assign), \
+                       PARAMS(_print))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 #undef __type_integer
@@ -199,12 +217,16 @@ void trace_##_name(_proto);
 #define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
 static void __event_probe__##_name(void *__data, _proto);
 
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+static void __event_probe__##_name(void *__data);
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 /*
- * Stage 4 of the trace events.
+ * Stage 3.9 of the trace events.
  *
- * Create an array of events.
+ * Create event descriptions.
  */
 
 /* Named field types must be defined in lttng-types.h */
@@ -215,20 +237,45 @@ static void __event_probe__##_name(void *__data, _proto);
 #define TP_PROBE_CB(_template) &__event_probe__##_template
 #endif
 
+#undef DEFINE_EVENT_NOARGS
+#define DEFINE_EVENT_NOARGS(_template, _name)                          \
+static const struct lttng_event_desc __event_desc___##_name = {                \
+       .fields = __event_fields___##_template,                         \
+       .name = #_name,                                                 \
+       .probe_callback = (void *) TP_PROBE_CB(_template),              \
+       .nr_fields = ARRAY_SIZE(__event_fields___##_template),          \
+       .owner = THIS_MODULE,                                           \
+};
+
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(_template, _name, _proto, _args)                  \
+       DEFINE_EVENT_NOARGS(_template, _name)
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+
+/*
+ * Stage 4 of the trace events.
+ *
+ * Create an array of event description pointers.
+ */
+
+/* Named field types must be defined in lttng-types.h */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef DEFINE_EVENT_NOARGS
+#define DEFINE_EVENT_NOARGS(_template, _name)                                 \
+               &__event_desc___##_name,
+
 #undef DEFINE_EVENT
 #define DEFINE_EVENT(_template, _name, _proto, _args)                         \
-               {                                                              \
-                       .fields = __event_fields___##_template,                \
-                       .name = #_name,                                        \
-                       .probe_callback = (void *) TP_PROBE_CB(_template),     \
-                       .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
-                       .owner = THIS_MODULE,                                  \
-               },
+       DEFINE_EVENT_NOARGS(_template, _name)
 
 #define TP_ID1(_token, _system)        _token##_system
 #define TP_ID(_token, _system) TP_ID1(_token, _system)
 
-static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
+static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 };
 
@@ -526,6 +573,37 @@ static void __event_probe__##_name(void *__data, _proto)                 \
        _assign                                                               \
 }
 
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+static void __event_probe__##_name(void *__data)                             \
+{                                                                            \
+       struct ltt_event *__event = __data;                                   \
+       struct ltt_channel *__chan = __event->chan;                           \
+       struct lib_ring_buffer_ctx __ctx;                                     \
+       size_t __event_len, __event_align;                                    \
+       int __ret;                                                            \
+                                                                             \
+       if (unlikely(!ACCESS_ONCE(__chan->session->active)))                  \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__chan->enabled)))                          \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__event->enabled)))                         \
+               return;                                                       \
+       __event_len = 0;                                                      \
+       __event_align = 1;                                                    \
+       lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len,  \
+                                __event_align, -1);                          \
+       __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
+       if (__ret < 0)                                                        \
+               return;                                                       \
+       /* Control code (field ordering) */                                   \
+       _tstruct                                                              \
+       __chan->ops->event_commit(&__ctx);                                    \
+       return;                                                               \
+       /* Copy code, steered by control code */                              \
+       _assign                                                               \
+}
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 /*
This page took 0.034262 seconds and 4 git commands to generate.