+#include "agent.hpp"
+#include "channel.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#include "channel.h"
-#include "lttng-sessiond.h"
-#include "kernel.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
-
chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
chan->attr.live_timer_interval = DEFAULT_KERNEL_CHANNEL_LIVE_TIMER;
extended_attr->blocking_timeout = DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
chan->attr.live_timer_interval = DEFAULT_KERNEL_CHANNEL_LIVE_TIMER;
extended_attr->blocking_timeout = DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
switch (type) {
case LTTNG_BUFFER_PER_UID:
chan->attr.subbuf_size = default_get_ust_uid_channel_subbuf_size();
chan->attr.num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
switch (type) {
case LTTNG_BUFFER_PER_UID:
chan->attr.subbuf_size = default_get_ust_uid_channel_subbuf_size();
chan->attr.num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
- chan->attr.switch_timer_interval =
- DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
- chan->attr.read_timer_interval =
- DEFAULT_UST_UID_CHANNEL_READ_TIMER;
- chan->attr.live_timer_interval =
- DEFAULT_UST_UID_CHANNEL_LIVE_TIMER;
+ chan->attr.switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
+ chan->attr.read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
+ chan->attr.live_timer_interval = DEFAULT_UST_UID_CHANNEL_LIVE_TIMER;
extended_attr->blocking_timeout = DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
extended_attr->monitor_timer_interval =
DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
extended_attr->blocking_timeout = DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
extended_attr->monitor_timer_interval =
DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
chan->attr.subbuf_size = default_get_ust_pid_channel_subbuf_size();
chan->attr.num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
chan->attr.subbuf_size = default_get_ust_pid_channel_subbuf_size();
chan->attr.num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
chan->attr.output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
- chan->attr.switch_timer_interval =
- DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
- chan->attr.read_timer_interval =
- DEFAULT_UST_PID_CHANNEL_READ_TIMER;
- chan->attr.live_timer_interval =
- DEFAULT_UST_PID_CHANNEL_LIVE_TIMER;
+ chan->attr.switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
+ chan->attr.read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
+ chan->attr.live_timer_interval = DEFAULT_UST_PID_CHANNEL_LIVE_TIMER;
extended_attr->blocking_timeout = DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
extended_attr->monitor_timer_interval =
DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
extended_attr->blocking_timeout = DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
extended_attr->monitor_timer_interval =
DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
- if (snprintf(chan->name, sizeof(chan->name), "%s",
- channel_name) < 0) {
+ if (snprintf(chan->name, sizeof(chan->name), "%s", channel_name) < 0) {
LTTNG_ASSERT(channel_name);
kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
LTTNG_ASSERT(channel_name);
kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
-int channel_kernel_enable(struct ltt_kernel_session *ksession,
- struct ltt_kernel_channel *kchan)
+enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
+ struct ltt_kernel_channel *kchan)
static int channel_validate_kernel(struct lttng_channel *attr)
{
/* Kernel channels do not support blocking timeout. */
static int channel_validate_kernel(struct lttng_channel *attr)
{
/* Kernel channels do not support blocking timeout. */
-int channel_kernel_create(struct ltt_kernel_session *ksession,
- struct lttng_channel *attr, int kernel_pipe)
+enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
+ struct lttng_channel *attr,
+ int kernel_pipe)
- if (attr == NULL) {
- defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL,
- LTTNG_BUFFER_GLOBAL);
- if (defattr == NULL) {
- ret = LTTNG_ERR_FATAL;
+ if (attr == nullptr) {
+ defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
+ if (defattr == nullptr) {
+ ret_code = LTTNG_ERR_FATAL;
- /* Channel not found, creating it */
- ret = kernel_create_channel(ksession, attr);
- if (ret < 0) {
- ret = LTTNG_ERR_KERN_CHAN_FAIL;
+ /* Channel not found, creating it. */
+ if (kernel_create_channel(ksession, attr) < 0) {
+ ret_code = LTTNG_ERR_KERN_CHAN_FAIL;
-int channel_ust_enable(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan)
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
-int channel_ust_create(struct ltt_ust_session *usess,
- struct lttng_channel *attr, enum lttng_buffer_type type)
+enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
+ struct lttng_channel *attr,
+ enum lttng_buffer_type type)
- int ret = LTTNG_OK;
- struct ltt_ust_channel *uchan = NULL;
- struct lttng_channel *defattr = NULL;
+ enum lttng_error_code ret_code = LTTNG_OK;
+ struct ltt_ust_channel *uchan = nullptr;
+ struct lttng_channel *defattr = nullptr;
enum lttng_domain_type domain = LTTNG_DOMAIN_UST;
bool chan_published = false;
LTTNG_ASSERT(usess);
/* Creating channel attributes if needed */
enum lttng_domain_type domain = LTTNG_DOMAIN_UST;
bool chan_published = false;
LTTNG_ASSERT(usess);
/* Creating channel attributes if needed */
* and nonzero. We validate right here for UST, because applications will
* not report the error to the user (unlike kernel tracing).
*/
* and nonzero. We validate right here for UST, because applications will
* not report the error to the user (unlike kernel tracing).
*/
- if (!attr->attr.subbuf_size ||
- (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
- ret = LTTNG_ERR_INVALID;
+ if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
+ ret_code = LTTNG_ERR_INVALID;
* Invalid subbuffer size if it's lower then the page size.
*/
if (attr->attr.subbuf_size < the_page_size) {
* Invalid subbuffer size if it's lower then the page size.
*/
if (attr->attr.subbuf_size < the_page_size) {
- if (!attr->attr.num_subbuf ||
- (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
- ret = LTTNG_ERR_INVALID;
+ if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
+ ret_code = LTTNG_ERR_INVALID;
goto error;
}
uchan->id = trace_ust_get_next_chan_id(usess);
DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
goto error;
}
uchan->id = trace_ust_get_next_chan_id(usess);
DBG2("Channel %s is being created for UST with buffer %d and id %" PRIu64,
usess->buffer_type_changed = 1;
} else if (usess->buffer_type != type) {
/* Buffer type was already set. Refuse to create channel. */
usess->buffer_type_changed = 1;
} else if (usess->buffer_type != type) {
/* Buffer type was already set. Refuse to create channel. */
- if (strncmp(uchan->name, DEFAULT_METADATA_NAME,
- sizeof(uchan->name))) {
+ if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name)) != 0) {
* application exists we can access that data in the shadow copy during
* the global update of newly registered application.
*/
* application exists we can access that data in the shadow copy during
* the global update of newly registered application.
*/
- memcpy(&usess->metadata_attr, &uchan->attr,
- sizeof(usess->metadata_attr));
+ memcpy(&usess->metadata_attr, &uchan->attr, sizeof(usess->metadata_attr));
- lttng_channel_set_blocking_timeout(
- channel, uchan->attr.u.s.blocking_timeout);
- lttng_channel_set_monitor_timer_interval(
- channel, uchan->monitor_timer_interval);
+ lttng_channel_set_blocking_timeout(channel, uchan->attr.u.s.blocking_timeout);
+ lttng_channel_set_monitor_timer_interval(channel, uchan->monitor_timer_interval);