Fix: sessiond: use system LTTng-UST headers when available
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 Oct 2019 20:39:00 +0000 (16:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 Oct 2019 21:06:59 +0000 (17:06 -0400)
The LTTng-Tools tree includes a local copy of three LTTng-UST headers:
  * ust-error.h
  * ust-ctl.h
  * ust-abi.h

The system headers should be used when UST support is configured to
ensure the appropriate ABI definitions are used. The local copies of
the headers should only be used when LTTng-Tools is built with the
--without-lttng-ust configuration option. Those headers are needed
since some UST support code is compiled-in even though the support
is deactivated.

A misconfiguration in the CI setup allowed us to notice that
sessiond-config.c is using the internal header unconditionally.

To ensure this doesn't happen in the future, the local copies
are renamed:
  * ust-error.h -> ust-error-internal.h
  * ust-ctl.h   -> ust-ctl-internal.h
  * ust-abi.h   -> ust-abi-internal.h

All code should use the `lttng-` prefixed versions of the headers
which include either the local or "system" copy of the headers
depending on the build configuration.

Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
21 files changed:
src/bin/lttng-sessiond/Makefile.am
src/bin/lttng-sessiond/buffer-registry.c
src/bin/lttng-sessiond/buffer-registry.h
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/context.h
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/lttng-ust-abi.h
src/bin/lttng-sessiond/lttng-ust-ctl.h
src/bin/lttng-sessiond/lttng-ust-error.h
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/trace-ust.h
src/bin/lttng-sessiond/ust-abi-internal.h [new file with mode: 0644]
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-app.h
src/bin/lttng-sessiond/ust-consumer.c
src/bin/lttng-sessiond/ust-ctl-internal.h [new file with mode: 0644]
src/bin/lttng-sessiond/ust-ctl.h [deleted file]
src/bin/lttng-sessiond/ust-error-internal.h [new file with mode: 0644]
src/bin/lttng-sessiond/ust-field-utils.h
src/bin/lttng-sessiond/ust-registry.h
src/common/consumer/consumer-timer.c

index 9800c4b2ccc065beb851b09d6a9c60d2658108c9..296ec148b7163022f9dbca696d5186c4c2dcae62 100644 (file)
@@ -10,7 +10,9 @@ bin_PROGRAMS = lttng-sessiond
 lttng_sessiond_SOURCES = utils.c utils.h \
                        trace-kernel.c trace-kernel.h \
                        kernel.c kernel.h \
-                       ust-ctl.h ust-app.h trace-ust.h notify-apps.h \
+                       ust-app.h trace-ust.h notify-apps.h \
+                       lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
+                       ust-ctl-internal.h ust-abi-internal.h ust-error-internal.h \
                        ust-registry.h \
                        context.c context.h \
                        channel.c channel.h \
@@ -19,7 +21,6 @@ lttng_sessiond_SOURCES = utils.c utils.h \
                        consumer.c consumer.h \
                        session.c session.h \
                        modprobe.c modprobe.h kern-modules.h \
-                       lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
                        fd-limit.c fd-limit.h \
                        kernel-consumer.c kernel-consumer.h \
                        consumer.h \
index 5db920781b5009d1a0b2b462e8e96c2825c24243..f0f57ebaa7a3749d5fbb8a8c4357dd2039c777d8 100644 (file)
@@ -24,7 +24,8 @@
 #include "buffer-registry.h"
 #include "fd-limit.h"
 #include "ust-consumer.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
+#include "lttng-ust-error.h"
 #include "utils.h"
 
 /*
index d0d1575fd47e478ea57b6ae91aca6af6effd3189..415793c9511e4387c4c4529a074ecfe68b35db8d 100644 (file)
@@ -25,7 +25,7 @@
 #include <common/hashtable/hashtable.h>
 
 #include "consumer.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 #include "ust-registry.h"
 
 struct buffer_reg_stream {
index b270a43ca3a29118a1218c6d32308ec1496fdef0..6989fd890f788fe32be95ebdd4a77edbf7e9af1d 100644 (file)
@@ -28,7 +28,8 @@
 #include "channel.h"
 #include "lttng-sessiond.h"
 #include "kernel.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
+#include "lttng-ust-error.h"
 #include "utils.h"
 #include "ust-app.h"
 #include "agent.h"
index e9de999c471d109320bfb439264fe9e07bc39b9e..59faf86ccc78cd1cf7b340fb65f0929290c2eeb6 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "trace-kernel.h"
 #include "trace-ust.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 
 int context_kernel_add(struct ltt_kernel_session *ksession,
                const struct lttng_event_context *ctx, char *channel_name);
index e687caf8622729a85a316ac367cf5172fce386d0..96b0d2e7a25555310e3fb567bd2096d3081674ee 100644 (file)
@@ -31,7 +31,8 @@
 #include "event.h"
 #include "kernel.h"
 #include "lttng-sessiond.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
+#include "lttng-ust-error.h"
 #include "ust-app.h"
 #include "trace-kernel.h"
 #include "trace-ust.h"
index 40ba1f478bde9819f3f56447ba9523a24b3712be..4a504d87165a07e41d020b221ac87bb5668e5a54 100644 (file)
-#ifndef _LTTNG_UST_ABI_H
-#define _LTTNG_UST_ABI_H
-
 /*
- * lttng/ust-abi.h
- *
- * LTTng-UST ABI header
+ * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License only.
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * This program 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 General Public License for more details.
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-
-#define lttng_ust_notrace __attribute__((no_instrument_function))
-#define LTTNG_PACKED    __attribute__((__packed__))
-
-#ifndef __ust_stringify
-#define __ust_stringify1(x)    #x
-#define __ust_stringify(x)     __ust_stringify1(x)
-#endif /* __ust_stringify */
-
-#define LTTNG_UST_SYM_NAME_LEN                 256
-#define LTTNG_UST_ABI_PROCNAME_LEN             16
-
-/* UST comm magic number, used to validate protocol and endianness. */
-#define LTTNG_UST_COMM_MAGIC                   0xC57C57C5
-
-/* Version for ABI between liblttng-ust, sessiond, consumerd */
-#define LTTNG_UST_ABI_MAJOR_VERSION            8
-#define LTTNG_UST_ABI_MINOR_VERSION            0
-
-struct lttng_ust_calibrate;
-
-enum lttng_ust_instrumentation {
-       LTTNG_UST_TRACEPOINT            = 0,
-       LTTNG_UST_PROBE                 = 1,
-       LTTNG_UST_FUNCTION              = 2,
-};
-
-enum lttng_ust_loglevel_type {
-       LTTNG_UST_LOGLEVEL_ALL          = 0,
-       LTTNG_UST_LOGLEVEL_RANGE        = 1,
-       LTTNG_UST_LOGLEVEL_SINGLE       = 2,
-};
-
-enum lttng_ust_output {
-       LTTNG_UST_MMAP          = 0,
-};
-
-enum lttng_ust_chan_type {
-       LTTNG_UST_CHAN_PER_CPU = 0,
-       LTTNG_UST_CHAN_METADATA = 1,
-};
-
-struct lttng_ust_tracer_version {
-       uint32_t major;
-       uint32_t minor;
-       uint32_t patchlevel;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CHANNEL_PADDING      (LTTNG_UST_SYM_NAME_LEN + 32)
-/*
- * Given that the consumerd is limited to 64k file descriptors, we
- * cannot expect much more than 1MB channel structure size. This size is
- * depends on the number of streams within a channel, which depends on
- * the number of possible CPUs on the system.
- */
-#define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
-struct lttng_ust_channel {
-       uint64_t len;
-       enum lttng_ust_chan_type type;
-       char padding[LTTNG_UST_CHANNEL_PADDING];
-       char data[];    /* variable sized data */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_STREAM_PADDING1      (LTTNG_UST_SYM_NAME_LEN + 32)
-struct lttng_ust_stream {
-       uint64_t len;           /* shm len */
-       uint32_t stream_nr;     /* stream number */
-       char padding[LTTNG_UST_STREAM_PADDING1];
-       /*
-        * shm_fd and wakeup_fd are send over unix socket as file
-        * descriptors after this structure.
-        */
-} LTTNG_PACKED;
-
-#define LTTNG_UST_EVENT_PADDING1       16
-#define LTTNG_UST_EVENT_PADDING2       (LTTNG_UST_SYM_NAME_LEN + 32)
-struct lttng_ust_event {
-       enum lttng_ust_instrumentation instrumentation;
-       char name[LTTNG_UST_SYM_NAME_LEN];      /* event name */
-
-       enum lttng_ust_loglevel_type loglevel_type;
-       int loglevel;   /* value, -1: all */
-       char padding[LTTNG_UST_EVENT_PADDING1];
-
-       /* Per instrumentation type configuration */
-       union {
-               char padding[LTTNG_UST_EVENT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-enum lttng_ust_field_type {
-       LTTNG_UST_FIELD_OTHER                   = 0,
-       LTTNG_UST_FIELD_INTEGER                 = 1,
-       LTTNG_UST_FIELD_ENUM                    = 2,
-       LTTNG_UST_FIELD_FLOAT                   = 3,
-       LTTNG_UST_FIELD_STRING                  = 4,
-};
-
-#define LTTNG_UST_FIELD_ITER_PADDING   (LTTNG_UST_SYM_NAME_LEN + 28)
-struct lttng_ust_field_iter {
-       char event_name[LTTNG_UST_SYM_NAME_LEN];
-       char field_name[LTTNG_UST_SYM_NAME_LEN];
-       enum lttng_ust_field_type type;
-       int loglevel;                           /* event loglevel */
-       int nowrite;
-       char padding[LTTNG_UST_FIELD_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_context_type {
-       LTTNG_UST_CONTEXT_VTID                  = 0,
-       LTTNG_UST_CONTEXT_VPID                  = 1,
-       LTTNG_UST_CONTEXT_PTHREAD_ID            = 2,
-       LTTNG_UST_CONTEXT_PROCNAME              = 3,
-       LTTNG_UST_CONTEXT_IP                    = 4,
-       LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER   = 5,
-       LTTNG_UST_CONTEXT_CPU_ID                = 6,
-       LTTNG_UST_CONTEXT_APP_CONTEXT           = 7,
-};
-
-struct lttng_ust_perf_counter_ctx {
-       uint32_t type;
-       uint64_t config;
-       char name[LTTNG_UST_SYM_NAME_LEN];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_CONTEXT_PADDING1     16
-#define LTTNG_UST_CONTEXT_PADDING2     (LTTNG_UST_SYM_NAME_LEN + 32)
-struct lttng_ust_context {
-       enum lttng_ust_context_type ctx;
-       char padding[LTTNG_UST_CONTEXT_PADDING1];
-
-       union {
-               struct lttng_ust_perf_counter_ctx perf_counter;
-               struct {
-                       /* Includes trailing '\0'. */
-                       uint32_t provider_name_len;
-                       uint32_t ctx_name_len;
-               } app_ctx;
-               char padding[LTTNG_UST_CONTEXT_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-/*
- * Tracer channel attributes.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-#define LTTNG_UST_CHANNEL_ATTR_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
-struct lttng_ust_channel_attr {
-       uint64_t subbuf_size;                   /* bytes, power of 2 */
-       uint64_t num_subbuf;                    /* power of 2 */
-       int overwrite;                          /* 1: overwrite, 0: discard */
-       unsigned int switch_timer_interval;     /* usec */
-       unsigned int read_timer_interval;       /* usec */
-       enum lttng_ust_output output;           /* splice, mmap */
-       union {
-               struct {
-                       int64_t blocking_timeout;       /* Retry timeout (usec) */
-               } s;
-               char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-#define LTTNG_UST_TRACEPOINT_ITER_PADDING      16
-struct lttng_ust_tracepoint_iter {
-       char name[LTTNG_UST_SYM_NAME_LEN];      /* provider:name */
-       int loglevel;
-       char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
-} LTTNG_PACKED;
-
-enum lttng_ust_object_type {
-       LTTNG_UST_OBJECT_TYPE_UNKNOWN = -1,
-       LTTNG_UST_OBJECT_TYPE_CHANNEL = 0,
-       LTTNG_UST_OBJECT_TYPE_STREAM = 1,
-       LTTNG_UST_OBJECT_TYPE_EVENT = 2,
-       LTTNG_UST_OBJECT_TYPE_CONTEXT = 3,
-};
-
-#define LTTNG_UST_OBJECT_DATA_PADDING1 32
-#define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
-
-struct lttng_ust_object_data {
-       enum lttng_ust_object_type type;
-       int handle;
-       uint64_t size;
-       char padding1[LTTNG_UST_OBJECT_DATA_PADDING1];
-       union {
-               struct {
-                       void *data;
-                       enum lttng_ust_chan_type type;
-                       int wakeup_fd;
-               } channel;
-               struct {
-                       int shm_fd;
-                       int wakeup_fd;
-                       uint32_t stream_nr;
-               } stream;
-               char padding2[LTTNG_UST_OBJECT_DATA_PADDING2];
-       } u;
-} LTTNG_PACKED;
-
-#define FILTER_BYTECODE_MAX_LEN                65536
-#define LTTNG_UST_FILTER_PADDING       32
-struct lttng_ust_filter_bytecode {
-       uint32_t len;
-       uint32_t reloc_offset;
-       uint64_t seqnum;
-       char padding[LTTNG_UST_FILTER_PADDING];
-       char data[0];
-} LTTNG_PACKED;
-
-#define LTTNG_UST_EXCLUSION_PADDING    32
-struct lttng_ust_event_exclusion {
-       uint32_t count;
-       char padding[LTTNG_UST_EXCLUSION_PADDING];
-       char names[LTTNG_UST_SYM_NAME_LEN][0];
-} LTTNG_PACKED;
-
-#define _UST_CMD(minor)                                (minor)
-#define _UST_CMDR(minor, type)                 (minor)
-#define _UST_CMDW(minor, type)                 (minor)
-
-/* Handled by object descriptor */
-#define LTTNG_UST_RELEASE                      _UST_CMD(0x1)
-
-/* Handled by object cmd */
-
-/* LTTng-UST commands */
-#define LTTNG_UST_SESSION                      _UST_CMD(0x40)
-#define LTTNG_UST_TRACER_VERSION               \
-       _UST_CMDR(0x41, struct lttng_ust_tracer_version)
-#define LTTNG_UST_TRACEPOINT_LIST              _UST_CMD(0x42)
-#define LTTNG_UST_WAIT_QUIESCENT               _UST_CMD(0x43)
-#define LTTNG_UST_REGISTER_DONE                        _UST_CMD(0x44)
-#define LTTNG_UST_TRACEPOINT_FIELD_LIST                _UST_CMD(0x45)
-
-/* Session FD commands */
-#define LTTNG_UST_CHANNEL                      \
-       _UST_CMDW(0x51, struct lttng_ust_channel)
-#define LTTNG_UST_SESSION_START                        _UST_CMD(0x52)
-#define LTTNG_UST_SESSION_STOP                 _UST_CMD(0x53)
-#define LTTNG_UST_SESSION_STATEDUMP            _UST_CMD(0x54)
-
-/* Channel FD commands */
-#define LTTNG_UST_STREAM                       _UST_CMD(0x60)
-#define LTTNG_UST_EVENT                        \
-       _UST_CMDW(0x61, struct lttng_ust_event)
-
-/* Event and Channel FD commands */
-#define LTTNG_UST_CONTEXT                      \
-       _UST_CMDW(0x70, struct lttng_ust_context)
-#define LTTNG_UST_FLUSH_BUFFER                 \
-       _UST_CMD(0x71)
-
-/* Event, Channel and Session commands */
-#define LTTNG_UST_ENABLE                       _UST_CMD(0x80)
-#define LTTNG_UST_DISABLE                      _UST_CMD(0x81)
-
-/* Tracepoint list commands */
-#define LTTNG_UST_TRACEPOINT_LIST_GET          _UST_CMD(0x90)
-#define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET    _UST_CMD(0x91)
-
-/* Event FD commands */
-#define LTTNG_UST_FILTER                       _UST_CMD(0xA0)
-
-#define LTTNG_UST_ROOT_HANDLE  0
-
-struct lttng_ust_obj;
-
-union ust_args {
-       struct {
-               void *chan_data;
-               int wakeup_fd;
-       } channel;
-       struct {
-               int shm_fd;
-               int wakeup_fd;
-       } stream;
-       struct {
-               struct lttng_ust_field_iter entry;
-       } field_list;
-};
-
-struct lttng_ust_objd_ops {
-       long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
-               union ust_args *args, void *owner);
-       int (*release)(int objd);
-};
-
-/* Create root handle. Always ID 0. */
-int lttng_abi_create_root_handle(void);
 
-const struct lttng_ust_objd_ops *objd_ops(int id);
-int lttng_ust_objd_unref(int id, int is_owner);
+#ifndef LTTNG_UST_ABI_H
+#define LTTNG_UST_ABI_H
 
-void lttng_ust_abi_exit(void);
-void lttng_ust_events_exit(void);
-void lttng_ust_objd_table_owner_cleanup(void *owner);
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-abi.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-abi-internal.h"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
 
-#endif /* _LTTNG_UST_ABI_H */
+#endif /* LTTNG_UST_ABI_H */
index e415da4a2a6942a9e8e6b9da9b8880db96a4b5c2..a6ee88575c7d14315a79e241286f891ebef2fc4f 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
- * Copyright (C) 2011-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifndef _LTTNG_UST_CTL_H
-#define _LTTNG_UST_CTL_H
+#ifndef LTTNG_UST_CTL_H
+#define LTTNG_UST_CTL_H
 
-#include <sys/types.h>
-#include <limits.h>
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-ctl.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-ctl-internal.h"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
 
-#include "lttng-ust-abi.h"
-
-#ifndef LTTNG_UST_UUID_LEN
-#define LTTNG_UST_UUID_LEN     16
-#endif
-
-/* Default unix socket path */
-#define LTTNG_UST_SOCK_FILENAME                                        \
-       "lttng-ust-sock-"                                       \
-       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
-
-/*
- * Shared memory files path are automatically related to shm root, e.g.
- * /dev/shm under linux.
- */
-#define LTTNG_UST_WAIT_FILENAME                                        \
-       "lttng-ust-wait-"                                       \
-       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
-
-struct lttng_ust_shm_handle;
-struct lttng_ust_lib_ring_buffer;
-
-struct ustctl_consumer_channel_attr {
-       enum lttng_ust_chan_type type;
-       uint64_t subbuf_size;                   /* bytes */
-       uint64_t num_subbuf;                    /* power of 2 */
-       int overwrite;                          /* 1: overwrite, 0: discard */
-       unsigned int switch_timer_interval;     /* usec */
-       unsigned int read_timer_interval;       /* usec */
-       enum lttng_ust_output output;           /* splice, mmap */
-       uint32_t chan_id;                       /* channel ID */
-       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
-       int64_t blocking_timeout;                       /* Blocking timeout (usec) */
-} LTTNG_PACKED;
-
-/*
- * API used by sessiond.
- */
-
-struct lttng_ust_context_attr {
-       enum lttng_ust_context_type ctx;
-       union {
-               struct lttng_ust_perf_counter_ctx perf_counter;
-               struct {
-                       char *provider_name;
-                       char *ctx_name;
-               } app_ctx;
-       } u;
-};
-
-/*
- * Error values: all the following functions return:
- * >= 0: Success (LTTNG_UST_OK)
- * < 0: error code.
- */
-int ustctl_register_done(int sock);
-int ustctl_create_session(int sock);
-int ustctl_create_event(int sock, struct lttng_ust_event *ev,
-               struct lttng_ust_object_data *channel_data,
-               struct lttng_ust_object_data **event_data);
-int ustctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
-               struct lttng_ust_object_data *obj_data,
-               struct lttng_ust_object_data **context_data);
-int ustctl_set_filter(int sock, struct lttng_ust_filter_bytecode *bytecode,
-               struct lttng_ust_object_data *obj_data);
-int ustctl_set_exclusion(int sock, struct lttng_ust_event_exclusion *exclusion,
-               struct lttng_ust_object_data *obj_data);
-
-int ustctl_enable(int sock, struct lttng_ust_object_data *object);
-int ustctl_disable(int sock, struct lttng_ust_object_data *object);
-int ustctl_start_session(int sock, int handle);
-int ustctl_stop_session(int sock, int handle);
-
-/*
- * ustctl_tracepoint_list returns a tracepoint list handle, or negative
- * error value.
- */
-int ustctl_tracepoint_list(int sock);
-
-/*
- * ustctl_tracepoint_list_get is used to iterate on the tp list
- * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
-               struct lttng_ust_tracepoint_iter *iter);
-
-/*
- * ustctl_tracepoint_field_list returns a tracepoint field list handle,
- * or negative error value.
- */
-int ustctl_tracepoint_field_list(int sock);
-
-/*
- * ustctl_tracepoint_field_list_get is used to iterate on the tp field
- * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
- * returned.
- */
-int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
-               struct lttng_ust_field_iter *iter);
-
-int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
-int ustctl_wait_quiescent(int sock);
-
-int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object);
-
-int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate);
-
-/* Release object created by members of this API. */
-int ustctl_release_object(int sock, struct lttng_ust_object_data *data);
-/* Release handle returned by create session. */
-int ustctl_release_handle(int sock, int handle);
-
-int ustctl_recv_channel_from_consumer(int sock,
-               struct lttng_ust_object_data **channel_data);
-int ustctl_recv_stream_from_consumer(int sock,
-               struct lttng_ust_object_data **stream_data);
-int ustctl_send_channel_to_ust(int sock, int session_handle,
-               struct lttng_ust_object_data *channel_data);
-int ustctl_send_stream_to_ust(int sock,
-               struct lttng_ust_object_data *channel_data,
-               struct lttng_ust_object_data *stream_data);
-
-/*
- * ustctl_duplicate_ust_object_data allocated a new object in "dest" if
- * it succeeds (returns 0). It must be released using
- * ustctl_release_object() and then freed with free().
- */
-int ustctl_duplicate_ust_object_data(struct lttng_ust_object_data **dest,
-               struct lttng_ust_object_data *src);
-
-/*
- * API used by consumer.
- */
-
-struct ustctl_consumer_channel;
-struct ustctl_consumer_stream;
-struct ustctl_consumer_channel_attr;
-
-int ustctl_get_nr_stream_per_channel(void);
-
-struct ustctl_consumer_channel *
-       ustctl_create_channel(struct ustctl_consumer_channel_attr *attr,
-               const int *stream_fds, int nr_stream_fds);
-/*
- * Each stream created needs to be destroyed before calling
- * ustctl_destroy_channel().
- */
-void ustctl_destroy_channel(struct ustctl_consumer_channel *chan);
-
-int ustctl_send_channel_to_sessiond(int sock,
-               struct ustctl_consumer_channel *channel);
-int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan);
-int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
-int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *consumer_chan);
-int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
-
-int ustctl_write_metadata_to_channel(
-               struct ustctl_consumer_channel *channel,
-               const char *metadata_str,       /* NOT null-terminated */
-               size_t len);                    /* metadata length */
-ssize_t ustctl_write_one_packet_to_channel(
-               struct ustctl_consumer_channel *channel,
-               const char *metadata_str,       /* NOT null-terminated */
-               size_t len);                    /* metadata length */
-
-/*
- * Send a NULL stream to finish iteration over all streams of a given
- * channel.
- */
-int ustctl_send_stream_to_sessiond(int sock,
-               struct ustctl_consumer_stream *stream);
-int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream);
-int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream);
-int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream);
-int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream);
-
-/* Create/destroy stream buffers for read */
-struct ustctl_consumer_stream *
-       ustctl_create_stream(struct ustctl_consumer_channel *channel,
-                       int cpu);
-void ustctl_destroy_stream(struct ustctl_consumer_stream *stream);
-
-/* For mmap mode, readable without "get" operation */
-int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream,
-               unsigned long *len);
-int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
-               unsigned long *len);
-
-/*
- * For mmap mode, operate on the current packet (between get/put or
- * get_next/put_next).
- */
-void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream);
-int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
-               unsigned long *off);
-int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream,
-               unsigned long *len);
-int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream,
-               unsigned long *len);
-int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream);
-int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream);
-
-/* snapshot */
-
-int ustctl_snapshot(struct ustctl_consumer_stream *stream);
-int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream);
-int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
-               unsigned long *pos);
-int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
-               unsigned long *pos);
-int ustctl_get_subbuf(struct ustctl_consumer_stream *stream,
-               unsigned long *pos);
-int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
-
-void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
-               int producer_active);
-
-/* index */
-int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
-               uint64_t *timestamp_begin);
-int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
-       uint64_t *timestamp_end);
-int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
-       uint64_t *events_discarded);
-int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
-       uint64_t *content_size);
-int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
-       uint64_t *packet_size);
-int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
-               uint64_t *stream_id);
-int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
-               uint64_t *ts);
-int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
-               uint64_t *seq);
-int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
-               uint64_t *id);
-
-/* returns whether UST has perf counters support. */
-int ustctl_has_perf_counters(void);
-
-/* Regenerate the statedump. */
-int ustctl_regenerate_statedump(int sock, int handle);
-
-/* event registry management */
-
-enum ustctl_socket_type {
-       USTCTL_SOCKET_CMD = 0,
-       USTCTL_SOCKET_NOTIFY = 1,
-};
-
-enum ustctl_notify_cmd {
-       USTCTL_NOTIFY_CMD_EVENT = 0,
-       USTCTL_NOTIFY_CMD_CHANNEL = 1,
-       USTCTL_NOTIFY_CMD_ENUM = 2,
-};
-
-enum ustctl_channel_header {
-       USTCTL_CHANNEL_HEADER_UNKNOWN = 0,
-       USTCTL_CHANNEL_HEADER_COMPACT = 1,
-       USTCTL_CHANNEL_HEADER_LARGE = 2,
-};
-
-/* event type structures */
-
-enum ustctl_abstract_types {
-       ustctl_atype_integer,
-       ustctl_atype_enum,
-       ustctl_atype_array,
-       ustctl_atype_sequence,
-       ustctl_atype_string,
-       ustctl_atype_float,
-       ustctl_atype_variant,
-       ustctl_atype_struct,
-       NR_USTCTL_ABSTRACT_TYPES,
-};
-
-enum ustctl_string_encodings {
-       ustctl_encode_none = 0,
-       ustctl_encode_UTF8 = 1,
-       ustctl_encode_ASCII = 2,
-       NR_USTCTL_STRING_ENCODINGS,
-};
-
-#define USTCTL_UST_INTEGER_TYPE_PADDING        24
-struct ustctl_integer_type {
-       uint32_t size;          /* in bits */
-       uint32_t signedness;
-       uint32_t reverse_byte_order;
-       uint32_t base;          /* 2, 8, 10, 16, for pretty print */
-       int32_t encoding;       /* enum ustctl_string_encodings */
-       uint16_t alignment;     /* in bits */
-       char padding[USTCTL_UST_INTEGER_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define USTCTL_UST_FLOAT_TYPE_PADDING  24
-struct ustctl_float_type {
-       uint32_t exp_dig;               /* exponent digits, in bits */
-       uint32_t mant_dig;              /* mantissa digits, in bits */
-       uint32_t reverse_byte_order;
-       uint16_t alignment;     /* in bits */
-       char padding[USTCTL_UST_FLOAT_TYPE_PADDING];
-} LTTNG_PACKED;
-
-#define USTCTL_UST_ENUM_VALUE_PADDING  15
-struct ustctl_enum_value {
-       uint64_t value;
-       uint8_t signedness;
-       char padding[USTCTL_UST_ENUM_VALUE_PADDING];
-} LTTNG_PACKED;
-
-enum ustctl_ust_enum_entry_options {
-       USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
-};
-
-#define USTCTL_UST_ENUM_ENTRY_PADDING  32
-struct ustctl_enum_entry {
-       struct ustctl_enum_value start, end; /* start and end are inclusive */
-       char string[LTTNG_UST_SYM_NAME_LEN];
-       union {
-               struct {
-                       uint32_t options;
-               } LTTNG_PACKED extra;
-               char padding[USTCTL_UST_ENUM_ENTRY_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-#define USTCTL_UST_BASIC_TYPE_PADDING  296
-union _ustctl_basic_type {
-       struct ustctl_integer_type integer;
-       struct {
-               char name[LTTNG_UST_SYM_NAME_LEN];
-               struct ustctl_integer_type container_type;
-               uint64_t id;    /* enum ID in sessiond. */
-       } enumeration;
-       struct {
-               int32_t encoding;       /* enum ustctl_string_encodings */
-       } string;
-       struct ustctl_float_type _float;
-       char padding[USTCTL_UST_BASIC_TYPE_PADDING];
-} LTTNG_PACKED;
-
-struct ustctl_basic_type {
-       enum ustctl_abstract_types atype;
-       union {
-               union _ustctl_basic_type basic;
-       } u;
-} LTTNG_PACKED;
-
-#define USTCTL_UST_TYPE_PADDING        128
-struct ustctl_type {
-       enum ustctl_abstract_types atype;
-       union {
-               union _ustctl_basic_type basic;
-               struct {
-                       struct ustctl_basic_type elem_type;
-                       uint32_t length;                /* num. elems. */
-               } array;
-               struct {
-                       struct ustctl_basic_type length_type;
-                       struct ustctl_basic_type elem_type;
-               } sequence;
-               struct {
-                       uint32_t nr_choices;
-                       char tag_name[LTTNG_UST_SYM_NAME_LEN];
-                       /* Followed by nr_choices struct ustctl_field. */
-               } variant;
-               struct {
-                       uint32_t nr_fields;
-                       /* Followed by nr_fields struct ustctl_field. */
-               } _struct;
-               char padding[USTCTL_UST_TYPE_PADDING];
-       } u;
-} LTTNG_PACKED;
-
-#define USTCTL_UST_FIELD_PADDING       28
-struct ustctl_field {
-       char name[LTTNG_UST_SYM_NAME_LEN];
-       struct ustctl_type type;
-       char padding[USTCTL_UST_FIELD_PADDING];
-} LTTNG_PACKED;
-
-/*
- * Returns 0 on success, negative error value on error.
- * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
- * the output fields are not populated.
- */
-int ustctl_recv_reg_msg(int sock,
-       enum ustctl_socket_type *type,
-       uint32_t *major,
-       uint32_t *minor,
-       uint32_t *pid,
-       uint32_t *ppid,
-       uint32_t *uid,
-       uint32_t *gid,
-       uint32_t *bits_per_long,
-       uint32_t *uint8_t_alignment,
-       uint32_t *uint16_t_alignment,
-       uint32_t *uint32_t_alignment,
-       uint32_t *uint64_t_alignment,
-       uint32_t *long_alignment,
-       int *byte_order,
-       char *name);    /* size LTTNG_UST_ABI_PROCNAME_LEN */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- * Receive the notification command. The "notify_cmd" can then be used
- * by the caller to find out which ustctl_recv_* function should be
- * called to receive the notification, and which ustctl_reply_* is
- * appropriate.
- */
-int ustctl_recv_notify(int sock, enum ustctl_notify_cmd *notify_cmd);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int ustctl_recv_register_event(int sock,
-       int *session_objd,              /* session descriptor (output) */
-       int *channel_objd,              /* channel descriptor (output) */
-       char *event_name,               /*
-                                        * event name (output,
-                                        * size LTTNG_UST_SYM_NAME_LEN)
-                                        */
-       int *loglevel,
-       char **signature,               /*
-                                        * event signature
-                                        * (output, dynamically
-                                        * allocated, must be free(3)'d
-                                        * by the caller if function
-                                        * returns success.)
-                                        */
-       size_t *nr_fields,
-       struct ustctl_field **fields,
-       char **model_emf_uri);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int ustctl_reply_register_event(int sock,
-       uint32_t id,                    /* event id (input) */
-       int ret_code);                  /* return code. 0 ok, negative error */
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int ustctl_recv_register_enum(int sock,
-       int *session_objd,
-       char *enum_name,
-       struct ustctl_enum_entry **entries,
-       size_t *nr_entries);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int ustctl_reply_register_enum(int sock,
-       uint64_t id,                    /* enum id (input) */
-       int ret_code);
-
-/*
- * Returns 0 on success, negative UST or system error value on error.
- */
-int ustctl_recv_register_channel(int sock,
-       int *session_objd,              /* session descriptor (output) */
-       int *channel_objd,              /* channel descriptor (output) */
-       size_t *nr_fields,              /* context fields */
-       struct ustctl_field **fields);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int ustctl_reply_register_channel(int sock,
-       uint32_t chan_id,
-       enum ustctl_channel_header header_type,
-       int ret_code);                  /* return code. 0 ok, negative error */
-
-#endif /* _LTTNG_UST_CTL_H */
+#endif /* LTTNG_UST_CTL_H */
index d9062c0a866946d2bef52881b8bf64233d41b00c..85b79cb19025b0e9fddff061cb4debe638b2cde7 100644 (file)
@@ -1,61 +1,28 @@
-#ifndef _LTTNG_UST_ERROR_H
-#define _LTTNG_UST_ERROR_H
-
 /*
- * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
- *                      Julien Desfossez <julien.desfossez@polymtl.ca>
- *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@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 program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License only.
  *
- * This library is distributed in the hope that it will be useful,
+ * This program 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU 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
- */
-
-/*
- * This header is meant for liblttng and libust internal use ONLY.
- * These declarations should NOT be considered stable API.
- */
-
-#include <limits.h>
-#include <unistd.h>
-
-#include "lttng-ust-abi.h"
-
-/*
- * ustcomm error code.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-enum lttng_ust_error_code {
-       LTTNG_UST_OK = 0,                       /* Ok */
-       LTTNG_UST_ERR = 1024,                   /* Unknown Error */
-       LTTNG_UST_ERR_NOENT = 1025,             /* No entry */
-       LTTNG_UST_ERR_EXIST = 1026,             /* Object exists */
-       LTTNG_UST_ERR_INVAL = 1027,             /* Invalid argument */
-       LTTNG_UST_ERR_PERM  = 1028,             /* Permission denied */
-       LTTNG_UST_ERR_NOSYS = 1029,             /* Not implemented */
-       LTTNG_UST_ERR_EXITING = 1030,           /* Process is exiting */
 
-       LTTNG_UST_ERR_INVAL_MAGIC = 1031,       /* Invalid magic number */
-       LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
-       LTTNG_UST_ERR_UNSUP_MAJOR = 1033,       /* Unsupported major version */
+#ifndef LTTNG_UST_ERROR_H
+#define LTTNG_UST_ERROR_H
 
-       /* MUST be last element */
-       LTTNG_UST_ERR_NR,                       /* Last element */
-};
-
-/*
- * Return a human-readable error message for an lttng-ust error code.
- * code must be a positive value (or 0).
- */
-extern const char *lttng_ust_strerror(int code);
+#ifdef HAVE_LIBLTTNG_UST_CTL
+#include <lttng/ust-error.h>
+#else /* HAVE_LIBLTTNG_UST_CTL */
+/* Use local copy of the LTTng-UST header. */
+#include "ust-error-internal.h"
+#endif /* HAVE_LIBLTTNG_UST_CTL */
 
-#endif /* _LTTNG_UST_ERROR_H */
+#endif /* LTTNG_UST_ERROR_H */
index f7832300a002222428e8b06a21023def90f9cf57..38ff2fd26b3d389d093fa458b897cf2dfe43b9f6 100644 (file)
@@ -62,7 +62,7 @@
 #include "kernel.h"
 #include "kernel-consumer.h"
 #include "shm.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 #include "ust-consumer.h"
 #include "utils.h"
 #include "fd-limit.h"
index 89088ec0324d95103919b2913f6b47b840b49955..7d923d5270d6f39b412e18d51a5509b854b7cc85 100644 (file)
@@ -27,7 +27,7 @@
 #include <common/defaults.h>
 
 #include "consumer.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 
 struct agent;
 
diff --git a/src/bin/lttng-sessiond/ust-abi-internal.h b/src/bin/lttng-sessiond/ust-abi-internal.h
new file mode 100644 (file)
index 0000000..5515613
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * lttng/ust-abi.h
+ *
+ * LTTng-UST ABI header
+ *
+ * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef LTTNG_UST_ABI_INTERNAL_H
+#define LTTNG_UST_ABI_INTERNAL_H
+
+#include <stdint.h>
+
+#define lttng_ust_notrace __attribute__((no_instrument_function))
+#define LTTNG_PACKED    __attribute__((__packed__))
+
+#ifndef __ust_stringify
+#define __ust_stringify1(x)    #x
+#define __ust_stringify(x)     __ust_stringify1(x)
+#endif /* __ust_stringify */
+
+#define LTTNG_UST_SYM_NAME_LEN                 256
+#define LTTNG_UST_ABI_PROCNAME_LEN             16
+
+/* UST comm magic number, used to validate protocol and endianness. */
+#define LTTNG_UST_COMM_MAGIC                   0xC57C57C5
+
+/* Version for ABI between liblttng-ust, sessiond, consumerd */
+#define LTTNG_UST_ABI_MAJOR_VERSION            8
+#define LTTNG_UST_ABI_MINOR_VERSION            0
+
+struct lttng_ust_calibrate;
+
+enum lttng_ust_instrumentation {
+       LTTNG_UST_TRACEPOINT            = 0,
+       LTTNG_UST_PROBE                 = 1,
+       LTTNG_UST_FUNCTION              = 2,
+};
+
+enum lttng_ust_loglevel_type {
+       LTTNG_UST_LOGLEVEL_ALL          = 0,
+       LTTNG_UST_LOGLEVEL_RANGE        = 1,
+       LTTNG_UST_LOGLEVEL_SINGLE       = 2,
+};
+
+enum lttng_ust_output {
+       LTTNG_UST_MMAP          = 0,
+};
+
+enum lttng_ust_chan_type {
+       LTTNG_UST_CHAN_PER_CPU = 0,
+       LTTNG_UST_CHAN_METADATA = 1,
+};
+
+struct lttng_ust_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CHANNEL_PADDING      (LTTNG_UST_SYM_NAME_LEN + 32)
+/*
+ * Given that the consumerd is limited to 64k file descriptors, we
+ * cannot expect much more than 1MB channel structure size. This size is
+ * depends on the number of streams within a channel, which depends on
+ * the number of possible CPUs on the system.
+ */
+#define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
+struct lttng_ust_channel {
+       uint64_t len;
+       enum lttng_ust_chan_type type;
+       char padding[LTTNG_UST_CHANNEL_PADDING];
+       char data[];    /* variable sized data */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_STREAM_PADDING1      (LTTNG_UST_SYM_NAME_LEN + 32)
+struct lttng_ust_stream {
+       uint64_t len;           /* shm len */
+       uint32_t stream_nr;     /* stream number */
+       char padding[LTTNG_UST_STREAM_PADDING1];
+       /*
+        * shm_fd and wakeup_fd are send over unix socket as file
+        * descriptors after this structure.
+        */
+} LTTNG_PACKED;
+
+#define LTTNG_UST_EVENT_PADDING1       16
+#define LTTNG_UST_EVENT_PADDING2       (LTTNG_UST_SYM_NAME_LEN + 32)
+struct lttng_ust_event {
+       enum lttng_ust_instrumentation instrumentation;
+       char name[LTTNG_UST_SYM_NAME_LEN];      /* event name */
+
+       enum lttng_ust_loglevel_type loglevel_type;
+       int loglevel;   /* value, -1: all */
+       char padding[LTTNG_UST_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               char padding[LTTNG_UST_EVENT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+enum lttng_ust_field_type {
+       LTTNG_UST_FIELD_OTHER                   = 0,
+       LTTNG_UST_FIELD_INTEGER                 = 1,
+       LTTNG_UST_FIELD_ENUM                    = 2,
+       LTTNG_UST_FIELD_FLOAT                   = 3,
+       LTTNG_UST_FIELD_STRING                  = 4,
+};
+
+#define LTTNG_UST_FIELD_ITER_PADDING   (LTTNG_UST_SYM_NAME_LEN + 28)
+struct lttng_ust_field_iter {
+       char event_name[LTTNG_UST_SYM_NAME_LEN];
+       char field_name[LTTNG_UST_SYM_NAME_LEN];
+       enum lttng_ust_field_type type;
+       int loglevel;                           /* event loglevel */
+       int nowrite;
+       char padding[LTTNG_UST_FIELD_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_context_type {
+       LTTNG_UST_CONTEXT_VTID                  = 0,
+       LTTNG_UST_CONTEXT_VPID                  = 1,
+       LTTNG_UST_CONTEXT_PTHREAD_ID            = 2,
+       LTTNG_UST_CONTEXT_PROCNAME              = 3,
+       LTTNG_UST_CONTEXT_IP                    = 4,
+       LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER   = 5,
+       LTTNG_UST_CONTEXT_CPU_ID                = 6,
+       LTTNG_UST_CONTEXT_APP_CONTEXT           = 7,
+};
+
+struct lttng_ust_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_UST_SYM_NAME_LEN];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_CONTEXT_PADDING1     16
+#define LTTNG_UST_CONTEXT_PADDING2     (LTTNG_UST_SYM_NAME_LEN + 32)
+struct lttng_ust_context {
+       enum lttng_ust_context_type ctx;
+       char padding[LTTNG_UST_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_ust_perf_counter_ctx perf_counter;
+               struct {
+                       /* Includes trailing '\0'. */
+                       uint32_t provider_name_len;
+                       uint32_t ctx_name_len;
+               } app_ctx;
+               char padding[LTTNG_UST_CONTEXT_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+/*
+ * Tracer channel attributes.
+ */
+#define LTTNG_UST_CHANNEL_ATTR_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
+struct lttng_ust_channel_attr {
+       uint64_t subbuf_size;                   /* bytes, power of 2 */
+       uint64_t num_subbuf;                    /* power of 2 */
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       unsigned int switch_timer_interval;     /* usec */
+       unsigned int read_timer_interval;       /* usec */
+       enum lttng_ust_output output;           /* splice, mmap */
+       union {
+               struct {
+                       int64_t blocking_timeout;       /* Retry timeout (usec) */
+               } s;
+               char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+#define LTTNG_UST_TRACEPOINT_ITER_PADDING      16
+struct lttng_ust_tracepoint_iter {
+       char name[LTTNG_UST_SYM_NAME_LEN];      /* provider:name */
+       int loglevel;
+       char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
+} LTTNG_PACKED;
+
+enum lttng_ust_object_type {
+       LTTNG_UST_OBJECT_TYPE_UNKNOWN = -1,
+       LTTNG_UST_OBJECT_TYPE_CHANNEL = 0,
+       LTTNG_UST_OBJECT_TYPE_STREAM = 1,
+       LTTNG_UST_OBJECT_TYPE_EVENT = 2,
+       LTTNG_UST_OBJECT_TYPE_CONTEXT = 3,
+};
+
+#define LTTNG_UST_OBJECT_DATA_PADDING1 32
+#define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
+
+struct lttng_ust_object_data {
+       enum lttng_ust_object_type type;
+       int handle;
+       uint64_t size;
+       char padding1[LTTNG_UST_OBJECT_DATA_PADDING1];
+       union {
+               struct {
+                       void *data;
+                       enum lttng_ust_chan_type type;
+                       int wakeup_fd;
+               } channel;
+               struct {
+                       int shm_fd;
+                       int wakeup_fd;
+                       uint32_t stream_nr;
+               } stream;
+               char padding2[LTTNG_UST_OBJECT_DATA_PADDING2];
+       } u;
+} LTTNG_PACKED;
+
+#define FILTER_BYTECODE_MAX_LEN                65536
+#define LTTNG_UST_FILTER_PADDING       32
+struct lttng_ust_filter_bytecode {
+       uint32_t len;
+       uint32_t reloc_offset;
+       uint64_t seqnum;
+       char padding[LTTNG_UST_FILTER_PADDING];
+       char data[0];
+} LTTNG_PACKED;
+
+#define LTTNG_UST_EXCLUSION_PADDING    32
+struct lttng_ust_event_exclusion {
+       uint32_t count;
+       char padding[LTTNG_UST_EXCLUSION_PADDING];
+       char names[LTTNG_UST_SYM_NAME_LEN][0];
+} LTTNG_PACKED;
+
+#define _UST_CMD(minor)                                (minor)
+#define _UST_CMDR(minor, type)                 (minor)
+#define _UST_CMDW(minor, type)                 (minor)
+
+/* Handled by object descriptor */
+#define LTTNG_UST_RELEASE                      _UST_CMD(0x1)
+
+/* Handled by object cmd */
+
+/* LTTng-UST commands */
+#define LTTNG_UST_SESSION                      _UST_CMD(0x40)
+#define LTTNG_UST_TRACER_VERSION               \
+       _UST_CMDR(0x41, struct lttng_ust_tracer_version)
+#define LTTNG_UST_TRACEPOINT_LIST              _UST_CMD(0x42)
+#define LTTNG_UST_WAIT_QUIESCENT               _UST_CMD(0x43)
+#define LTTNG_UST_REGISTER_DONE                        _UST_CMD(0x44)
+#define LTTNG_UST_TRACEPOINT_FIELD_LIST                _UST_CMD(0x45)
+
+/* Session FD commands */
+#define LTTNG_UST_CHANNEL                      \
+       _UST_CMDW(0x51, struct lttng_ust_channel)
+#define LTTNG_UST_SESSION_START                        _UST_CMD(0x52)
+#define LTTNG_UST_SESSION_STOP                 _UST_CMD(0x53)
+#define LTTNG_UST_SESSION_STATEDUMP            _UST_CMD(0x54)
+
+/* Channel FD commands */
+#define LTTNG_UST_STREAM                       _UST_CMD(0x60)
+#define LTTNG_UST_EVENT                        \
+       _UST_CMDW(0x61, struct lttng_ust_event)
+
+/* Event and Channel FD commands */
+#define LTTNG_UST_CONTEXT                      \
+       _UST_CMDW(0x70, struct lttng_ust_context)
+#define LTTNG_UST_FLUSH_BUFFER                 \
+       _UST_CMD(0x71)
+
+/* Event, Channel and Session commands */
+#define LTTNG_UST_ENABLE                       _UST_CMD(0x80)
+#define LTTNG_UST_DISABLE                      _UST_CMD(0x81)
+
+/* Tracepoint list commands */
+#define LTTNG_UST_TRACEPOINT_LIST_GET          _UST_CMD(0x90)
+#define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET    _UST_CMD(0x91)
+
+/* Event FD commands */
+#define LTTNG_UST_FILTER                       _UST_CMD(0xA0)
+
+#define LTTNG_UST_ROOT_HANDLE  0
+
+struct lttng_ust_obj;
+
+union ust_args {
+       struct {
+               void *chan_data;
+               int wakeup_fd;
+       } channel;
+       struct {
+               int shm_fd;
+               int wakeup_fd;
+       } stream;
+       struct {
+               struct lttng_ust_field_iter entry;
+       } field_list;
+};
+
+struct lttng_ust_objd_ops {
+       long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
+               union ust_args *args, void *owner);
+       int (*release)(int objd);
+};
+
+/* Create root handle. Always ID 0. */
+int lttng_abi_create_root_handle(void);
+
+const struct lttng_ust_objd_ops *objd_ops(int id);
+int lttng_ust_objd_unref(int id, int is_owner);
+
+void lttng_ust_abi_exit(void);
+void lttng_ust_events_exit(void);
+void lttng_ust_objd_table_owner_cleanup(void *owner);
+
+#endif /* LTTNG_UST_ABI_INTERNAL_H */
index c03772842b88e39976716c7c9f926217d2668e04..1731c368328b31fcf8712a6e02309418dc686bda 100644 (file)
@@ -27,7 +27,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <urcu/compiler.h>
-#include <lttng/ust-error.h>
 #include <signal.h>
 
 #include <common/common.h>
@@ -38,7 +37,8 @@
 #include "health-sessiond.h"
 #include "ust-app.h"
 #include "ust-consumer.h"
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
+#include "lttng-ust-error.h"
 #include "utils.h"
 #include "session.h"
 #include "lttng-sessiond.h"
index a385cfcd3e5faf06ea2ab7f3616e1d2b838628ce..4c8c3cc62f310be594444d33492fe5634c4103da 100644 (file)
@@ -363,6 +363,8 @@ int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
 enum lttng_error_code ust_app_rotate_session(struct ltt_session *session);
 enum lttng_error_code ust_app_create_channel_subdirectories(
                const struct ltt_ust_session *session);
+int ust_app_release_object(struct ust_app *app,
+               struct lttng_ust_object_data *data);
 
 static inline
 int ust_app_supported(void)
@@ -603,6 +605,12 @@ enum lttng_error_code ust_app_create_channel_subdirectories(
        return 0;
 }
 
+static inline
+int ust_app_release_object(struct ust_app *app, struct lttng_ust_object_data *data)
+{
+       return 0;
+}
+
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
 #endif /* _LTT_UST_APP_H */
index 9ab54e9d7a64553f9e0d61d31d2e54661ad67ef9..a3e7eea008aee322566ff32a622871cfe6d060f9 100644 (file)
@@ -30,6 +30,7 @@
 #include "consumer.h"
 #include "health-sessiond.h"
 #include "ust-consumer.h"
+#include "lttng-ust-error.h"
 #include "buffer-registry.h"
 #include "session.h"
 #include "lttng-sessiond.h"
diff --git a/src/bin/lttng-sessiond/ust-ctl-internal.h b/src/bin/lttng-sessiond/ust-ctl-internal.h
new file mode 100644 (file)
index 0000000..9ab1b8c
--- /dev/null
@@ -0,0 +1,500 @@
+/*
+ * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Copyright (C) 2011-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License only.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef LTTNG_UST_CTL_INTERNAL_H
+#define LTTNG_UST_CTL_INTERNAL_H
+
+#include <sys/types.h>
+#include <limits.h>
+
+#include "lttng-ust-abi.h"
+
+#ifndef LTTNG_UST_UUID_LEN
+#define LTTNG_UST_UUID_LEN     16
+#endif
+
+/* Default unix socket path */
+#define LTTNG_UST_SOCK_FILENAME                                        \
+       "lttng-ust-sock-"                                       \
+       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
+
+/*
+ * Shared memory files path are automatically related to shm root, e.g.
+ * /dev/shm under linux.
+ */
+#define LTTNG_UST_WAIT_FILENAME                                        \
+       "lttng-ust-wait-"                                       \
+       __ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
+
+struct lttng_ust_shm_handle;
+struct lttng_ust_lib_ring_buffer;
+
+struct ustctl_consumer_channel_attr {
+       enum lttng_ust_chan_type type;
+       uint64_t subbuf_size;                   /* bytes */
+       uint64_t num_subbuf;                    /* power of 2 */
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       unsigned int switch_timer_interval;     /* usec */
+       unsigned int read_timer_interval;       /* usec */
+       enum lttng_ust_output output;           /* splice, mmap */
+       uint32_t chan_id;                       /* channel ID */
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
+       int64_t blocking_timeout;                       /* Blocking timeout (usec) */
+} LTTNG_PACKED;
+
+/*
+ * API used by sessiond.
+ */
+
+struct lttng_ust_context_attr {
+       enum lttng_ust_context_type ctx;
+       union {
+               struct lttng_ust_perf_counter_ctx perf_counter;
+               struct {
+                       char *provider_name;
+                       char *ctx_name;
+               } app_ctx;
+       } u;
+};
+
+/*
+ * Error values: all the following functions return:
+ * >= 0: Success (LTTNG_UST_OK)
+ * < 0: error code.
+ */
+int ustctl_register_done(int sock);
+int ustctl_create_session(int sock);
+int ustctl_create_event(int sock, struct lttng_ust_event *ev,
+               struct lttng_ust_object_data *channel_data,
+               struct lttng_ust_object_data **event_data);
+int ustctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
+               struct lttng_ust_object_data *obj_data,
+               struct lttng_ust_object_data **context_data);
+int ustctl_set_filter(int sock, struct lttng_ust_filter_bytecode *bytecode,
+               struct lttng_ust_object_data *obj_data);
+int ustctl_set_exclusion(int sock, struct lttng_ust_event_exclusion *exclusion,
+               struct lttng_ust_object_data *obj_data);
+
+int ustctl_enable(int sock, struct lttng_ust_object_data *object);
+int ustctl_disable(int sock, struct lttng_ust_object_data *object);
+int ustctl_start_session(int sock, int handle);
+int ustctl_stop_session(int sock, int handle);
+
+/*
+ * ustctl_tracepoint_list returns a tracepoint list handle, or negative
+ * error value.
+ */
+int ustctl_tracepoint_list(int sock);
+
+/*
+ * ustctl_tracepoint_list_get is used to iterate on the tp list
+ * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
+               struct lttng_ust_tracepoint_iter *iter);
+
+/*
+ * ustctl_tracepoint_field_list returns a tracepoint field list handle,
+ * or negative error value.
+ */
+int ustctl_tracepoint_field_list(int sock);
+
+/*
+ * ustctl_tracepoint_field_list_get is used to iterate on the tp field
+ * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
+ * returned.
+ */
+int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
+               struct lttng_ust_field_iter *iter);
+
+int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
+int ustctl_wait_quiescent(int sock);
+
+int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object);
+
+int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate);
+
+/* Release object created by members of this API. */
+int ustctl_release_object(int sock, struct lttng_ust_object_data *data);
+/* Release handle returned by create session. */
+int ustctl_release_handle(int sock, int handle);
+
+int ustctl_recv_channel_from_consumer(int sock,
+               struct lttng_ust_object_data **channel_data);
+int ustctl_recv_stream_from_consumer(int sock,
+               struct lttng_ust_object_data **stream_data);
+int ustctl_send_channel_to_ust(int sock, int session_handle,
+               struct lttng_ust_object_data *channel_data);
+int ustctl_send_stream_to_ust(int sock,
+               struct lttng_ust_object_data *channel_data,
+               struct lttng_ust_object_data *stream_data);
+
+/*
+ * ustctl_duplicate_ust_object_data allocated a new object in "dest" if
+ * it succeeds (returns 0). It must be released using
+ * ustctl_release_object() and then freed with free().
+ */
+int ustctl_duplicate_ust_object_data(struct lttng_ust_object_data **dest,
+               struct lttng_ust_object_data *src);
+
+/*
+ * API used by consumer.
+ */
+
+struct ustctl_consumer_channel;
+struct ustctl_consumer_stream;
+struct ustctl_consumer_channel_attr;
+
+int ustctl_get_nr_stream_per_channel(void);
+
+struct ustctl_consumer_channel *
+       ustctl_create_channel(struct ustctl_consumer_channel_attr *attr,
+               const int *stream_fds, int nr_stream_fds);
+/*
+ * Each stream created needs to be destroyed before calling
+ * ustctl_destroy_channel().
+ */
+void ustctl_destroy_channel(struct ustctl_consumer_channel *chan);
+
+int ustctl_send_channel_to_sessiond(int sock,
+               struct ustctl_consumer_channel *channel);
+int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan);
+int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
+int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *consumer_chan);
+int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
+
+int ustctl_write_metadata_to_channel(
+               struct ustctl_consumer_channel *channel,
+               const char *metadata_str,       /* NOT null-terminated */
+               size_t len);                    /* metadata length */
+ssize_t ustctl_write_one_packet_to_channel(
+               struct ustctl_consumer_channel *channel,
+               const char *metadata_str,       /* NOT null-terminated */
+               size_t len);                    /* metadata length */
+
+/*
+ * Send a NULL stream to finish iteration over all streams of a given
+ * channel.
+ */
+int ustctl_send_stream_to_sessiond(int sock,
+               struct ustctl_consumer_stream *stream);
+int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream);
+int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream);
+int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream);
+int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream);
+
+/* Create/destroy stream buffers for read */
+struct ustctl_consumer_stream *
+       ustctl_create_stream(struct ustctl_consumer_channel *channel,
+                       int cpu);
+void ustctl_destroy_stream(struct ustctl_consumer_stream *stream);
+
+/* For mmap mode, readable without "get" operation */
+int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream,
+               unsigned long *len);
+int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
+               unsigned long *len);
+
+/*
+ * For mmap mode, operate on the current packet (between get/put or
+ * get_next/put_next).
+ */
+void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream);
+int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
+               unsigned long *off);
+int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream,
+               unsigned long *len);
+int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream,
+               unsigned long *len);
+int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream);
+int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream);
+
+/* snapshot */
+
+int ustctl_snapshot(struct ustctl_consumer_stream *stream);
+int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream);
+int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
+               unsigned long *pos);
+int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
+               unsigned long *pos);
+int ustctl_get_subbuf(struct ustctl_consumer_stream *stream,
+               unsigned long *pos);
+int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
+
+void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
+               int producer_active);
+
+/* index */
+int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
+               uint64_t *timestamp_begin);
+int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
+       uint64_t *timestamp_end);
+int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
+       uint64_t *events_discarded);
+int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
+       uint64_t *content_size);
+int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
+       uint64_t *packet_size);
+int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
+               uint64_t *stream_id);
+int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
+               uint64_t *ts);
+int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
+               uint64_t *seq);
+int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
+               uint64_t *id);
+
+/* returns whether UST has perf counters support. */
+int ustctl_has_perf_counters(void);
+
+/* Regenerate the statedump. */
+int ustctl_regenerate_statedump(int sock, int handle);
+
+/* event registry management */
+
+enum ustctl_socket_type {
+       USTCTL_SOCKET_CMD = 0,
+       USTCTL_SOCKET_NOTIFY = 1,
+};
+
+enum ustctl_notify_cmd {
+       USTCTL_NOTIFY_CMD_EVENT = 0,
+       USTCTL_NOTIFY_CMD_CHANNEL = 1,
+       USTCTL_NOTIFY_CMD_ENUM = 2,
+};
+
+enum ustctl_channel_header {
+       USTCTL_CHANNEL_HEADER_UNKNOWN = 0,
+       USTCTL_CHANNEL_HEADER_COMPACT = 1,
+       USTCTL_CHANNEL_HEADER_LARGE = 2,
+};
+
+/* event type structures */
+
+enum ustctl_abstract_types {
+       ustctl_atype_integer,
+       ustctl_atype_enum,
+       ustctl_atype_array,
+       ustctl_atype_sequence,
+       ustctl_atype_string,
+       ustctl_atype_float,
+       ustctl_atype_variant,
+       ustctl_atype_struct,
+       NR_USTCTL_ABSTRACT_TYPES,
+};
+
+enum ustctl_string_encodings {
+       ustctl_encode_none = 0,
+       ustctl_encode_UTF8 = 1,
+       ustctl_encode_ASCII = 2,
+       NR_USTCTL_STRING_ENCODINGS,
+};
+
+#define USTCTL_UST_INTEGER_TYPE_PADDING        24
+struct ustctl_integer_type {
+       uint32_t size;          /* in bits */
+       uint32_t signedness;
+       uint32_t reverse_byte_order;
+       uint32_t base;          /* 2, 8, 10, 16, for pretty print */
+       int32_t encoding;       /* enum ustctl_string_encodings */
+       uint16_t alignment;     /* in bits */
+       char padding[USTCTL_UST_INTEGER_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define USTCTL_UST_FLOAT_TYPE_PADDING  24
+struct ustctl_float_type {
+       uint32_t exp_dig;               /* exponent digits, in bits */
+       uint32_t mant_dig;              /* mantissa digits, in bits */
+       uint32_t reverse_byte_order;
+       uint16_t alignment;     /* in bits */
+       char padding[USTCTL_UST_FLOAT_TYPE_PADDING];
+} LTTNG_PACKED;
+
+#define USTCTL_UST_ENUM_VALUE_PADDING  15
+struct ustctl_enum_value {
+       uint64_t value;
+       uint8_t signedness;
+       char padding[USTCTL_UST_ENUM_VALUE_PADDING];
+} LTTNG_PACKED;
+
+enum ustctl_ust_enum_entry_options {
+       USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
+};
+
+#define USTCTL_UST_ENUM_ENTRY_PADDING  32
+struct ustctl_enum_entry {
+       struct ustctl_enum_value start, end; /* start and end are inclusive */
+       char string[LTTNG_UST_SYM_NAME_LEN];
+       union {
+               struct {
+                       uint32_t options;
+               } LTTNG_PACKED extra;
+               char padding[USTCTL_UST_ENUM_ENTRY_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+#define USTCTL_UST_BASIC_TYPE_PADDING  296
+union _ustctl_basic_type {
+       struct ustctl_integer_type integer;
+       struct {
+               char name[LTTNG_UST_SYM_NAME_LEN];
+               struct ustctl_integer_type container_type;
+               uint64_t id;    /* enum ID in sessiond. */
+       } enumeration;
+       struct {
+               int32_t encoding;       /* enum ustctl_string_encodings */
+       } string;
+       struct ustctl_float_type _float;
+       char padding[USTCTL_UST_BASIC_TYPE_PADDING];
+} LTTNG_PACKED;
+
+struct ustctl_basic_type {
+       enum ustctl_abstract_types atype;
+       union {
+               union _ustctl_basic_type basic;
+       } u;
+} LTTNG_PACKED;
+
+#define USTCTL_UST_TYPE_PADDING        128
+struct ustctl_type {
+       enum ustctl_abstract_types atype;
+       union {
+               union _ustctl_basic_type basic;
+               struct {
+                       struct ustctl_basic_type elem_type;
+                       uint32_t length;                /* num. elems. */
+               } array;
+               struct {
+                       struct ustctl_basic_type length_type;
+                       struct ustctl_basic_type elem_type;
+               } sequence;
+               struct {
+                       uint32_t nr_choices;
+                       char tag_name[LTTNG_UST_SYM_NAME_LEN];
+                       /* Followed by nr_choices struct ustctl_field. */
+               } variant;
+               struct {
+                       uint32_t nr_fields;
+                       /* Followed by nr_fields struct ustctl_field. */
+               } _struct;
+               char padding[USTCTL_UST_TYPE_PADDING];
+       } u;
+} LTTNG_PACKED;
+
+#define USTCTL_UST_FIELD_PADDING       28
+struct ustctl_field {
+       char name[LTTNG_UST_SYM_NAME_LEN];
+       struct ustctl_type type;
+       char padding[USTCTL_UST_FIELD_PADDING];
+} LTTNG_PACKED;
+
+/*
+ * Returns 0 on success, negative error value on error.
+ * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
+ * the output fields are not populated.
+ */
+int ustctl_recv_reg_msg(int sock,
+       enum ustctl_socket_type *type,
+       uint32_t *major,
+       uint32_t *minor,
+       uint32_t *pid,
+       uint32_t *ppid,
+       uint32_t *uid,
+       uint32_t *gid,
+       uint32_t *bits_per_long,
+       uint32_t *uint8_t_alignment,
+       uint32_t *uint16_t_alignment,
+       uint32_t *uint32_t_alignment,
+       uint32_t *uint64_t_alignment,
+       uint32_t *long_alignment,
+       int *byte_order,
+       char *name);    /* size LTTNG_UST_ABI_PROCNAME_LEN */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ * Receive the notification command. The "notify_cmd" can then be used
+ * by the caller to find out which ustctl_recv_* function should be
+ * called to receive the notification, and which ustctl_reply_* is
+ * appropriate.
+ */
+int ustctl_recv_notify(int sock, enum ustctl_notify_cmd *notify_cmd);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int ustctl_recv_register_event(int sock,
+       int *session_objd,              /* session descriptor (output) */
+       int *channel_objd,              /* channel descriptor (output) */
+       char *event_name,               /*
+                                        * event name (output,
+                                        * size LTTNG_UST_SYM_NAME_LEN)
+                                        */
+       int *loglevel,
+       char **signature,               /*
+                                        * event signature
+                                        * (output, dynamically
+                                        * allocated, must be free(3)'d
+                                        * by the caller if function
+                                        * returns success.)
+                                        */
+       size_t *nr_fields,
+       struct ustctl_field **fields,
+       char **model_emf_uri);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int ustctl_reply_register_event(int sock,
+       uint32_t id,                    /* event id (input) */
+       int ret_code);                  /* return code. 0 ok, negative error */
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int ustctl_recv_register_enum(int sock,
+       int *session_objd,
+       char *enum_name,
+       struct ustctl_enum_entry **entries,
+       size_t *nr_entries);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int ustctl_reply_register_enum(int sock,
+       uint64_t id,                    /* enum id (input) */
+       int ret_code);
+
+/*
+ * Returns 0 on success, negative UST or system error value on error.
+ */
+int ustctl_recv_register_channel(int sock,
+       int *session_objd,              /* session descriptor (output) */
+       int *channel_objd,              /* channel descriptor (output) */
+       size_t *nr_fields,              /* context fields */
+       struct ustctl_field **fields);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int ustctl_reply_register_channel(int sock,
+       uint32_t chan_id,
+       enum ustctl_channel_header header_type,
+       int ret_code);                  /* return code. 0 ok, negative error */
+
+#endif /* LTTNG_UST_CTL_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/ust-ctl.h b/src/bin/lttng-sessiond/ust-ctl.h
deleted file mode 100644 (file)
index 131ff63..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ust-ctl.h
- *
- * Meta header used to include all relevant file from the lttng ust ABI.
- *
- * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * This program 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 General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef LTTNG_UST_CTL_H
-#define LTTNG_UST_CTL_H
-
-struct ust_app;
-
-/*
- * FIXME: temporary workaround: we use a lttng-tools local version of
- * lttng-ust-abi.h if UST is not found. Eventually, we should use our
- * own internal structures within lttng-tools instead of relying on the
- * UST ABI.
- */
-#ifdef HAVE_LIBLTTNG_UST_CTL
-
-#include <lttng/ust-ctl.h>
-#include <lttng/ust-abi.h>
-#include <lttng/ust-error.h>
-
-int ust_app_release_object(struct ust_app *app, struct lttng_ust_object_data *data);
-
-#else /* HAVE_LIBLTTNG_UST_CTL */
-
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-abi.h"
-#include "lttng-ust-error.h"
-
-static inline
-int ust_app_release_object(struct ust_app *app, struct lttng_ust_object_data *data)
-{
-       return 0;
-}
-
-#endif /* HAVE_LIBLTTNG_UST_CTL */
-
-#endif /* _LTT_UST_CTL_H */
diff --git a/src/bin/lttng-sessiond/ust-error-internal.h b/src/bin/lttng-sessiond/ust-error-internal.h
new file mode 100644 (file)
index 0000000..d9062c0
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef _LTTNG_UST_ERROR_H
+#define _LTTNG_UST_ERROR_H
+
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *                      Julien Desfossez <julien.desfossez@polymtl.ca>
+ *                      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
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+
+#include "lttng-ust-abi.h"
+
+/*
+ * ustcomm error code.
+ */
+enum lttng_ust_error_code {
+       LTTNG_UST_OK = 0,                       /* Ok */
+       LTTNG_UST_ERR = 1024,                   /* Unknown Error */
+       LTTNG_UST_ERR_NOENT = 1025,             /* No entry */
+       LTTNG_UST_ERR_EXIST = 1026,             /* Object exists */
+       LTTNG_UST_ERR_INVAL = 1027,             /* Invalid argument */
+       LTTNG_UST_ERR_PERM  = 1028,             /* Permission denied */
+       LTTNG_UST_ERR_NOSYS = 1029,             /* Not implemented */
+       LTTNG_UST_ERR_EXITING = 1030,           /* Process is exiting */
+
+       LTTNG_UST_ERR_INVAL_MAGIC = 1031,       /* Invalid magic number */
+       LTTNG_UST_ERR_INVAL_SOCKET_TYPE = 1032, /* Invalid socket type */
+       LTTNG_UST_ERR_UNSUP_MAJOR = 1033,       /* Unsupported major version */
+
+       /* MUST be last element */
+       LTTNG_UST_ERR_NR,                       /* Last element */
+};
+
+/*
+ * Return a human-readable error message for an lttng-ust error code.
+ * code must be a positive value (or 0).
+ */
+extern const char *lttng_ust_strerror(int code);
+
+#endif /* _LTTNG_UST_ERROR_H */
index e75621f42f0cc68c1ee426f31e9dc403abe96bcf..f97080c627dbc6f6683dfb5f324716d338b421ef 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef LTTNG_UST_FIELD_UTILS_H
 #define LTTNG_UST_FIELD_UTILS_H
 
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 
 /*
  * Compare two UST fields.
index a0a4a17f43b8ba0edd8ecd3f9d29798ffe421c01..e118ac8cc1f6528080bd4ce79e44ddd556496049 100644 (file)
@@ -24,7 +24,7 @@
 #include <common/hashtable/hashtable.h>
 #include <common/compat/uuid.h>
 
-#include "ust-ctl.h"
+#include "lttng-ust-ctl.h"
 
 #define CTF_SPEC_MAJOR 1
 #define CTF_SPEC_MINOR 8
index 7d000c145494fba7250e8901cd7d304e86936492..dab30d4053ecbda6826521e592873cf5fa35a6ca 100644 (file)
@@ -21,7 +21,6 @@
 #include <inttypes.h>
 #include <signal.h>
 
-#include <bin/lttng-sessiond/ust-ctl.h>
 #include <bin/lttng-consumerd/health-consumerd.h>
 #include <common/common.h>
 #include <common/compat/endian.h>
This page took 0.063179 seconds and 4 git commands to generate.