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:59:04 +0000 (17:59 -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 6fc18097f134eb5f97f94a8ac34489e452445408..4efbdcb41ff58c138bcc9f281e915d3d3e033d19 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 ust-thread.h \
+                       ust-app.h trace-ust.h ust-thread.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 7002b33c7b2969bca7ce97f04b2ffd64ecd394a6..d54fa4d24c86bb2636b6e21cacc6ae7dd8a73348 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 db1ce0cbbbc821d338aa7edb3a81e2093e2e2084..5bb71e55d5d2223bce88d86609e17f6e9b95d03b 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 f19dbec37f51697209c0ae1d678a1af7768e8533..7c40b7ed1f3b6750871bc89ba9e7733808515bd7 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 01b35167e484b11ebe3a104d65a1e24828fe24b5..4cd8851b24d3c19c0210b61c961e94dea3701bfd 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,
                struct lttng_event_context *ctx, char *channel_name);
index 387b06fc5b10d04fdc9c1a283ea9bb93f39d6ff7..26ed6d1a541975d749ff4c9b948ff10236a521b2 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 687eb0b231991b6c559b933720fa3f3af20ed004..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            7
-#define LTTNG_UST_ABI_MINOR_VERSION            2
-
-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 1d67e858caa44fc7c899face35928e8bbd6f5834..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>
+#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, 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 */
-       uint32_t chan_id;           /* channel ID */
-       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
-       int64_t blocking_timeout;                       /* Retry 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_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);
-
-/* 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;
-
-struct ustctl_consumer_channel *
-       ustctl_create_channel(struct ustctl_consumer_channel_attr *attr);
-/*
- * 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 */
-
-/*
- * 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);
-
-/* 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,
-       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;
-       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 {
-               int32_t encoding;
-       } string;
-       struct ustctl_float_type _float;
-       struct {
-               char name[LTTNG_UST_SYM_NAME_LEN];
-       } enumeration;
-       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;
-               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_value,
-       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,
-       unsigned int *nr_entries);
-
-/*
- * Returns 0 on success, negative error value on error.
- */
-int ustctl_reply_register_enum(int sock,
-       int64_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 d559306cb323a7578d62058063777d2a07466d21..7626b56a335b5fee3319f1dc62ee34ea75bfb634 100644 (file)
@@ -61,7 +61,7 @@
 #include "kernel-consumer.h"
 #include "modprobe.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 33b0a20315fe23b8ac543a43af286c811d54e9e6..6df259973b115fd89f8e6a1acd874ad9a1d07349 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..687eb0b
--- /dev/null
@@ -0,0 +1,328 @@
+#ifndef _LTTNG_UST_ABI_H
+#define _LTTNG_UST_ABI_H
+
+/*
+ * 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.
+ */
+
+#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            7
+#define LTTNG_UST_ABI_MINOR_VERSION            2
+
+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_H */
index 62a6e9c0916467772ecb96511e1f712cd26edcc9..d3bcfd3d78ebf81479a38085923248f99a202d12 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 3c375f30d82e33513db0445d134da6931315463d..0c69a6e6ea77287f16b95b7a4995b6fc3a52545e 100644 (file)
@@ -357,6 +357,8 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
                struct consumer_output *consumer,
                int overwrite, uint64_t *discarded, uint64_t *lost);
 int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess);
+int ust_app_release_object(struct ust_app *app,
+               struct lttng_ust_object_data *data);
 
 static inline
 int ust_app_supported(void)
@@ -590,6 +592,12 @@ int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess)
        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 a2258f409ad1a9ef8b773446da01205800458f12..8dc0fd905ae823d53709dd498dc68583acfb288a 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..1d67e85
--- /dev/null
@@ -0,0 +1,449 @@
+/*
+ * 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_H
+#define _LTTNG_UST_CTL_H
+
+#include <sys/types.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, 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 */
+       uint32_t chan_id;           /* channel ID */
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
+       int64_t blocking_timeout;                       /* Retry 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_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);
+
+/* 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;
+
+struct ustctl_consumer_channel *
+       ustctl_create_channel(struct ustctl_consumer_channel_attr *attr);
+/*
+ * 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 */
+
+/*
+ * 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);
+
+/* 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,
+       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;
+       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 {
+               int32_t encoding;
+       } string;
+       struct ustctl_float_type _float;
+       struct {
+               char name[LTTNG_UST_SYM_NAME_LEN];
+       } enumeration;
+       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;
+               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_value,
+       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,
+       unsigned int *nr_entries);
+
+/*
+ * Returns 0 on success, negative error value on error.
+ */
+int ustctl_reply_register_enum(int sock,
+       int64_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 */
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 414975cafc4b1f3b209e49ce5900c7373e18f2dd..cc6d317f492370b8e56351e4827303181e96d7d3 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 06c9f1a1e007e3c4d18b9e9fc55962d48329adf0..f7d4b78e6ca80313af1ce819d236336cf4dfbdef 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.050161 seconds and 4 git commands to generate.