callstack context: use delimiter when stack is incomplete
[lttng-modules.git] / lttng-syscalls.c
index e691e8bfc48f42af574ea336f0be0b121b5e52a1..0b980a1a92be53dc11442e672ff7f1ab0b08b5c6 100644 (file)
 #include <asm/ptrace.h>
 #include <asm/syscall.h>
 
-#include "lib/bitfield.h"
-#include "wrapper/tracepoint.h"
-#include "wrapper/file.h"
-#include "wrapper/rcu.h"
-#include "lttng-events.h"
+#include <lib/bitfield.h>
+#include <wrapper/tracepoint.h>
+#include <wrapper/file.h>
+#include <wrapper/rcu.h>
+#include <lttng-events.h>
 
 #ifndef CONFIG_COMPAT
 # ifndef is_compat_task
 # endif
 #endif
 
+/* in_compat_syscall appears in kernel 4.6. */
+#ifndef in_compat_syscall
+ #define in_compat_syscall()   is_compat_task()
+#endif
+
 enum sc_type {
        SC_TYPE_ENTRY,
        SC_TYPE_EXIT,
@@ -92,14 +97,14 @@ struct user_msghdr;
 #define LTTNG_PACKAGE_BUILD
 #define CREATE_TRACE_POINTS
 #define TP_MODULE_NOINIT
-#define TRACE_INCLUDE_PATH ../instrumentation/syscalls/headers
+#define TRACE_INCLUDE_PATH instrumentation/syscalls/headers
 
 #define PARAMS(args...)        args
 
 /* Handle unknown syscalls */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM syscalls_unknown
-#include "instrumentation/syscalls/headers/syscalls_unknown.h"
+#include <instrumentation/syscalls/headers/syscalls_unknown.h>
 #undef TRACE_SYSTEM
 
 #define SC_ENTER
@@ -127,17 +132,21 @@ struct user_msghdr;
        LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_entry_##_name, PARAMS(_fields))
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
        LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_entry_##_template, syscall_entry_##_name)
+/* Enumerations only defined at first inclusion. */
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
+       LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM syscall_entry_integers
 #define TRACE_INCLUDE_FILE syscalls_integers
-#include "instrumentation/syscalls/headers/syscalls_integers.h"
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM syscall_entry_pointers
 #define TRACE_INCLUDE_FILE syscalls_pointers
-#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
 #undef SC_LTTNG_TRACEPOINT_EVENT_CODE
 #undef SC_LTTNG_TRACEPOINT_EVENT
 #undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
@@ -148,6 +157,7 @@ struct user_msghdr;
 
 /* Hijack probe callback for compat system call enter */
 #define TP_PROBE_CB(_template)         &syscall_entry_probe
+#define LTTNG_SC_COMPAT
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
@@ -159,16 +169,19 @@ struct user_msghdr;
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
        LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_entry_##_template, \
                compat_syscall_entry_##_name)
+/* Enumerations only defined at inital inclusion (not here). */
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
 #define TRACE_SYSTEM compat_syscall_entry_integers
 #define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM compat_syscall_entry_pointers
 #define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
 #undef SC_LTTNG_TRACEPOINT_EVENT_CODE
 #undef SC_LTTNG_TRACEPOINT_EVENT
 #undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
@@ -176,6 +189,7 @@ struct user_msghdr;
 #undef TP_PROBE_CB
 #undef _TRACE_SYSCALLS_INTEGERS_H
 #undef _TRACE_SYSCALLS_POINTERS_H
+#undef LTTNG_SC_COMPAT
 
 #undef SC_ENTER
 
@@ -203,16 +217,19 @@ struct user_msghdr;
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
        LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_exit_##_template,        \
                syscall_exit_##_name)
+/* Enumerations only defined at inital inclusion (not here). */
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
 #define TRACE_SYSTEM syscall_exit_integers
 #define TRACE_INCLUDE_FILE syscalls_integers
-#include "instrumentation/syscalls/headers/syscalls_integers.h"
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM syscall_exit_pointers
 #define TRACE_INCLUDE_FILE syscalls_pointers
-#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
 #undef SC_LTTNG_TRACEPOINT_EVENT_CODE
 #undef SC_LTTNG_TRACEPOINT_EVENT
 #undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
@@ -224,6 +241,7 @@ struct user_msghdr;
 
 /* Hijack probe callback for compat system call exit */
 #define TP_PROBE_CB(_template)         &syscall_exit_probe
+#define LTTNG_SC_COMPAT
 #define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
        LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
                PARAMS(_fields))
@@ -235,16 +253,19 @@ struct user_msghdr;
 #define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name)            \
        LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_exit_##_template, \
                compat_syscall_exit_##_name)
+/* Enumerations only defined at inital inclusion (not here). */
+#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
 #define TRACE_SYSTEM compat_syscall_exit_integers
 #define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM compat_syscall_exit_pointers
 #define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
 #undef TRACE_INCLUDE_FILE
 #undef TRACE_SYSTEM
+#undef SC_LTTNG_TRACEPOINT_ENUM
 #undef SC_LTTNG_TRACEPOINT_EVENT_CODE
 #undef SC_LTTNG_TRACEPOINT_EVENT
 #undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
@@ -252,6 +273,7 @@ struct user_msghdr;
 #undef TP_PROBE_CB
 #undef _TRACE_SYSCALLS_INTEGERS_H
 #undef _TRACE_SYSCALLS_POINTERS_H
+#undef LTTNG_SC_COMPAT
 
 #undef SC_EXIT
 
@@ -284,8 +306,8 @@ struct trace_syscall_entry {
 
 /* Syscall enter tracing table */
 static const struct trace_syscall_entry sc_table[] = {
-#include "instrumentation/syscalls/headers/syscalls_integers.h"
-#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
 };
 
 #undef TRACE_SYSCALL_TABLE
@@ -299,8 +321,8 @@ static const struct trace_syscall_entry sc_table[] = {
 
 /* Compat syscall enter table */
 const struct trace_syscall_entry compat_sc_table[] = {
-#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
-#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
 };
 
 #undef SC_ENTER
@@ -321,8 +343,8 @@ const struct trace_syscall_entry compat_sc_table[] = {
 
 /* Syscall exit table */
 static const struct trace_syscall_entry sc_exit_table[] = {
-#include "instrumentation/syscalls/headers/syscalls_integers.h"
-#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/syscalls_integers.h>
+#include <instrumentation/syscalls/headers/syscalls_pointers.h>
 };
 
 #undef TRACE_SYSCALL_TABLE
@@ -336,8 +358,8 @@ static const struct trace_syscall_entry sc_exit_table[] = {
 
 /* Compat syscall exit table */
 const struct trace_syscall_entry compat_sc_exit_table[] = {
-#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
-#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
+#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
 };
 
 #undef SC_EXIT
@@ -355,7 +377,7 @@ static void syscall_entry_unknown(struct lttng_event *event,
        unsigned long args[UNKNOWN_SYSCALL_NRARGS];
 
        syscall_get_arguments(current, regs, 0, UNKNOWN_SYSCALL_NRARGS, args);
-       if (unlikely(is_compat_task()))
+       if (unlikely(in_compat_syscall()))
                __event_probe__compat_syscall_entry_unknown(event, id, args);
        else
                __event_probe__syscall_entry_unknown(event, id, args);
@@ -368,7 +390,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id)
        const struct trace_syscall_entry *table, *entry;
        size_t table_len;
 
-       if (unlikely(is_compat_task())) {
+       if (unlikely(in_compat_syscall())) {
                struct lttng_syscall_filter *filter;
 
                filter = lttng_rcu_dereference(chan->sc_filter);
@@ -401,7 +423,7 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id)
                syscall_entry_unknown(unknown_event, regs, id);
                return;
        }
-       if (unlikely(is_compat_task()))
+       if (unlikely(in_compat_syscall()))
                event = chan->compat_sc_table[id];
        else
                event = chan->sc_table[id];
@@ -506,7 +528,7 @@ static void syscall_exit_unknown(struct lttng_event *event,
        unsigned long args[UNKNOWN_SYSCALL_NRARGS];
 
        syscall_get_arguments(current, regs, 0, UNKNOWN_SYSCALL_NRARGS, args);
-       if (unlikely(is_compat_task()))
+       if (unlikely(in_compat_syscall()))
                __event_probe__compat_syscall_exit_unknown(event, id, ret,
                        args);
        else
@@ -522,7 +544,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret)
        long id;
 
        id = syscall_get_nr(current, regs);
-       if (unlikely(is_compat_task())) {
+       if (unlikely(in_compat_syscall())) {
                struct lttng_syscall_filter *filter;
 
                filter = lttng_rcu_dereference(chan->sc_filter);
@@ -555,7 +577,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret)
                syscall_exit_unknown(unknown_event, regs, id, ret);
                return;
        }
-       if (unlikely(is_compat_task()))
+       if (unlikely(in_compat_syscall()))
                event = chan->compat_sc_exit_table[id];
        else
                event = chan->sc_exit_table[id];
@@ -1237,7 +1259,7 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel,
        filter = channel->sc_filter;
 
        for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
-               bool state;
+               char state;
 
                if (channel->sc_table) {
                        if (filter)
@@ -1250,7 +1272,7 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel,
                bt_bitfield_write_be(tmp_mask, char, bit, 1, state);
        }
        for (; bit < sc_tables_len; bit++) {
-               bool state;
+               char state;
 
                if (channel->compat_sc_table) {
                        if (filter)
This page took 0.027155 seconds and 4 git commands to generate.