From: Mathieu Desnoyers Date: Fri, 16 Sep 2011 17:27:35 +0000 (-0400) Subject: Syscall detail mode: generate syscall table X-Git-Tag: v2.0-pre9~58 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=054f2ed356b2616742a8e507f679d499c7e2bafa;p=lttng-modules.git Syscall detail mode: generate syscall table Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/headers/syscalls.h b/instrumentation/syscalls/headers/syscalls.h new file mode 100644 index 00000000..72fba30e --- /dev/null +++ b/instrumentation/syscalls/headers/syscalls.h @@ -0,0 +1 @@ +#include "x86-64-syscalls-3.0.4-integers.h" diff --git a/instrumentation/syscalls/headers/x86-64-syscalls-3.0.4-integers.h b/instrumentation/syscalls/headers/x86-64-syscalls-3.0.4-integers.h index 040ef79e..0d0c2c1a 100644 --- a/instrumentation/syscalls/headers/x86-64-syscalls-3.0.4-integers.h +++ b/instrumentation/syscalls/headers/x86-64-syscalls-3.0.4-integers.h @@ -1,4 +1,6 @@ /* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */ +#ifndef CREATE_SYSCALL_TABLE + #undef TRACE_SYSTEM #define TRACE_SYSTEM syscalls @@ -526,82 +528,87 @@ TRACE_EVENT(sys_mmap, TP_fast_assign(tp_assign(mmap0, mmap0) tp_assign(mmap1, mmap1) tp_assign(mmap2, 12) tp_assign(mmap3, mmap3) tp_assign(mmap4, mmap4) tp_assign(mmap5, mmap5)), TP_printk() ) -TRACE_SYSCALL_TABLE(sys_close, 3) -TRACE_SYSCALL_TABLE(sys_brk, 12) -TRACE_SYSCALL_TABLE(sys_dup, 32) -TRACE_SYSCALL_TABLE(sys_alarm, 37) -TRACE_SYSCALL_TABLE(sys_exit, 60) -TRACE_SYSCALL_TABLE(sys_fsync, 74) -TRACE_SYSCALL_TABLE(sys_fdatasync, 75) -TRACE_SYSCALL_TABLE(sys_fchdir, 81) -TRACE_SYSCALL_TABLE(sys_umask, 95) -TRACE_SYSCALL_TABLE(sys_setuid, 105) -TRACE_SYSCALL_TABLE(sys_setgid, 106) -TRACE_SYSCALL_TABLE(sys_getpgid, 121) -TRACE_SYSCALL_TABLE(sys_setfsuid, 122) -TRACE_SYSCALL_TABLE(sys_setfsgid, 123) -TRACE_SYSCALL_TABLE(sys_getsid, 124) -TRACE_SYSCALL_TABLE(sys_personality, 135) -TRACE_SYSCALL_TABLE(sys_sched_getscheduler, 145) -TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, 146) -TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, 147) -TRACE_SYSCALL_TABLE(sys_mlockall, 151) -TRACE_SYSCALL_TABLE(sys_io_destroy, 207) -TRACE_SYSCALL_TABLE(sys_epoll_create, 213) -TRACE_SYSCALL_TABLE(sys_timer_getoverrun, 225) -TRACE_SYSCALL_TABLE(sys_timer_delete, 226) -TRACE_SYSCALL_TABLE(sys_exit_group, 231) -TRACE_SYSCALL_TABLE(sys_unshare, 272) -TRACE_SYSCALL_TABLE(sys_eventfd, 284) -TRACE_SYSCALL_TABLE(sys_epoll_create1, 291) -TRACE_SYSCALL_TABLE(sys_inotify_init1, 294) -TRACE_SYSCALL_TABLE(sys_syncfs, 306) -TRACE_SYSCALL_TABLE(sys_munmap, 11) -TRACE_SYSCALL_TABLE(sys_dup2, 33) -TRACE_SYSCALL_TABLE(sys_shutdown, 48) -TRACE_SYSCALL_TABLE(sys_listen, 50) -TRACE_SYSCALL_TABLE(sys_kill, 62) -TRACE_SYSCALL_TABLE(sys_msgget, 68) -TRACE_SYSCALL_TABLE(sys_flock, 73) -TRACE_SYSCALL_TABLE(sys_ftruncate, 77) -TRACE_SYSCALL_TABLE(sys_fchmod, 91) -TRACE_SYSCALL_TABLE(sys_setpgid, 109) -TRACE_SYSCALL_TABLE(sys_setreuid, 113) -TRACE_SYSCALL_TABLE(sys_setregid, 114) -TRACE_SYSCALL_TABLE(sys_getpriority, 140) -TRACE_SYSCALL_TABLE(sys_mlock, 149) -TRACE_SYSCALL_TABLE(sys_munlock, 150) -TRACE_SYSCALL_TABLE(sys_tkill, 200) -TRACE_SYSCALL_TABLE(sys_ioprio_get, 252) -TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, 255) -TRACE_SYSCALL_TABLE(sys_timerfd_create, 283) -TRACE_SYSCALL_TABLE(sys_eventfd2, 290) -TRACE_SYSCALL_TABLE(sys_setns, 308) -TRACE_SYSCALL_TABLE(sys_lseek, 8) -TRACE_SYSCALL_TABLE(sys_mprotect, 10) -TRACE_SYSCALL_TABLE(sys_ioctl, 16) -TRACE_SYSCALL_TABLE(sys_msync, 26) -TRACE_SYSCALL_TABLE(sys_madvise, 28) -TRACE_SYSCALL_TABLE(sys_shmget, 29) -TRACE_SYSCALL_TABLE(sys_socket, 41) -TRACE_SYSCALL_TABLE(sys_semget, 64) -TRACE_SYSCALL_TABLE(sys_fcntl, 72) -TRACE_SYSCALL_TABLE(sys_fchown, 93) -TRACE_SYSCALL_TABLE(sys_setresuid, 117) -TRACE_SYSCALL_TABLE(sys_setresgid, 119) -TRACE_SYSCALL_TABLE(sys_sysfs, 139) -TRACE_SYSCALL_TABLE(sys_setpriority, 141) -TRACE_SYSCALL_TABLE(sys_tgkill, 234) -TRACE_SYSCALL_TABLE(sys_ioprio_set, 251) -TRACE_SYSCALL_TABLE(sys_dup3, 292) -TRACE_SYSCALL_TABLE(sys_ptrace, 101) -TRACE_SYSCALL_TABLE(sys_tee, 276) -TRACE_SYSCALL_TABLE(sys_mremap, 25) -TRACE_SYSCALL_TABLE(sys_prctl, 157) -TRACE_SYSCALL_TABLE(sys_remap_file_pages, 216) -TRACE_SYSCALL_TABLE(sys_mmap, 9) #endif /* _TRACE_SYSCALLS_H */ /* This part must be outside protection */ #include "../../../probes/define_trace.h" + +#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) + +#endif /* CREATE_SYSCALL_TABLE */ diff --git a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh index a42054d5..87daf0fc 100644 --- a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh +++ b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh @@ -44,7 +44,9 @@ HEADER=headers/${INPUTFILE}-${CLASS}.h echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER} echo \ -"#undef TRACE_SYSTEM +"#ifndef CREATE_SYSCALL_TABLE + +#undef TRACE_SYSTEM #define TRACE_SYSTEM syscalls #if !defined(_TRACE_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ) @@ -167,16 +169,23 @@ for NRARGS in $(seq 1 6); do grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} >> ${TMPFILE} done -sed 's/^syscall \([^ ]*\) nr \([^ ]*\).*$/'\ -'TRACE_SYSCALL_TABLE(sys_\1, \2)/g'\ - ${TMPFILE} >> ${HEADER} - -echo -n \ +echo \ " #endif /* _TRACE_SYSCALLS_H */ /* This part must be outside protection */ #include \"../../../probes/define_trace.h\" + +#else /* CREATE_SYSCALL_TABLE */ +" >> ${HEADER} + +sed 's/^syscall \([^ ]*\) nr \([^ ]*\) nbargs \([^ ]*\) .*$/'\ +'TRACE_SYSCALL_TABLE(sys_\1, \2, \3)/g'\ + ${TMPFILE} >> ${HEADER} + +echo -n \ +" +#endif /* CREATE_SYSCALL_TABLE */ " >> ${HEADER} rm -f ${INPUTFILE}.tmp diff --git a/probes/lttng-probe-syscalls.c b/probes/lttng-probe-syscalls.c index ee196e41..6bc65fcf 100644 --- a/probes/lttng-probe-syscalls.c +++ b/probes/lttng-probe-syscalls.c @@ -10,6 +10,8 @@ #include +#ifndef SYSCALL_DETAIL + /* * Create the tracepoint static inlines from the kernel to validate that our * trace event macros match the kernel we run on. @@ -21,12 +23,45 @@ */ #define LTTNG_PACKAGE_BUILD #define CREATE_TRACE_POINTS -//test #define TRACE_INCLUDE_PATH ../instrumentation/syscalls/headers #define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module -//test #include "../instrumentation/syscalls/headers/syscalls.h" #include "../instrumentation/events/lttng-module/syscalls.h" +#else /* SYSCALL_DETAIL */ + +/* + * Create LTTng tracepoint probes. + */ +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS + +#define TRACE_INCLUDE_PATH ../instrumentation/syscalls/headers + +#define TRACE_SYSCALL_TABLE(_name, _nr, _nrargs) + +#include "../instrumentation/syscalls/headers/syscalls.h" + +#undef LTTNG_PACKAGE_BUILD +#undef CREATE_TRACE_POINTS + +struct trace_syscall_entry { + void *func; + unsigned int nrargs; +}; + +#define CREATE_SYSCALL_TABLE + +#undef TRACE_SYSCALL_TABLE +#define TRACE_SYSCALL_TABLE(_name, _nr, _nrargs) \ + [ _nr ] = { .func = __event_probe__##_name, .nrargs = (_nrargs) }, + +static struct trace_syscall_entry sc_table[] = { +#include "../instrumentation/syscalls/headers/syscalls.h" +}; +#undef CREATE_SYSCALL_TABLE + +#endif /* SYSCALL_DETAIL */ + MODULE_LICENSE("GPL and additional rights"); MODULE_AUTHOR("Mathieu Desnoyers "); MODULE_DESCRIPTION("LTTng sched probes");