From 850767541647c102a299d7fbc39c97555ac70224 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 19 Jul 2013 09:04:29 -0400 Subject: [PATCH] Fix: (slight UI change) refuse missing -c if non-default channel exists After a user creates a channel within a session, creating a "default" channel if a user forgets to put "-c channel_name" in the following add-context, enable-event, disable-event commands is misleading. The natural expected behavior would be that the command would apply the the last enabled channel (notion of a "current" channel, like we have for sessions), but certainly not that it creates a new channel with default attributes behind the user's back. An intermediate fix that would not require to keep a notion of current channel is to refuse creation of a default channel if at least one non-default channel has already been created in the session. This commit affects enable-event, disable-event and add-context commands. This fix belongs to the 2.3-rc cycle, and cannot be backported, since it: a) changes the user interface of lttng (returns an error in the case where -c name is missing and the session contains an non-default channel) b) changes the ABI between lttng-ctl and sessiond: a default channel is now expressed as an empty string ('\0') rather than by "channel0", which allows making the difference between an explicit "channel0" channel and a default channel in the session daemon. Fixes #522 Signed-off-by: Mathieu Desnoyers --- doc/man/lttng.1 | 17 +++- include/lttng/lttng-error.h | 2 +- src/bin/lttng-sessiond/cmd.c | 115 +++++++++++++++++++++++- src/bin/lttng-sessiond/trace-kernel.c | 17 ++++ src/bin/lttng-sessiond/trace-kernel.h | 1 + src/bin/lttng-sessiond/trace-ust.c | 19 +++- src/bin/lttng-sessiond/trace-ust.h | 1 + src/bin/lttng/commands/disable_events.c | 40 +++++---- src/bin/lttng/commands/enable_events.c | 93 +++++++++++-------- src/common/error.c | 1 + src/common/ust-consumer/ust-consumer.c | 2 + src/lib/lttng-ctl/lttng-ctl.c | 34 ++++--- 12 files changed, 269 insertions(+), 73 deletions(-) diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 index 236603fa0..c0df43119 100644 --- a/doc/man/lttng.1 +++ b/doc/man/lttng.1 @@ -104,7 +104,9 @@ contexts. If no channel is given (\-c), the context is added to all channels that were already enabled. If the session has no channel, a default channel is created. -Otherwise the context will be added only to the given channel (\-c). +If \fB\-c, \-\-channel\fP is omitted, but a non-default channel already +exists within the session, an error is returned. Otherwise the context +will be added only to the given channel (\-c). If \fB\-s, \-\-session\fP is omitted, the session name is taken from the .lttngrc file. @@ -453,8 +455,10 @@ Enable tracing event A tracing event is always assigned to a channel. If \fB\-c, \-\-channel\fP is omitted, a default channel named '\fBchannel0\fP' is created and the event is -added to it. For the user-space tracer, using \fB\-a, \-\-all\fP is the same as -using the wildcard "*". +added to it. If \fB\-c, \-\-channel\fP is omitted, but a non-default +channel already exists within the session, an error is returned. For the +user-space tracer, using \fB\-a, \-\-all\fP is the same as using the +wildcard "*". If \fB\-s, \-\-session\fP is omitted, the session name is taken from the .lttngrc file. @@ -595,6 +599,10 @@ NAME\fP again. If \fB\-s, \-\-session\fP is omitted, the session name is taken from the .lttngrc file. +If \fB\-c, \-\-channel\fP is omitted, the default channel name is used. +If \fB\-c, \-\-channel\fP is omitted, but a non-default channel already +exists within the session, an error is returned. + .B OPTIONS: .TP @@ -607,6 +615,9 @@ Simple listing of options .BR "\-s, \-\-session NAME" Apply on session name .TP +.BR "\-c, \-\-channel NAME" +Apply on channel name +.TP .BR "\-a, \-\-all-events" Disable all events. This does NOT disable "*" but rather every known events of the session. diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h index 4e98f43be..51ef9ca1e 100644 --- a/include/lttng/lttng-error.h +++ b/include/lttng/lttng-error.h @@ -113,7 +113,7 @@ enum lttng_error_code { LTTNG_ERR_TRACE_ALREADY_STARTED = 80, /* Tracing already started */ LTTNG_ERR_TRACE_ALREADY_STOPPED = 81, /* Tracing already stopped */ LTTNG_ERR_KERN_EVENT_ENOSYS = 82, /* Kernel event type not supported */ - /* 83 */ + LTTNG_ERR_NEED_CHANNEL_NAME = 83, /* Non-default channel exists within session: channel name needs to be specified with '-c name' */ /* 84 */ /* 85 */ /* 86 */ diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index a351d63de..84594ad24 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -877,6 +877,9 @@ int cmd_enable_channel(struct ltt_session *session, session->kernel_session); if (kchan == NULL) { ret = channel_kernel_create(session->kernel_session, attr, wpipe); + if (attr->name[0] != '\0') { + session->kernel_session->has_non_default_channel = 1; + } } else { ret = channel_kernel_enable(session->kernel_session, kchan); } @@ -897,6 +900,9 @@ int cmd_enable_channel(struct ltt_session *session, uchan = trace_ust_find_channel_by_name(chan_ht, attr->name); if (uchan == NULL) { ret = channel_ust_create(usess, attr, domain->buf_type); + if (attr->name[0] != '\0') { + usess->has_non_default_channel = 1; + } } else { ret = channel_ust_enable(usess, uchan); } @@ -931,6 +937,16 @@ int cmd_disable_event(struct ltt_session *session, int domain, ksess = session->kernel_session; + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (ksess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + kchan = trace_kernel_get_channel_by_name(channel_name, ksess); if (kchan == NULL) { ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; @@ -952,6 +968,16 @@ int cmd_disable_event(struct ltt_session *session, int domain, usess = session->ust_session; + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (usess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { @@ -1003,6 +1029,16 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, ksess = session->kernel_session; + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (ksess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + kchan = trace_kernel_get_channel_by_name(channel_name, ksess); if (kchan == NULL) { ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND; @@ -1024,6 +1060,16 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, usess = session->ust_session; + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (usess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { @@ -1069,6 +1115,17 @@ int cmd_add_context(struct ltt_session *session, int domain, case LTTNG_DOMAIN_KERNEL: assert(session->kernel_session); + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (session->kernel_session->has_non_default_channel + && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + if (session->kernel_session->channel_count == 0) { /* Create default channel */ ret = channel_kernel_create(session->kernel_session, NULL, kwpipe); @@ -1077,7 +1134,6 @@ int cmd_add_context(struct ltt_session *session, int domain, } chan_kern_created = 1; } - /* Add kernel context to kernel tracer */ ret = context_kernel_add(session->kernel_session, ctx, channel_name); if (ret != LTTNG_OK) { @@ -1087,10 +1143,21 @@ int cmd_add_context(struct ltt_session *session, int domain, case LTTNG_DOMAIN_UST: { struct ltt_ust_session *usess = session->ust_session; + unsigned int chan_count; + assert(usess); - unsigned int chan_count = - lttng_ht_get_count(usess->domain_global.channels); + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (usess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + + chan_count = lttng_ht_get_count(usess->domain_global.channels); if (chan_count == 0) { struct lttng_channel *attr; /* Create default channel */ @@ -1173,6 +1240,17 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, { struct ltt_kernel_channel *kchan; + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (session->kernel_session->has_non_default_channel + && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session); if (kchan == NULL) { @@ -1222,6 +1300,16 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, assert(usess); + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (usess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + /* Get channel from global UST domain */ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); @@ -1294,6 +1382,17 @@ int cmd_enable_event_all(struct ltt_session *session, assert(session->kernel_session); + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (session->kernel_session->has_non_default_channel + && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session); if (kchan == NULL) { @@ -1358,6 +1457,16 @@ int cmd_enable_event_all(struct ltt_session *session, assert(usess); + /* + * If a non-default channel has been created in the + * session, explicitely require that -c chan_name needs + * to be provided. + */ + if (usess->has_non_default_channel && channel_name[0] == '\0') { + ret = LTTNG_ERR_NEED_CHANNEL_NAME; + goto error; + } + /* Get channel from global UST domain */ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 33e5488ef..0c14052e1 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -38,6 +38,13 @@ struct ltt_kernel_channel *trace_kernel_get_channel_by_name( assert(session); assert(name); + /* + * If we receive an empty string for channel name, it means the + * default channel name is requested. + */ + if (name[0] == '\0') + name = DEFAULT_CHANNEL_NAME; + DBG("Trying to find channel %s", name); cds_list_for_each_entry(chan, &session->channel_list.head, list) { @@ -144,6 +151,16 @@ struct ltt_kernel_channel *trace_kernel_create_channel( } memcpy(lkc->channel, chan, sizeof(struct lttng_channel)); + /* + * If we receive an empty string for channel name, it means the + * default channel name is requested. + */ + if (chan->name[0] == '\0') { + strncpy(lkc->channel->name, DEFAULT_CHANNEL_NAME, + sizeof(lkc->channel->name)); + } + lkc->channel->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + lkc->fd = -1; lkc->stream_count = 0; lkc->event_count = 0; diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 5502e42bd..934aaffe8 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -114,6 +114,7 @@ struct ltt_kernel_session { /* Tell or not if the session has to output the traces. */ unsigned int output_traces; unsigned int snapshot_mode; + unsigned int has_non_default_channel; }; /* diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 9eabf6225..c80d5e772 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -128,6 +128,13 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, struct lttng_ht_node_str *node; struct lttng_ht_iter iter; + /* + * If we receive an empty string for channel name, it means the + * default channel name is requested. + */ + if (name[0] == '\0') + name = DEFAULT_CHANNEL_NAME; + lttng_ht_lookup(ht, (void *)name, &iter); node = lttng_ht_iter_get_node_str(&iter); if (node == NULL) { @@ -268,8 +275,16 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan) break; } - /* Copy channel name */ - strncpy(luc->name, chan->name, sizeof(luc->name)); + /* + * If we receive an empty string for channel name, it means the + * default channel name is requested. + */ + if (chan->name[0] == '\0') { + strncpy(luc->name, DEFAULT_CHANNEL_NAME, sizeof(luc->name)); + } else { + /* Copy channel name */ + strncpy(luc->name, chan->name, sizeof(luc->name)); + } luc->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; /* Init node */ diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 5ca7964ea..f4244fdef 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -108,6 +108,7 @@ struct ltt_ust_session { /* Tell or not if the session has to output the traces. */ unsigned int output_traces; unsigned int snapshot_mode; + unsigned int has_non_default_channel; }; /* diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c index ac3d4a473..f9dc3396b 100644 --- a/src/bin/lttng/commands/disable_events.c +++ b/src/bin/lttng/commands/disable_events.c @@ -82,6 +82,18 @@ static void usage(FILE *ofp) fprintf(ofp, "\n"); } +static +const char *print_channel_name(const char *name) +{ + return name ? : DEFAULT_CHANNEL_NAME; +} + +static +const char *print_raw_channel_name(const char *name) +{ + return name ? : ""; +} + /* * disable_events * @@ -89,7 +101,7 @@ static void usage(FILE *ofp) */ static int disable_events(char *session_name) { - int err, ret = CMD_SUCCESS, warn = 0; + int ret = CMD_SUCCESS, warn = 0; char *event_name, *channel_name = NULL; struct lttng_domain dom; @@ -106,16 +118,7 @@ static int disable_events(char *session_name) goto error; } - /* Get channel name */ - if (opt_channel_name == NULL) { - err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME); - if (err < 0) { - ret = CMD_FATAL; - goto error; - } - } else { - channel_name = opt_channel_name; - } + channel_name = opt_channel_name; handle = lttng_create_handle(session_name, &dom); if (handle == NULL) { @@ -131,7 +134,8 @@ static int disable_events(char *session_name) } MSG("All %s events are disabled in channel %s", - opt_kernel ? "kernel" : "UST", channel_name); + opt_kernel ? "kernel" : "UST", + print_channel_name(channel_name)); goto end; } @@ -143,11 +147,16 @@ static int disable_events(char *session_name) ret = lttng_disable_event(handle, event_name, channel_name); if (ret < 0) { ERR("Event %s: %s (channel %s, session %s)", event_name, - lttng_strerror(ret), channel_name, session_name); + lttng_strerror(ret), + ret == -LTTNG_ERR_NEED_CHANNEL_NAME + ? print_raw_channel_name(channel_name) + : print_channel_name(channel_name), + session_name); warn = 1; } else { MSG("%s event %s disabled in channel %s for session %s", - opt_kernel ? "kernel" : "UST", event_name, channel_name, + opt_kernel ? "kernel" : "UST", event_name, + print_channel_name(channel_name), session_name); } @@ -162,9 +171,6 @@ error: if (warn) { ret = CMD_WARNING; } - if (opt_channel_name == NULL) { - free(channel_name); - } lttng_destroy_handle(handle); return ret; diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 18a958d32..26195af5a 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -312,12 +312,24 @@ int loglevel_str_to_value(const char *inputstr) } } +static +const char *print_channel_name(const char *name) +{ + return name ? : DEFAULT_CHANNEL_NAME; +} + +static +const char *print_raw_channel_name(const char *name) +{ + return name ? : ""; +} + /* * Enabling event using the lttng API. */ static int enable_events(char *session_name) { - int err, ret = CMD_SUCCESS, warn = 0; + int ret = CMD_SUCCESS, warn = 0; char *event_name, *channel_name = NULL; struct lttng_event ev; struct lttng_domain dom; @@ -347,15 +359,7 @@ static int enable_events(char *session_name) goto error; } - if (opt_channel_name == NULL) { - err = asprintf(&channel_name, DEFAULT_CHANNEL_NAME); - if (err < 0) { - ret = CMD_FATAL; - goto error; - } - } else { - channel_name = opt_channel_name; - } + channel_name = opt_channel_name; handle = lttng_create_handle(session_name, &dom); if (handle == NULL) { @@ -392,11 +396,15 @@ static int enable_events(char *session_name) switch (-ret) { case LTTNG_ERR_KERN_EVENT_EXIST: WARN("Kernel events already enabled (channel %s, session %s)", - channel_name, session_name); + print_channel_name(channel_name), session_name); break; default: ERR("Events: %s (channel %s, session %s)", - lttng_strerror(ret), channel_name, session_name); + lttng_strerror(ret), + ret == -LTTNG_ERR_NEED_CHANNEL_NAME + ? print_raw_channel_name(channel_name) + : print_channel_name(channel_name), + session_name); break; } goto end; @@ -406,28 +414,32 @@ static int enable_events(char *session_name) case LTTNG_EVENT_TRACEPOINT: if (opt_loglevel) { MSG("All %s tracepoints are enabled in channel %s for loglevel %s", - opt_kernel ? "kernel" : "UST", channel_name, + opt_kernel ? "kernel" : "UST", + print_channel_name(channel_name), opt_loglevel); } else { MSG("All %s tracepoints are enabled in channel %s", - opt_kernel ? "kernel" : "UST", channel_name); + opt_kernel ? "kernel" : "UST", + print_channel_name(channel_name)); } break; case LTTNG_EVENT_SYSCALL: if (opt_kernel) { MSG("All kernel system calls are enabled in channel %s", - channel_name); + print_channel_name(channel_name)); } break; case LTTNG_EVENT_ALL: if (opt_loglevel) { MSG("All %s events are enabled in channel %s for loglevel %s", - opt_kernel ? "kernel" : "UST", channel_name, + opt_kernel ? "kernel" : "UST", + print_channel_name(channel_name), opt_loglevel); } else { MSG("All %s events are enabled in channel %s", - opt_kernel ? "kernel" : "UST", channel_name); + opt_kernel ? "kernel" : "UST", + print_channel_name(channel_name)); } break; default: @@ -444,14 +456,17 @@ static int enable_events(char *session_name) if (ret < 0) { switch (-ret) { case LTTNG_ERR_FILTER_EXIST: - WARN("Filter on events is already enabled" + WARN("Filter on all events is already enabled" " (channel %s, session %s)", - channel_name, session_name); + print_channel_name(channel_name), session_name); break; - case LTTNG_ERR_FILTER_INVAL: - case LTTNG_ERR_FILTER_NOMEM: default: - ERR("%s", lttng_strerror(ret)); + ERR("All events: %s (channel %s, session %s, filter \'%s\')", + lttng_strerror(ret), + ret == -LTTNG_ERR_NEED_CHANNEL_NAME + ? print_raw_channel_name(channel_name) + : print_channel_name(channel_name), + session_name, opt_filter); break; } goto error; @@ -473,7 +488,8 @@ static int enable_events(char *session_name) /* Kernel tracer action */ if (opt_kernel) { DBG("Enabling kernel event %s for channel %s", - event_name, channel_name); + event_name, + print_channel_name(channel_name)); switch (opt_event_type) { case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */ @@ -528,7 +544,7 @@ static int enable_events(char *session_name) #endif DBG("Enabling UST event %s for channel %s, loglevel %s", event_name, - channel_name, opt_loglevel ? : ""); + print_channel_name(channel_name), opt_loglevel ? : ""); switch (opt_event_type) { case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */ @@ -573,17 +589,23 @@ static int enable_events(char *session_name) switch (-ret) { case LTTNG_ERR_KERN_EVENT_EXIST: WARN("Kernel event %s already enabled (channel %s, session %s)", - event_name, channel_name, session_name); + event_name, + print_channel_name(channel_name), session_name); break; default: ERR("Event %s: %s (channel %s, session %s)", event_name, - lttng_strerror(ret), channel_name, session_name); + lttng_strerror(ret), + ret == -LTTNG_ERR_NEED_CHANNEL_NAME + ? print_raw_channel_name(channel_name) + : print_channel_name(channel_name), + session_name); break; } warn = 1; } else { MSG("%s event %s created in channel %s", - opt_kernel ? "kernel": "UST", event_name, channel_name); + opt_kernel ? "kernel": "UST", event_name, + print_channel_name(channel_name)); } } @@ -595,14 +617,16 @@ static int enable_events(char *session_name) case LTTNG_ERR_FILTER_EXIST: WARN("Filter on event %s is already enabled" " (channel %s, session %s)", - event_name, channel_name, session_name); + event_name, + print_channel_name(channel_name), session_name); break; - case LTTNG_ERR_FILTER_INVAL: - case LTTNG_ERR_FILTER_NOMEM: - ERR("%s", lttng_strerror(ret)); default: - ERR("Setting filter for event %s: '%s'", ev.name, - opt_filter); + ERR("Event %s: %s (channel %s, session %s, filter \'%s\')", ev.name, + lttng_strerror(ret), + ret == -LTTNG_ERR_NEED_CHANNEL_NAME + ? print_raw_channel_name(channel_name) + : print_channel_name(channel_name), + session_name, opt_filter); break; } goto error; @@ -620,9 +644,6 @@ error: if (warn) { ret = CMD_WARNING; } - if (opt_channel_name == NULL) { - free(channel_name); - } lttng_destroy_handle(handle); return ret; diff --git a/src/common/error.c b/src/common/error.c index 585101252..acfd6c678 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -86,6 +86,7 @@ static const char *error_string_array[] = { [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STARTED) ] = "Tracing already started", [ ERROR_INDEX(LTTNG_ERR_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped", [ ERROR_INDEX(LTTNG_ERR_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported", + [ ERROR_INDEX(LTTNG_ERR_NEED_CHANNEL_NAME) ] = "Non-default channel exists within session: channel name needs to be specified with '-c name'", [ ERROR_INDEX(LTTNG_ERR_INVALID) ] = "Invalid parameter", [ ERROR_INDEX(LTTNG_ERR_NO_USTCONSUMERD) ] = "No UST consumer detected", [ ERROR_INDEX(LTTNG_ERR_NO_KERNCONSUMERD) ] = "No kernel consumer detected", diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index f8c02ee72..4f374f030 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1568,6 +1568,8 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream, DBG("In UST read_subbuffer (wait_fd: %d, name: %s)", stream->wait_fd, stream->name); + sleep(1); + /* Ease our life for what's next. */ ustream = stream->ustream; diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index d8d5db6c7..033a28105 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -640,9 +640,14 @@ int lttng_add_context(struct lttng_handle *handle, lsm.cmd_type = LTTNG_ADD_CONTEXT; - /* Copy channel name */ - lttng_ctl_copy_string(lsm.u.context.channel_name, channel_name, - sizeof(lsm.u.context.channel_name)); + /* If no channel name, send empty string. */ + if (channel_name == NULL) { + lttng_ctl_copy_string(lsm.u.context.channel_name, "", + sizeof(lsm.u.context.channel_name)); + } else { + lttng_ctl_copy_string(lsm.u.context.channel_name, channel_name, + sizeof(lsm.u.context.channel_name)); + } lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain); @@ -671,9 +676,9 @@ int lttng_enable_event(struct lttng_handle *handle, memset(&lsm, 0, sizeof(lsm)); - /* If no channel name, we put the default name */ + /* If no channel name, send empty string. */ if (channel_name == NULL) { - lttng_ctl_copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, + lttng_ctl_copy_string(lsm.u.enable.channel_name, "", sizeof(lsm.u.enable.channel_name)); } else { lttng_ctl_copy_string(lsm.u.enable.channel_name, channel_name, @@ -800,9 +805,15 @@ int lttng_enable_event_with_filter(struct lttng_handle *handle, lsm.cmd_type = LTTNG_ENABLE_EVENT_WITH_FILTER; - /* Copy channel name */ - lttng_ctl_copy_string(lsm.u.enable.channel_name, channel_name, - sizeof(lsm.u.enable.channel_name)); + /* If no channel name, send empty string. */ + if (channel_name == NULL) { + lttng_ctl_copy_string(lsm.u.enable.channel_name, "", + sizeof(lsm.u.enable.channel_name)); + } else { + lttng_ctl_copy_string(lsm.u.enable.channel_name, channel_name, + sizeof(lsm.u.enable.channel_name)); + } + /* Copy event name */ if (event) { memcpy(&lsm.u.enable.event, event, sizeof(lsm.u.enable.event)); @@ -855,11 +866,12 @@ int lttng_disable_event(struct lttng_handle *handle, const char *name, memset(&lsm, 0, sizeof(lsm)); - if (channel_name) { - lttng_ctl_copy_string(lsm.u.disable.channel_name, channel_name, + /* If no channel name, send empty string. */ + if (channel_name == NULL) { + lttng_ctl_copy_string(lsm.u.disable.channel_name, "", sizeof(lsm.u.disable.channel_name)); } else { - lttng_ctl_copy_string(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME, + lttng_ctl_copy_string(lsm.u.disable.channel_name, channel_name, sizeof(lsm.u.disable.channel_name)); } -- 2.34.1