From: Mathieu Desnoyers Date: Wed, 27 Jul 2011 18:10:36 +0000 (-0400) Subject: TRACEPOINT_EVENT API X-Git-Tag: v1.9.1~319 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0a42beb627df1b9ea5cce4b1908e8a9cefaa1631;p=lttng-ust.git TRACEPOINT_EVENT API Signed-off-by: Mathieu Desnoyers --- diff --git a/include/Makefile.am b/include/Makefile.am index 1bd30320..93853642 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,8 +1,10 @@ nobase_include_HEADERS = \ ust/marker.h \ ust/tracepoint.h \ - ust/tracepoint_event.h \ - ust/probe.h \ + ust/tracepoint-event.h \ + ust/lttng-tracepoint-event.h \ + ust/lttng-tracepoint-event-reset.h \ + ust/lttng-events.h \ ust/version.h \ ust/lttng-ust-abi.h \ ust/ringbuffer-abi.h diff --git a/include/ust/lttng-events.h b/include/ust/lttng-events.h new file mode 100644 index 00000000..743ff161 --- /dev/null +++ b/include/ust/lttng-events.h @@ -0,0 +1,279 @@ +#ifndef _UST_LTTNG_EVENTS_H +#define _UST_LTTNG_EVENTS_H + +/* + * ust/lttng-events.h + * + * Copyright 2010 (c) - Mathieu Desnoyers + * + * Holds LTTng per-session event registry. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include + +#undef is_signed_type +#define is_signed_type(type) (((type)(-1)) < 0) + +struct ltt_channel; +struct ltt_session; +struct lib_ring_buffer_ctx; + +/* Type description */ + +/* Update the astract_types name table in lttng-types.c along with this enum */ +enum abstract_types { + atype_integer, + atype_enum, + atype_array, + atype_sequence, + atype_string, + NR_ABSTRACT_TYPES, +}; + +/* Update the string_encodings name table in lttng-types.c along with this enum */ +enum lttng_string_encodings { + lttng_encode_none = 0, + lttng_encode_UTF8 = 1, + lttng_encode_ASCII = 2, + NR_STRING_ENCODINGS, +}; + +struct lttng_enum_entry { + unsigned long long start, end; /* start and end are inclusive */ + const char *string; +}; + +#define __type_integer(_type, _byte_order, _base, _encoding) \ + { \ + .atype = atype_integer, \ + .u.basic.integer = \ + { \ + .size = sizeof(_type) * CHAR_BIT, \ + .alignment = ltt_alignof(_type) * CHAR_BIT, \ + .signedness = is_signed_type(_type), \ + .reverse_byte_order = _byte_order != __BYTE_ORDER, \ + .base = _base, \ + .encoding = lttng_encode_##_encoding, \ + }, \ + } \ + +struct lttng_integer_type { + unsigned int size; /* in bits */ + unsigned short alignment; /* in bits */ + unsigned int signedness:1; + unsigned int reverse_byte_order:1; + unsigned int base; /* 2, 8, 10, 16, for pretty print */ + enum lttng_string_encodings encoding; +}; + +union _lttng_basic_type { + struct lttng_integer_type integer; + struct { + const char *name; + } enumeration; + struct { + enum lttng_string_encodings encoding; + } string; +}; + +struct lttng_basic_type { + enum abstract_types atype; + union { + union _lttng_basic_type basic; + } u; +}; + +struct lttng_type { + enum abstract_types atype; + union { + union _lttng_basic_type basic; + struct { + struct lttng_basic_type elem_type; + unsigned int length; /* num. elems. */ + } array; + struct { + struct lttng_basic_type length_type; + struct lttng_basic_type elem_type; + } sequence; + } u; +}; + +struct lttng_enum { + const char *name; + struct lttng_type container_type; + const struct lttng_enum_entry *entries; + unsigned int len; +}; + +/* Event field description */ + +struct lttng_event_field { + const char *name; + struct lttng_type type; +}; + +struct lttng_ctx_field { + struct lttng_event_field event_field; + size_t (*get_size)(size_t offset); + void (*record)(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan); + union { + } u; + void (*destroy)(struct lttng_ctx_field *field); +}; + +struct lttng_ctx { + struct lttng_ctx_field *fields; + unsigned int nr_fields; + unsigned int allocated_fields; +}; + +struct lttng_event_desc { + const char *name; + void *probe_callback; + const struct lttng_event_ctx *ctx; /* context */ + const struct lttng_event_field *fields; /* event payload */ + unsigned int nr_fields; +}; + +struct lttng_probe_desc { + const struct lttng_event_desc *event_desc; + unsigned int nr_events; + struct cds_list_head head; /* chain registered probes */ +}; + +/* + * ltt_event structure is referred to by the tracing fast path. It must be + * kept small. + */ +struct ltt_event { + unsigned int id; + struct ltt_channel *chan; + int enabled; + const struct lttng_event_desc *desc; + void *filter; + struct lttng_ctx *ctx; + enum lttng_ust_instrumentation instrumentation; + union { + } u; + struct cds_list_head list; /* Event list */ + int metadata_dumped:1; +}; + +struct ltt_channel_ops { + struct channel *(*channel_create)(const char *name, + struct ltt_channel *ltt_chan, + void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval, + int *shmid); + void (*channel_destroy)(struct channel *chan); + struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); + void (*buffer_read_close)(struct lib_ring_buffer *buf); + int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, + uint32_t event_id); + void (*event_commit)(struct lib_ring_buffer_ctx *ctx); + void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, + size_t len); + /* + * packet_avail_size returns the available size in the current + * packet. Note that the size returned is only a hint, since it + * may change due to concurrent writes. + */ + size_t (*packet_avail_size)(struct channel *chan); + //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan); + //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); + int (*is_finalized)(struct channel *chan); + int (*is_disabled)(struct channel *chan); +}; + +struct ltt_channel { + unsigned int id; + struct channel *chan; /* Channel buffers */ + int enabled; + struct lttng_ctx *ctx; + /* Event ID management */ + struct ltt_session *session; + int objd; /* Object associated to channel */ + unsigned int free_event_id; /* Next event ID to allocate */ + struct cds_list_head list; /* Channel list */ + struct ltt_channel_ops *ops; + int header_type; /* 0: unset, 1: compact, 2: large */ + int shmid; /* shared memory ID */ + int metadata_dumped:1; +}; + +struct ltt_session { + int active; /* Is trace session active ? */ + int been_active; /* Has trace session been active ? */ + int objd; /* Object associated to session */ + struct ltt_channel *metadata; /* Metadata channel */ + struct cds_list_head chan; /* Channel list head */ + struct cds_list_head events; /* Event list head */ + struct cds_list_head list; /* Session list */ + unsigned int free_chan_id; /* Next chan ID to allocate */ + uuid_t uuid; /* Trace session unique ID */ + int metadata_dumped:1; +}; + +struct ltt_transport { + char *name; + struct cds_list_head node; + struct ltt_channel_ops ops; +}; + +struct ltt_session *ltt_session_create(void); +int ltt_session_enable(struct ltt_session *session); +int ltt_session_disable(struct ltt_session *session); +void ltt_session_destroy(struct ltt_session *session); + +struct ltt_channel *ltt_channel_create(struct ltt_session *session, + const char *transport_name, + void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval); +struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, + int overwrite, void *buf_addr, + size_t subbuf_size, size_t num_subbuf, + unsigned int switch_timer_interval, + unsigned int read_timer_interval); + +struct ltt_event *ltt_event_create(struct ltt_channel *chan, + struct lttng_ust_event *event_param, + void *filter); + +int ltt_channel_enable(struct ltt_channel *channel); +int ltt_channel_disable(struct ltt_channel *channel); +int ltt_event_enable(struct ltt_event *event); +int ltt_event_disable(struct ltt_event *event); + +void ltt_transport_register(struct ltt_transport *transport); +void ltt_transport_unregister(struct ltt_transport *transport); + +void synchronize_trace(void); +//int ltt_debugfs_abi_init(void); +//void ltt_debugfs_abi_exit(void); + +int ltt_probe_register(struct lttng_probe_desc *desc); +void ltt_probe_unregister(struct lttng_probe_desc *desc); +const struct lttng_event_desc *ltt_event_get(const char *name); +void ltt_event_put(const struct lttng_event_desc *desc); +int ltt_probes_init(void); +void ltt_probes_exit(void); +struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); +void lttng_remove_context_field(struct lttng_ctx **ctx, + struct lttng_ctx_field *field); +void lttng_destroy_context(struct lttng_ctx *ctx); +int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); + +//extern const struct file_operations lttng_tracepoint_list_fops; + +#endif /* _UST_LTTNG_EVENTS_H */ diff --git a/include/ust/lttng-tracepoint-event-reset.h b/include/ust/lttng-tracepoint-event-reset.h new file mode 100644 index 00000000..b42a794a --- /dev/null +++ b/include/ust/lttng-tracepoint-event-reset.h @@ -0,0 +1,37 @@ +/* + * lttng-tracepoint-events-reset.h + * + * Copyright (C) 2010-2011 Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +/* Reset macros used within TRACE_EVENT to "nothing" */ + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) + +#undef ctf_string +#define ctf_string(_item, _src) + +#undef TP_PROTO +#define TP_PROTO(args...) + +#undef TP_ARGS +#define TP_ARGS(args...) + +#undef TP_FIELDS +#define TP_FIELDS(args...) + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) + +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) diff --git a/include/ust/lttng-tracepoint-event.h b/include/ust/lttng-tracepoint-event.h new file mode 100644 index 00000000..10b2d23f --- /dev/null +++ b/include/ust/lttng-tracepoint-event.h @@ -0,0 +1,440 @@ +/* + * Copyright (C) 2009 Steven Rostedt + * Copyright (C) 2011 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; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +/* + * Macro declarations used for all stages. + */ + +#undef ctf_integer +#define ctf_integer(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10) + +#undef ctf_integer_hex +#define ctf_integer_hex(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16) + +#undef ctf_integer_network +#define ctf_integer_network(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10) + +#undef ctf_integer_network_hex +#define ctf_integer_network_hex(_type, _item, _src) \ + ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16) + +#undef ctf_array +#define ctf_array(_type, _item, _src, _length) \ + ctf_array_encoded(_type, _item, _src, _length, none) + +#undef ctf_array_text +#define ctf_array_text(_type, _item, _src, _length) \ + ctf_array_encoded(_type, _item, _src, _length, UTF8) + +#undef ctf_sequence +#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ + ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, none) + +#undef ctf_sequence_text +#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ + ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, UTF8) + +/* ctf_string is redefined at each step */ + +/* + * TRACEPOINT_EVENT_CLASS can be used to add a generic function handlers + * for events. That is, if all events have the same parameters and just + * have distinct trace points. Each tracepoint can be defined with + * TRACEPOINT_EVENT_INSTANCE and that will map the + * TRACEPOINT_EVENT_CLASS to the tracepoint. + * + * TRACEPOINT_EVENT is a one to one mapping between tracepoint and + * template. + */ + +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + TRACEPOINT_EVENT_CLASS(name, \ + TP_PARAMS(proto), \ + TP_PARAMS(args), \ + TP_PARAMS(fields)) \ + TRACEPOINT_EVENT_INSTANCE(name, name, TP_PARAMS(proto), TP_PARAMS(args)) + +/* + * Stage 1 of the trace events. + * + * Create event field type metadata section. + * Each event produce an array of fields. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +/* Named field types must be defined in lttng-types.h */ + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + { \ + .name = #_item, \ + .type = __type_integer(_type, _byte_order, _base, none),\ + }, + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_array, \ + .u.array = \ + { \ + .length = _length, \ + .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ + }, \ + }, \ + }, + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, _encoding) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_sequence, \ + .u.sequence = \ + { \ + .length_type = __type_integer(_length_type, BYTE_ORDER, 10, none), \ + .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ + }, \ + }, \ + }, + +#undef ctf_string +#define ctf_string(_item, _src) \ + { \ + .name = #_item, \ + .type = \ + { \ + .atype = atype_string, \ + .u.basic.string.encoding = lttng_encode_UTF8, \ + }, \ + }, + +#undef TP_FIELDS +#define TP_FIELDS(args...) args /* Only one used in this phase */ + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ + static const struct lttng_event_field __event_fields___##_name[] = { \ + _fields \ + }; + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +/* + * Stage 2 of the trace events. + * + * Create probe callback prototypes. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static void __event_probe__##_name(void *__data, _proto); + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +/* + * Stage 3 of the trace events. + * + * Create an array of events. + */ + +/* Named field types must be defined in lttng-types.h */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(_template, _name, _proto, _args) \ + { \ + .fields = __event_fields___##_template, \ + .name = #_name, \ + .probe_callback = (void *) &__event_probe__##_template,\ + .nr_fields = ARRAY_SIZE(__event_fields___##_template), \ + }, + +#define TP_ID1(_token, _system) _token##_system +#define TP_ID(_token, _system) TP_ID1(_token, _system) + +static const struct lttng_event_desc TP_ID(__event_desc___, TRACE_SYSTEM)[] = { +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +}; + +#undef TP_ID1 +#undef TP_ID + + +/* + * Stage 4 of the trace events. + * + * Create a toplevel descriptor for the whole probe. + */ + +#define TP_ID1(_token, _system) _token##_system +#define TP_ID(_token, _system) TP_ID1(_token, _system) + +/* non-const because list head will be modified when registered. */ +static struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = { + .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM), + .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)), +}; + +#undef TP_ID1 +#undef TP_ID + +/* + * Stage 5 of the trace events. + * + * Create static inline function that calculates event size. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +/* Named field types must be defined in lttng-types.h */ + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += sizeof(_type); + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length) \ + __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __event_len += sizeof(_type) * (_length); + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) \ + __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_length_type)); \ + __event_len += sizeof(_length_type); \ + __event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \ + __dynamic_len[__dynamic_len_idx] = (_length); \ + __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ + __dynamic_len_idx++; + +#undef ctf_string +#define ctf_string(_item, _src) \ + __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \ +{ \ + size_t __event_len = 0; \ + unsigned int __dynamic_len_idx = 0; \ + \ + if (0) \ + (void) __dynamic_len_idx; /* don't warn if unused */ \ + _fields \ + return __event_len; \ +} + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +/* + * Stage 6 of the trace events. + * + * Create static inline function that calculates event payload alignment. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +/* Named field types must be defined in lttng-types.h */ + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length) \ + __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) \ + __event_align = max_t(size_t, __event_align, ltt_alignof(_length_type)); \ + __event_align = max_t(size_t, __event_align, ltt_alignof(_type)); + +#undef ctf_string +#define ctf_string(_item, _src) + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static inline size_t __event_get_align__##_name(_proto) \ +{ \ + size_t __event_align = 1; \ + _fields \ + return __event_align; \ +} + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + + +/* + * Stage 7 of the trace events. + * + * Create the probe function : call even size calculation and write event data + * into the buffer. + * + * We use both the field and assignment macros to write the fields in the order + * defined in the field declaration. The field declarations control the + * execution order, jumping to the appropriate assignment block. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +#undef ctf_integer_ext +#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ + { \ + _type __tmp = (_src); \ + lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__tmp)); \ + __chan->ops->event_write(&ctx, &__tmp, sizeof(__tmp)); \ + } + +#undef ctf_array_encoded +#define ctf_array_encoded(_type, _item, _src, _length) \ + lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_type)); \ + __chan->ops->event_write(&ctx, _src, _length); + +#undef ctf_sequence_encoded +#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding) \ + { \ + _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ + lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_length_type)); \ + __chan->ops->event_write(&ctx, &__tmpl, sizeof(_length_type)); \ + } \ + lib_ring_buffer_align_ctx(&ctx, ltt_alignof(_type)); \ + __chan->ops->event_write(&ctx, _src, \ + sizeof(_type) * __get_sequence_len(dest)); + +#undef ctf_string +#define ctf_string(_item, _src) \ + tp_memcpy(dest, _src, __get_sequence_len(dest)) + +/* Beware: this get len actually consumes the len value */ +#undef __get_sequence_len +#define __get_sequence_len(field) __dynamic_len[__dynamic_len_idx++] + +#undef TP_PROTO +#define TP_PROTO(args...) args + +#undef TP_ARGS +#define TP_ARGS(args...) args + +#undef TP_FIELDS +#define TP_FIELDS(args...) args + +#undef TRACEPOINT_EVENT_CLASS +#define TRACEPOINT_EVENT_CLASS(_name, _proto, _args, _fields) \ +static void __event_probe__##_name(void *__data, _proto) \ +{ \ + struct ltt_event *__event = __data; \ + struct ltt_channel *__chan = __event->chan; \ + struct lib_ring_buffer_ctx ctx; \ + size_t __event_len, __event_align; \ + size_t __dynamic_len_idx = 0; \ + size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \ + int __ret; \ + \ + if (0) \ + (void) __dynamic_len_idx; /* don't warn if unused */ \ + if (unlikely(!ACCESS_ONCE(__chan->session->active))) \ + return; \ + if (unlikely(!ACCESS_ONCE(__chan->enabled))) \ + return; \ + if (unlikely(!ACCESS_ONCE(__event->enabled))) \ + return; \ + __event_len = __event_get_size__##_name(__dynamic_len, _args); \ + __event_align = __event_get_align__##_name(_args); \ + lib_ring_buffer_ctx_init(&ctx, __chan->chan, __event, __event_len, \ + __event_align, -1); \ + __ret = __chan->ops->event_reserve(&ctx, __event->id); \ + if (__ret < 0) \ + return; \ + _fields \ + __chan->ops->event_commit(&ctx); \ +} + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +/* + * Stage 8 of the trace events. + * + * Register/unregister probes at module load/unload. + */ + +/* Reset all macros within TRACE_EVENT */ +#include "lttng-tracepoint-events-reset.h" + +#define TP_ID1(_token, _system) _token##_system +#define TP_ID(_token, _system) TP_ID1(_token, _system) + +static void __attribute__((constructor)) +TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) +{ + int ret; + + ret = ltt_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM)); + assert(!ret); +} + +static void __attribute__((destructor)) +TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void) +{ + ltt_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM)); +} + +#undef TP_ID1 +#undef TP_ID diff --git a/include/ust/lttng-ust-abi.h b/include/ust/lttng-ust-abi.h index ff76a710..f8ba13e5 100644 --- a/include/ust/lttng-ust-abi.h +++ b/include/ust/lttng-ust-abi.h @@ -11,6 +11,8 @@ * Dual LGPL v2.1/GPL v2 license. */ +#include + #define LTTNG_UST_SYM_NAME_LEN 128 enum lttng_ust_instrumentation { diff --git a/include/ust/probe.h b/include/ust/probe.h deleted file mode 100644 index fe27da2b..00000000 --- a/include/ust/probe.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2009 Steven Rostedt - * Copyright (C) 2010 Nils Carlson - * Copyright (C) 2011 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; - * 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 whole file is currently a dummy. - */ - -#include - -#undef TRACEPOINT_EVENT -#define TRACEPOINT_EVENT(name, proto, args, fields) \ - TRACEPOINT_EVENT_CLASS(name, \ - TP_PARAMS(proto), \ - TP_PARAMS(args), \ - TP_PARAMS(fields)); \ - TRACEPOINT_EVENT_INSTANCE(name, name, TP_PARAMS(proto), \ - TP_PARAMS(args)); - -#undef TRACEPOINT_EVENT_NOARGS -#define TRACEPOINT_EVENT_NOARGS(name, fields) \ - TRACEPOINT_EVENT_CLASS_NOARGS(name, \ - TP_PARAMS(fields)); \ - TRACEPOINT_EVENT_INSTANCE_NOARGS(name, name); - -#undef tp_field -#define tp_field(type, item, src) type item; - -#undef TP_FIELDS -#define TP_FIELDS(args...) args - -#undef TRACEPOINT_EVENT_INSTANCE -#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) - -#undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) - -#undef TRACEPOINT_EVENT_CLASS -#define TRACEPOINT_EVENT_CLASS(name, proto, args, fields) \ - struct trace_raw_##name { \ - fields \ - }; \ - static void trace_printf_##name(void *dummy, proto) \ - { \ - } \ - struct trace_event __event_##name = { \ - __tpstrtab_##name, \ - }; \ - static struct trace_event * const __event_ptrs_##name \ - __attribute__((used, section("__trace_events_ptrs"))) = \ - &__event_##name; \ - \ - static void __attribute__((constructor)) init_##name() \ - { \ - void *dummy = NULL; \ - __register_tracepoint(name, trace_printf_##name, dummy);\ - } - -#undef TRACEPOINT_EVENT_CLASS_NOARGS -#define TRACEPOINT_EVENT_CLASS_NOARGS(name, fields) \ - struct trace_raw_##name { \ - fields \ - }; \ - static void trace_printf_##name(void *dummy) \ - { \ - } \ - struct trace_event __event_##name = { \ - __tpstrtab_##name, \ - }; \ - static struct trace_event * const __event_ptrs_##name \ - __attribute__((used, section("__trace_events_ptrs"))) = \ - &__event_##name; \ - \ - static void __attribute__((constructor)) init_##name() \ - { \ - void *dummy = NULL; \ - __register_tracepoint(name, trace_printf_##name, dummy);\ - } - -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) diff --git a/include/ust/tracepoint-event.h b/include/ust/tracepoint-event.h new file mode 100644 index 00000000..d1d5069b --- /dev/null +++ b/include/ust/tracepoint-event.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Steven Rostedt + * Copyright (C) 2011 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; + * 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 + * + * + * Trace files that want to automate creationg of all tracepoints defined + * in their file should include this file. The following are macros that the + * trace file may define: + * + * TRACE_SYSTEM defines the system the tracepoint is for + * + * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h + * This macro may be defined to tell define_trace.h what file to include. + * Note, leave off the ".h". + * + * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace + * then this macro can define the path to use. Note, the path is relative to + * tracepoint_event.h, not the file including it. Full path names for out of tree + * modules must be used. + */ + +#ifdef TRACEPOINT_CREATE_PROBES + +/* Prevent recursion */ +#undef TRACEPOINT_CREATE_PROBES + +#ifndef __tp_stringify +#define __tp_stringify_1(x...) #x +#define __tp_stringify(x...) __tp_stringify_1(x) +#endif + +#undef TRACEPOINT_EVENT +#define TRACEPOINT_EVENT(name, proto, args, fields) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_INSTANCE +#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_NOARGS +#define TRACEPOINT_EVENT_NOARGS(name, fields) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ + _DEFINE_TRACEPOINT(name) + +#undef TRACE_INCLUDE +#undef __TRACE_INCLUDE + +#ifndef TRACE_INCLUDE_FILE +# define TRACE_INCLUDE_FILE TRACE_SYSTEM +# define UNDEF_TRACE_INCLUDE_FILE +#endif + +#ifndef TRACE_INCLUDE_PATH +# define __TRACE_INCLUDE(system) +# define UNDEF_TRACE_INCLUDE_PATH +#else +# define __TRACE_INCLUDE(system) __tp_stringify(TRACE_INCLUDE_PATH/system.h) +#endif + +# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system) + +/* Let the trace headers be reread */ +#define TRACE_HEADER_MULTI_READ + +#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) + +#ifndef CONFIG_NO_EVENT_TRACING +#include +#endif + +#undef TRACEPOINT_EVENT +#undef TRACEPOINT_EVENT_CLASS +#undef TRACEPOINT_EVENT_INSTANCE +#undef TRACEPOINT_EVENT_NOARGS +#undef TRACEPOINT_EVENT_CLASS_NOARGS +#undef TRACEPOINT_EVENT_INSTANCE_NOARGS +#undef TRACE_HEADER_MULTI_READ + +/* Only undef what we defined in this file */ +#ifdef UNDEF_TRACE_INCLUDE_FILE +# undef TRACE_INCLUDE_FILE +# undef UNDEF_TRACE_INCLUDE_FILE +#endif + +#ifdef UNDEF_TRACE_INCLUDE_PATH +# undef TRACE_INCLUDE_PATH +# undef UNDEF_TRACE_INCLUDE_PATH +#endif + +/* We may be processing more files */ +#define TRACEPOINT_CREATE_PROBES + +#endif /* TRACEPOINT_CREATE_PROBES */ diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 3d61f728..18ee28b0 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -199,17 +199,48 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); /* * For use with the TRACEPOINT_EVENT macro: * - * We define a tracepoint, its arguments, its printf format - * and its 'fast binary record' layout. + * We define a tracepoint, its arguments, and its 'fast binary record' + * layout. * - * Firstly, name your tracepoint via TRACEPOINT_EVENT(name : the - * 'subsystem_event' notation is fine. + * Firstly, name your tracepoint via TRACEPOINT_EVENT(name, * - * Think about this whole construct as the - * 'trace_sched_switch() function' from now on. + * The "name" MUST follow these rules to ensure no namespace clash + * occurs: * + * For projects (applications and libraries) for which an entity + * specific to the project controls the source code and thus its + * tracepoints (typically with a scope larger than a single company): * - * TRACEPOINT_EVENT(sched_switch, + * either: + * project_component_event + * or: + * project_event + * + * Where "project" is the name of the project, + * "component" is the name of the project component where the + * tracepoint is located (optional), + * "event" is the name of the tracepoint event. + * + * For projects issued from a single company wishing to advertise that + * the company controls the source code and thus the tracepoints, the + * "com_" prefix should be used: + * + * either: + * com_company_project_component_event + * or: + * com_company_project_event + * + * Where "company" is the name of the company, + * "project" is the name of the project, + * "component" is the name of the project component where the + * tracepoint is located (optional), + * "event" is the name of the tracepoint event. + * + * + * As an example, let's consider a user-space application "someproject" + * that would have an internal thread scheduler: + * + * TRACEPOINT_EVENT(someproject_sched_switch, * * * * * A function has a regular function arguments @@ -236,7 +267,7 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); * * be saved into the ring buffer. These are the fields * * that will be exposed to readers. * * - * * tp_field(pid_t, prev_pid, prev->pid) is equivalent + * * ctf_integer(pid_t, prev_pid, prev->pid) is equivalent * * to a standard declaraton: * * * * pid_t prev_pid; @@ -245,7 +276,7 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); * * * * prev_pid = prev->pid; * * - * * tp_array(char, prev_comm, TASK_COMM_LEN, prev->comm) is + * * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) is * * equivalent to: * * * * char prev_comm[TASK_COMM_LEN]; @@ -256,14 +287,14 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); * * * * TP_FIELDS( - * tp_array(char, prev_comm, TASK_COMM_LEN, prev->comm) - * tp_field(pid_t, prev_pid, prev->pid) - * tp_field(int, prev_prio, prev->prio) - * tp_array(char, next_comm, TASK_COMM_LEN, next->comm) - * tp_field(pid_t, next_pid, next->pid) - * tp_field(int, next_prio, next->prio) + * ctf_array(char, prev_comm, prev->comm, TASK_COMM_LEN) + * ctf_integer(pid_t, prev_pid, prev->pid) + * ctf_integer(int, prev_prio, prev->prio) + * ctf_array(char, next_comm, next->comm, TASK_COMM_LEN) + * ctf_integer(pid_t, next_pid, next->pid) + * ctf_integer(int, next_prio, next->prio) * ) - * ); + * ) */ #define TRACEPOINT_EVENT(name, proto, args, fields) \ @@ -283,45 +314,6 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start); #define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ _DECLARE_TRACEPOINT_NOARGS(name) - - -#define TRACEPOINT_EVENT_LIB \ - extern struct trace_event * const __start___trace_events_ptrs[] \ - __attribute__((weak, visibility("hidden"))); \ - extern struct trace_event * const __stop___trace_events_ptrs[] \ - __attribute__((weak, visibility("hidden"))); \ - static struct trace_event * __event_ptrs_dummy \ - __attribute__((used, section("__trace_events_ptrs"))); \ - static void __attribute__((constructor)) \ - __trace_events__init(void) \ - { \ - trace_event_register_lib(__start___trace_events_ptrs, \ - __stop___trace_events_ptrs - \ - __start___trace_events_ptrs); \ - } \ - \ - static void __attribute__((destructor)) \ - __trace_event__destroy(void) \ - { \ - trace_event_unregister_lib(__start___trace_events_ptrs);\ - } - -struct trace_event { - const char *name; -}; - -struct trace_event_lib { - struct trace_event * const *trace_events_start; - int trace_events_count; - struct cds_list_head list; -}; - -extern -int trace_event_register_lib(struct trace_event * const *start_trace_events, - int trace_event_count); -extern -int trace_event_unregister_lib(struct trace_event * const *start_trace_events); - #endif /* #ifndef TRACEPOINT_EVENT */ #endif /* _UST_TRACEPOINT_H */ diff --git a/include/ust/tracepoint_event.h b/include/ust/tracepoint_event.h deleted file mode 100644 index 12e8e497..00000000 --- a/include/ust/tracepoint_event.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2009 Steven Rostedt - * Copyright (C) 2011 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; - * 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 - * - * - * Trace files that want to automate creationg of all tracepoints defined - * in their file should include this file. The following are macros that the - * trace file may define: - * - * TRACE_SYSTEM defines the system the tracepoint is for - * - * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h - * This macro may be defined to tell define_trace.h what file to include. - * Note, leave off the ".h". - * - * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace - * then this macro can define the path to use. Note, the path is relative to - * tracepoint_event.h, not the file including it. Full path names for out of tree - * modules must be used. - */ - -#ifdef TRACEPOINT_CREATE_PROBES - -/* Prevent recursion */ -#undef TRACEPOINT_CREATE_PROBES - -#ifndef __tp_stringify -#define __tp_stringify_1(x...) #x -#define __tp_stringify(x...) __tp_stringify_1(x) -#endif - -#undef TRACEPOINT_EVENT -#define TRACEPOINT_EVENT(name, proto, args, fields) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_INSTANCE -#define TRACEPOINT_EVENT_INSTANCE(template, name, proto, args) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_NOARGS -#define TRACEPOINT_EVENT_NOARGS(name, fields) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#define TRACEPOINT_EVENT_INSTANCE_NOARGS(template, name) \ - _DEFINE_TRACEPOINT(name) - -#undef TRACE_INCLUDE -#undef __TRACE_INCLUDE - -#ifndef TRACE_INCLUDE_FILE -# define TRACE_INCLUDE_FILE TRACE_SYSTEM -# define UNDEF_TRACE_INCLUDE_FILE -#endif - -#ifndef TRACE_INCLUDE_PATH -# define __TRACE_INCLUDE(system) -# define UNDEF_TRACE_INCLUDE_PATH -#else -# define __TRACE_INCLUDE(system) __tp_stringify(TRACE_INCLUDE_PATH/system.h) -#endif - -# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system) - -/* Let the trace headers be reread */ -#define TRACE_HEADER_MULTI_READ - -#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) - -#ifndef CONFIG_NO_EVENT_TRACING -#include -#endif - -#undef TRACEPOINT_EVENT -#undef TRACEPOINT_EVENT_CLASS -#undef TRACEPOINT_EVENT_INSTANCE -#undef TRACEPOINT_EVENT_NOARGS -#undef TRACEPOINT_EVENT_CLASS_NOARGS -#undef TRACEPOINT_EVENT_INSTANCE_NOARGS -#undef TRACE_HEADER_MULTI_READ - -/* Only undef what we defined in this file */ -#ifdef UNDEF_TRACE_INCLUDE_FILE -# undef TRACE_INCLUDE_FILE -# undef UNDEF_TRACE_INCLUDE_FILE -#endif - -#ifdef UNDEF_TRACE_INCLUDE_PATH -# undef TRACE_INCLUDE_PATH -# undef UNDEF_TRACE_INCLUDE_PATH -#endif - -/* We may be processing more files */ -#define TRACEPOINT_CREATE_PROBES - -#endif /* TRACEPOINT_CREATE_PROBES */ diff --git a/libust/ltt-events.h b/libust/ltt-events.h deleted file mode 100644 index a66f5840..00000000 --- a/libust/ltt-events.h +++ /dev/null @@ -1,279 +0,0 @@ -#ifndef _LTT_EVENTS_H -#define _LTT_EVENTS_H - -/* - * ltt-events.h - * - * Copyright 2010 (c) - Mathieu Desnoyers - * - * Holds LTTng per-session event registry. - * - * Dual LGPL v2.1/GPL v2 license. - */ - -#include -#include -#include -#include - -#undef is_signed_type -#define is_signed_type(type) (((type)(-1)) < 0) - -struct ltt_channel; -struct ltt_session; -struct lib_ring_buffer_ctx; - -/* Type description */ - -/* Update the astract_types name table in lttng-types.c along with this enum */ -enum abstract_types { - atype_integer, - atype_enum, - atype_array, - atype_sequence, - atype_string, - NR_ABSTRACT_TYPES, -}; - -/* Update the string_encodings name table in lttng-types.c along with this enum */ -enum lttng_string_encodings { - lttng_encode_none = 0, - lttng_encode_UTF8 = 1, - lttng_encode_ASCII = 2, - NR_STRING_ENCODINGS, -}; - -struct lttng_enum_entry { - unsigned long long start, end; /* start and end are inclusive */ - const char *string; -}; - -#define __type_integer(_type, _byte_order, _base, _encoding) \ - { \ - .atype = atype_integer, \ - .u.basic.integer = \ - { \ - .size = sizeof(_type) * CHAR_BIT, \ - .alignment = ltt_alignof(_type) * CHAR_BIT, \ - .signedness = is_signed_type(_type), \ - .reverse_byte_order = _byte_order != __BYTE_ORDER, \ - .base = _base, \ - .encoding = lttng_encode_##_encoding, \ - }, \ - } \ - -struct lttng_integer_type { - unsigned int size; /* in bits */ - unsigned short alignment; /* in bits */ - unsigned int signedness:1; - unsigned int reverse_byte_order:1; - unsigned int base; /* 2, 8, 10, 16, for pretty print */ - enum lttng_string_encodings encoding; -}; - -union _lttng_basic_type { - struct lttng_integer_type integer; - struct { - const char *name; - } enumeration; - struct { - enum lttng_string_encodings encoding; - } string; -}; - -struct lttng_basic_type { - enum abstract_types atype; - union { - union _lttng_basic_type basic; - } u; -}; - -struct lttng_type { - enum abstract_types atype; - union { - union _lttng_basic_type basic; - struct { - struct lttng_basic_type elem_type; - unsigned int length; /* num. elems. */ - } array; - struct { - struct lttng_basic_type length_type; - struct lttng_basic_type elem_type; - } sequence; - } u; -}; - -struct lttng_enum { - const char *name; - struct lttng_type container_type; - const struct lttng_enum_entry *entries; - unsigned int len; -}; - -/* Event field description */ - -struct lttng_event_field { - const char *name; - struct lttng_type type; -}; - -struct lttng_ctx_field { - struct lttng_event_field event_field; - size_t (*get_size)(size_t offset); - void (*record)(struct lttng_ctx_field *field, - struct lib_ring_buffer_ctx *ctx, - struct ltt_channel *chan); - union { - } u; - void (*destroy)(struct lttng_ctx_field *field); -}; - -struct lttng_ctx { - struct lttng_ctx_field *fields; - unsigned int nr_fields; - unsigned int allocated_fields; -}; - -struct lttng_event_desc { - const char *name; - void *probe_callback; - const struct lttng_event_ctx *ctx; /* context */ - const struct lttng_event_field *fields; /* event payload */ - unsigned int nr_fields; -}; - -struct lttng_probe_desc { - const struct lttng_event_desc *event_desc; - unsigned int nr_events; - struct cds_list_head head; /* chain registered probes */ -}; - -/* - * ltt_event structure is referred to by the tracing fast path. It must be - * kept small. - */ -struct ltt_event { - unsigned int id; - struct ltt_channel *chan; - int enabled; - const struct lttng_event_desc *desc; - void *filter; - struct lttng_ctx *ctx; - enum lttng_ust_instrumentation instrumentation; - union { - } u; - struct cds_list_head list; /* Event list */ - int metadata_dumped:1; -}; - -struct ltt_channel_ops { - struct channel *(*channel_create)(const char *name, - struct ltt_channel *ltt_chan, - void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shmid); - void (*channel_destroy)(struct channel *chan); - struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); - void (*buffer_read_close)(struct lib_ring_buffer *buf); - int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, - uint32_t event_id); - void (*event_commit)(struct lib_ring_buffer_ctx *ctx); - void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, - size_t len); - /* - * packet_avail_size returns the available size in the current - * packet. Note that the size returned is only a hint, since it - * may change due to concurrent writes. - */ - size_t (*packet_avail_size)(struct channel *chan); - //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan); - //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); - int (*is_finalized)(struct channel *chan); - int (*is_disabled)(struct channel *chan); -}; - -struct ltt_channel { - unsigned int id; - struct channel *chan; /* Channel buffers */ - int enabled; - struct lttng_ctx *ctx; - /* Event ID management */ - struct ltt_session *session; - struct file *file; /* File associated to channel */ - unsigned int free_event_id; /* Next event ID to allocate */ - struct cds_list_head list; /* Channel list */ - struct ltt_channel_ops *ops; - int header_type; /* 0: unset, 1: compact, 2: large */ - int metadata_dumped:1; -}; - -struct ltt_session { - int active; /* Is trace session active ? */ - int been_active; /* Has trace session been active ? */ - struct file *file; /* File associated to session */ - struct ltt_channel *metadata; /* Metadata channel */ - struct cds_list_head chan; /* Channel list head */ - struct cds_list_head events; /* Event list head */ - struct cds_list_head list; /* Session list */ - unsigned int free_chan_id; /* Next chan ID to allocate */ - uuid_t uuid; /* Trace session unique ID */ - int metadata_dumped:1; -}; - -struct ltt_transport { - char *name; - struct cds_list_head node; - struct ltt_channel_ops ops; -}; - -struct ltt_session *ltt_session_create(void); -int ltt_session_enable(struct ltt_session *session); -int ltt_session_disable(struct ltt_session *session); -void ltt_session_destroy(struct ltt_session *session); - -struct ltt_channel *ltt_channel_create(struct ltt_session *session, - const char *transport_name, - void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval, - int *shmid); -struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, - int overwrite, void *buf_addr, - size_t subbuf_size, size_t num_subbuf, - unsigned int switch_timer_interval, - unsigned int read_timer_interval); - -struct ltt_event *ltt_event_create(struct ltt_channel *chan, - struct lttng_ust_event *event_param, - void *filter); - -int ltt_channel_enable(struct ltt_channel *channel); -int ltt_channel_disable(struct ltt_channel *channel); -int ltt_event_enable(struct ltt_event *event); -int ltt_event_disable(struct ltt_event *event); - -void ltt_transport_register(struct ltt_transport *transport); -void ltt_transport_unregister(struct ltt_transport *transport); - -void synchronize_trace(void); -//int ltt_debugfs_abi_init(void); -//void ltt_debugfs_abi_exit(void); - -int ltt_probe_register(struct lttng_probe_desc *desc); -void ltt_probe_unregister(struct lttng_probe_desc *desc); -const struct lttng_event_desc *ltt_event_get(const char *name); -void ltt_event_put(const struct lttng_event_desc *desc); -int ltt_probes_init(void); -void ltt_probes_exit(void); -struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); -void lttng_remove_context_field(struct lttng_ctx **ctx, - struct lttng_ctx_field *field); -void lttng_destroy_context(struct lttng_ctx *ctx); -int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); - -//extern const struct file_operations lttng_tracepoint_list_fops; - -#endif /* _LTT_EVENTS_H */