From fc4b93fa8aa36b19caad0f8dc4a6a3237fcc36bf Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 12 Mar 2021 16:52:42 -0500 Subject: [PATCH] Adapt to lttng-ust ust-abi.h naming prefix update MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit LTTng-UST updates all its ust-abi.h symbols and defines to use the lttng_ust_abi_ and LTTNG_UST_ABI_ prefixes. Adapt lttng-tools accordingly. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau Change-Id: Ifde8b73604c84ee37e9123f5dd912e7a806deb38 Depends-on: lttng-ust: I1273be9615846304266206769700e799bde4e51f --- src/bin/lttng-sessiond/buffer-registry.h | 4 +- src/bin/lttng-sessiond/cmd.c | 14 +- src/bin/lttng-sessiond/event.c | 4 +- .../notification-thread-events.c | 2 +- src/bin/lttng-sessiond/save.c | 74 +-- src/bin/lttng-sessiond/trace-ust.c | 90 ++-- src/bin/lttng-sessiond/trace-ust.h | 14 +- src/bin/lttng-sessiond/ust-abi-internal.h | 456 ++++++++++-------- src/bin/lttng-sessiond/ust-app.c | 106 ++-- src/bin/lttng-sessiond/ust-app.h | 26 +- src/bin/lttng-sessiond/ust-consumer.c | 4 +- src/bin/lttng-sessiond/ust-ctl-internal.h | 208 ++++++-- src/bin/lttng-sessiond/ust-field-utils.c | 12 +- src/bin/lttng-sessiond/ust-metadata.c | 6 +- src/bin/lttng-sessiond/ust-registry.c | 10 +- src/bin/lttng-sessiond/ust-registry.h | 4 +- src/common/sessiond-comm/sessiond-comm.h | 12 +- src/common/ust-consumer/ust-consumer.c | 14 +- tests/unit/test_ust_data.c | 12 +- 19 files changed, 619 insertions(+), 453 deletions(-) diff --git a/src/bin/lttng-sessiond/buffer-registry.h b/src/bin/lttng-sessiond/buffer-registry.h index 0812414e5..440493d47 100644 --- a/src/bin/lttng-sessiond/buffer-registry.h +++ b/src/bin/lttng-sessiond/buffer-registry.h @@ -22,7 +22,7 @@ struct buffer_reg_stream { struct cds_list_head lnode; union { /* Original object data that MUST be copied over. */ - struct lttng_ust_object_data *ust; + struct lttng_ust_abi_object_data *ust; } obj; }; @@ -45,7 +45,7 @@ struct buffer_reg_channel { size_t num_subbuf; union { /* Original object data that MUST be copied over. */ - struct lttng_ust_object_data *ust; + struct lttng_ust_abi_object_data *ust; } obj; }; diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index a2af8882f..83ad957fc 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -359,7 +359,7 @@ static ssize_t list_lttng_channels(enum lttng_domain_type domain, * Map enum lttng_ust_output to enum lttng_event_output. */ switch (uchan->attr.output) { - case LTTNG_UST_MMAP: + case LTTNG_UST_ABI_MMAP: channels[i].attr.output = LTTNG_EVENT_MMAP; break; default: @@ -579,26 +579,26 @@ static int list_lttng_ust_global_events(char *channel_name, event.enabled = uevent->enabled; switch (uevent->attr.instrumentation) { - case LTTNG_UST_TRACEPOINT: + case LTTNG_UST_ABI_TRACEPOINT: event.type = LTTNG_EVENT_TRACEPOINT; break; - case LTTNG_UST_PROBE: + case LTTNG_UST_ABI_PROBE: event.type = LTTNG_EVENT_PROBE; break; - case LTTNG_UST_FUNCTION: + case LTTNG_UST_ABI_FUNCTION: event.type = LTTNG_EVENT_FUNCTION; break; } event.loglevel = uevent->attr.loglevel; switch (uevent->attr.loglevel_type) { - case LTTNG_UST_LOGLEVEL_ALL: + case LTTNG_UST_ABI_LOGLEVEL_ALL: event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; break; - case LTTNG_UST_LOGLEVEL_RANGE: + case LTTNG_UST_ABI_LOGLEVEL_RANGE: event.loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE; break; - case LTTNG_UST_LOGLEVEL_SINGLE: + case LTTNG_UST_ABI_LOGLEVEL_SINGLE: event.loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE; break; } diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 125adb9a0..84375d3b4 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -169,7 +169,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, rcu_read_lock(); uevent = trace_ust_find_event(uchan->events, event->name, filter, - (enum lttng_ust_loglevel_type) event->loglevel_type, + (enum lttng_ust_abi_loglevel_type) event->loglevel_type, event->loglevel, exclusion); if (!uevent) { ret = trace_ust_create_event(event, filter_expression, @@ -780,7 +780,7 @@ static int event_agent_disable_one(struct ltt_ust_session *usess, * ignored since the type is LTTNG_UST_LOGLEVEL_ALL. */ uevent = trace_ust_find_event(uchan->events, (char *) ust_event_name, - aevent->filter, LTTNG_UST_LOGLEVEL_ALL, -1, NULL); + aevent->filter, LTTNG_UST_ABI_LOGLEVEL_ALL, -1, NULL); /* If the agent event exists, it must be available on the UST side. */ assert(uevent); diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 747902612..309c54c87 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -4247,7 +4247,7 @@ struct lttng_event_notifier_notification *recv_one_event_notifier_notification( void *reception_buffer; size_t reception_size; - struct lttng_ust_event_notifier_notification ust_notification; + struct lttng_ust_abi_event_notifier_notification ust_notification; struct lttng_kernel_event_notifier_notification kernel_notification; /* Init lttng_event_notifier_notification */ diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 6ca756365..c9bed2e20 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -134,7 +134,7 @@ end: /* Return LTTNG_OK on success else a LTTNG_ERR* code. */ static int save_ust_channel_attributes(struct config_writer *writer, - struct lttng_ust_channel_attr *attr) + struct lttng_ust_abi_channel_attr *attr) { int ret; struct ltt_ust_channel *channel = NULL; @@ -181,7 +181,7 @@ int save_ust_channel_attributes(struct config_writer *writer, ret = config_writer_write_element_string(writer, config_element_output_type, - attr->output == LTTNG_UST_MMAP ? + attr->output == LTTNG_UST_ABI_MMAP ? config_output_type_mmap : config_output_type_splice); if (ret) { ret = LTTNG_ERR_SAVE_IO_FAIL; @@ -376,72 +376,72 @@ const char *get_kernel_context_type_string( static const char *get_ust_context_type_string( - enum lttng_ust_context_type context_type) + enum lttng_ust_abi_context_type context_type) { const char *context_type_string; switch (context_type) { - case LTTNG_UST_CONTEXT_PROCNAME: + case LTTNG_UST_ABI_CONTEXT_PROCNAME: context_type_string = config_event_context_procname; break; - case LTTNG_UST_CONTEXT_VPID: + case LTTNG_UST_ABI_CONTEXT_VPID: context_type_string = config_event_context_vpid; break; - case LTTNG_UST_CONTEXT_VTID: + case LTTNG_UST_ABI_CONTEXT_VTID: context_type_string = config_event_context_vtid; break; - case LTTNG_UST_CONTEXT_IP: + case LTTNG_UST_ABI_CONTEXT_IP: context_type_string = config_event_context_ip; break; - case LTTNG_UST_CONTEXT_PTHREAD_ID: + case LTTNG_UST_ABI_CONTEXT_PTHREAD_ID: context_type_string = config_event_context_pthread_id; break; - case LTTNG_UST_CONTEXT_APP_CONTEXT: + case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: context_type_string = config_event_context_app; break; - case LTTNG_UST_CONTEXT_CGROUP_NS: + case LTTNG_UST_ABI_CONTEXT_CGROUP_NS: context_type_string = config_event_context_cgroup_ns; break; - case LTTNG_UST_CONTEXT_IPC_NS: + case LTTNG_UST_ABI_CONTEXT_IPC_NS: context_type_string = config_event_context_ipc_ns; break; - case LTTNG_UST_CONTEXT_MNT_NS: + case LTTNG_UST_ABI_CONTEXT_MNT_NS: context_type_string = config_event_context_mnt_ns; break; - case LTTNG_UST_CONTEXT_NET_NS: + case LTTNG_UST_ABI_CONTEXT_NET_NS: context_type_string = config_event_context_net_ns; break; - case LTTNG_UST_CONTEXT_TIME_NS: + case LTTNG_UST_ABI_CONTEXT_TIME_NS: context_type_string = config_event_context_time_ns; break; - case LTTNG_UST_CONTEXT_PID_NS: + case LTTNG_UST_ABI_CONTEXT_PID_NS: context_type_string = config_event_context_pid_ns; break; - case LTTNG_UST_CONTEXT_USER_NS: + case LTTNG_UST_ABI_CONTEXT_USER_NS: context_type_string = config_event_context_user_ns; break; - case LTTNG_UST_CONTEXT_UTS_NS: + case LTTNG_UST_ABI_CONTEXT_UTS_NS: context_type_string = config_event_context_uts_ns; break; - case LTTNG_UST_CONTEXT_VUID: + case LTTNG_UST_ABI_CONTEXT_VUID: context_type_string = config_event_context_vuid; break; - case LTTNG_UST_CONTEXT_VEUID: + case LTTNG_UST_ABI_CONTEXT_VEUID: context_type_string = config_event_context_veuid; break; - case LTTNG_UST_CONTEXT_VSUID: + case LTTNG_UST_ABI_CONTEXT_VSUID: context_type_string = config_event_context_vsuid; break; - case LTTNG_UST_CONTEXT_VGID: + case LTTNG_UST_ABI_CONTEXT_VGID: context_type_string = config_event_context_vgid; break; - case LTTNG_UST_CONTEXT_VEGID: + case LTTNG_UST_ABI_CONTEXT_VEGID: context_type_string = config_event_context_vegid; break; - case LTTNG_UST_CONTEXT_VSGID: + case LTTNG_UST_ABI_CONTEXT_VSGID: context_type_string = config_event_context_vsgid; break; - case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER: + case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: /* * Error, should not be stored in the XML, perf contexts * are stored as a node of type event_perf_context_type. @@ -479,18 +479,18 @@ const char *get_buffer_type_string( static const char *get_loglevel_type_string( - enum lttng_ust_loglevel_type loglevel_type) + enum lttng_ust_abi_loglevel_type loglevel_type) { const char *loglevel_type_string; switch (loglevel_type) { - case LTTNG_UST_LOGLEVEL_ALL: + case LTTNG_UST_ABI_LOGLEVEL_ALL: loglevel_type_string = config_loglevel_type_all; break; - case LTTNG_UST_LOGLEVEL_RANGE: + case LTTNG_UST_ABI_LOGLEVEL_RANGE: loglevel_type_string = config_loglevel_type_range; break; - case LTTNG_UST_LOGLEVEL_SINGLE: + case LTTNG_UST_ABI_LOGLEVEL_SINGLE: loglevel_type_string = config_loglevel_type_single; break; default: @@ -1051,7 +1051,7 @@ int save_ust_event(struct config_writer *writer, goto end; } - if (event->attr.instrumentation != LTTNG_UST_TRACEPOINT) { + if (event->attr.instrumentation != LTTNG_UST_ABI_TRACEPOINT) { ERR("Unsupported UST instrumentation type."); ret = LTTNG_ERR_INVALID; goto end; @@ -1079,7 +1079,7 @@ int save_ust_event(struct config_writer *writer, } /* The log level is irrelevant if no "filtering" is enabled */ - if (event->attr.loglevel_type != LTTNG_UST_LOGLEVEL_ALL) { + if (event->attr.loglevel_type != LTTNG_UST_ABI_LOGLEVEL_ALL) { ret = config_writer_write_element_signed_int(writer, config_element_loglevel, event->attr.loglevel); if (ret) { @@ -1188,10 +1188,10 @@ int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event, struct agent_event *agent_event) { int ret; - enum lttng_ust_loglevel_type ust_loglevel_type; + enum lttng_ust_abi_loglevel_type ust_loglevel_type; ust_event->enabled = AGENT_EVENT_IS_ENABLED(agent_event); - ust_event->attr.instrumentation = LTTNG_UST_TRACEPOINT; + ust_event->attr.instrumentation = LTTNG_UST_ABI_TRACEPOINT; if (lttng_strncpy(ust_event->attr.name, agent_event->name, LTTNG_SYMBOL_NAME_LEN)) { ret = LTTNG_ERR_INVALID; @@ -1199,13 +1199,13 @@ int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event, } switch (agent_event->loglevel_type) { case LTTNG_EVENT_LOGLEVEL_ALL: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; break; case LTTNG_EVENT_LOGLEVEL_SINGLE: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE; break; case LTTNG_EVENT_LOGLEVEL_RANGE: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_RANGE; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE; break; default: ERR("Invalid agent_event loglevel_type."); @@ -1551,10 +1551,10 @@ int save_ust_context(struct config_writer *writer, } switch (ctx->ctx.ctx) { - case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER: + case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: ret = save_ust_context_perf_thread_counter(writer, ctx); break; - case LTTNG_UST_CONTEXT_APP_CONTEXT: + case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: ret = save_ust_context_app_ctx(writer, ctx); break; default: diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 527b354f1..b6cf57cf2 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -83,7 +83,7 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) /* Event loglevel value and type. */ ll_match = loglevels_match(event->attr.loglevel_type, ev_loglevel_value, key->loglevel_type, - key->loglevel_value, LTTNG_UST_LOGLEVEL_ALL); + key->loglevel_value, LTTNG_UST_ABI_LOGLEVEL_ALL); if (!ll_match) { goto no_match; @@ -195,7 +195,7 @@ error: */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, char *name, struct lttng_bytecode *filter, - enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, + enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion) { struct lttng_ht_node_str *node; @@ -285,7 +285,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) lus->metadata_attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; lus->metadata_attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; lus->metadata_attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; - lus->metadata_attr.output = LTTNG_UST_MMAP; + lus->metadata_attr.output = LTTNG_UST_ABI_MMAP; /* * Default buffer type. This can be changed through an enable channel @@ -362,7 +362,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc->attr.num_subbuf = chan->attr.num_subbuf; luc->attr.switch_timer_interval = chan->attr.switch_timer_interval; luc->attr.read_timer_interval = chan->attr.read_timer_interval; - luc->attr.output = (enum lttng_ust_output) chan->attr.output; + luc->attr.output = (enum lttng_ust_abi_output) chan->attr.output; luc->monitor_timer_interval = ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval; luc->attr.u.s.blocking_timeout = ((struct lttng_channel_extended *) @@ -371,7 +371,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, /* Translate to UST output enum */ switch (luc->attr.output) { default: - luc->attr.output = LTTNG_UST_MMAP; + luc->attr.output = LTTNG_UST_ABI_MMAP; break; } @@ -385,7 +385,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, /* Copy channel name */ strncpy(luc->name, chan->name, sizeof(luc->name)); } - luc->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + luc->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; /* Init node */ lttng_ht_node_init_str(&luc->node, luc->name); @@ -472,16 +472,16 @@ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, switch (ev->type) { case LTTNG_EVENT_PROBE: - local_ust_event->attr.instrumentation = LTTNG_UST_PROBE; + local_ust_event->attr.instrumentation = LTTNG_UST_ABI_PROBE; break; case LTTNG_EVENT_FUNCTION: - local_ust_event->attr.instrumentation = LTTNG_UST_FUNCTION; + local_ust_event->attr.instrumentation = LTTNG_UST_ABI_FUNCTION; break; case LTTNG_EVENT_FUNCTION_ENTRY: - local_ust_event->attr.instrumentation = LTTNG_UST_FUNCTION; + local_ust_event->attr.instrumentation = LTTNG_UST_ABI_FUNCTION; break; case LTTNG_EVENT_TRACEPOINT: - local_ust_event->attr.instrumentation = LTTNG_UST_TRACEPOINT; + local_ust_event->attr.instrumentation = LTTNG_UST_ABI_TRACEPOINT; break; default: ERR("Unknown ust instrumentation type (%d)", ev->type); @@ -490,20 +490,20 @@ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev, } /* Copy event name */ - strncpy(local_ust_event->attr.name, ev->name, LTTNG_UST_SYM_NAME_LEN); - local_ust_event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + strncpy(local_ust_event->attr.name, ev->name, LTTNG_UST_ABI_SYM_NAME_LEN); + local_ust_event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; switch (ev->loglevel_type) { case LTTNG_EVENT_LOGLEVEL_ALL: - local_ust_event->attr.loglevel_type = LTTNG_UST_LOGLEVEL_ALL; + local_ust_event->attr.loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; local_ust_event->attr.loglevel = -1; /* Force to -1 */ break; case LTTNG_EVENT_LOGLEVEL_RANGE: - local_ust_event->attr.loglevel_type = LTTNG_UST_LOGLEVEL_RANGE; + local_ust_event->attr.loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE; local_ust_event->attr.loglevel = ev->loglevel; break; case LTTNG_EVENT_LOGLEVEL_SINGLE: - local_ust_event->attr.loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE; + local_ust_event->attr.loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE; local_ust_event->attr.loglevel = ev->loglevel; break; default: @@ -545,72 +545,72 @@ int trace_ust_context_type_event_to_ust( switch (type) { case LTTNG_EVENT_CONTEXT_VTID: - utype = LTTNG_UST_CONTEXT_VTID; + utype = LTTNG_UST_ABI_CONTEXT_VTID; break; case LTTNG_EVENT_CONTEXT_VPID: - utype = LTTNG_UST_CONTEXT_VPID; + utype = LTTNG_UST_ABI_CONTEXT_VPID; break; case LTTNG_EVENT_CONTEXT_PTHREAD_ID: - utype = LTTNG_UST_CONTEXT_PTHREAD_ID; + utype = LTTNG_UST_ABI_CONTEXT_PTHREAD_ID; break; case LTTNG_EVENT_CONTEXT_PROCNAME: - utype = LTTNG_UST_CONTEXT_PROCNAME; + utype = LTTNG_UST_ABI_CONTEXT_PROCNAME; break; case LTTNG_EVENT_CONTEXT_IP: - utype = LTTNG_UST_CONTEXT_IP; + utype = LTTNG_UST_ABI_CONTEXT_IP; break; case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER: if (!ustctl_has_perf_counters()) { utype = -1; WARN("Perf counters not implemented in UST"); } else { - utype = LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER; + utype = LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER; } break; case LTTNG_EVENT_CONTEXT_APP_CONTEXT: - utype = LTTNG_UST_CONTEXT_APP_CONTEXT; + utype = LTTNG_UST_ABI_CONTEXT_APP_CONTEXT; break; case LTTNG_EVENT_CONTEXT_CGROUP_NS: - utype = LTTNG_UST_CONTEXT_CGROUP_NS; + utype = LTTNG_UST_ABI_CONTEXT_CGROUP_NS; break; case LTTNG_EVENT_CONTEXT_IPC_NS: - utype = LTTNG_UST_CONTEXT_IPC_NS; + utype = LTTNG_UST_ABI_CONTEXT_IPC_NS; break; case LTTNG_EVENT_CONTEXT_MNT_NS: - utype = LTTNG_UST_CONTEXT_MNT_NS; + utype = LTTNG_UST_ABI_CONTEXT_MNT_NS; break; case LTTNG_EVENT_CONTEXT_NET_NS: - utype = LTTNG_UST_CONTEXT_NET_NS; + utype = LTTNG_UST_ABI_CONTEXT_NET_NS; break; case LTTNG_EVENT_CONTEXT_PID_NS: - utype = LTTNG_UST_CONTEXT_PID_NS; + utype = LTTNG_UST_ABI_CONTEXT_PID_NS; break; case LTTNG_EVENT_CONTEXT_TIME_NS: - utype = LTTNG_UST_CONTEXT_TIME_NS; + utype = LTTNG_UST_ABI_CONTEXT_TIME_NS; break; case LTTNG_EVENT_CONTEXT_USER_NS: - utype = LTTNG_UST_CONTEXT_USER_NS; + utype = LTTNG_UST_ABI_CONTEXT_USER_NS; break; case LTTNG_EVENT_CONTEXT_UTS_NS: - utype = LTTNG_UST_CONTEXT_UTS_NS; + utype = LTTNG_UST_ABI_CONTEXT_UTS_NS; break; case LTTNG_EVENT_CONTEXT_VUID: - utype = LTTNG_UST_CONTEXT_VUID; + utype = LTTNG_UST_ABI_CONTEXT_VUID; break; case LTTNG_EVENT_CONTEXT_VEUID: - utype = LTTNG_UST_CONTEXT_VEUID; + utype = LTTNG_UST_ABI_CONTEXT_VEUID; break; case LTTNG_EVENT_CONTEXT_VSUID: - utype = LTTNG_UST_CONTEXT_VSUID; + utype = LTTNG_UST_ABI_CONTEXT_VSUID; break; case LTTNG_EVENT_CONTEXT_VGID: - utype = LTTNG_UST_CONTEXT_VGID; + utype = LTTNG_UST_ABI_CONTEXT_VGID; break; case LTTNG_EVENT_CONTEXT_VEGID: - utype = LTTNG_UST_CONTEXT_VEGID; + utype = LTTNG_UST_ABI_CONTEXT_VEGID; break; case LTTNG_EVENT_CONTEXT_VSGID: - utype = LTTNG_UST_CONTEXT_VSGID; + utype = LTTNG_UST_ABI_CONTEXT_VSGID; break; default: utype = -1; @@ -635,7 +635,7 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, return 0; } switch (utype) { - case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER: + case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: if (uctx->ctx.u.perf_counter.type != ctx->u.perf_counter.type) { return 0; @@ -646,11 +646,11 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, } if (strncmp(uctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { return 0; } break; - case LTTNG_UST_CONTEXT_APP_CONTEXT: + case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: assert(uctx->ctx.u.app_ctx.provider_name); assert(uctx->ctx.u.app_ctx.ctx_name); if (strcmp(uctx->ctx.u.app_ctx.provider_name, @@ -691,16 +691,16 @@ struct ltt_ust_context *trace_ust_create_context( goto end; } - uctx->ctx.ctx = (enum lttng_ust_context_type) utype; + uctx->ctx.ctx = (enum lttng_ust_abi_context_type) utype; switch (utype) { - case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER: + case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: uctx->ctx.u.perf_counter.type = ctx->u.perf_counter.type; uctx->ctx.u.perf_counter.config = ctx->u.perf_counter.config; strncpy(uctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name, - LTTNG_UST_SYM_NAME_LEN); - uctx->ctx.u.perf_counter.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + LTTNG_UST_ABI_SYM_NAME_LEN); + uctx->ctx.u.perf_counter.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; break; - case LTTNG_UST_CONTEXT_APP_CONTEXT: + case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: { char *provider_name = NULL, *ctx_name = NULL; @@ -1255,7 +1255,7 @@ void trace_ust_destroy_context(struct ltt_ust_context *ctx) { assert(ctx); - if (ctx->ctx.ctx == LTTNG_UST_CONTEXT_APP_CONTEXT) { + if (ctx->ctx.ctx == LTTNG_UST_ABI_CONTEXT_APP_CONTEXT) { free(ctx->ctx.u.app_ctx.provider_name); free(ctx->ctx.u.app_ctx.ctx_name); } diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 53e1ab2b5..cc7cd332c 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -25,7 +25,7 @@ struct agent; struct ltt_ust_ht_key { const char *name; const struct lttng_bytecode *filter; - enum lttng_ust_loglevel_type loglevel_type; + enum lttng_ust_abi_loglevel_type loglevel_type; int loglevel_value; const struct lttng_event_exclusion *exclusion; }; @@ -40,7 +40,7 @@ struct ltt_ust_context { /* UST event */ struct ltt_ust_event { unsigned int enabled; - struct lttng_ust_event attr; + struct lttng_ust_abi_event attr; struct lttng_ht_node_str node; char *filter_expression; struct lttng_bytecode *filter; @@ -63,8 +63,8 @@ struct ltt_ust_channel { * Log4j, Python. */ enum lttng_domain_type domain; - char name[LTTNG_UST_SYM_NAME_LEN]; - struct lttng_ust_channel_attr attr; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; + struct lttng_ust_abi_channel_attr attr; struct lttng_ht *ctx; struct cds_list_head ctx_list; struct lttng_ht *events; @@ -121,7 +121,7 @@ struct ltt_ust_session { unsigned int live_timer_interval; /* usec */ /* Metadata channel attributes. */ - struct lttng_ust_channel_attr metadata_attr; + struct lttng_ust_abi_channel_attr metadata_attr; /* * Path where to keep the shared memory files. @@ -183,7 +183,7 @@ int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, char *name, struct lttng_bytecode *filter, - enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, + enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion); struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, const char *name); @@ -311,7 +311,7 @@ int trace_ust_match_context(const struct ltt_ust_context *uctx, static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, char *name, struct lttng_bytecode *filter, - enum lttng_ust_loglevel_type loglevel_type, int loglevel_value, + enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value, struct lttng_event_exclusion *exclusion) { return NULL; diff --git a/src/bin/lttng-sessiond/ust-abi-internal.h b/src/bin/lttng-sessiond/ust-abi-internal.h index 0f12be083..ebe960212 100644 --- a/src/bin/lttng-sessiond/ust-abi-internal.h +++ b/src/bin/lttng-sessiond/ust-abi-internal.h @@ -24,209 +24,276 @@ #define __ust_stringify(x) __ust_stringify1(x) #endif /* __ust_stringify */ -#define LTTNG_UST_SYM_NAME_LEN 256 +#define LTTNG_UST_ABI_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 +#define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5 /* Version for ABI between liblttng-ust, sessiond, consumerd */ -#define LTTNG_UST_ABI_MAJOR_VERSION 8 -#define LTTNG_UST_ABI_MINOR_VERSION 1 - -enum lttng_ust_instrumentation { - LTTNG_UST_TRACEPOINT = 0, - LTTNG_UST_PROBE = 1, - LTTNG_UST_FUNCTION = 2, +#define LTTNG_UST_ABI_MAJOR_VERSION 9 +#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8 +#define LTTNG_UST_ABI_MINOR_VERSION 0 + +enum lttng_ust_abi_instrumentation { + LTTNG_UST_ABI_TRACEPOINT = 0, + LTTNG_UST_ABI_PROBE = 1, + LTTNG_UST_ABI_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_abi_loglevel_type { + LTTNG_UST_ABI_LOGLEVEL_ALL = 0, + LTTNG_UST_ABI_LOGLEVEL_RANGE = 1, + LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2, }; -enum lttng_ust_output { - LTTNG_UST_MMAP = 0, +enum lttng_ust_abi_output { + LTTNG_UST_ABI_MMAP = 0, }; -enum lttng_ust_chan_type { - LTTNG_UST_CHAN_PER_CPU = 0, - LTTNG_UST_CHAN_METADATA = 1, +enum lttng_ust_abi_chan_type { + LTTNG_UST_ABI_CHAN_PER_CPU = 0, + LTTNG_UST_ABI_CHAN_METADATA = 1, }; -struct lttng_ust_tracer_version { +struct lttng_ust_abi_tracer_version { uint32_t major; uint32_t minor; uint32_t patchlevel; } LTTNG_PACKED; -#define LTTNG_UST_CHANNEL_PADDING (LTTNG_UST_SYM_NAME_LEN + 32) +#define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_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 { +#define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U +struct lttng_ust_abi_channel { uint64_t len; - enum lttng_ust_chan_type type; - char padding[LTTNG_UST_CHANNEL_PADDING]; + int32_t type; /* enum lttng_ust_abi_chan_type */ + char padding[LTTNG_UST_ABI_CHANNEL_PADDING]; char data[]; /* variable sized data */ } LTTNG_PACKED; -#define LTTNG_UST_STREAM_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32) -struct lttng_ust_stream { +#define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_stream { uint64_t len; /* shm len */ uint32_t stream_nr; /* stream number */ - char padding[LTTNG_UST_STREAM_PADDING1]; + char padding[LTTNG_UST_ABI_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 */ +#define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4 + +enum lttng_ust_abi_counter_arithmetic { + LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0, + LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1, +}; + +enum lttng_ust_abi_counter_bitness { + LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0, + LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1, +}; + +struct lttng_ust_abi_counter_dimension { + uint64_t size; + uint64_t underflow_index; + uint64_t overflow_index; + uint8_t has_underflow; + uint8_t has_overflow; +} LTTNG_PACKED; + +#define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67 +struct lttng_ust_abi_counter_conf { + uint32_t arithmetic; /* enum lttng_ust_counter_arithmetic */ + uint32_t bitness; /* enum lttng_ust_counter_bitness */ + uint32_t number_dimensions; + int64_t global_sum_step; + struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX]; + uint8_t coalesce_hits; + char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1]; +} LTTNG_PACKED; + +struct lttng_ust_abi_counter_value { + uint32_t number_dimensions; + uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX]; + int64_t value; +} LTTNG_PACKED; + +#define LTTNG_UST_ABI_EVENT_PADDING1 8 +#define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_event { + int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */ + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */ - enum lttng_ust_loglevel_type loglevel_type; - int loglevel; /* value, -1: all */ - char padding[LTTNG_UST_EVENT_PADDING1]; + int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */ + int32_t loglevel; /* value, -1: all */ + uint64_t token; /* User-provided token */ + char padding[LTTNG_UST_ABI_EVENT_PADDING1]; /* Per instrumentation type configuration */ union { - char padding[LTTNG_UST_EVENT_PADDING2]; + char padding[LTTNG_UST_ABI_EVENT_PADDING2]; } u; } LTTNG_PACKED; -#define LTTNG_UST_EVENT_NOTIFIER_PADDING 40 -struct lttng_ust_event_notifier { - struct lttng_ust_event event; - char padding[LTTNG_UST_EVENT_NOTIFIER_PADDING]; +#define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32 +struct lttng_ust_abi_event_notifier { + struct lttng_ust_abi_event event; + uint64_t error_counter_index; + char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING]; } LTTNG_PACKED; -#define LTTNG_UST_EVENT_NOTIFIER_NOTIFICATION_PADDING 34 -struct lttng_ust_event_notifier_notification { +#define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32 +struct lttng_ust_abi_event_notifier_notification { uint64_t token; - char padding[LTTNG_UST_EVENT_NOTIFIER_NOTIFICATION_PADDING]; + uint16_t capture_buf_size; + char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING]; } 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_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +#define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U +struct lttng_ust_abi_counter { + uint64_t len; + char padding[LTTNG_UST_ABI_COUNTER_PADDING1]; + char data[]; /* variable sized data */ +} LTTNG_PACKED; + +#define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_counter_global { + uint64_t len; /* shm len */ + char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1]; +} LTTNG_PACKED; + +#define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_counter_cpu { + uint64_t len; /* shm len */ + uint32_t cpu_nr; + char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1]; +} LTTNG_PACKED; + +enum lttng_ust_abi_field_type { + LTTNG_UST_ABI_FIELD_OTHER = 0, + LTTNG_UST_ABI_FIELD_INTEGER = 1, + LTTNG_UST_ABI_FIELD_ENUM = 2, + LTTNG_UST_ABI_FIELD_FLOAT = 3, + LTTNG_UST_ABI_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; +#define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28) +struct lttng_ust_abi_field_iter { + char event_name[LTTNG_UST_ABI_SYM_NAME_LEN]; + char field_name[LTTNG_UST_ABI_SYM_NAME_LEN]; + int32_t type; /* enum lttng_ust_abi_field_type */ int loglevel; /* event loglevel */ int nowrite; - char padding[LTTNG_UST_FIELD_ITER_PADDING]; + char padding[LTTNG_UST_ABI_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, - LTTNG_UST_CONTEXT_CGROUP_NS = 8, - LTTNG_UST_CONTEXT_IPC_NS = 9, - LTTNG_UST_CONTEXT_MNT_NS = 10, - LTTNG_UST_CONTEXT_NET_NS = 11, - LTTNG_UST_CONTEXT_PID_NS = 12, - LTTNG_UST_CONTEXT_USER_NS = 13, - LTTNG_UST_CONTEXT_UTS_NS = 14, - LTTNG_UST_CONTEXT_VUID = 15, - LTTNG_UST_CONTEXT_VEUID = 16, - LTTNG_UST_CONTEXT_VSUID = 17, - LTTNG_UST_CONTEXT_VGID = 18, - LTTNG_UST_CONTEXT_VEGID = 19, - LTTNG_UST_CONTEXT_VSGID = 20, - LTTNG_UST_CONTEXT_TIME_NS = 21, +enum lttng_ust_abi_context_type { + LTTNG_UST_ABI_CONTEXT_VTID = 0, + LTTNG_UST_ABI_CONTEXT_VPID = 1, + LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2, + LTTNG_UST_ABI_CONTEXT_PROCNAME = 3, + LTTNG_UST_ABI_CONTEXT_IP = 4, + LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5, + LTTNG_UST_ABI_CONTEXT_CPU_ID = 6, + LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7, + LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8, + LTTNG_UST_ABI_CONTEXT_IPC_NS = 9, + LTTNG_UST_ABI_CONTEXT_MNT_NS = 10, + LTTNG_UST_ABI_CONTEXT_NET_NS = 11, + LTTNG_UST_ABI_CONTEXT_PID_NS = 12, + LTTNG_UST_ABI_CONTEXT_USER_NS = 13, + LTTNG_UST_ABI_CONTEXT_UTS_NS = 14, + LTTNG_UST_ABI_CONTEXT_VUID = 15, + LTTNG_UST_ABI_CONTEXT_VEUID = 16, + LTTNG_UST_ABI_CONTEXT_VSUID = 17, + LTTNG_UST_ABI_CONTEXT_VGID = 18, + LTTNG_UST_ABI_CONTEXT_VEGID = 19, + LTTNG_UST_ABI_CONTEXT_VSGID = 20, + LTTNG_UST_ABI_CONTEXT_TIME_NS = 21, }; -struct lttng_ust_perf_counter_ctx { +struct lttng_ust_abi_perf_counter_ctx { uint32_t type; uint64_t config; - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_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]; +#define LTTNG_UST_ABI_CONTEXT_PADDING1 16 +#define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_context { + int32_t ctx; /* enum lttng_ust_abi_context_type */ + char padding[LTTNG_UST_ABI_CONTEXT_PADDING1]; union { - struct lttng_ust_perf_counter_ctx perf_counter; + struct lttng_ust_abi_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]; + char padding[LTTNG_UST_ABI_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 { +#define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_channel_attr { uint64_t subbuf_size; /* bytes */ uint64_t num_subbuf; /* power of 2 */ int overwrite; /* 1: overwrite, 0: discard */ unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ - enum lttng_ust_output output; /* splice, mmap */ + int32_t output; /* enum lttng_ust_abi_output */ union { struct { int64_t blocking_timeout; /* Blocking timeout (usec) */ } s; - char padding[LTTNG_UST_CHANNEL_ATTR_PADDING]; + char padding[LTTNG_UST_ABI_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 */ +#define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16 +struct lttng_ust_abi_tracepoint_iter { + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */ int loglevel; - char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING]; + char padding[LTTNG_UST_ABI_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, +enum lttng_ust_abi_object_type { + LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1, + LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0, + LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1, + LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2, + LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3, + LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4, + LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5, + LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6, + LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7, + LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8, }; -#define LTTNG_UST_OBJECT_DATA_PADDING1 32 -#define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32) +#define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32 +#define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) -struct lttng_ust_object_data { - enum lttng_ust_object_type type; +struct lttng_ust_abi_object_data { + int32_t type; /* enum lttng_ust_abi_object_type */ int handle; uint64_t size; - char padding1[LTTNG_UST_OBJECT_DATA_PADDING1]; + char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1]; union { struct { void *data; - enum lttng_ust_chan_type type; + int32_t type; /* enum lttng_ust_abi_chan_type */ int wakeup_fd; } channel; struct { @@ -234,140 +301,129 @@ struct lttng_ust_object_data { int wakeup_fd; uint32_t stream_nr; } stream; - char padding2[LTTNG_UST_OBJECT_DATA_PADDING2]; + struct { + void *data; + } counter; + struct { + int shm_fd; + } counter_global; + struct { + int shm_fd; + uint32_t cpu_nr; + } counter_cpu; + char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2]; } u; } LTTNG_PACKED; enum lttng_ust_calibrate_type { - LTTNG_UST_CALIBRATE_TRACEPOINT, + LTTNG_UST_ABI_CALIBRATE_TRACEPOINT, }; -#define LTTNG_UST_CALIBRATE_PADDING1 16 -#define LTTNG_UST_CALIBRATE_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32) -struct lttng_ust_calibrate { +#define LTTNG_UST_ABI_CALIBRATE_PADDING1 16 +#define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32) +struct lttng_ust_abi_calibrate { enum lttng_ust_calibrate_type type; /* type (input) */ - char padding[LTTNG_UST_CALIBRATE_PADDING1]; + char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1]; union { - char padding[LTTNG_UST_CALIBRATE_PADDING2]; + char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2]; } u; } LTTNG_PACKED; -#define FILTER_BYTECODE_MAX_LEN 65536 -#define LTTNG_UST_FILTER_PADDING 32 -struct lttng_ust_filter_bytecode { +#define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536 +#define LTTNG_UST_ABI_FILTER_PADDING 32 +struct lttng_ust_abi_filter_bytecode { uint32_t len; uint32_t reloc_offset; uint64_t seqnum; - char padding[LTTNG_UST_FILTER_PADDING]; + char padding[LTTNG_UST_ABI_FILTER_PADDING]; char data[0]; } LTTNG_PACKED; -#define CAPTURE_BYTECODE_MAX_LEN 65536 -#define LTTNG_UST_CAPTURE_PADDING 32 -struct lttng_ust_capture_bytecode { +#define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536 +#define LTTNG_UST_ABI_CAPTURE_PADDING 32 +struct lttng_ust_abi_capture_bytecode { uint32_t len; uint32_t reloc_offset; uint64_t seqnum; - char padding[LTTNG_UST_CAPTURE_PADDING]; + char padding[LTTNG_UST_ABI_CAPTURE_PADDING]; char data[0]; } LTTNG_PACKED; -#define LTTNG_UST_EXCLUSION_PADDING 32 -struct lttng_ust_event_exclusion { +#define LTTNG_UST_ABI_EXCLUSION_PADDING 32 +struct lttng_ust_abi_event_exclusion { uint32_t count; - char padding[LTTNG_UST_EXCLUSION_PADDING]; - char names[LTTNG_UST_SYM_NAME_LEN][0]; + char padding[LTTNG_UST_ABI_EXCLUSION_PADDING]; + char names[LTTNG_UST_ABI_SYM_NAME_LEN][0]; } LTTNG_PACKED; -#define _UST_CMD(minor) (minor) -#define _UST_CMDR(minor, type) (minor) -#define _UST_CMDW(minor, type) (minor) +#define LTTNG_UST_ABI_CMD(minor) (minor) +#define LTTNG_UST_ABI_CMDR(minor, type) (minor) +#define LTTNG_UST_ABI_CMDW(minor, type) (minor) /* Handled by object descriptor */ -#define LTTNG_UST_RELEASE _UST_CMD(0x1) +#define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_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) -#define LTTNG_UST_EVENT_NOTIFIER_GROUP_CREATE _UST_CMD(0x46) - -/* 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) +#define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40) +#define LTTNG_UST_ABI_TRACER_VERSION \ + LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version) +#define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42) +#define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43) +#define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44) +#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45) +#define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \ + LTTNG_UST_ABI_CMD(0x46) + +/* Session commands */ +#define LTTNG_UST_ABI_CHANNEL \ + LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel) +#define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52) +#define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53) +#define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54) + +/* Channel commands */ +#define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60) +#define LTTNG_UST_ABI_EVENT \ + LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event) + +/* Event and channel commands */ +#define LTTNG_UST_ABI_CONTEXT \ + LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context) +#define LTTNG_UST_ABI_FLUSH_BUFFER \ + LTTNG_UST_ABI_CMD(0x71) + +/* Event, event notifier, channel and session commands */ +#define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80) +#define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81) /* Tracepoint list commands */ -#define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90) -#define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91) +#define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90) +#define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91) -/* Event FD commands */ -#define LTTNG_UST_FILTER _UST_CMD(0xA0) -#define LTTNG_UST_EXCLUSION _UST_CMD(0xA1) +/* Event and event notifier commands */ +#define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0) +#define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1) /* Event notifier group commands */ -#define LTTNG_UST_EVENT_NOTIFIER_CREATE \ - _UST_CMDW(0xB0, struct lttng_ust_event_notifier) - -#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 { - char *ctxname; - } app_context; -}; +#define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \ + LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier) -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); -}; +/* Event notifier commands */ +#define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6) -/* Create root handle. Always ID 0. */ -int lttng_abi_create_root_handle(void); +/* Session and event notifier group commands */ +#define LTTNG_UST_ABI_COUNTER \ + LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter) -const struct lttng_ust_objd_ops *objd_ops(int id); -int lttng_ust_objd_unref(int id, int is_owner); +/* Counter commands */ +#define LTTNG_UST_ABI_COUNTER_GLOBAL \ + LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global) +#define LTTNG_UST_ABI_COUNTER_CPU \ + LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu) -void lttng_ust_abi_exit(void); -void lttng_ust_events_exit(void); -void lttng_ust_objd_table_owner_cleanup(void *owner); +#define LTTNG_UST_ABI_ROOT_HANDLE 0 #endif /* LTTNG_UST_ABI_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 43864bd0f..6e2659c1e 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -88,7 +88,7 @@ static uint64_t get_next_session_id(void) static void copy_channel_attr_to_ustctl( struct ustctl_consumer_channel_attr *attr, - struct lttng_ust_channel_attr *uattr) + struct lttng_ust_abi_channel_attr *uattr) { /* Copy event attributes since the layout is different. */ attr->subbuf_size = uattr->subbuf_size; @@ -128,7 +128,7 @@ static int ht_match_ust_app_event(struct cds_lfht_node *node, const void *_key) /* Event loglevel. */ if (ev_loglevel_value != key->loglevel_type) { - if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL + if (event->attr.loglevel_type == LTTNG_UST_ABI_LOGLEVEL_ALL && key->loglevel_type == 0 && ev_loglevel_value == -1) { /* @@ -165,7 +165,7 @@ static int ht_match_ust_app_event(struct cds_lfht_node *node, const void *_key) /* Both exclusions exists, check count followed by the names. */ if (event->exclusion->count != key->exclusion->count || memcmp(event->exclusion->names, key->exclusion->names, - event->exclusion->count * LTTNG_UST_SYM_NAME_LEN) != 0) { + event->exclusion->count * LTTNG_UST_ABI_SYM_NAME_LEN) != 0) { goto no_match; } } @@ -440,7 +440,7 @@ void save_per_pid_lost_discarded_counters(struct ust_app_channel *ua_chan) struct ltt_session *session; struct ltt_ust_channel *uchan; - if (ua_chan->attr.type != LTTNG_UST_CHAN_PER_CPU) { + if (ua_chan->attr.type != LTTNG_UST_ABI_CHAN_PER_CPU) { return; } @@ -580,7 +580,7 @@ int ust_app_register_done(struct ust_app *app) return ret; } -int ust_app_release_object(struct ust_app *app, struct lttng_ust_object_data *data) +int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data *data) { int ret, sock; @@ -1109,7 +1109,7 @@ struct ust_app_session *alloc_ust_app_session(void) ua_sess->handle = -1; ua_sess->channels = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); - ua_sess->metadata_attr.type = LTTNG_UST_CHAN_METADATA; + ua_sess->metadata_attr.type = LTTNG_UST_ABI_CHAN_METADATA; pthread_mutex_init(&ua_sess->lock, NULL); return ua_sess; @@ -1124,7 +1124,7 @@ error_free: static struct ust_app_channel *alloc_ust_app_channel(const char *name, struct ust_app_session *ua_sess, - struct lttng_ust_channel_attr *attr) + struct lttng_ust_abi_channel_attr *attr) { struct ust_app_channel *ua_chan; @@ -1162,7 +1162,7 @@ struct ust_app_channel *alloc_ust_app_channel(const char *name, ua_chan->attr.blocking_timeout = attr->u.s.blocking_timeout; } /* By default, the channel is a per cpu channel. */ - ua_chan->attr.type = LTTNG_UST_CHAN_PER_CPU; + ua_chan->attr.type = LTTNG_UST_ABI_CHAN_PER_CPU; DBG3("UST app channel %s allocated", ua_chan->name); @@ -1199,7 +1199,7 @@ error: */ static struct ust_app_event *alloc_ust_app_event(char *name, - struct lttng_ust_event *attr) + struct lttng_ust_abi_event *attr) { struct ust_app_event *ua_event; @@ -1304,7 +1304,7 @@ struct ust_app_ctx *alloc_ust_app_ctx(struct lttng_ust_context_attr *uctx) if (uctx) { memcpy(&ua_ctx->ctx, uctx, sizeof(ua_ctx->ctx)); - if (uctx->ctx == LTTNG_UST_CONTEXT_APP_CONTEXT) { + if (uctx->ctx == LTTNG_UST_ABI_CONTEXT_APP_CONTEXT) { char *provider_name = NULL, *ctx_name = NULL; provider_name = strdup(uctx->u.app_ctx.provider_name); @@ -1332,10 +1332,10 @@ error: * * Return allocated filter or NULL on error. */ -static struct lttng_ust_filter_bytecode * -create_ust_filter_bytecode_from_bytecode(const struct lttng_bytecode *orig_f) +static struct lttng_ust_abi_filter_bytecode *create_ust_filter_bytecode_from_bytecode( + const struct lttng_bytecode *orig_f) { - struct lttng_ust_filter_bytecode *filter = NULL; + struct lttng_ust_abi_filter_bytecode *filter = NULL; /* Copy filter bytecode. */ filter = zmalloc(sizeof(*filter) + orig_f->len); @@ -1345,7 +1345,7 @@ create_ust_filter_bytecode_from_bytecode(const struct lttng_bytecode *orig_f) } assert(sizeof(struct lttng_bytecode) == - sizeof(struct lttng_ust_filter_bytecode)); + sizeof(struct lttng_ust_abi_filter_bytecode)); memcpy(filter, orig_f, sizeof(*filter) + orig_f->len); error: return filter; @@ -1356,20 +1356,20 @@ error: * * Return allocated filter or NULL on error. */ -static struct lttng_ust_capture_bytecode * +static struct lttng_ust_abi_capture_bytecode * create_ust_capture_bytecode_from_bytecode(const struct lttng_bytecode *orig_f) { - struct lttng_ust_capture_bytecode *capture = NULL; + struct lttng_ust_abi_capture_bytecode *capture = NULL; /* Copy capture bytecode. */ capture = zmalloc(sizeof(*capture) + orig_f->len); if (!capture) { - PERROR("Failed to allocate lttng_ust_capture_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len); + PERROR("Failed to allocate lttng_ust_abi_capture_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len); goto error; } assert(sizeof(struct lttng_bytecode) == - sizeof(struct lttng_ust_capture_bytecode)); + sizeof(struct lttng_ust_abi_capture_bytecode)); memcpy(capture, orig_f, sizeof(*capture) + orig_f->len); error: return capture; @@ -1537,10 +1537,10 @@ error: */ static int set_ust_object_filter(struct ust_app *app, const struct lttng_bytecode *bytecode, - struct lttng_ust_object_data *ust_object) + struct lttng_ust_abi_object_data *ust_object) { int ret; - struct lttng_ust_filter_bytecode *ust_bytecode = NULL; + struct lttng_ust_abi_filter_bytecode *ust_bytecode = NULL; health_code_update(); @@ -1588,7 +1588,7 @@ static int set_ust_capture(struct ust_app *app, struct lttng_ust_object_data *ust_object) { int ret; - struct lttng_ust_capture_bytecode *ust_bytecode = NULL; + struct lttng_ust_abi_capture_bytecode *ust_bytecode = NULL; health_code_update(); @@ -1633,12 +1633,12 @@ error: } static -struct lttng_ust_event_exclusion *create_ust_exclusion_from_exclusion( +struct lttng_ust_abi_event_exclusion *create_ust_exclusion_from_exclusion( const struct lttng_event_exclusion *exclusion) { - struct lttng_ust_event_exclusion *ust_exclusion = NULL; - size_t exclusion_alloc_size = sizeof(struct lttng_ust_event_exclusion) + - LTTNG_UST_SYM_NAME_LEN * exclusion->count; + struct lttng_ust_abi_event_exclusion *ust_exclusion = NULL; + size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) + + LTTNG_UST_ABI_SYM_NAME_LEN * exclusion->count; ust_exclusion = zmalloc(exclusion_alloc_size); if (!ust_exclusion) { @@ -1647,7 +1647,7 @@ struct lttng_ust_event_exclusion *create_ust_exclusion_from_exclusion( } assert(sizeof(struct lttng_event_exclusion) == - sizeof(struct lttng_ust_event_exclusion)); + sizeof(struct lttng_ust_abi_event_exclusion)); memcpy(ust_exclusion, exclusion, exclusion_alloc_size); end: return ust_exclusion; @@ -1658,10 +1658,10 @@ end: */ static int set_ust_object_exclusions(struct ust_app *app, const struct lttng_event_exclusion *exclusions, - struct lttng_ust_object_data *ust_object) + struct lttng_ust_abi_object_data *ust_object) { int ret; - struct lttng_ust_event_exclusion *ust_exclusions = NULL; + struct lttng_ust_abi_event_exclusion *ust_exclusions = NULL; assert(exclusions && exclusions->count > 0); @@ -1704,7 +1704,7 @@ error: * Disable the specified event on to UST tracer for the UST session. */ static int disable_ust_object(struct ust_app *app, - struct lttng_ust_object_data *object) + struct lttng_ust_abi_object_data *object) { int ret; @@ -1819,7 +1819,7 @@ error: * Enable the specified event on to UST tracer for the UST session. */ static int enable_ust_object( - struct ust_app *app, struct lttng_ust_object_data *ust_object) + struct ust_app *app, struct lttng_ust_abi_object_data *ust_object) { int ret; @@ -1997,11 +1997,11 @@ error: static int init_ust_event_notifier_from_event_rule( const struct lttng_event_rule *rule, - struct lttng_ust_event_notifier *event_notifier) + struct lttng_ust_abi_event_notifier *event_notifier) { enum lttng_event_rule_status status; enum lttng_loglevel_type loglevel_type; - enum lttng_ust_loglevel_type ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL; + enum lttng_ust_abi_loglevel_type ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; int loglevel = -1, ret = 0; const char *pattern; @@ -2021,7 +2021,7 @@ static int init_ust_event_notifier_from_event_rule( pattern = event_get_default_agent_ust_name( lttng_event_rule_get_domain_type(rule)); loglevel = 0; - ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; } else { status = lttng_event_rule_tracepoint_get_pattern( rule, &pattern); @@ -2039,13 +2039,13 @@ static int init_ust_event_notifier_from_event_rule( switch (loglevel_type) { case LTTNG_EVENT_LOGLEVEL_ALL: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_ALL; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL; break; case LTTNG_EVENT_LOGLEVEL_RANGE: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_RANGE; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE; break; case LTTNG_EVENT_LOGLEVEL_SINGLE: - ust_loglevel_type = LTTNG_UST_LOGLEVEL_SINGLE; + ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE; break; default: /* Unknown log level specification type. */ @@ -2059,9 +2059,9 @@ static int init_ust_event_notifier_from_event_rule( } } - event_notifier->event.instrumentation = LTTNG_UST_TRACEPOINT; + event_notifier->event.instrumentation = LTTNG_UST_ABI_TRACEPOINT; ret = lttng_strncpy(event_notifier->event.name, pattern, - LTTNG_UST_SYM_NAME_LEN - 1); + LTTNG_UST_ABI_SYM_NAME_LEN - 1); if (ret) { ERR("Failed to copy event rule pattern to notifier: pattern = '%s' ", pattern); @@ -2084,7 +2084,7 @@ static int create_ust_event_notifier(struct ust_app *app, int ret = 0; enum lttng_condition_status condition_status; const struct lttng_condition *condition = NULL; - struct lttng_ust_event_notifier event_notifier; + struct lttng_ust_abi_event_notifier event_notifier; const struct lttng_event_rule *event_rule = NULL; unsigned int capture_bytecode_count = 0, i; enum lttng_condition_status cond_status; @@ -2232,7 +2232,7 @@ static void shadow_copy_event(struct ust_app_event *ua_event, /* Copy exclusion data */ if (uevent->exclusion) { exclusion_alloc_size = sizeof(struct lttng_event_exclusion) + - LTTNG_UST_SYM_NAME_LEN * uevent->exclusion->count; + LTTNG_UST_ABI_SYM_NAME_LEN * uevent->exclusion->count; ua_event->exclusion = zmalloc(exclusion_alloc_size); if (ua_event->exclusion == NULL) { PERROR("malloc"); @@ -2682,14 +2682,14 @@ static int ht_match_ust_app_ctx(struct cds_lfht_node *node, const void *_key) } switch(key->ctx) { - case LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER: + case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER: if (strncmp(key->u.perf_counter.name, ctx->ctx.u.perf_counter.name, sizeof(key->u.perf_counter.name))) { goto no_match; } break; - case LTTNG_UST_CONTEXT_APP_CONTEXT: + case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT: if (strcmp(key->u.app_ctx.provider_name, ctx->ctx.u.app_ctx.provider_name) || strcmp(key->u.app_ctx.ctx_name, @@ -3532,7 +3532,7 @@ error: */ static int ust_app_channel_allocate(struct ust_app_session *ua_sess, struct ltt_ust_channel *uchan, - enum lttng_ust_chan_type type, struct ltt_ust_session *usess, + enum lttng_ust_abi_chan_type type, struct ltt_ust_session *usess, struct ust_app_channel **ua_chanp) { int ret = 0; @@ -3990,7 +3990,7 @@ int ust_app_setup_event_notifier_group(struct ust_app *app) { int ret; int event_pipe_write_fd; - struct lttng_ust_object_data *event_notifier_group = NULL; + struct lttng_ust_abi_object_data *event_notifier_group = NULL; enum lttng_error_code lttng_ret; assert(app); @@ -4190,7 +4190,7 @@ int ust_app_list_events(struct lttng_event **events) rcu_read_lock(); cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) { - struct lttng_ust_tracepoint_iter uiter; + struct lttng_ust_abi_tracepoint_iter uiter; health_code_update(); @@ -4273,9 +4273,9 @@ int ust_app_list_events(struct lttng_event **events) nbmem = new_nbmem; tmp_event = new_tmp_event; } - memcpy(tmp_event[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN); + memcpy(tmp_event[count].name, uiter.name, LTTNG_UST_ABI_SYM_NAME_LEN); tmp_event[count].loglevel = uiter.loglevel; - tmp_event[count].type = (enum lttng_event_type) LTTNG_UST_TRACEPOINT; + tmp_event[count].type = (enum lttng_event_type) LTTNG_UST_ABI_TRACEPOINT; tmp_event[count].pid = app->pid; tmp_event[count].enabled = -1; count++; @@ -4321,7 +4321,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) rcu_read_lock(); cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) { - struct lttng_ust_field_iter uiter; + struct lttng_ust_abi_field_iter uiter; health_code_update(); @@ -4405,12 +4405,12 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) tmp_event = new_tmp_event; } - memcpy(tmp_event[count].field_name, uiter.field_name, LTTNG_UST_SYM_NAME_LEN); + memcpy(tmp_event[count].field_name, uiter.field_name, LTTNG_UST_ABI_SYM_NAME_LEN); /* Mapping between these enums matches 1 to 1. */ tmp_event[count].type = (enum lttng_event_field_type) uiter.type; tmp_event[count].nowrite = uiter.nowrite; - memcpy(tmp_event[count].event.name, uiter.event_name, LTTNG_UST_SYM_NAME_LEN); + memcpy(tmp_event[count].event.name, uiter.event_name, LTTNG_UST_ABI_SYM_NAME_LEN); tmp_event[count].event.loglevel = uiter.loglevel; tmp_event[count].event.type = LTTNG_EVENT_TRACEPOINT; tmp_event[count].event.pid = app->pid; @@ -4709,7 +4709,7 @@ int ust_app_channel_create(struct ltt_ust_session *usess, * configuration. */ ret = ust_app_channel_allocate(ua_sess, uchan, - LTTNG_UST_CHAN_PER_CPU, usess, + LTTNG_UST_ABI_CHAN_PER_CPU, usess, &ua_chan); if (ret < 0) { goto error; @@ -6429,7 +6429,7 @@ int ust_app_recv_notify(int sock) case USTCTL_NOTIFY_CMD_EVENT: { int sobjd, cobjd, loglevel_value; - char name[LTTNG_UST_SYM_NAME_LEN], *sig, *model_emf_uri; + char name[LTTNG_UST_ABI_SYM_NAME_LEN], *sig, *model_emf_uri; size_t nr_fields; struct ustctl_field *fields; @@ -6496,7 +6496,7 @@ int ust_app_recv_notify(int sock) case USTCTL_NOTIFY_CMD_ENUM: { int sobjd; - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; size_t nr_entries; struct ustctl_enum_entry *entries; diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 29024b4de..9b42d518d 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -40,7 +40,7 @@ struct ust_app_notify_sock_obj { struct ust_app_ht_key { const char *name; const struct lttng_bytecode *filter; - enum lttng_ust_loglevel_type loglevel_type; + enum lttng_ust_abi_loglevel_type loglevel_type; const struct lttng_event_exclusion *exclusion; }; @@ -96,7 +96,7 @@ struct ust_app_stream_list { struct ust_app_ctx { int handle; struct lttng_ust_context_attr ctx; - struct lttng_ust_object_data *obj; + struct lttng_ust_abi_object_data *obj; struct lttng_ht_node_ulong node; struct cds_list_head list; }; @@ -104,9 +104,9 @@ struct ust_app_ctx { struct ust_app_event { int enabled; int handle; - struct lttng_ust_object_data *obj; - struct lttng_ust_event attr; - char name[LTTNG_UST_SYM_NAME_LEN]; + struct lttng_ust_abi_object_data *obj; + struct lttng_ust_abi_event attr; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; struct lttng_ht_node_str node; struct lttng_bytecode *filter; struct lttng_event_exclusion *exclusion; @@ -115,7 +115,7 @@ struct ust_app_event { struct ust_app_event_notifier_rule { int enabled; int handle; - struct lttng_ust_object_data *obj; + struct lttng_ust_abi_object_data *obj; /* Holds a strong reference. */ struct lttng_trigger *trigger; /* Unique ID returned by the tracer to identify this event notifier. */ @@ -134,7 +134,7 @@ struct ust_app_stream { char pathname[PATH_MAX]; /* Format is %s_%d respectively channel name and CPU number. */ char name[DEFAULT_STREAM_NAME_LEN]; - struct lttng_ust_object_data *obj; + struct lttng_ust_abi_object_data *obj; /* Using a list of streams to keep order. */ struct cds_list_head list; }; @@ -154,8 +154,8 @@ struct ust_app_channel { uint64_t tracing_channel_id; /* Number of stream that this channel is expected to receive. */ unsigned int expected_stream_count; - char name[LTTNG_UST_SYM_NAME_LEN]; - struct lttng_ust_object_data *obj; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; + struct lttng_ust_abi_object_data *obj; struct ustctl_consumer_channel_attr attr; struct ust_app_stream_list streams; /* Session pointer that owns this object. */ @@ -267,7 +267,7 @@ struct ust_app { int compatible; /* If the lttng-ust tracer version does not match the supported version of the session daemon, this flag is set to 0 (NOT compatible) else 1. */ - struct lttng_ust_tracer_version version; + struct lttng_ust_abi_tracer_version version; uint32_t v_major; /* Version major number */ uint32_t v_minor; /* Version minor number */ /* Extra for the NULL byte. */ @@ -317,7 +317,7 @@ struct ust_app { * Handle to the lttng_ust object representing the event * notifier group. */ - struct lttng_ust_object_data *object; + struct lttng_ust_abi_object_data *object; struct lttng_pipe *event_pipe; } event_notifier_group; /* @@ -387,7 +387,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session); enum lttng_error_code ust_app_create_channel_subdirectories( const struct ltt_ust_session *session); int ust_app_release_object(struct ust_app *app, - struct lttng_ust_object_data *data); + struct lttng_ust_abi_object_data *data); enum lttng_error_code ust_app_clear_session(struct ltt_session *session); enum lttng_error_code ust_app_open_packets(struct ltt_session *session); @@ -638,7 +638,7 @@ enum lttng_error_code ust_app_create_channel_subdirectories( } static inline -int ust_app_release_object(struct ust_app *app, struct lttng_ust_object_data *data) +int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data *data) { return 0; } diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index cd6b53ee1..35c60f8ed 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -97,7 +97,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, chan_reg_key = ua_chan->key; } - if (ua_chan->attr.type == LTTNG_UST_CHAN_METADATA) { + if (ua_chan->attr.type == LTTNG_UST_ABI_CHAN_METADATA) { chan_id = -1U; /* * Metadata channels shm_path (buffers) are handled within @@ -123,7 +123,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, } switch (ua_chan->attr.output) { - case LTTNG_UST_MMAP: + case LTTNG_UST_ABI_MMAP: default: output = LTTNG_EVENT_MMAP; break; diff --git a/src/bin/lttng-sessiond/ust-ctl-internal.h b/src/bin/lttng-sessiond/ust-ctl-internal.h index 7a89dbc26..77292b002 100644 --- a/src/bin/lttng-sessiond/ust-ctl-internal.h +++ b/src/bin/lttng-sessiond/ust-ctl-internal.h @@ -35,13 +35,13 @@ struct lttng_ust_shm_handle; struct lttng_ust_lib_ring_buffer; struct ustctl_consumer_channel_attr { - enum lttng_ust_chan_type type; + enum lttng_ust_abi_chan_type type; uint64_t subbuf_size; /* bytes */ uint64_t num_subbuf; /* power of 2 */ int overwrite; /* 1: overwrite, 0: discard */ unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ - enum lttng_ust_output output; /* splice, mmap */ + enum lttng_ust_abi_output output; /* splice, mmap */ uint32_t chan_id; /* channel ID */ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ int64_t blocking_timeout; /* Blocking timeout (usec) */ @@ -52,9 +52,9 @@ struct ustctl_consumer_channel_attr { */ struct lttng_ust_context_attr { - enum lttng_ust_context_type ctx; + enum lttng_ust_abi_context_type ctx; union { - struct lttng_ust_perf_counter_ctx perf_counter; + struct lttng_ust_abi_perf_counter_ctx perf_counter; struct { char *provider_name; char *ctx_name; @@ -69,31 +69,45 @@ struct lttng_ust_context_attr { */ 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_create_event(int sock, struct lttng_ust_abi_event *ev, + struct lttng_ust_abi_object_data *channel_data, + struct lttng_ust_abi_object_data **event_data); int ustctl_add_context(int sock, struct lttng_ust_context_attr *ctx, - struct lttng_ust_object_data *obj_data, - struct lttng_ust_object_data **context_data); -int ustctl_set_filter(int sock, struct lttng_ust_filter_bytecode *bytecode, - struct lttng_ust_object_data *obj_data); -int ustctl_set_exclusion(int sock, struct lttng_ust_event_exclusion *exclusion, - struct lttng_ust_object_data *obj_data); -int ustctl_set_capture(int sock, struct lttng_ust_capture_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); + struct lttng_ust_abi_object_data *obj_data, + struct lttng_ust_abi_object_data **context_data); +int ustctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode, + struct lttng_ust_abi_object_data *obj_data); +int ustctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode, + struct lttng_ust_abi_object_data *obj_data); +int ustctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion, + struct lttng_ust_abi_object_data *obj_data); + +int ustctl_enable(int sock, struct lttng_ust_abi_object_data *object); +int ustctl_disable(int sock, struct lttng_ust_abi_object_data *object); int ustctl_start_session(int sock, int handle); int ustctl_stop_session(int sock, int handle); -int ustctl_create_event_notifier_group(int sock, - int pipe_fd, - struct lttng_ust_object_data **event_notifier_group_handle); +/* + * ustctl_create_event notifier_group creates a event notifier group. It + * establishes the connection with the application by providing a file + * descriptor of the pipe to be used by the application when a event notifier + * of that group is fired. It returns a handle to be used when creating event + * notifier in that group. + */ +int ustctl_create_event_notifier_group(int sock, int pipe_fd, + struct lttng_ust_abi_object_data **event_notifier_group); + +/* + * ustctl_create_event notifier creates a event notifier in a event notifier + * group giving a event notifier description and a event notifier group handle. + * It returns a event notifier handle to be used when enabling the event + * notifier, attaching filter, attaching exclusion, and disabling the event + * notifier. + */ int ustctl_create_event_notifier(int sock, - struct lttng_ust_event_notifier *event_notifier, - struct lttng_ust_object_data *event_notifier_group_handle, - struct lttng_ust_object_data **event_notifier_data); + struct lttng_ust_abi_event_notifier *event_notifier, + struct lttng_ust_abi_object_data *event_notifier_group, + struct lttng_ust_abi_object_data **event_notifier_data); /* * ustctl_tracepoint_list returns a tracepoint list handle, or negative @@ -107,7 +121,7 @@ int ustctl_tracepoint_list(int sock); * returned. */ int ustctl_tracepoint_list_get(int sock, int tp_list_handle, - struct lttng_ust_tracepoint_iter *iter); + struct lttng_ust_abi_tracepoint_iter *iter); /* * ustctl_tracepoint_field_list returns a tracepoint field list handle, @@ -121,37 +135,37 @@ int ustctl_tracepoint_field_list(int sock); * returned. */ int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle, - struct lttng_ust_field_iter *iter); + struct lttng_ust_abi_field_iter *iter); -int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); +int ustctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v); int ustctl_wait_quiescent(int sock); -int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object); +int ustctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object); -int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate); +int ustctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate); /* Release object created by members of this API. */ -int ustctl_release_object(int sock, struct lttng_ust_object_data *data); +int ustctl_release_object(int sock, struct lttng_ust_abi_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); + struct lttng_ust_abi_object_data **channel_data); int ustctl_recv_stream_from_consumer(int sock, - struct lttng_ust_object_data **stream_data); + struct lttng_ust_abi_object_data **stream_data); int ustctl_send_channel_to_ust(int sock, int session_handle, - struct lttng_ust_object_data *channel_data); + struct lttng_ust_abi_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); + struct lttng_ust_abi_object_data *channel_data, + struct lttng_ust_abi_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); +int ustctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest, + struct lttng_ust_abi_object_data *src); /* * API used by consumer. @@ -239,8 +253,15 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream); void ustctl_flush_buffer(struct ustctl_consumer_stream *stream, int producer_active); +void ustctl_clear_buffer(struct ustctl_consumer_stream *stream); /* index */ + +/* + * Getters which need to be used on the current packet (between get/put + * or get_next/put_next. + */ + int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream, uint64_t *timestamp_begin); int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream, @@ -251,15 +272,26 @@ int ustctl_get_content_size(struct ustctl_consumer_stream *stream, uint64_t *content_size); int ustctl_get_packet_size(struct ustctl_consumer_stream *stream, uint64_t *packet_size); -int ustctl_get_stream_id(struct ustctl_consumer_stream *stream, - uint64_t *stream_id); -int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream, - uint64_t *ts); int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream, uint64_t *seq); + +/* + * Getter returning state invariant for the stream, which can be used + * without "get" operation. + */ + +int ustctl_get_stream_id(struct ustctl_consumer_stream *stream, + uint64_t *stream_id); int ustctl_get_instance_id(struct ustctl_consumer_stream *stream, uint64_t *id); +/* + * Getter returning the current timestamp as perceived from the + * tracer. + */ +int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream, + uint64_t *ts); + /* returns whether UST has perf counters support. */ int ustctl_has_perf_counters(void); @@ -345,7 +377,7 @@ enum ustctl_ust_enum_entry_options { #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]; + char string[LTTNG_UST_ABI_SYM_NAME_LEN]; union { struct { uint32_t options; @@ -359,7 +391,7 @@ struct ustctl_enum_entry { union _ustctl_basic_type { struct ustctl_integer_type integer; struct { - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; struct ustctl_integer_type container_type; uint64_t id; /* enum ID in sessiond. */ } enumeration; @@ -392,7 +424,7 @@ struct ustctl_type { int32_t encoding; /* enum ustctl_string_encodings */ } string; struct { - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; uint64_t id; /* enum ID in sessiond. */ /* container_type follows after this struct ustctl_field. */ } enum_nestable; @@ -402,7 +434,7 @@ struct ustctl_type { /* elem_type follows after this struct ustctl_field. */ } array_nestable; struct { - char length_name[LTTNG_UST_SYM_NAME_LEN]; + char length_name[LTTNG_UST_ABI_SYM_NAME_LEN]; uint32_t alignment; /* Alignment before elements. */ /* elem_type follows after the length_type. */ } sequence_nestable; @@ -413,7 +445,7 @@ struct ustctl_type { } struct_nestable; struct { uint32_t nr_choices; - char tag_name[LTTNG_UST_SYM_NAME_LEN]; + char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN]; uint32_t alignment; /* Followed by nr_choices struct ustctl_field. */ } variant_nestable; @@ -435,7 +467,7 @@ struct ustctl_type { } _struct; struct { uint32_t nr_choices; - char tag_name[LTTNG_UST_SYM_NAME_LEN]; + char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* Followed by nr_choices struct ustctl_field. */ } variant; } legacy; @@ -445,7 +477,7 @@ struct ustctl_type { #define USTCTL_UST_FIELD_PADDING 28 struct ustctl_field { - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; struct ustctl_type type; char padding[USTCTL_UST_FIELD_PADDING]; } LTTNG_PACKED; @@ -489,7 +521,7 @@ int ustctl_recv_register_event(int sock, int *channel_objd, /* channel descriptor (output) */ char *event_name, /* * event name (output, - * size LTTNG_UST_SYM_NAME_LEN) + * size LTTNG_UST_ABI_SYM_NAME_LEN) */ int *loglevel, char **signature, /* @@ -543,4 +575,82 @@ int ustctl_reply_register_channel(int sock, enum ustctl_channel_header header_type, int ret_code); /* return code. 0 ok, negative error */ +/* + * Counter API. + */ + +enum ustctl_counter_bitness { + USTCTL_COUNTER_BITNESS_32 = 0, + USTCTL_COUNTER_BITNESS_64 = 1, +}; + +enum ustctl_counter_arithmetic { + USTCTL_COUNTER_ARITHMETIC_MODULAR = 0, + USTCTL_COUNTER_ARITHMETIC_SATURATION = 1, +}; + +/* Used as alloc flags. */ +enum ustctl_counter_alloc { + USTCTL_COUNTER_ALLOC_PER_CPU = (1 << 0), + USTCTL_COUNTER_ALLOC_GLOBAL = (1 << 1), +}; + +struct ustctl_daemon_counter; + +int ustctl_get_nr_cpu_per_counter(void); + +struct ustctl_counter_dimension { + uint64_t size; + uint64_t underflow_index; + uint64_t overflow_index; + uint8_t has_underflow; + uint8_t has_overflow; +}; + +struct ustctl_daemon_counter * + ustctl_create_counter(size_t nr_dimensions, + const struct ustctl_counter_dimension *dimensions, + int64_t global_sum_step, + int global_counter_fd, + int nr_counter_cpu_fds, + const int *counter_cpu_fds, + enum ustctl_counter_bitness bitness, + enum ustctl_counter_arithmetic arithmetic, + uint32_t alloc_flags, + bool coalesce_hits); + +int ustctl_create_counter_data(struct ustctl_daemon_counter *counter, + struct lttng_ust_abi_object_data **counter_data); + +int ustctl_create_counter_global_data(struct ustctl_daemon_counter *counter, + struct lttng_ust_abi_object_data **counter_global_data); +int ustctl_create_counter_cpu_data(struct ustctl_daemon_counter *counter, int cpu, + struct lttng_ust_abi_object_data **counter_cpu_data); + +/* + * Each counter data and counter cpu data created need to be destroyed + * before calling ustctl_destroy_counter(). + */ +void ustctl_destroy_counter(struct ustctl_daemon_counter *counter); + +int ustctl_send_counter_data_to_ust(int sock, int parent_handle, + struct lttng_ust_abi_object_data *counter_data); +int ustctl_send_counter_global_data_to_ust(int sock, + struct lttng_ust_abi_object_data *counter_data, + struct lttng_ust_abi_object_data *counter_global_data); +int ustctl_send_counter_cpu_data_to_ust(int sock, + struct lttng_ust_abi_object_data *counter_data, + struct lttng_ust_abi_object_data *counter_cpu_data); + +int ustctl_counter_read(struct ustctl_daemon_counter *counter, + const size_t *dimension_indexes, + int cpu, int64_t *value, + bool *overflow, bool *underflow); +int ustctl_counter_aggregate(struct ustctl_daemon_counter *counter, + const size_t *dimension_indexes, + int64_t *value, + bool *overflow, bool *underflow); +int ustctl_counter_clear(struct ustctl_daemon_counter *counter, + const size_t *dimension_indexes); + #endif /* LTTNG_UST_CTL_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/ust-field-utils.c b/src/bin/lttng-sessiond/ust-field-utils.c index d7b6cfd2b..9b0ff7a1d 100644 --- a/src/bin/lttng-sessiond/ust-field-utils.c +++ b/src/bin/lttng-sessiond/ust-field-utils.c @@ -87,7 +87,7 @@ static bool match_ustctl_field_enum_from_raw_basic_type( * during enum registration. */ if (strncmp(first->enumeration.name, second->enumeration.name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } if (!match_ustctl_field_integer(&first->enumeration.container_type, @@ -203,7 +203,7 @@ int match_ustctl_field(const struct ustctl_field *first, const struct ustctl_field *second) { /* Check the name of the field is identical. */ - if (strncmp(first->name, second->name, LTTNG_UST_SYM_NAME_LEN)) { + if (strncmp(first->name, second->name, LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } @@ -259,7 +259,7 @@ int match_ustctl_field(const struct ustctl_field *first, /* Compare tag name of the variants. */ if (strncmp(first->type.u.legacy.variant.tag_name, second->type.u.legacy.variant.tag_name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } break; @@ -276,7 +276,7 @@ int match_ustctl_field(const struct ustctl_field *first, /* Compare length_name of the sequences. */ if (strncmp(first->type.u.sequence_nestable.length_name, second->type.u.sequence_nestable.length_name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } /* Comparison will be done when marshalling following items. */ @@ -298,7 +298,7 @@ int match_ustctl_field(const struct ustctl_field *first, /* Compare name of the enums. */ if (strncmp(first->type.u.enum_nestable.name, second->type.u.enum_nestable.name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } /* Comparison of element type will be done when marshalling following item. */ @@ -325,7 +325,7 @@ int match_ustctl_field(const struct ustctl_field *first, /* Compare tag name of the variants. */ if (strncmp(first->type.u.variant_nestable.tag_name, second->type.u.variant_nestable.tag_name, - LTTNG_UST_SYM_NAME_LEN)) { + LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } break; diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index ddcfb5aa4..86dcc0182 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -163,7 +163,7 @@ void sanitize_ctf_identifier(char *out, const char *in) { size_t i; - for (i = 0; i < LTTNG_UST_SYM_NAME_LEN; i++) { + for (i = 0; i < LTTNG_UST_ABI_SYM_NAME_LEN; i++) { switch (in[i]) { case '.': case '$': @@ -226,7 +226,7 @@ int ust_metadata_enum_statedump(struct ust_registry_session *session, size_t nr_entries; int ret = 0; size_t i; - char identifier[LTTNG_UST_SYM_NAME_LEN]; + char identifier[LTTNG_UST_ABI_SYM_NAME_LEN]; rcu_read_lock(); reg_enum = ust_registry_lookup_enum_by_id(session, enum_name, enum_id); @@ -367,7 +367,7 @@ int _lttng_variant_statedump(struct ust_registry_session *session, const struct ustctl_field *variant = &fields[*iter_field]; uint32_t i; int ret; - char identifier[LTTNG_UST_SYM_NAME_LEN]; + char identifier[LTTNG_UST_ABI_SYM_NAME_LEN]; if (variant->type.atype != ustctl_atype_variant) { ret = -EINVAL; diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 1b1e65eba..8eee74979 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -149,7 +149,7 @@ static int ht_match_enum(struct cds_lfht_node *node, const void *_key) assert(_enum); key = _key; - if (strncmp(_enum->name, key->name, LTTNG_UST_SYM_NAME_LEN)) { + if (strncmp(_enum->name, key->name, LTTNG_UST_ABI_SYM_NAME_LEN)) { goto no_match; } if (compare_enums(_enum, key)) { @@ -584,8 +584,8 @@ struct ust_registry_enum * struct ust_registry_enum reg_enum_lookup; memset(®_enum_lookup, 0, sizeof(reg_enum_lookup)); - strncpy(reg_enum_lookup.name, enum_name, LTTNG_UST_SYM_NAME_LEN); - reg_enum_lookup.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + strncpy(reg_enum_lookup.name, enum_name, LTTNG_UST_ABI_SYM_NAME_LEN); + reg_enum_lookup.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; reg_enum_lookup.id = enum_id; cds_lfht_lookup(session->enums->ht, ht_hash_enum((void *) ®_enum_lookup, lttng_ht_seed), @@ -639,8 +639,8 @@ int ust_registry_create_or_find_enum(struct ust_registry_session *session, ret = -ENOMEM; goto end; } - strncpy(reg_enum->name, enum_name, LTTNG_UST_SYM_NAME_LEN); - reg_enum->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + strncpy(reg_enum->name, enum_name, LTTNG_UST_ABI_SYM_NAME_LEN); + reg_enum->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; /* entries will be owned by reg_enum. */ reg_enum->entries = entries; reg_enum->nr_entries = nr_entries; diff --git a/src/bin/lttng-sessiond/ust-registry.h b/src/bin/lttng-sessiond/ust-registry.h index 12614c5d5..ba1ff75d3 100644 --- a/src/bin/lttng-sessiond/ust-registry.h +++ b/src/bin/lttng-sessiond/ust-registry.h @@ -172,7 +172,7 @@ struct ust_registry_event { int session_objd; int channel_objd; /* Name of the event returned by the tracer. */ - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; char *signature; int loglevel_value; size_t nr_fields; @@ -191,7 +191,7 @@ struct ust_registry_event { }; struct ust_registry_enum { - char name[LTTNG_UST_SYM_NAME_LEN]; + char name[LTTNG_UST_ABI_SYM_NAME_LEN]; struct ustctl_enum_entry *entries; size_t nr_entries; uint64_t id; /* enum id in session */ diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 4c1ba5cce..8891557c1 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -860,11 +860,11 @@ struct lttcomm_ust_msg { uint32_t handle; uint32_t cmd; union { - struct lttng_ust_channel channel; - struct lttng_ust_stream stream; - struct lttng_ust_event event; - struct lttng_ust_context context; - struct lttng_ust_tracer_version version; + struct lttng_ust_abi_channel channel; + struct lttng_ust_abi_stream stream; + struct lttng_ust_abi_event event; + struct lttng_ust_abi_context context; + struct lttng_ust_abi_tracer_version version; } u; } LTTNG_PACKED; @@ -884,7 +884,7 @@ struct lttcomm_ust_reply { struct { uint64_t memory_map_size; } LTTNG_PACKED stream; - struct lttng_ust_tracer_version version; + struct lttng_ust_abi_tracer_version version; } u; } LTTNG_PACKED; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 6b195c77d..68b6cac6c 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1560,15 +1560,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, switch (msg.u.ask_channel.output) { case LTTNG_EVENT_MMAP: default: - attr.output = LTTNG_UST_MMAP; + attr.output = LTTNG_UST_ABI_MMAP; break; } /* Translate and save channel type. */ switch (msg.u.ask_channel.type) { - case LTTNG_UST_CHAN_PER_CPU: + case LTTNG_UST_ABI_CHAN_PER_CPU: channel->type = CONSUMER_CHANNEL_TYPE_DATA; - attr.type = LTTNG_UST_CHAN_PER_CPU; + attr.type = LTTNG_UST_ABI_CHAN_PER_CPU; /* * Set refcount to 1 for owner. Below, we will * pass ownership to the @@ -1576,9 +1576,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, */ channel->refcount = 1; break; - case LTTNG_UST_CHAN_METADATA: + case LTTNG_UST_ABI_CHAN_METADATA: channel->type = CONSUMER_CHANNEL_TYPE_METADATA; - attr.type = LTTNG_UST_CHAN_METADATA; + attr.type = LTTNG_UST_ABI_CHAN_METADATA; break; default: assert(0); @@ -1592,7 +1592,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_channel_error; } - if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { + if (msg.u.ask_channel.type == LTTNG_UST_ABI_CHAN_METADATA) { ret = consumer_metadata_cache_allocate(channel); if (ret < 0) { ERR("Allocating metadata cache"); @@ -1625,7 +1625,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, */ ret = add_channel(channel, ctx); if (ret < 0) { - if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { + if (msg.u.ask_channel.type == LTTNG_UST_ABI_CHAN_METADATA) { if (channel->switch_timer_enabled == 1) { consumer_timer_switch_stop(channel); } diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index ec61ffbad..f92b1f802 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -103,7 +103,7 @@ static void test_create_ust_channel(void) ok(uchan->enabled == 0 && strncmp(uchan->name, "channel0", 8) == 0 && - uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0' && + uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' && uchan->ctx != NULL && uchan->events != NULL && uchan->attr.overwrite == attr.attr.overwrite, @@ -135,9 +135,9 @@ static void test_create_ust_event(void) } ok(event->enabled == 0 && - event->attr.instrumentation == LTTNG_UST_TRACEPOINT && + event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT && strcmp(event->attr.name, ev.name) == 0 && - event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0', + event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0', "Validate UST event"); trace_ust_destroy_event(event); @@ -229,13 +229,13 @@ static void test_create_ust_event_exclusion(void) } ok(event->enabled == 0 && - event->attr.instrumentation == LTTNG_UST_TRACEPOINT && + event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT && strcmp(event->attr.name, ev.name) == 0 && event->exclusion != NULL && event->exclusion->count == exclusion_count && !memcmp(event->exclusion->names, exclusion_copy->names, LTTNG_SYMBOL_NAME_LEN * exclusion_count) && - event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0', + event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0', "Validate UST event and exclusion"); trace_ust_destroy_event(event); @@ -257,7 +257,7 @@ static void test_create_ust_context(void) ok(uctx != NULL, "Create UST context"); if (uctx) { - ok((int) uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID, + ok((int) uctx->ctx.ctx == LTTNG_UST_ABI_CONTEXT_VTID, "Validate UST context"); } else { skip(1, "Skipping UST context validation as creation failed"); -- 2.34.1