From 2106efa08d11229241a114d1d71635a02006690e Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 1 Sep 2015 21:52:40 -0400 Subject: [PATCH] sessiond: use `loglevel_value` and `loglevel_type` names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit By using the `loglevel_value` and `loglevel_type` names instead of `loglevel` for one or the other, some unsettling inconsistencies are exposed. This patch only changes the names to show the weird stuff, e.g.: key.loglevel_type = loglevel_value; A future patch will fix this. The only `loglevel` names left untouched are those in public headers as well as those in the tools<->UST ABI. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/agent.c | 17 ++++++------- src/bin/lttng-sessiond/agent.h | 4 ++-- src/bin/lttng-sessiond/cmd.c | 2 +- src/bin/lttng-sessiond/event.c | 2 +- src/bin/lttng-sessiond/lttng-ust-ctl.h | 2 +- src/bin/lttng-sessiond/save.c | 2 +- src/bin/lttng-sessiond/trace-ust.c | 12 ++++++---- src/bin/lttng-sessiond/trace-ust.h | 10 ++++---- src/bin/lttng-sessiond/ust-app.c | 33 +++++++++++++++----------- src/bin/lttng-sessiond/ust-app.h | 4 ++-- src/bin/lttng-sessiond/ust-metadata.c | 2 +- src/bin/lttng-sessiond/ust-registry.c | 14 +++++------ src/bin/lttng-sessiond/ust-registry.h | 13 +++++----- src/common/sessiond-comm/agent.h | 2 +- 14 files changed, 64 insertions(+), 55 deletions(-) diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index b7d41f2f4..f230c3619 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -117,9 +117,10 @@ static int ht_match_event(struct cds_lfht_node *node, goto no_match; } - if (event->loglevel != key->loglevel) { + if (event->loglevel_value != key->loglevel_value) { if (event->loglevel_type == LTTNG_EVENT_LOGLEVEL_ALL && - key->loglevel == 0 && event->loglevel == -1) { + key->loglevel_value == 0 && + event->loglevel_value == -1) { goto match; } goto no_match; @@ -145,7 +146,7 @@ static void add_unique_agent_event(struct lttng_ht *ht, assert(event); key.name = event->name; - key.loglevel = event->loglevel; + key.loglevel_value = event->loglevel_value; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(event->node.key, lttng_ht_seed), @@ -378,7 +379,7 @@ static int enable_event(struct agent_app *app, struct agent_event *event) } memset(&msg, 0, sizeof(msg)); - msg.loglevel = event->loglevel; + msg.loglevel_value = event->loglevel_value; msg.loglevel_type = event->loglevel_type; strncpy(msg.name, event->name, sizeof(msg.name)); ret = send_payload(app->sock, &msg, sizeof(msg)); @@ -826,7 +827,7 @@ error: * Return a new object else NULL on error. */ struct agent_event *agent_create_event(const char *name, - int loglevel, enum lttng_loglevel_type loglevel_type, + int loglevel_value, enum lttng_loglevel_type loglevel_type, struct lttng_filter_bytecode *filter, char *filter_expression) { struct agent_event *event = NULL; @@ -847,7 +848,7 @@ struct agent_event *agent_create_event(const char *name, event->name[sizeof(event->name) - 1] = '\0'; lttng_ht_node_init_str(&event->node, event->name); - event->loglevel = loglevel; + event->loglevel_value = loglevel_value; event->loglevel_type = loglevel_type; event->filter = filter; event->filter_expression = filter_expression; @@ -913,7 +914,7 @@ error: * * Return object if found else NULL. */ -struct agent_event *agent_find_event(const char *name, int loglevel, +struct agent_event *agent_find_event(const char *name, int loglevel_value, struct agent *agt) { struct lttng_ht_node_str *node; @@ -927,7 +928,7 @@ struct agent_event *agent_find_event(const char *name, int loglevel, ht = agt->events; key.name = name; - key.loglevel = loglevel; + key.loglevel_value = loglevel_value; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), ht_match_event, &key, &iter.iter); diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h index ed263e3fb..b737b166a 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -36,7 +36,7 @@ extern struct lttng_ht *agent_apps_ht_by_sock; struct agent_ht_key { const char *name; - int loglevel; + int loglevel_value; }; /* @@ -80,7 +80,7 @@ struct agent_app { struct agent_event { /* Name of the event. */ char name[LTTNG_SYMBOL_NAME_LEN]; - int loglevel; + int loglevel_value; enum lttng_loglevel_type loglevel_type; /* diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 020a8756a..26845535c 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -237,7 +237,7 @@ static int list_lttng_agent_events(struct agent *agt, strncpy(tmp_events[i].name, event->name, sizeof(tmp_events[i].name)); tmp_events[i].name[sizeof(tmp_events[i].name) - 1] = '\0'; tmp_events[i].enabled = event->enabled; - tmp_events[i].loglevel = event->loglevel; + tmp_events[i].loglevel = event->loglevel_value; tmp_events[i].loglevel_type = event->loglevel_type; i++; } diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 65e2edf3a..36f6f483a 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -50,7 +50,7 @@ static void add_unique_ust_event(struct lttng_ht *ht, key.name = event->attr.name; key.filter = (struct lttng_filter_bytecode *) event->filter; - key.loglevel = event->attr.loglevel; + key.loglevel_type = event->attr.loglevel; key.exclusion = event->exclusion; node_ptr = cds_lfht_add_unique(ht->ht, diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h index 3d20c38a1..b3de5a9ba 100644 --- a/src/bin/lttng-sessiond/lttng-ust-ctl.h +++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h @@ -356,7 +356,7 @@ int ustctl_recv_register_event(int sock, * event name (output, * size LTTNG_UST_SYM_NAME_LEN) */ - int *loglevel, + int *loglevel_value, char **signature, /* * event signature * (output, dynamically diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index 4c70e5836..862cedd26 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -768,7 +768,7 @@ int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event, } ust_event->attr.loglevel_type = ust_loglevel_type; - ust_event->attr.loglevel = agent_event->loglevel; + ust_event->attr.loglevel = agent_event->loglevel_value; ust_event->filter_expression = agent_event->filter_expression; ust_event->exclusion = agent_event->exclusion; end: diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 9ec6e43b0..906f916a9 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -71,12 +71,14 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) { struct ltt_ust_event *event; const struct ltt_ust_ht_key *key; + int ev_loglevel_value; assert(node); assert(_key); event = caa_container_of(node, struct ltt_ust_event, node.node); key = _key; + ev_loglevel_value = event->attr.loglevel; /* Match the 4 elements of the key: name, filter, loglevel, exclusions. */ @@ -86,9 +88,9 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) } /* Event loglevel. */ - if (event->attr.loglevel != key->loglevel) { + if (ev_loglevel_value != key->loglevel_type) { if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL - && key->loglevel == 0 && event->attr.loglevel == -1) { + && key->loglevel_type == 0 && ev_loglevel_value == -1) { /* * Match is accepted. This is because on event creation, the * loglevel is set to -1 if the event loglevel type is ALL so 0 and @@ -171,8 +173,8 @@ error: * MUST be acquired before calling this. */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, int loglevel, - struct lttng_event_exclusion *exclusion) + char *name, struct lttng_filter_bytecode *filter, + int loglevel_value, struct lttng_event_exclusion *exclusion) { struct lttng_ht_node_str *node; struct lttng_ht_iter iter; @@ -183,7 +185,7 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, key.name = name; key.filter = filter; - key.loglevel = loglevel; + key.loglevel_type = loglevel_value; key.exclusion = exclusion; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 890a68d95..0e2cb6420 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -34,7 +34,7 @@ struct agent; struct ltt_ust_ht_key { const char *name; const struct lttng_filter_bytecode *filter; - enum lttng_ust_loglevel_type loglevel; + enum lttng_ust_loglevel_type loglevel_type; const struct lttng_event_exclusion *exclusion; }; @@ -176,8 +176,8 @@ int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, * Lookup functions. NULL is returned if not found. */ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, int loglevel, - struct lttng_event_exclusion *exclusion); + char *name, struct lttng_filter_bytecode *filter, + int loglevel_value, struct lttng_event_exclusion *exclusion); struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, char *name); struct agent *trace_ust_find_agent(struct ltt_ust_session *session, @@ -283,8 +283,8 @@ int trace_ust_match_context(struct ltt_ust_context *uctx, return 0; } static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, int loglevel, - struct lttng_event_exclusion *exclusion) + char *name, struct lttng_filter_bytecode *filter, + int loglevel_value, struct lttng_event_exclusion *exclusion) { return NULL; } diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index c4d9fb5a4..4066b065c 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -101,12 +101,14 @@ static int ht_match_ust_app_event(struct cds_lfht_node *node, const void *_key) { struct ust_app_event *event; const struct ust_app_ht_key *key; + int ev_loglevel_value; assert(node); assert(_key); event = caa_container_of(node, struct ust_app_event, node.node); key = _key; + ev_loglevel_value = event->attr.loglevel; /* Match the 4 elements of the key: name, filter, loglevel, exclusions */ @@ -116,9 +118,10 @@ static int ht_match_ust_app_event(struct cds_lfht_node *node, const void *_key) } /* Event loglevel. */ - if (event->attr.loglevel != key->loglevel) { + if (ev_loglevel_value != key->loglevel_type) { if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL - && key->loglevel == 0 && event->attr.loglevel == -1) { + && key->loglevel_type == 0 && + ev_loglevel_value == -1) { /* * Match is accepted. This is because on event creation, the * loglevel is set to -1 if the event loglevel type is ALL so 0 and @@ -184,7 +187,7 @@ static void add_unique_ust_app_event(struct ust_app_channel *ua_chan, ht = ua_chan->events; key.name = event->attr.name; key.filter = event->filter; - key.loglevel = event->attr.loglevel; + key.loglevel_type = event->attr.loglevel; key.exclusion = event->exclusion; node_ptr = cds_lfht_add_unique(ht->ht, @@ -1149,7 +1152,8 @@ error: * Return an ust_app_event object or NULL on error. */ static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht, - char *name, struct lttng_filter_bytecode *filter, int loglevel, + char *name, struct lttng_filter_bytecode *filter, + int loglevel_value, const struct lttng_event_exclusion *exclusion) { struct lttng_ht_iter iter; @@ -1163,7 +1167,7 @@ static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht, /* Setup key for event lookup. */ key.name = name; key.filter = filter; - key.loglevel = loglevel; + key.loglevel_type = loglevel_value; /* lttng_event_exclusion and lttng_ust_event_exclusion structures are similar */ key.exclusion = exclusion; @@ -5173,8 +5177,8 @@ error_rcu_unlock: * On success 0 is returned else a negative value. */ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, - char *sig, size_t nr_fields, struct ustctl_field *fields, int loglevel, - char *model_emf_uri) + char *sig, size_t nr_fields, struct ustctl_field *fields, + int loglevel_value, char *model_emf_uri) { int ret, ret_code; uint32_t event_id = 0; @@ -5229,9 +5233,9 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, * three variables MUST NOT be read/write after this. */ ret_code = ust_registry_create_event(registry, chan_reg_key, - sobjd, cobjd, name, sig, nr_fields, fields, loglevel, - model_emf_uri, ua_sess->buffer_type, &event_id, - app); + sobjd, cobjd, name, sig, nr_fields, fields, + loglevel_value, model_emf_uri, ua_sess->buffer_type, + &event_id, app); /* * The return value is returned to ustctl so in case of an error, the @@ -5287,15 +5291,16 @@ int ust_app_recv_notify(int sock) switch (cmd) { case USTCTL_NOTIFY_CMD_EVENT: { - int sobjd, cobjd, loglevel; + int sobjd, cobjd, loglevel_value; char name[LTTNG_UST_SYM_NAME_LEN], *sig, *model_emf_uri; size_t nr_fields; struct ustctl_field *fields; DBG2("UST app ustctl register event received"); - ret = ustctl_recv_register_event(sock, &sobjd, &cobjd, name, &loglevel, - &sig, &nr_fields, &fields, &model_emf_uri); + ret = ustctl_recv_register_event(sock, &sobjd, &cobjd, name, + &loglevel_value, &sig, &nr_fields, &fields, + &model_emf_uri); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { ERR("UST app recv event failed with ret %d", ret); @@ -5312,7 +5317,7 @@ int ust_app_recv_notify(int sock) * to the this function. */ ret = add_event_ust_registry(sock, sobjd, cobjd, name, sig, nr_fields, - fields, loglevel, model_emf_uri); + fields, loglevel_value, model_emf_uri); if (ret < 0) { goto error; } diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 27e3dd0e4..ff0720d18 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -15,7 +15,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _LTT_UST_APP_H +#ifndef _LTT_UST_APP_H #define _LTT_UST_APP_H #include @@ -48,7 +48,7 @@ struct ust_app_notify_sock_obj { struct ust_app_ht_key { const char *name; const struct lttng_filter_bytecode *filter; - enum lttng_ust_loglevel_type loglevel; + enum lttng_ust_loglevel_type loglevel_type; const struct lttng_event_exclusion *exclusion; }; diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index ea5978888..afcb89ddf 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -359,7 +359,7 @@ int ust_metadata_event_statedump(struct ust_registry_session *session, ret = lttng_metadata_printf(session, " loglevel = %d;\n", - event->loglevel); + event->loglevel_value); if (ret) goto end; diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 3f1390dc3..315aed945 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -133,8 +133,8 @@ int validate_event_fields(size_t nr_fields, struct ustctl_field *fields, */ static struct ust_registry_event *alloc_event(int session_objd, int channel_objd, char *name, char *sig, size_t nr_fields, - struct ustctl_field *fields, int loglevel, char *model_emf_uri, - struct ust_app *app) + struct ustctl_field *fields, int loglevel_value, + char *model_emf_uri, struct ust_app *app) { struct ust_registry_event *event = NULL; @@ -157,7 +157,7 @@ static struct ust_registry_event *alloc_event(int session_objd, event->signature = sig; event->nr_fields = nr_fields; event->fields = fields; - event->loglevel = loglevel; + event->loglevel_value = loglevel_value; event->model_emf_uri = model_emf_uri; if (name) { /* Copy event name and force NULL byte. */ @@ -248,9 +248,9 @@ end: */ int ust_registry_create_event(struct ust_registry_session *session, uint64_t chan_key, int session_objd, int channel_objd, char *name, - char *sig, size_t nr_fields, struct ustctl_field *fields, int loglevel, - char *model_emf_uri, int buffer_type, uint32_t *event_id_p, - struct ust_app *app) + char *sig, size_t nr_fields, struct ustctl_field *fields, + int loglevel_value, char *model_emf_uri, int buffer_type, + uint32_t *event_id_p, struct ust_app *app) { int ret; uint32_t event_id; @@ -287,7 +287,7 @@ int ust_registry_create_event(struct ust_registry_session *session, } event = alloc_event(session_objd, channel_objd, name, sig, nr_fields, - fields, loglevel, model_emf_uri, app); + fields, loglevel_value, model_emf_uri, app); if (!event) { ret = -ENOMEM; goto error_free; diff --git a/src/bin/lttng-sessiond/ust-registry.h b/src/bin/lttng-sessiond/ust-registry.h index 77d4d9195..b51b505f1 100644 --- a/src/bin/lttng-sessiond/ust-registry.h +++ b/src/bin/lttng-sessiond/ust-registry.h @@ -139,7 +139,7 @@ struct ust_registry_event { /* Name of the event returned by the tracer. */ char name[LTTNG_UST_SYM_NAME_LEN]; char *signature; - int loglevel; + int loglevel_value; size_t nr_fields; struct ustctl_field *fields; char *model_emf_uri; @@ -244,9 +244,9 @@ void ust_registry_session_destroy(struct ust_registry_session *session); int ust_registry_create_event(struct ust_registry_session *session, uint64_t chan_key, int session_objd, int channel_objd, char *name, - char *sig, size_t nr_fields, struct ustctl_field *fields, int loglevel, - char *model_emf_uri, int buffer_type, uint32_t *event_id_p, - struct ust_app *app); + char *sig, size_t nr_fields, struct ustctl_field *fields, + int loglevel_value, char *model_emf_uri, int buffer_type, + uint32_t *event_id_p, struct ust_app *app); struct ust_registry_event *ust_registry_find_event( struct ust_registry_channel *chan, char *name, char *sig); void ust_registry_destroy_event(struct ust_registry_channel *chan, @@ -302,8 +302,9 @@ void ust_registry_session_destroy(struct ust_registry_session *session) static inline int ust_registry_create_event(struct ust_registry_session *session, uint64_t chan_key, int session_objd, int channel_objd, char *name, - char *sig, size_t nr_fields, struct ustctl_field *fields, int loglevel, - char *model_emf_uri, int buffer_type, uint32_t *event_id_p) + char *sig, size_t nr_fields, struct ustctl_field *fields, + int loglevel_value, char *model_emf_uri, int buffer_type, + uint32_t *event_id_p) { return 0; } diff --git a/src/common/sessiond-comm/agent.h b/src/common/sessiond-comm/agent.h index b562b7402..4fbe3db7a 100644 --- a/src/common/sessiond-comm/agent.h +++ b/src/common/sessiond-comm/agent.h @@ -59,7 +59,7 @@ struct lttcomm_agent_hdr { * Enable event command payload. */ struct lttcomm_agent_enable { - uint32_t loglevel; + uint32_t loglevel_value; uint32_t loglevel_type; char name[LTTNG_SYMBOL_NAME_LEN]; } LTTNG_PACKED; -- 2.34.1