Document last supported kernel version for stable-2.11 branch
[lttng-modules.git] / lttng-events.h
index 42a7b24bbb35f103e771d8488cf11ffc6273f265..f6026292656b05f55a812e92388b1ad042db5ba3 100644 (file)
@@ -1,38 +1,27 @@
-#ifndef _LTTNG_EVENTS_H
-#define _LTTNG_EVENTS_H
-
-/*
+/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
+ *
  * lttng-events.h
  *
  * Holds LTTng per-session event registry.
  *
  * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <linux/version.h>
+#ifndef _LTTNG_EVENTS_H
+#define _LTTNG_EVENTS_H
+
+#include <lttng-kernel-version.h>
 #include <linux/list.h>
 #include <linux/kprobes.h>
 #include <linux/kref.h>
-#include <wrapper/uuid.h>
+#include <lttng-cpuhotplug.h>
+#include <linux/uuid.h>
+#include <wrapper/uprobes.h>
 #include <lttng-tracer.h>
 #include <lttng-abi.h>
 #include <lttng-abi-old.h>
 
-#define lttng_is_signed_type(type)     (((type)(-1)) < 0)
+#define lttng_is_signed_type(type)     (((type) -1) < (type) 1)
 
 struct lttng_channel;
 struct lttng_session;
@@ -54,6 +43,8 @@ enum abstract_types {
        atype_array_compound,           /* Array of compound types. */
        atype_sequence_compound,        /* Sequence of compound types. */
        atype_variant,
+       atype_array_bitfield,
+       atype_sequence_bitfield,
        NR_ABSTRACT_TYPES,
 };
 
@@ -184,8 +175,13 @@ union lttng_ctx_value {
  * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
  */
 struct lttng_perf_counter_field {
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
+       struct lttng_cpuhp_node cpuhp_prepare;
+       struct lttng_cpuhp_node cpuhp_online;
+#else
        struct notifier_block nb;
        int hp_enable;
+#endif
        struct perf_event_attr *attr;
        struct perf_event **e;  /* per-cpu array */
 };
@@ -198,6 +194,9 @@ struct lttng_probe_ctx {
 struct lttng_ctx_field {
        struct lttng_event_field event_field;
        size_t (*get_size)(size_t offset);
+       size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
+                              struct lib_ring_buffer_ctx *ctx,
+                              struct lttng_channel *chan);
        void (*record)(struct lttng_ctx_field *field,
                       struct lib_ring_buffer_ctx *ctx,
                       struct lttng_channel *chan);
@@ -208,6 +207,12 @@ struct lttng_ctx_field {
                struct lttng_perf_counter_field *perf_counter;
        } u;
        void (*destroy)(struct lttng_ctx_field *field);
+       /*
+        * Private data to keep state between get_size and record.
+        * User must perform its own synchronization to protect against
+        * concurrent and reentrant contexts.
+        */
+       void *priv;
 };
 
 struct lttng_ctx {
@@ -269,6 +274,7 @@ struct lttng_bytecode_runtime {
                        const char *filter_stack_data);
        int link_failed;
        struct list_head node;  /* list of bytecode runtime in event */
+       struct lttng_event *event;
 };
 
 /*
@@ -279,6 +285,23 @@ struct lttng_enabler_ref {
        struct lttng_enabler *ref;              /* backward ref */
 };
 
+struct lttng_uprobe_handler {
+       struct lttng_event *event;
+       loff_t offset;
+       struct uprobe_consumer up_consumer;
+       struct list_head node;
+};
+
+enum lttng_syscall_entryexit {
+       LTTNG_SYSCALL_ENTRY,
+       LTTNG_SYSCALL_EXIT,
+};
+
+enum lttng_syscall_abi {
+       LTTNG_SYSCALL_ABI_NATIVE,
+       LTTNG_SYSCALL_ABI_COMPAT,
+};
+
 /*
  * lttng_event structure is referred to by the tracing fast path. It must be
  * kept small.
@@ -302,8 +325,14 @@ struct lttng_event {
                        char *symbol_name;
                } kretprobe;
                struct {
-                       char *symbol_name;
-               } ftrace;
+                       struct inode *inode;
+                       struct list_head head;
+               } uprobe;
+               struct {
+                       char *syscall_name;
+                       enum lttng_syscall_entryexit entryexit;
+                       enum lttng_syscall_abi abi;
+               } syscall;
        } u;
        struct list_head list;          /* Event list in session */
        unsigned int metadata_dumped:1;
@@ -318,7 +347,7 @@ struct lttng_event {
 };
 
 enum lttng_enabler_type {
-       LTTNG_ENABLER_WILDCARD,
+       LTTNG_ENABLER_STAR_GLOB,
        LTTNG_ENABLER_NAME,
 };
 
@@ -443,10 +472,10 @@ struct lttng_channel {
        struct lttng_syscall_filter *sc_filter;
        int header_type;                /* 0: unset, 1: compact, 2: large */
        enum channel_type channel_type;
+       int syscall_all;
        unsigned int metadata_dumped:1,
                sys_enter_registered:1,
                sys_exit_registered:1,
-               syscall_all:1,
                tstate:1;               /* Transient enable state */
 };
 
@@ -460,6 +489,7 @@ struct lttng_metadata_stream {
        struct list_head list;          /* Stream list */
        struct lttng_transport *transport;
        uint64_t version;               /* Current version of the metadata cache */
+       bool coherent;                  /* Stream in a coherent state */
 };
 
 #define LTTNG_DYNAMIC_LEN_STACK_SIZE   128
@@ -504,12 +534,15 @@ struct lttng_session {
        struct list_head enablers_head;
        /* Hash table of events */
        struct lttng_event_ht events_ht;
+       char name[LTTNG_KERNEL_SESSION_NAME_LEN];
+       char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
 };
 
 struct lttng_metadata_cache {
        char *data;                     /* Metadata cache */
        unsigned int cache_alloc;       /* Metadata allocated size (bytes) */
        unsigned int metadata_written;  /* Number of bytes written in metadata cache */
+       atomic_t producing;             /* Metadata being produced (incomplete) */
        struct kref refcount;           /* Metadata cache usage */
        struct list_head metadata_stream;       /* Metadata stream list */
        uuid_le uuid;                   /* Trace session unique ID (copy) */
@@ -590,7 +623,7 @@ int lttng_probes_init(void);
 void lttng_probes_exit(void);
 
 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
-               struct channel *chan);
+               struct channel *chan, bool *coherent);
 
 int lttng_pid_tracker_get_node_pid(const struct lttng_pid_hash_node *node);
 struct lttng_pid_tracker *lttng_pid_tracker_create(void);
@@ -610,10 +643,11 @@ void lttng_clock_unref(void);
 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
 int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
 int lttng_syscalls_unregister(struct lttng_channel *chan);
+int lttng_syscalls_destroy(struct lttng_channel *chan);
 int lttng_syscall_filter_enable(struct lttng_channel *chan,
-               const char *name);
+               struct lttng_event *event);
 int lttng_syscall_filter_disable(struct lttng_channel *chan,
-               const char *name);
+               struct lttng_event *event);
 long lttng_channel_syscall_mask(struct lttng_channel *channel,
                struct lttng_kernel_syscall_mask __user *usyscall_mask);
 #else
@@ -627,14 +661,19 @@ static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
        return 0;
 }
 
+static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
+{
+       return 0;
+}
+
 static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
-               const char *name)
+               struct lttng_event *event);
 {
        return -ENOSYS;
 }
 
 static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
-               const char *name)
+               struct lttng_event *event);
 {
        return -ENOSYS;
 }
@@ -651,6 +690,7 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
                struct lttng_kernel_filter_bytecode __user *bytecode);
 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
                struct lttng_enabler *enabler);
+void lttng_free_event_filter_runtime(struct lttng_event *event);
 
 int lttng_probes_init(void);
 
@@ -696,11 +736,18 @@ int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
        return -ENOSYS;
 }
 #endif
-#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+
+int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
+
+#if defined(CONFIG_PERF_EVENTS) && (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
 int lttng_add_perf_counter_to_ctx(uint32_t type,
                                  uint64_t config,
                                  const char *name,
                                  struct lttng_ctx **ctx);
+int lttng_cpuhp_perf_counter_online(unsigned int cpu,
+               struct lttng_cpuhp_node *node);
+int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
+               struct lttng_cpuhp_node *node);
 #else
 static inline
 int lttng_add_perf_counter_to_ctx(uint32_t type,
@@ -710,6 +757,18 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
 {
        return -ENOSYS;
 }
+static inline
+int lttng_cpuhp_perf_counter_online(unsigned int cpu,
+               struct lttng_cpuhp_node *node)
+{
+       return 0;
+}
+static inline
+int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
+               struct lttng_cpuhp_node *node)
+{
+       return 0;
+}
 #endif
 
 int lttng_logger_init(void);
@@ -747,6 +806,42 @@ void lttng_kprobes_destroy_private(struct lttng_event *event)
 }
 #endif
 
+int lttng_event_add_callsite(struct lttng_event *event,
+       struct lttng_kernel_event_callsite *callsite);
+
+#ifdef CONFIG_UPROBES
+int lttng_uprobes_register(const char *name,
+       int fd, struct lttng_event *event);
+int lttng_uprobes_add_callsite(struct lttng_event *event,
+       struct lttng_kernel_event_callsite *callsite);
+void lttng_uprobes_unregister(struct lttng_event *event);
+void lttng_uprobes_destroy_private(struct lttng_event *event);
+#else
+static inline
+int lttng_uprobes_register(const char *name,
+       int fd, struct lttng_event *event)
+{
+       return -ENOSYS;
+}
+
+static inline
+int lttng_uprobes_add_callsite(struct lttng_event *event,
+       struct lttng_kernel_event_callsite *callsite)
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_uprobes_unregister(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_uprobes_destroy_private(struct lttng_event *event)
+{
+}
+#endif
+
 #ifdef CONFIG_KRETPROBES
 int lttng_kretprobes_register(const char *name,
                const char *symbol_name,
@@ -788,38 +883,12 @@ int lttng_kretprobes_event_enable_state(struct lttng_event *event,
 }
 #endif
 
-#ifdef CONFIG_DYNAMIC_FTRACE
-int lttng_ftrace_register(const char *name,
-                         const char *symbol_name,
-                         struct lttng_event *event);
-void lttng_ftrace_unregister(struct lttng_event *event);
-void lttng_ftrace_destroy_private(struct lttng_event *event);
-#else
-static inline
-int lttng_ftrace_register(const char *name,
-                         const char *symbol_name,
-                         struct lttng_event *event)
-{
-       return -ENOSYS;
-}
-
-static inline
-void lttng_ftrace_unregister(struct lttng_event *event)
-{
-}
-
-static inline
-void lttng_ftrace_destroy_private(struct lttng_event *event)
-{
-}
-#endif
-
 int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
 
 extern const struct file_operations lttng_tracepoint_list_fops;
 extern const struct file_operations lttng_syscall_list_fops;
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,35))
 #define TRACEPOINT_HAS_DATA_ARG
 #endif
 
This page took 0.027325 seconds and 4 git commands to generate.