From: David Goulet Date: Mon, 14 Nov 2011 21:56:58 +0000 (-0500) Subject: Fix enabled state when listing UST events X-Git-Tag: v2.0-pre15~114 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=3735745270b83fc911d8ee39c8437256b3af4e3d;ds=sidebyside Fix enabled state when listing UST events NOTE: When listing all UST events from all registered apps, the enabled state is set to -1 meaning that there is no enable/disable state semantic at this point. Signed-off-by: David Goulet --- diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index d52dcb945..ccdc50f1d 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -1879,6 +1879,7 @@ static int list_lttng_ust_global_events(char *channel_name, cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) { strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN); tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; + tmp[i].enabled = uevent->enabled; switch (uevent->attr.instrumentation) { case LTTNG_UST_TRACEPOINT: tmp[i].type = LTTNG_EVENT_TRACEPOINT; @@ -2101,6 +2102,8 @@ static int cmd_enable_channel(struct ltt_session *session, goto error; } + uchan->enabled = 1; + break; } case LTTNG_DOMAIN_UST_PID: @@ -2368,6 +2371,8 @@ static int cmd_enable_event(struct ltt_session *session, int domain, hashtable_add_unique(uchan->events, &uevent->node); rcu_read_unlock(); + uevent->enabled = 1; + DBG3("UST ltt event %s added to channel %s", uevent->attr.name, uchan->name); break; diff --git a/lttng-sessiond/trace-ust.c b/lttng-sessiond/trace-ust.c index bc73b7977..a0d3b1b41 100644 --- a/lttng-sessiond/trace-ust.c +++ b/lttng-sessiond/trace-ust.c @@ -137,7 +137,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, int ret; struct ltt_ust_channel *luc; - luc = malloc(sizeof(struct ltt_ust_channel)); + luc = zmalloc(sizeof(struct ltt_ust_channel)); if (luc == NULL) { perror("ltt_ust_channel malloc"); goto error; @@ -194,7 +194,7 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) { struct ltt_ust_event *lue; - lue = malloc(sizeof(struct ltt_ust_event)); + lue = zmalloc(sizeof(struct ltt_ust_event)); if (lue == NULL) { PERROR("ust event malloc"); goto error; diff --git a/lttng-sessiond/trace-ust.h b/lttng-sessiond/trace-ust.h index f2ec7405f..9235ca62c 100644 --- a/lttng-sessiond/trace-ust.h +++ b/lttng-sessiond/trace-ust.h @@ -43,6 +43,7 @@ struct ltt_ust_context { /* UST event */ struct ltt_ust_event { + unsigned int enabled; struct lttng_ust_event attr; struct cds_lfht *ctx; struct cds_lfht_node node; @@ -59,6 +60,7 @@ struct ltt_ust_stream { /* UST channel */ struct ltt_ust_channel { + unsigned int enabled; char name[LTTNG_UST_SYM_NAME_LEN]; char pathname[PATH_MAX]; struct lttng_ust_channel attr; diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index 0fc208311..6e25c5b3e 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -414,6 +414,7 @@ int ust_app_list_events(struct lttng_event **events) tmp[count].type = LTTNG_UST_TRACEPOINT; tmp[count].pid = app->key.pid; + tmp[count].enabled = -1; count++; } }