From: Mathieu Desnoyers Date: Wed, 1 Feb 2012 19:39:49 +0000 (-0500) Subject: Fix loglevel handling in test case (API change) and lttng command X-Git-Tag: v2.0-pre19~20 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ed7f40833d26f9d757c455607118c6d8e866a956;p=lttng-tools.git Fix loglevel handling in test case (API change) and lttng command Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 433d2d804..c83f98325 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -152,9 +152,9 @@ struct lttng_event { char name[LTTNG_SYMBOL_NAME_LEN]; enum lttng_loglevel_type loglevel_type; - char loglevel[LTTNG_SYMBOL_NAME_LEN]; - int64_t loglevel_value; /* for printing */ + char loglevel[LTTNG_SYMBOL_NAME_LEN]; /* '\0' for all loglevels */ + int64_t loglevel_value; /* for printing */ uint32_t enabled; pid_t pid; /* Per event type configuration */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 8e4afb00b..2aa93e63e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2426,12 +2426,6 @@ error: /* * Command LTTNG_ENABLE_EVENT processed by the client thread. - * - * TODO: currently, both events and loglevels are kept within the same - * namespace for UST global registry/app registery, so if an event - * happen to have the same name as the loglevel (very unlikely though), - * and an attempt is made to enable/disable both in the same session, - * the first to be created will be the only one allowed to exist. */ static int cmd_enable_event(struct ltt_session *session, int domain, char *channel_name, struct lttng_event *event) diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 0fa3e916c..1fcc81acb 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -341,7 +341,7 @@ static int enable_events(char *session_name) goto error; } - if (opt_loglevel[0] != '\0') { + if (opt_loglevel) { MSG("Kernel loglevels are not supported."); ret = CMD_UNDEFINED; goto error; @@ -381,8 +381,12 @@ static int enable_events(char *session_name) } ev.loglevel_type = opt_loglevel_type; - strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN); - ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; + if (opt_loglevel) { + strncpy(ev.loglevel, opt_loglevel, LTTNG_SYMBOL_NAME_LEN); + ev.loglevel[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; + } else { + ev.loglevel[0] = '\0'; + } } else { ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); goto error; diff --git a/tests/lttng/ust_global_all_events_basic.c b/tests/lttng/ust_global_all_events_basic.c index 32c39fb5e..b141057c6 100644 --- a/tests/lttng/ust_global_all_events_basic.c +++ b/tests/lttng/ust_global_all_events_basic.c @@ -42,6 +42,8 @@ int main(int argc, char **argv) memset(&event, 0, sizeof(struct lttng_event)); event.type = LTTNG_EVENT_TRACEPOINT; + event.loglevel[0] = '\0'; + event.loglevel_type = LTTNG_EVENT_LOGLEVEL; printf("\nTesting tracing all UST events:\n"); printf("-----------\n"); diff --git a/tests/lttng/ust_global_event_basic.c b/tests/lttng/ust_global_event_basic.c index d3a103033..ac0687daa 100644 --- a/tests/lttng/ust_global_event_basic.c +++ b/tests/lttng/ust_global_event_basic.c @@ -52,12 +52,18 @@ int main(int argc, char **argv) strcpy(ev1.name, "tp1"); ev1.type = LTTNG_EVENT_TRACEPOINT; + ev1.loglevel[0] = '\0'; + ev1.loglevel_type = LTTNG_EVENT_LOGLEVEL; strcpy(ev2.name, "ev2"); ev2.type = LTTNG_EVENT_TRACEPOINT; + ev2.loglevel[0] = '\0'; + ev2.loglevel_type = LTTNG_EVENT_LOGLEVEL; strcpy(ev3.name, "ev3"); ev3.type = LTTNG_EVENT_TRACEPOINT; + ev3.loglevel[0] = '\0'; + ev3.loglevel_type = LTTNG_EVENT_LOGLEVEL; printf("\nTesting tracing UST events:\n"); printf("-----------\n");