From e4baff1ed855ca743e95068ca6449fd906d2d833 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 6 Dec 2011 10:29:06 -0500 Subject: [PATCH] listing and activation of loglevel by number Signed-off-by: Mathieu Desnoyers --- include/lttng/lttng.h | 1 + lttng-sessiond/main.c | 4 +--- lttng-sessiond/ust-app.c | 1 + lttng/commands/enable_events.c | 12 +++++++----- lttng/commands/list.c | 28 ++++++++++++++++++++++------ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 3dd915f61..a137a4385 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -145,6 +145,7 @@ struct lttng_event_function_attr { struct lttng_event { char name[LTTNG_SYMBOL_NAME_LEN]; char loglevel[LTTNG_SYMBOL_NAME_LEN]; + int64_t loglevel_value; enum lttng_event_type type; uint32_t enabled; pid_t pid; diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index 46fcba939..0a6319f35 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -2093,9 +2093,7 @@ static int list_lttng_ust_global_events(char *channel_name, tmp[i].type = LTTNG_EVENT_FUNCTION; break; case LTTNG_UST_TRACEPOINT_LOGLEVEL: - /* TODO */ - ret = -LTTCOMM_NOT_IMPLEMENTED; - goto error; + tmp[i].type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; break; } i++; diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index f5dfb110b..bd4160b9a 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -1396,6 +1396,7 @@ int ust_app_list_events(struct lttng_event **events) } memcpy(tmp[count].name, iter.name, LTTNG_UST_SYM_NAME_LEN); memcpy(tmp[count].loglevel, iter.loglevel, LTTNG_UST_SYM_NAME_LEN); + tmp[count].loglevel_value = iter.loglevel_value; tmp[count].type = LTTNG_UST_TRACEPOINT; tmp[count].pid = app->key.pid; tmp[count].enabled = -1; diff --git a/lttng/commands/enable_events.c b/lttng/commands/enable_events.c index 5740d3cbc..45cef9f60 100644 --- a/lttng/commands/enable_events.c +++ b/lttng/commands/enable_events.c @@ -335,19 +335,21 @@ static int enable_events(char *session_name) } DBG("Enabling UST event %s for channel %s", event_name, channel_name); - /* Copy name and type of the event */ - strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); - ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; - ev.type = opt_event_type; switch (opt_event_type) { case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */ - ev.type = LTTNG_EVENT_TRACEPOINT; /* Fall-through */ case LTTNG_EVENT_TRACEPOINT: + /* Copy name and type of the event */ + ev.type = LTTNG_EVENT_TRACEPOINT; + strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); + ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; break; case LTTNG_EVENT_TRACEPOINT_LOGLEVEL: + /* Copy name and type of the event */ ev.type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL; + strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); + ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; break; case LTTNG_EVENT_PROBE: case LTTNG_EVENT_FUNCTION: diff --git a/lttng/commands/list.c b/lttng/commands/list.c index 4b29d4dc9..8c1dadac8 100644 --- a/lttng/commands/list.c +++ b/lttng/commands/list.c @@ -134,19 +134,21 @@ const char *enabled_string(int value) static const char *loglevel_string_pre(const char *loglevel) { - if (loglevel[0] == '\0') + if (loglevel[0] == '\0') { return ""; - else + } else { return " (loglevel: "; + } } static const char *loglevel_string_post(const char *loglevel) { - if (loglevel[0] == '\0') + if (loglevel[0] == '\0') { return ""; - else + } else { return ")"; + } } /* @@ -156,13 +158,26 @@ static void print_events(struct lttng_event *event) { switch (event->type) { case LTTNG_EVENT_TRACEPOINT: - MSG("%s%s%s%s%s (type: tracepoint)%s", indent6, + { + char ll_value[LTTNG_SYMBOL_NAME_LEN] = ""; + + if (event->loglevel[0] != '\0') { + int ret; + + ret = snprintf(ll_value, LTTNG_SYMBOL_NAME_LEN, + ", %lld", (long long) event->loglevel_value); + if (ret < 0) + ERR("snprintf error"); + } + MSG("%s%s%s%s%s%s (type: tracepoint)%s", indent6, event->name, loglevel_string_pre(event->loglevel), event->loglevel, + ll_value, loglevel_string_post(event->loglevel), enabled_string(event->enabled)); break; + } case LTTNG_EVENT_PROBE: MSG("%s%s (type: probe)%s", indent6, event->name, enabled_string(event->enabled)); @@ -189,7 +204,8 @@ static void print_events(struct lttng_event *event) break; case LTTNG_EVENT_TRACEPOINT_LOGLEVEL: MSG("%s%s (type: tracepoint loglevel)%s", indent6, - event->name, enabled_string(event->enabled)); + event->name, + enabled_string(event->enabled)); break; case LTTNG_EVENT_ALL: /* We should never have "all" events in list. */ -- 2.34.1