X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-events.c;h=30cc224a2f7c755c3190071711022e08b1b46f6e;hb=0950190a1ef3270ac1a93e5c1647361320776f5e;hp=035548947ad381af2338fc371040ab1608d93703;hpb=daacdbfc04fe07ecff0a0d1878b4f48d38912c78;p=lttng-ust.git diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 03554894..30cc224a 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -74,9 +74,9 @@ static void _lttng_event_destroy(struct lttng_ust_event_common *event); static void _lttng_enum_destroy(struct lttng_enum *_enum); static -void lttng_session_lazy_sync_event_enablers(struct lttng_session *session); +void lttng_session_lazy_sync_event_enablers(struct lttng_ust_session *session); static -void lttng_session_sync_event_enablers(struct lttng_session *session); +void lttng_session_sync_event_enablers(struct lttng_ust_session *session); static void lttng_event_notifier_group_sync_enablers( struct lttng_event_notifier_group *event_notifier_group); @@ -127,16 +127,16 @@ int lttng_loglevel_match(int loglevel, } } -struct lttng_session *lttng_session_create(void) +struct lttng_ust_session *lttng_session_create(void) { - struct lttng_session *session; + struct lttng_ust_session *session; struct lttng_ust_session_private *session_priv; int i; - session = zmalloc(sizeof(struct lttng_session)); + session = zmalloc(sizeof(struct lttng_ust_session)); if (!session) return NULL; - session->struct_size = sizeof(struct lttng_session); + session->struct_size = sizeof(struct lttng_ust_session); session_priv = zmalloc(sizeof(struct lttng_ust_session_private)); if (!session_priv) { free(session); @@ -230,27 +230,26 @@ struct lttng_event_notifier_group *lttng_event_notifier_group_create(void) * Only used internally at session destruction. */ static -void _lttng_channel_unmap(struct lttng_channel *lttng_chan) +void _lttng_channel_unmap(struct lttng_ust_channel_buffer *lttng_chan) { struct lttng_ust_lib_ring_buffer_channel *chan; struct lttng_ust_shm_handle *handle; - cds_list_del(<tng_chan->node); - lttng_destroy_context(lttng_chan->ctx); + cds_list_del(<tng_chan->priv->node); + lttng_destroy_context(lttng_chan->priv->ctx); chan = lttng_chan->chan; handle = lttng_chan->handle; - /* - * note: lttng_chan is private data contained within handle. It - * will be freed along with the handle. - */ channel_destroy(chan, handle, 0); + free(lttng_chan->parent); + free(lttng_chan->priv); + free(lttng_chan); } static void register_event(struct lttng_ust_event_common *event) { int ret; - const struct lttng_ust_event_desc *desc; + struct lttng_ust_event_desc *desc; assert(event->priv->registered == 0); desc = event->priv->desc; @@ -266,7 +265,7 @@ static void unregister_event(struct lttng_ust_event_common *event) { int ret; - const struct lttng_ust_event_desc *desc; + struct lttng_ust_event_desc *desc; assert(event->priv->registered == 1); desc = event->priv->desc; @@ -285,9 +284,9 @@ void _lttng_event_unregister(struct lttng_ust_event_common *event) unregister_event(event); } -void lttng_session_destroy(struct lttng_session *session) +void lttng_session_destroy(struct lttng_ust_session *session) { - struct lttng_channel *chan, *tmpchan; + struct lttng_ust_channel_buffer_private *chan, *tmpchan; struct lttng_ust_event_recorder_private *event_recorder_priv, *tmpevent_recorder_priv; struct lttng_enum *_enum, *tmp_enum; struct lttng_event_enabler *event_enabler, *event_tmpenabler; @@ -308,7 +307,7 @@ void lttng_session_destroy(struct lttng_session *session) &session->priv->enums_head, node) _lttng_enum_destroy(_enum); cds_list_for_each_entry_safe(chan, tmpchan, &session->priv->chan_head, node) - _lttng_channel_unmap(chan); + _lttng_channel_unmap(chan->pub); cds_list_del(&session->priv->node); lttng_destroy_context(session->priv->ctx); free(session->priv); @@ -398,8 +397,8 @@ void lttng_enabler_destroy(struct lttng_enabler *enabler) } static -int lttng_enum_create(const struct lttng_ust_enum_desc *desc, - struct lttng_session *session) +int lttng_enum_create(struct lttng_ust_enum_desc *desc, + struct lttng_ust_session *session) { const char *enum_name = desc->name; struct lttng_enum *_enum; @@ -456,16 +455,16 @@ exist: } static -int lttng_create_enum_check(const struct lttng_type *type, - struct lttng_session *session) +int lttng_create_enum_check(struct lttng_ust_type_common *type, + struct lttng_ust_session *session) { - switch (type->atype) { - case atype_enum_nestable: + switch (type->type) { + case lttng_ust_type_enum: { - const struct lttng_ust_enum_desc *enum_desc; + struct lttng_ust_enum_desc *enum_desc; int ret; - enum_desc = type->u.enum_nestable.desc; + enum_desc = lttng_ust_get_type_enum(type)->desc; ret = lttng_enum_create(enum_desc, session); if (ret && ret != -EEXIST) { DBG("Unable to create enum error: (%d)", ret); @@ -473,14 +472,14 @@ int lttng_create_enum_check(const struct lttng_type *type, } break; } - case atype_dynamic: + case lttng_ust_type_dynamic: { - const struct lttng_ust_event_field *tag_field_generic; - const struct lttng_ust_enum_desc *enum_desc; + struct lttng_ust_event_field *tag_field_generic; + struct lttng_ust_enum_desc *enum_desc; int ret; tag_field_generic = lttng_ust_dynamic_type_tag_field(); - enum_desc = tag_field_generic->type.u.enum_nestable.desc; + enum_desc = lttng_ust_get_type_enum(tag_field_generic->type)->desc; ret = lttng_enum_create(enum_desc, session); if (ret && ret != -EEXIST) { DBG("Unable to create enum error: (%d)", ret); @@ -497,15 +496,15 @@ int lttng_create_enum_check(const struct lttng_type *type, static int lttng_create_all_event_enums(size_t nr_fields, - const struct lttng_ust_event_field **event_fields, - struct lttng_session *session) + struct lttng_ust_event_field **event_fields, + struct lttng_ust_session *session) { size_t i; int ret; /* For each field, ensure enum is part of the session. */ for (i = 0; i < nr_fields; i++) { - const struct lttng_type *type = &event_fields[i]->type; + struct lttng_ust_type_common *type = event_fields[i]->type; ret = lttng_create_enum_check(type, session); if (ret) @@ -517,14 +516,14 @@ int lttng_create_all_event_enums(size_t nr_fields, static int lttng_create_all_ctx_enums(size_t nr_fields, struct lttng_ust_ctx_field **ctx_fields, - struct lttng_session *session) + struct lttng_ust_session *session) { size_t i; int ret; /* For each field, ensure enum is part of the session. */ for (i = 0; i < nr_fields; i++) { - const struct lttng_type *type = &ctx_fields[i]->event_field->type; + struct lttng_ust_type_common *type = ctx_fields[i]->event_field->type; ret = lttng_create_enum_check(type, session); if (ret) @@ -537,17 +536,17 @@ int lttng_create_all_ctx_enums(size_t nr_fields, * Ensure that a state-dump will be performed for this session at the end * of the current handle_message(). */ -int lttng_session_statedump(struct lttng_session *session) +int lttng_session_statedump(struct lttng_ust_session *session) { session->priv->statedump_pending = 1; lttng_ust_sockinfo_session_enabled(session->priv->owner); return 0; } -int lttng_session_enable(struct lttng_session *session) +int lttng_session_enable(struct lttng_ust_session *session) { int ret = 0; - struct lttng_channel *chan; + struct lttng_ust_channel_buffer_private *chan; int notify_socket; if (session->active) { @@ -570,7 +569,7 @@ int lttng_session_enable(struct lttng_session *session) * we need to use. */ cds_list_for_each_entry(chan, &session->priv->chan_head, node) { - const struct lttng_ust_ctx *ctx; + struct lttng_ust_ctx *ctx; struct lttng_ust_ctx_field **fields = NULL; size_t nr_fields = 0; uint32_t chan_id; @@ -592,7 +591,7 @@ int lttng_session_enable(struct lttng_session *session) ret = ustcomm_register_channel(notify_socket, session, session->priv->objd, - chan->objd, + chan->parent.objd, nr_fields, fields, &chan_id, @@ -619,7 +618,7 @@ end: return ret; } -int lttng_session_disable(struct lttng_session *session) +int lttng_session_disable(struct lttng_ust_session *session) { int ret = 0; @@ -637,36 +636,36 @@ end: return ret; } -int lttng_channel_enable(struct lttng_channel *channel) +int lttng_channel_enable(struct lttng_ust_channel_common *lttng_channel) { int ret = 0; - if (channel->enabled) { + if (lttng_channel->enabled) { ret = -EBUSY; goto end; } /* Set transient enabler state to "enabled" */ - channel->tstate = 1; - lttng_session_sync_event_enablers(channel->session); + lttng_channel->priv->tstate = 1; + lttng_session_sync_event_enablers(lttng_channel->session); /* Set atomically the state to "enabled" */ - CMM_ACCESS_ONCE(channel->enabled) = 1; + CMM_ACCESS_ONCE(lttng_channel->enabled) = 1; end: return ret; } -int lttng_channel_disable(struct lttng_channel *channel) +int lttng_channel_disable(struct lttng_ust_channel_common *lttng_channel) { int ret = 0; - if (!channel->enabled) { + if (!lttng_channel->enabled) { ret = -EBUSY; goto end; } /* Set atomically the state to "disabled" */ - CMM_ACCESS_ONCE(channel->enabled) = 0; + CMM_ACCESS_ONCE(lttng_channel->enabled) = 0; /* Set transient enabler state to "enabled" */ - channel->tstate = 0; - lttng_session_sync_event_enablers(channel->session); + lttng_channel->priv->tstate = 0; + lttng_session_sync_event_enablers(lttng_channel->session); end: return ret; } @@ -675,7 +674,7 @@ static inline struct cds_hlist_head *borrow_hash_table_bucket( struct cds_hlist_head *hash_table, unsigned int hash_table_size, - const struct lttng_ust_event_desc *desc) + struct lttng_ust_event_desc *desc) { const char *event_name; size_t name_len; @@ -692,18 +691,18 @@ struct cds_hlist_head *borrow_hash_table_bucket( * Supports event creation while tracing session is active. */ static -int lttng_event_recorder_create(const struct lttng_ust_event_desc *desc, - struct lttng_channel *chan) +int lttng_event_recorder_create(struct lttng_ust_event_desc *desc, + struct lttng_ust_channel_buffer *chan) { struct lttng_ust_event_recorder *event_recorder; struct lttng_ust_event_recorder_private *event_recorder_priv; - struct lttng_session *session = chan->session; + struct lttng_ust_session *session = chan->parent->session; struct cds_hlist_head *head; int ret = 0; int notify_socket, loglevel; const char *uri; - head = borrow_hash_table_bucket(chan->session->priv->events_ht.table, + head = borrow_hash_table_bucket(chan->parent->session->priv->events_ht.table, LTTNG_UST_EVENT_HT_SIZE, desc); notify_socket = lttng_get_notify_socket(session->priv->owner); @@ -770,7 +769,7 @@ int lttng_event_recorder_create(const struct lttng_ust_event_desc *desc, ret = ustcomm_register_event(notify_socket, session, session->priv->objd, - chan->objd, + chan->priv->parent.objd, desc->name, loglevel, desc->signature, @@ -783,7 +782,7 @@ int lttng_event_recorder_create(const struct lttng_ust_event_desc *desc, goto sessiond_register_error; } - cds_list_add(&event_recorder_priv->node, &chan->session->priv->events_head); + cds_list_add(&event_recorder_priv->node, &chan->parent->session->priv->events_head); cds_hlist_add_head(&event_recorder_priv->hlist, head); return 0; @@ -800,7 +799,7 @@ socket_error: } static -int lttng_event_notifier_create(const struct lttng_ust_event_desc *desc, +int lttng_event_notifier_create(struct lttng_ust_event_desc *desc, uint64_t token, uint64_t error_counter_index, struct lttng_event_notifier_group *event_notifier_group) { @@ -872,7 +871,7 @@ error: } static -int lttng_desc_match_star_glob_enabler(const struct lttng_ust_event_desc *desc, +int lttng_desc_match_star_glob_enabler(struct lttng_ust_event_desc *desc, struct lttng_enabler *enabler) { int loglevel = 0; @@ -895,7 +894,7 @@ int lttng_desc_match_star_glob_enabler(const struct lttng_ust_event_desc *desc, } static -int lttng_desc_match_event_enabler(const struct lttng_ust_event_desc *desc, +int lttng_desc_match_event_enabler(struct lttng_ust_event_desc *desc, struct lttng_enabler *enabler) { int loglevel = 0; @@ -917,7 +916,7 @@ int lttng_desc_match_event_enabler(const struct lttng_ust_event_desc *desc, } static -int lttng_desc_match_enabler(const struct lttng_ust_event_desc *desc, +int lttng_desc_match_enabler(struct lttng_ust_event_desc *desc, struct lttng_enabler *enabler) { switch (enabler->format_type) { @@ -1004,9 +1003,9 @@ struct lttng_enabler_ref *lttng_enabler_ref( static void lttng_create_event_recorder_if_missing(struct lttng_event_enabler *event_enabler) { - struct lttng_session *session = event_enabler->chan->session; + struct lttng_ust_session *session = event_enabler->chan->parent->session; struct lttng_ust_probe_desc *probe_desc; - const struct lttng_ust_event_desc *desc; + struct lttng_ust_event_desc *desc; struct lttng_ust_event_recorder_private *event_recorder_priv; int i; struct cds_list_head *probe_list; @@ -1073,7 +1072,7 @@ void probe_provider_event_for_each(struct lttng_ust_probe_desc *provider_desc, * sessions to queue the unregistration of the events. */ for (i = 0; i < provider_desc->nr_events; i++) { - const struct lttng_ust_event_desc *event_desc; + struct lttng_ust_event_desc *event_desc; struct lttng_event_notifier_group *event_notifier_group; struct lttng_ust_event_recorder_private *event_recorder_priv; struct lttng_ust_event_notifier_private *event_notifier_priv; @@ -1135,19 +1134,19 @@ void _event_enum_destroy(struct lttng_ust_event_common *event) case LTTNG_UST_EVENT_TYPE_RECORDER: { struct lttng_ust_event_recorder *event_recorder = event->child; - struct lttng_session *session = event_recorder->chan->session; + struct lttng_ust_session *session = event_recorder->chan->parent->session; unsigned int i; /* Destroy enums of the current event. */ for (i = 0; i < event_recorder->parent->priv->desc->nr_fields; i++) { - const struct lttng_ust_enum_desc *enum_desc; - const struct lttng_ust_event_field *field; + struct lttng_ust_enum_desc *enum_desc; + struct lttng_ust_event_field *field; struct lttng_enum *curr_enum; field = event_recorder->parent->priv->desc->fields[i]; - switch (field->type.atype) { - case atype_enum_nestable: - enum_desc = field->type.u.enum_nestable.desc; + switch (field->type->type) { + case lttng_ust_type_enum: + enum_desc = lttng_ust_get_type_enum(field->type)->desc; break; default: continue; @@ -1202,7 +1201,7 @@ void lttng_probe_provider_unregister_events( static int lttng_event_enabler_ref_event_recorders(struct lttng_event_enabler *event_enabler) { - struct lttng_session *session = event_enabler->chan->session; + struct lttng_ust_session *session = event_enabler->chan->parent->session; struct lttng_ust_event_recorder_private *event_recorder_priv; if (!lttng_event_enabler_as_enabler(event_enabler)->enabled) @@ -1369,7 +1368,7 @@ void lttng_ust_abi_events_exit(void) struct lttng_event_enabler *lttng_event_enabler_create( enum lttng_enabler_format_type format_type, struct lttng_ust_abi_event *event_param, - struct lttng_channel *chan) + struct lttng_ust_channel_buffer *chan) { struct lttng_event_enabler *event_enabler; @@ -1384,8 +1383,8 @@ struct lttng_event_enabler *lttng_event_enabler_create( event_enabler->chan = chan; /* ctx left NULL */ event_enabler->base.enabled = 0; - cds_list_add(&event_enabler->node, &event_enabler->chan->session->priv->enablers_head); - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + cds_list_add(&event_enabler->node, &event_enabler->chan->parent->session->priv->enablers_head); + lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session); return event_enabler; } @@ -1433,7 +1432,7 @@ struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler) { lttng_event_enabler_as_enabler(event_enabler)->enabled = 1; - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session); return 0; } @@ -1441,7 +1440,7 @@ int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler) int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler) { lttng_event_enabler_as_enabler(event_enabler)->enabled = 0; - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session); return 0; } @@ -1462,7 +1461,7 @@ int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event _lttng_enabler_attach_filter_bytecode( lttng_event_enabler_as_enabler(event_enabler), bytecode); - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session); return 0; } @@ -1482,7 +1481,7 @@ int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *event_enabl _lttng_enabler_attach_exclusion( lttng_event_enabler_as_enabler(event_enabler), excluder); - lttng_session_lazy_sync_event_enablers(event_enabler->chan->session); + lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session); return 0; } @@ -1546,7 +1545,7 @@ int lttng_event_notifier_enabler_attach_exclusion( int lttng_attach_context(struct lttng_ust_abi_context *context_param, union lttng_ust_abi_args *uargs, - struct lttng_ust_ctx **ctx, struct lttng_session *session) + struct lttng_ust_ctx **ctx, struct lttng_ust_session *session) { /* * We cannot attach a context after trace has been started for a @@ -1640,7 +1639,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler) * session. */ static -void lttng_session_sync_event_enablers(struct lttng_session *session) +void lttng_session_sync_event_enablers(struct lttng_ust_session *session) { struct lttng_event_enabler *event_enabler; struct lttng_ust_event_recorder_private *event_recorder_priv; @@ -1670,7 +1669,7 @@ void lttng_session_sync_event_enablers(struct lttng_session *session) * intesection of session and channel transient enable * states. */ - enabled = enabled && session->priv->tstate && event_recorder_priv->pub->chan->tstate; + enabled = enabled && session->priv->tstate && event_recorder_priv->pub->chan->priv->parent.tstate; CMM_STORE_SHARED(event_recorder_priv->pub->parent->enabled, enabled); /* @@ -1728,7 +1727,7 @@ void lttng_create_event_notifier_if_missing( for (i = 0; i < probe_desc->nr_events; i++) { int ret; bool found = false; - const struct lttng_ust_event_desc *desc; + struct lttng_ust_event_desc *desc; struct lttng_ust_event_notifier_private *event_notifier_priv; struct cds_hlist_head *head; struct cds_hlist_node *node; @@ -1931,7 +1930,7 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group * "lazy" sync means we only sync if required. */ static -void lttng_session_lazy_sync_event_enablers(struct lttng_session *session) +void lttng_session_lazy_sync_event_enablers(struct lttng_ust_session *session) { /* We can skip if session is not active */ if (!session->active) @@ -1950,14 +1949,14 @@ void lttng_ust_context_set_session_provider(const char *name, size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset), void (*record)(struct lttng_ust_ctx_field *field, struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan), + struct lttng_ust_channel_buffer *chan), void (*get_value)(struct lttng_ust_ctx_field *field, struct lttng_ust_ctx_value *value)) { struct lttng_ust_session_private *session_priv; cds_list_for_each_entry(session_priv, &sessions, node) { - struct lttng_channel *chan; + struct lttng_ust_channel_buffer_private *chan; struct lttng_ust_event_recorder_private *event_recorder_priv; int ret; @@ -1991,7 +1990,7 @@ void lttng_ust_context_set_event_notifier_group_provider(const char *name, size_t (*get_size)(struct lttng_ust_ctx_field *field, size_t offset), void (*record)(struct lttng_ust_ctx_field *field, struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_channel *chan), + struct lttng_ust_channel_buffer *chan), void (*get_value)(struct lttng_ust_ctx_field *field, struct lttng_ust_ctx_value *value)) {