}
/* Only if channel is enabled disable it. */
- if (kchan->enabled == 1) {
+ if (kchan->enabled) {
ret = kernel_disable_channel(kchan);
if (ret < 0 && ret != -EEXIST) {
ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
LTTNG_ASSERT(ksession);
LTTNG_ASSERT(kchan);
- if (kchan->enabled == 0) {
+ if (!kchan->enabled) {
if (kernel_enable_channel(kchan) < 0) {
ret_code = LTTNG_ERR_KERN_CHAN_ENABLE_FAIL;
goto error;
ret_code = LTTNG_ERR_UST_CHAN_EXIST;
goto end;
} else {
- uchan->enabled = 1;
+ uchan->enabled = true;
DBG2("Channel %s enabled successfully", uchan->name);
}
goto error;
}
- uchan->enabled = 1;
+ uchan->enabled = true;
if (trace_ust_is_max_id(usess->used_channel_id)) {
ret_code = LTTNG_ERR_UST_CHAN_FAIL;
goto error;
LTTNG_ASSERT(uchan);
/* Already disabled */
- if (uchan->enabled == 0) {
+ if (!uchan->enabled) {
DBG2("Channel UST %s already disabled", uchan->name);
goto end;
}
- uchan->enabled = 0;
+ uchan->enabled = false;
/*
* If session is inactive we don't notify the tracer right away. We
* since the relayd connection failed thus making any tracing or/and
* streaming not usable.
*/
- consumer->enabled = 0;
+ consumer->enabled = false;
}
(void) relayd_close(rsock);
free(rsock);
/* Quiescent wait after starting trace */
kernel_wait_quiescent();
- ksess->active = 1;
+ ksess->active = true;
ret = LTTNG_OK;
}
}
- ksess->active = 0;
+ ksess->active = false;
if (error_occurred) {
ret = LTTNG_ERR_UNK;
} else {
goto error;
}
- session->active = 1;
+ session->active = true;
session->rotated_after_last_stop = false;
session->cleared_after_last_stop = false;
if (session->output_traces && !session->current_trace_chunk) {
error:
if (ret == LTTNG_OK) {
/* Flag this after a successful start. */
- session->has_been_started |= 1;
+ session->has_been_started = true;
} else {
- session->active = 0;
+ session->active = false;
/* Restore initial state on error. */
session->rotated_after_last_stop = session_rotated_after_last_stop;
session->cleared_after_last_stop = session_cleared_after_last_stop;
DBG("Completed stop session \"%s\" (id %" PRIu64 ")", session->name, session->id);
/* Flag inactive after a successful stop. */
- session->active = 0;
+ session->active = false;
ret = LTTNG_OK;
error:
if (ret_code != LTTNG_OK) {
goto end;
}
- new_session->consumer->enabled = 1;
+ new_session->consumer->enabled = true;
ret_code = LTTNG_OK;
end:
/* Release reference provided by the session_create function. */
}
/* By default, consumer output is enabled */
- output->enabled = 1;
+ output->enabled = true;
output->type = type;
output->net_seq_index = (uint64_t) -1ULL;
urcu_ref_init(&output->ref);
struct urcu_ref ref; /* Refcount */
/* If the consumer is enabled meaning that should be used */
- unsigned int enabled;
+ bool enabled;
enum consumer_dst_type type;
/*
if (ret) {
goto end;
}
- } else if (kevent->enabled == 0) {
+ } else if (!kevent->enabled) {
ret = kernel_enable_event(kevent);
if (ret < 0) {
ret = LTTNG_ERR_KERN_ENABLE_FAIL;
goto end;
}
- uevent->enabled = 1;
+ uevent->enabled = true;
if (to_create) {
/* Add ltt ust event to channel */
add_unique_ust_event(uchan->events, uevent);
uevent = lttng::utils::container_of(node, <t_ust_event::node);
LTTNG_ASSERT(uevent);
- if (uevent->enabled == 0) {
+ if (!uevent->enabled) {
/* It's already disabled so everything is OK */
goto next;
}
- uevent->enabled = 0;
+ uevent->enabled = false;
DBG2("Event UST %s disabled in channel %s", uevent->attr.name, uchan->name);
if (!usess->active) {
/* Disabling existing events */
cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) {
- if (uevent->enabled == 1) {
+ if (uevent->enabled) {
ret = event_ust_disable_tracepoint(usess, uchan, uevent->attr.name);
if (ret < 0) {
error = LTTNG_ERR_UST_DISABLE_FAIL;
* Flag event that it's disabled so the shadow copy on the ust app side
* will disable it if an application shows up.
*/
- uevent->enabled = 0;
+ uevent->enabled = false;
ret = agent_disable_event(aevent, agt->domain);
if (ret != LTTNG_OK) {
goto error;
}
- chan->enabled = 0;
+ chan->enabled = false;
DBG("Kernel channel %s disabled (fd: %d, key: %" PRIu64 ")",
chan->channel->name,
chan->fd,
goto error;
}
- chan->enabled = 1;
+ chan->enabled = true;
DBG("Kernel channel %s enabled (fd: %d, key: %" PRIu64 ")",
chan->channel->name,
chan->fd,
goto error;
}
- event->enabled = 1;
+ event->enabled = true;
DBG("Kernel event %s enabled (fd: %d)", event->event->name, event->fd);
return 0;
goto error;
}
- event->enabled = 0;
+ event->enabled = false;
DBG("Kernel event %s disabled (fd: %d)", event->event->name, event->fd);
return 0;
goto error;
}
- event->enabled = 0;
+ event->enabled = false;
DBG("Disabled kernel event notifier: fd = %d, token = %" PRIu64, event->fd, event->token);
error:
*/
bool has_user_specified_directory;
/* Did at least ONE start command has been triggered?. */
- unsigned int has_been_started:1;
- /*
- * Is the session active? Start trace command sets this to 1 and the stop
- * command reset it to 0.
- */
- unsigned int active:1;
+ bool has_been_started;
+ /* Is the session active? */
+ bool active;
/* Snapshot representation in a session. */
struct snapshot snapshot;
lkc->fd = -1;
lkc->stream_count = 0;
lkc->event_count = 0;
- lkc->enabled = 1;
+ lkc->enabled = true;
lkc->published_to_notification_thread = false;
/* Init linked list */
CDS_INIT_LIST_HEAD(&lkc->events_list.head);
/* Setting up a kernel event */
local_kernel_event->fd = -1;
local_kernel_event->event = attr;
- local_kernel_event->enabled = 1;
+ local_kernel_event->enabled = true;
local_kernel_event->filter_expression = filter_expression;
local_kernel_event->filter = filter;
local_kernel_event->userspace_probe_location = userspace_probe_location;
}
local_kernel_token_event_rule->fd = -1;
- local_kernel_token_event_rule->enabled = 1;
+ local_kernel_token_event_rule->enabled = true;
local_kernel_token_event_rule->token = token;
local_kernel_token_event_rule->error_counter_index = error_counter_index;
/* Kernel event */
struct ltt_kernel_event {
int fd;
- int enabled;
+ bool enabled;
enum lttng_event_type type;
struct lttng_kernel_abi_event *event;
struct cds_list_head list;
struct ltt_kernel_event_notifier_rule {
int fd;
uint64_t error_counter_index;
- int enabled;
+ bool enabled;
enum lttng_event_type type;
struct lttng_trigger *trigger;
uint64_t token;
struct ltt_kernel_channel {
int fd;
uint64_t key; /* Key to reference this channel with the consumer. */
- int enabled;
+ bool enabled;
unsigned int stream_count;
unsigned int event_count;
bool published_to_notification_thread;
/* Tracing session id */
uint64_t id;
/* Session is active or not meaning it has been started or stopped. */
- unsigned int active:1;
+ bool active;
/* Tell or not if the session has to output the traces. */
unsigned int output_traces;
unsigned int snapshot_mode;
/* UST event */
struct ltt_ust_event {
- unsigned int enabled;
+ bool enabled;
struct lttng_ust_abi_event attr;
struct lttng_ht_node_str node;
char *filter_expression;
/* UST channel */
struct ltt_ust_channel {
uint64_t id; /* unique id per session. */
- unsigned int enabled;
+ bool enabled;
/*
* A UST channel can be part of a userspace sub-domain such as JUL,
* Log4j, Python.
uid_t uid;
gid_t gid;
/* Is the session active meaning has is been started or stopped. */
- unsigned int active:1;
+ bool active;
struct consumer_output *consumer;
/* Sequence number for filters so the tracer knows the ordering. */
uint64_t filter_seq_num;
strncpy(ua_chan->name, name, sizeof(ua_chan->name));
ua_chan->name[sizeof(ua_chan->name) - 1] = '\0';
- ua_chan->enabled = 1;
+ ua_chan->enabled = true;
ua_chan->handle = -1;
ua_chan->session = ua_sess;
ua_chan->key = get_next_channel_key();
goto error;
}
- ua_event->enabled = 1;
+ ua_event->enabled = true;
strncpy(ua_event->name, name, sizeof(ua_event->name));
ua_event->name[sizeof(ua_event->name) - 1] = '\0';
lttng_ht_node_init_str(&ua_event->node, ua_event->name);
goto error;
}
- ua_event_notifier_rule->enabled = 1;
+ ua_event_notifier_rule->enabled = true;
ua_event_notifier_rule->token = lttng_trigger_get_tracer_token(trigger);
lttng_ht_node_init_u64(&ua_event_notifier_rule->node, ua_event_notifier_rule->token);
goto error;
}
- ua_chan->enabled = 1;
+ ua_chan->enabled = true;
DBG2("UST app channel %s enabled successfully for app: pid = %d", ua_chan->name, app->pid);
goto error;
}
- ua_event->enabled = 1;
+ ua_event->enabled = true;
error:
return ret;
goto error;
}
- ua_event->enabled = 0;
+ ua_event->enabled = false;
error:
return ret;
goto error;
}
- ua_chan->enabled = 0;
+ ua_chan->enabled = false;
error:
return ret;
ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
/* The channel must not be already disabled */
- LTTNG_ASSERT(ua_chan->enabled == 1);
+ LTTNG_ASSERT(ua_chan->enabled);
/* Disable channel onto application */
ret = disable_ust_app_channel(ua_sess, ua_chan, app);
}
/* Indicate that the session has been started once */
- ua_sess->started = 1;
- ua_sess->enabled = 1;
+ ua_sess->started = true;
+ ua_sess->enabled = true;
pthread_mutex_unlock(&ua_sess->lock);
}
health_code_update();
- ua_sess->enabled = 0;
+ ua_sess->enabled = false;
/* Quiescent wait after stopping trace */
pthread_mutex_lock(&app->sock_lock);
* Even though the start trace might fail, flag this session active so
* other application coming in are started by default.
*/
- usess->active = 1;
+ usess->active = true;
rcu_read_lock();
* Even though the stop trace might fail, flag this session inactive so
* other application coming in are not started by default.
*/
- usess->active = 0;
+ usess->active = false;
rcu_read_lock();
};
struct ust_app_event {
- int enabled;
+ bool enabled;
int handle;
struct lttng_ust_abi_object_data *obj;
struct lttng_ust_abi_event attr;
};
struct ust_app_event_notifier_rule {
- int enabled;
+ bool enabled;
uint64_t error_counter_index;
int handle;
struct lttng_ust_abi_object_data *obj;
};
struct ust_app_channel {
- int enabled;
+ bool enabled;
int handle;
/*
* Unique key used to identify the channel on the consumer side.
*/
pthread_mutex_t lock;
- int enabled;
+ bool enabled;
/* started: has the session been in started state at any time ? */
- int started; /* allows detection of start vs restart. */
+ bool started; /* allows detection of start vs restart. */
int handle; /* used has unique identifier for app session */
bool deleted; /* Session deleted flag. Check with lock held. */
*/
static int disable_channels(char *session_name, char *channel_list)
{
- int ret = CMD_SUCCESS, warn = 0, success;
-
- /* Normal case for disable channed is enabled = 0 */
- unsigned int enabled = 0;
+ int ret = CMD_SUCCESS;
+ /* Normal case for disable channed is enabled = false */
+ bool warn = false, success, enabled = false;
char *channel_name;
struct lttng_domain dom;
channel_name,
lttng_strerror(ret),
session_name);
- warn = 1;
+ warn = true;
/*
* Mi:
* The client should look at the stderr stream
* for more informations.
*/
- enabled = 1;
- success = 0;
+ enabled = true;
+ success = false;
} else {
MSG("%s channel %s disabled for session %s",
lttng_domain_type_str(dom.type),
channel_name,
session_name);
- enabled = 0;
- success = 1;
+ enabled = false;
+ success = true;
}
/* Print the channel */
*/
static int disable_events(char *session_name, char *event_list)
{
- int ret = CMD_SUCCESS, warn = 0, command_ret = CMD_SUCCESS;
- int enabled = 1, success = 1;
+ enum cmd_error_code ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
+ bool enabled = true, success = true, warn = false;
char *event_name, *channel_name = nullptr;
struct lttng_domain dom;
struct lttng_event event;
handle = lttng_create_handle(session_name, &dom);
if (handle == nullptr) {
- ret = -1;
+ ret = CMD_ERROR;
goto error;
}
/* Mi print the channel and open the events element */
if (lttng_opt_mi) {
- ret = mi_lttng_writer_open_element(writer, config_element_channel);
- if (ret) {
+ int mi_ret = mi_lttng_writer_open_element(writer, config_element_channel);
+ if (mi_ret) {
ret = CMD_ERROR;
goto end;
}
- ret = mi_lttng_writer_write_element_string(
+ mi_ret = mi_lttng_writer_write_element_string(
writer, config_element_name, print_channel_name(channel_name));
- if (ret) {
+ if (mi_ret) {
ret = CMD_ERROR;
goto end;
}
/* Open events element */
- ret = mi_lttng_writer_open_element(writer, config_element_events);
- if (ret) {
+ mi_ret = mi_lttng_writer_open_element(writer, config_element_events);
+ if (mi_ret) {
ret = CMD_ERROR;
goto end;
}
event.type = (lttng_event_type) opt_event_type;
if (opt_disable_all) {
- command_ret = lttng_disable_event_ext(handle, &event, channel_name, nullptr);
- if (command_ret < 0) {
- ERR("%s", lttng_strerror(command_ret));
- enabled = 1;
- success = 0;
+ const int disable_ret = lttng_disable_event_ext(handle, &event, channel_name, nullptr);
+ if (disable_ret < 0) {
+ ERR("%s", lttng_strerror(command_ret));
+ command_ret = CMD_ERROR;
+ enabled = true;
+ success = false;
} else {
- enabled = 0;
- success = 1;
+ enabled = false;
+ success = true;
MSG("All %s events of type %s are disabled in channel %s",
lttng_domain_type_str(dom.type),
print_event_type((lttng_event_type) opt_event_type),
}
if (lttng_opt_mi) {
- ret = mi_print_event("*", enabled, success);
- if (ret) {
+ const int mi_ret = mi_print_event("*", enabled, success);
+
+ if (mi_ret) {
ret = CMD_ERROR;
goto error;
}
strncpy(event.name, event_name, sizeof(event.name));
event.name[sizeof(event.name) - 1] = '\0';
- command_ret =
+ const int disable_ret =
lttng_disable_event_ext(handle, &event, channel_name, nullptr);
- if (command_ret < 0) {
+ if (disable_ret < 0) {
ERR("%s of type %s : %s (channel %s, session %s)",
event_name,
print_event_type((lttng_event_type) opt_event_type),
print_raw_channel_name(channel_name) :
print_channel_name(channel_name),
session_name);
- warn = 1;
- success = 0;
+ warn = true;
+ success = false;
/*
* If an error occurred we assume that the event is still
* enabled.
*/
- enabled = 1;
+ enabled = true;
+ command_ret = CMD_ERROR;
} else {
MSG("%s %s of type %s disabled in channel %s for session %s",
lttng_domain_type_str(dom.type),
print_event_type((lttng_event_type) opt_event_type),
print_channel_name(channel_name),
session_name);
- success = 1;
- enabled = 0;
+ success = true;
+ enabled = false;
}
if (lttng_opt_mi) {
- ret = mi_print_event(event_name, enabled, success);
- if (ret) {
+ const int mi_ret = mi_print_event(event_name, enabled, success);
+
+ if (mi_ret) {
ret = CMD_ERROR;
goto error;
}
end:
if (lttng_opt_mi) {
/* Close events element and channel element */
- ret = mi_lttng_close_multi_element(writer, 2);
- if (ret) {
+ const int mi_ret = mi_lttng_close_multi_element(writer, 2);
+
+ if (mi_ret) {
ret = CMD_ERROR;
}
}
return;
}
- ok(chan->fd == -1 && chan->enabled == 1 && chan->stream_count == 0 &&
+ ok(chan->fd == -1 && chan->enabled && chan->stream_count == 0 &&
chan->channel->attr.overwrite == attr.attr.overwrite,
"Validate kernel channel");
return;
}
- ok(event->fd == -1 && event->enabled == 1 &&
+ ok(event->fd == -1 && event->enabled &&
event->event->instrumentation == LTTNG_KERNEL_ABI_TRACEPOINT &&
strlen(event->event->name),
"Validate kernel event");
return;
}
- ok(usess->id == 42 && usess->active == 0 && usess->domain_global.channels != nullptr &&
+ ok(usess->id == 42 && !usess->active && usess->domain_global.channels != nullptr &&
usess->uid == 0 && usess->gid == 0,
"Validate UST session");
return;
}
- ok(uchan->enabled == 0 && strncmp(uchan->name, "channel0", 8) == 0 &&
+ ok(!uchan->enabled && strncmp(uchan->name, "channel0", 8) == 0 &&
uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' && uchan->ctx != nullptr &&
uchan->events != nullptr && uchan->attr.overwrite == attr.attr.overwrite,
"Validate UST channel");
return;
}
- ok(event->enabled == 0 && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
+ ok(!event->enabled && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
strcmp(event->attr.name, ev.name) == 0 &&
event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0',
"Validate UST event");
goto end;
}
- ok(event->enabled == 0 && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
+ ok(!event->enabled && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
strcmp(event->attr.name, ev.name) == 0 && event->exclusion != nullptr &&
event->exclusion->count == exclusion_count &&
!memcmp(event->exclusion->names,