From: Jérémie Galarneau Date: Fri, 18 Oct 2019 20:39:00 +0000 (-0400) Subject: Fix: sessiond: use system LTTng-UST headers when available X-Git-Tag: v2.10.10~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c57c2c7421d2bd7611d316ac8ca1cb443e1bc95c;p=lttng-tools.git Fix: sessiond: use system LTTng-UST headers when available 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/Makefile.am b/src/bin/lttng-sessiond/Makefile.am index 6fc18097f..4efbdcb41 100644 --- a/src/bin/lttng-sessiond/Makefile.am +++ b/src/bin/lttng-sessiond/Makefile.am @@ -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 \ diff --git a/src/bin/lttng-sessiond/buffer-registry.c b/src/bin/lttng-sessiond/buffer-registry.c index 7002b33c7..d54fa4d24 100644 --- a/src/bin/lttng-sessiond/buffer-registry.c +++ b/src/bin/lttng-sessiond/buffer-registry.c @@ -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" /* diff --git a/src/bin/lttng-sessiond/buffer-registry.h b/src/bin/lttng-sessiond/buffer-registry.h index db1ce0cbb..5bb71e55d 100644 --- a/src/bin/lttng-sessiond/buffer-registry.h +++ b/src/bin/lttng-sessiond/buffer-registry.h @@ -25,7 +25,7 @@ #include #include "consumer.h" -#include "ust-ctl.h" +#include "lttng-ust-ctl.h" #include "ust-registry.h" struct buffer_reg_stream { diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index f19dbec37..7c40b7ed1 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -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" diff --git a/src/bin/lttng-sessiond/context.h b/src/bin/lttng-sessiond/context.h index 01b35167e..4cd8851b2 100644 --- a/src/bin/lttng-sessiond/context.h +++ b/src/bin/lttng-sessiond/context.h @@ -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); diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 387b06fc5..26ed6d1a5 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -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" diff --git a/src/bin/lttng-sessiond/lttng-ust-abi.h b/src/bin/lttng-sessiond/lttng-ust-abi.h index 687eb0b23..4a504d871 100644 --- a/src/bin/lttng-sessiond/lttng-ust-abi.h +++ b/src/bin/lttng-sessiond/lttng-ust-abi.h @@ -1,328 +1,28 @@ -#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 * - * Copyright 2010-2012 - Mathieu Desnoyers + * 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 - -#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 +#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 */ diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h index 1d67e858c..a6ee88575 100644 --- a/src/bin/lttng-sessiond/lttng-ust-ctl.h +++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h @@ -1,6 +1,5 @@ /* - * Copyright (C) 2011 - Julien Desfossez - * Copyright (C) 2011-2013 - Mathieu Desnoyers + * Copyright (C) 2019 - Jérémie Galarneau * * 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 @@ -16,434 +15,14 @@ * 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 +#ifdef HAVE_LIBLTTNG_UST_CTL +#include +#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 */ diff --git a/src/bin/lttng-sessiond/lttng-ust-error.h b/src/bin/lttng-sessiond/lttng-ust-error.h index d9062c0a8..85b79cb19 100644 --- a/src/bin/lttng-sessiond/lttng-ust-error.h +++ b/src/bin/lttng-sessiond/lttng-ust-error.h @@ -1,61 +1,28 @@ -#ifndef _LTTNG_UST_ERROR_H -#define _LTTNG_UST_ERROR_H - /* - * Copyright (C) 2011 - David Goulet - * Julien Desfossez - * Mathieu Desnoyers + * Copyright (C) 2019 - Jérémie Galarneau * - * 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 -#include - -#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 +#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 */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d559306cb..7626b56a3 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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" diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 33b0a2031..6df259973 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -27,7 +27,7 @@ #include #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 index 000000000..687eb0b23 --- /dev/null +++ b/src/bin/lttng-sessiond/ust-abi-internal.h @@ -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 + * + * 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 + +#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 */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 62a6e9c09..d3bcfd3d7 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -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" diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 3c375f30d..0c69a6e6e 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -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 */ diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index a2258f409..8dc0fd905 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -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 index 000000000..1d67e858c --- /dev/null +++ b/src/bin/lttng-sessiond/ust-ctl-internal.h @@ -0,0 +1,449 @@ +/* + * Copyright (C) 2011 - Julien Desfossez + * Copyright (C) 2011-2013 - Mathieu Desnoyers + * + * 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 + +#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 index 131ff63b6..000000000 --- a/src/bin/lttng-sessiond/ust-ctl.h +++ /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 - * - * 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 -#include -#include - -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 index 000000000..d9062c0a8 --- /dev/null +++ b/src/bin/lttng-sessiond/ust-error-internal.h @@ -0,0 +1,61 @@ +#ifndef _LTTNG_UST_ERROR_H +#define _LTTNG_UST_ERROR_H + +/* + * Copyright (C) 2011 - David Goulet + * Julien Desfossez + * Mathieu Desnoyers + * + * 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 +#include + +#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 */ diff --git a/src/bin/lttng-sessiond/ust-field-utils.h b/src/bin/lttng-sessiond/ust-field-utils.h index e75621f42..f97080c62 100644 --- a/src/bin/lttng-sessiond/ust-field-utils.h +++ b/src/bin/lttng-sessiond/ust-field-utils.h @@ -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. diff --git a/src/bin/lttng-sessiond/ust-registry.h b/src/bin/lttng-sessiond/ust-registry.h index 414975caf..cc6d317f4 100644 --- a/src/bin/lttng-sessiond/ust-registry.h +++ b/src/bin/lttng-sessiond/ust-registry.h @@ -24,7 +24,7 @@ #include #include -#include "ust-ctl.h" +#include "lttng-ust-ctl.h" #define CTF_SPEC_MAJOR 1 #define CTF_SPEC_MINOR 8 diff --git a/src/common/consumer/consumer-timer.c b/src/common/consumer/consumer-timer.c index 06c9f1a1e..f7d4b78e6 100644 --- a/src/common/consumer/consumer-timer.c +++ b/src/common/consumer/consumer-timer.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include