*
*/
+#include <common/macros.hpp>
+
#include <lttng/lttng.h>
#include <inttypes.h>
#include <sys/time.h>
#include <time.h>
-#include <common/macros.hpp>
-
static int print_capture(const struct lttng_condition *condition,
- const struct lttng_event_field_value *capture,
- unsigned int indent_level);
+ const struct lttng_event_field_value *capture,
+ unsigned int indent_level);
static int print_array(const struct lttng_condition *condition,
- const struct lttng_event_field_value *array,
- unsigned int indent_level);
+ const struct lttng_event_field_value *array,
+ unsigned int indent_level);
static void indent(unsigned int indentation_level)
{
{
const char *name;
- name = lttng_event_expr_event_payload_field_get_name(
- event_expr);
+ name = lttng_event_expr_event_payload_field_get_name(event_expr);
printf("%s", name);
break;
{
const char *name;
- name = lttng_event_expr_channel_context_field_get_name(
- event_expr);
+ name = lttng_event_expr_channel_context_field_get_name(event_expr);
printf("$ctx.%s", name);
break;
const char *provider_name;
const char *type_name;
- provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(
- event_expr);
- type_name = lttng_event_expr_app_specific_context_field_get_type_name(
- event_expr);
+ provider_name =
+ lttng_event_expr_app_specific_context_field_get_provider_name(event_expr);
+ type_name = lttng_event_expr_app_specific_context_field_get_type_name(event_expr);
printf("$app.%s:%s", provider_name, type_name);
const struct lttng_event_expr *parent_expr;
enum lttng_event_expr_status status;
- parent_expr = lttng_event_expr_array_field_element_get_parent_expr(
- event_expr);
+ parent_expr = lttng_event_expr_array_field_element_get_parent_expr(event_expr);
LTTNG_ASSERT(parent_expr != NULL);
print_one_event_expr(parent_expr);
- status = lttng_event_expr_array_field_element_get_index(
- event_expr, &index);
+ status = lttng_event_expr_array_field_element_get_index(event_expr, &index);
LTTNG_ASSERT(status == LTTNG_EVENT_EXPR_STATUS_OK);
printf("[%u]", index);
}
}
-static bool action_group_contains_notify(
- const struct lttng_action *action_group)
+static bool action_group_contains_notify(const struct lttng_action *action_group)
{
unsigned int i, count;
- enum lttng_action_status status =
- lttng_action_list_get_count(action_group, &count);
+ enum lttng_action_status status = lttng_action_list_get_count(action_group, &count);
if (status != LTTNG_ACTION_STATUS_OK) {
printf("Failed to get action count from action group\n");
}
for (i = 0; i < count; i++) {
- const struct lttng_action *action =
- lttng_action_list_get_at_index(action_group, i);
- const enum lttng_action_type action_type =
- lttng_action_get_type(action);
+ const struct lttng_action *action = lttng_action_list_get_at_index(action_group, i);
+ const enum lttng_action_type action_type = lttng_action_get_type(action);
if (action_type == LTTNG_ACTION_TYPE_NOTIFY) {
return true;
}
static int print_capture(const struct lttng_condition *condition,
- const struct lttng_event_field_value *capture,
- unsigned int indent_level)
+ const struct lttng_event_field_value *capture,
+ unsigned int indent_level)
{
int ret = 0;
enum lttng_event_field_value_status event_field_status;
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT:
{
event_field_status =
- lttng_event_field_value_unsigned_int_get_value(
- capture, &u_val);
+ lttng_event_field_value_unsigned_int_get_value(capture, &u_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT:
{
- event_field_status =
- lttng_event_field_value_signed_int_get_value(
- capture, &s_val);
+ event_field_status = lttng_event_field_value_signed_int_get_value(capture, &s_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM:
{
event_field_status =
- lttng_event_field_value_unsigned_int_get_value(
- capture, &u_val);
+ lttng_event_field_value_unsigned_int_get_value(capture, &u_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM:
{
- event_field_status =
- lttng_event_field_value_signed_int_get_value(
- capture, &s_val);
+ event_field_status = lttng_event_field_value_signed_int_get_value(capture, &s_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_REAL:
{
- event_field_status = lttng_event_field_value_real_get_value(
- capture, &d_val);
+ event_field_status = lttng_event_field_value_real_get_value(capture, &d_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING:
{
- event_field_status = lttng_event_field_value_string_get_value(
- capture, &string_val);
+ event_field_status = lttng_event_field_value_string_get_value(capture, &string_val);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
}
static int print_array(const struct lttng_condition *condition,
- const struct lttng_event_field_value *array,
- unsigned int indent_level)
+ const struct lttng_event_field_value *array,
+ unsigned int indent_level)
{
int ret = 0;
enum lttng_event_field_value_status event_field_status;
unsigned int captured_field_count;
- event_field_status = lttng_event_field_value_array_get_length(
- array, &captured_field_count);
+ event_field_status = lttng_event_field_value_array_get_length(array, &captured_field_count);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
ret = 1;
goto end;
for (unsigned int i = 0; i < captured_field_count; i++) {
const struct lttng_event_field_value *captured_field = NULL;
const struct lttng_event_expr *expr =
- lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition, i);
LTTNG_ASSERT(expr);
indent(indent_level + 1);
print_one_event_expr(expr);
printf(" Value: ");
- event_field_status =
- lttng_event_field_value_array_get_element_at_index(
- array, i, &captured_field);
+ event_field_status = lttng_event_field_value_array_get_element_at_index(
+ array, i, &captured_field);
if (event_field_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
- if (event_field_status ==
- LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE) {
+ if (event_field_status == LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE) {
print_unavailabe();
} else {
ret = 1;
goto end;
}
} else {
- print_capture(condition, captured_field,
- indent_level + 1);
+ print_capture(condition, captured_field, indent_level + 1);
}
if (i + 1 < captured_field_count) {
static int print_captures(struct lttng_notification *notification)
{
int ret = 0;
- const struct lttng_evaluation *evaluation =
- lttng_notification_get_evaluation(notification);
- const struct lttng_condition *condition =
- lttng_notification_get_condition(notification);
+ const struct lttng_evaluation *evaluation = lttng_notification_get_evaluation(notification);
+ const struct lttng_condition *condition = lttng_notification_get_condition(notification);
/* Status */
enum lttng_condition_status condition_status;
unsigned int expected_capture_field_count;
LTTNG_ASSERT(lttng_evaluation_get_type(evaluation) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- condition_status =
- lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition,
- &expected_capture_field_count);
+ condition_status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
+ condition, &expected_capture_field_count);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ret = 1;
goto end;
goto end;
}
- evaluation_status =
- lttng_evaluation_event_rule_matches_get_captured_values(
- evaluation, &captured_field_array);
+ evaluation_status = lttng_evaluation_event_rule_matches_get_captured_values(
+ evaluation, &captured_field_array);
if (evaluation_status != LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK) {
ret = 1;
goto end;
static int print_notification(struct lttng_notification *notification)
{
int ret = 0;
- const struct lttng_evaluation *evaluation =
- lttng_notification_get_evaluation(notification);
- const enum lttng_condition_type type =
- lttng_evaluation_get_type(evaluation);
+ const struct lttng_evaluation *evaluation = lttng_notification_get_evaluation(notification);
+ const enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
switch (type) {
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
gettimeofday(&tv, NULL);
the_time = tv.tv_sec;
- strftime(time_str, sizeof(time_str), "[%m-%d-%Y] %T",
- localtime(&the_time));
+ strftime(time_str, sizeof(time_str), "[%m-%d-%Y] %T", localtime(&the_time));
printf("%s.%ld - ", time_str, tv.tv_usec);
trigger = lttng_notification_get_trigger(notification);
}
printf("Received notification of event rule matches trigger \"%s\"\n",
- trigger_name);
+ trigger_name);
ret = print_captures(notification);
break;
}
trigger_count = argc - 1;
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
if (!notification_channel) {
fprintf(stderr, "Failed to create notification channel\n");
ret = -1;
}
for (i = 0; i < count; i++) {
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
const struct lttng_condition *condition =
- lttng_trigger_get_const_condition(trigger);
- const struct lttng_action *action =
- lttng_trigger_get_const_action(trigger);
- const enum lttng_action_type action_type =
- lttng_action_get_type(action);
+ lttng_trigger_get_const_condition(trigger);
+ const struct lttng_action *action = lttng_trigger_get_const_action(trigger);
+ const enum lttng_action_type action_type = lttng_action_get_type(action);
enum lttng_notification_channel_status channel_status;
const char *trigger_name = NULL;
bool subscribe = false;
}
if (!((action_type == LTTNG_ACTION_TYPE_LIST &&
- action_group_contains_notify(action)) ||
- action_type == LTTNG_ACTION_TYPE_NOTIFY)) {
+ action_group_contains_notify(action)) ||
+ action_type == LTTNG_ACTION_TYPE_NOTIFY)) {
printf("The action of trigger \"%s\" is not \"notify\", skipping.\n",
- trigger_name);
+ trigger_name);
continue;
}
- channel_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
- if (channel_status ==
- LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED) {
+ channel_status =
+ lttng_notification_channel_subscribe(notification_channel, condition);
+ if (channel_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED) {
continue;
}
if (channel_status) {
- fprintf(stderr, "Failed to subscribe to notifications of trigger \"%s\"\n",
- trigger_name);
+ fprintf(stderr,
+ "Failed to subscribe to notifications of trigger \"%s\"\n",
+ trigger_name);
ret = -1;
goto end;
}
- printf("Subscribed to notifications of trigger \"%s\"\n",
- trigger_name);
+ printf("Subscribed to notifications of trigger \"%s\"\n", trigger_name);
subcription_count++;
}
struct lttng_notification *notification;
enum lttng_notification_channel_status channel_status;
- channel_status =
- lttng_notification_channel_get_next_notification(
- notification_channel,
- ¬ification);
+ channel_status = lttng_notification_channel_get_next_notification(
+ notification_channel, ¬ification);
switch (channel_status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED:
printf("Dropped notification\n");
printf("Notification channel was closed by peer.\n");
break;
default:
- fprintf(stderr, "A communication error occurred on the notification channel.\n");
+ fprintf(stderr,
+ "A communication error occurred on the notification channel.\n");
ret = -1;
goto end;
}
*/
#define _LGPL_SOURCE
+#include "health-consumerd.hpp"
+#include "lttng-consumerd.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/poll.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
+#include <inttypes.h>
#include <limits.h>
+#include <poll.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
+#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <urcu/list.h>
-#include <poll.h>
+#include <ulimit.h>
#include <unistd.h>
-#include <sys/mman.h>
#include <urcu/compiler.h>
-#include <ulimit.h>
-#include <inttypes.h>
-
-#include <common/defaults.hpp>
-#include <common/common.hpp>
-#include <common/consumer/consumer.hpp>
-#include <common/consumer/consumer-timer.hpp>
-#include <common/compat/poll.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
-
-#include "lttng-consumerd.hpp"
-#include "health-consumerd.hpp"
+#include <urcu/list.h>
/* Global health check unix path */
static char health_unix_sock_path[PATH_MAX];
-int health_quit_pipe[2] = {-1, -1};
+int health_quit_pipe[2] = { -1, -1 };
/*
* Send data on a unix socket using the liblttsessiondcomm API.
return lttcomm_send_unix_sock(sock, buf, len);
}
-static
-int setup_health_path(void)
+static int setup_health_path(void)
{
int is_root, ret = 0;
enum lttng_consumer_type type;
}
switch (type) {
case LTTNG_CONSUMER_KERNEL:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK);
break;
case LTTNG_CONSUMER64_UST:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK);
break;
case LTTNG_CONSUMER32_UST:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK);
break;
default:
ret = -EINVAL;
}
switch (type) {
case LTTNG_CONSUMER_KERNEL:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK, home_path);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK,
+ home_path);
break;
case LTTNG_CONSUMER64_UST:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK, home_path);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK,
+ home_path);
break;
case LTTNG_CONSUMER32_UST:
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK, home_path);
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK,
+ home_path);
break;
default:
ret = -EINVAL;
goto error;
}
- ret = chmod(health_unix_sock_path,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ ret = chmod(health_unix_sock_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
ERR("Unable to set permissions on %s", health_unix_sock_path);
PERROR("chmod");
DBG("Health check ready");
/* Inifinite blocking call, waiting for transmission */
-restart:
+ restart:
ret = lttng_poll_wait(&events, -1);
if (ret < 0) {
/*
/* Event on the registration socket */
if (pollfd == sock) {
- if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)
- && !(revents & LPOLLIN)) {
+ if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP) &&
+ !(revents & LPOLLIN)) {
ERR("Health socket poll error");
goto error;
}
(void) utils_set_fd_cloexec(new_sock);
DBG("Receiving data from client for health...");
- ret = lttcomm_recv_unix_sock(new_sock, (void *)&msg, sizeof(msg));
+ ret = lttcomm_recv_unix_sock(new_sock, (void *) &msg, sizeof(msg));
if (ret <= 0) {
DBG("Nothing recv() from client... continuing");
ret = close(new_sock);
*/
#define _LGPL_SOURCE
+#include "health-consumerd.hpp"
+#include "lttng-consumerd.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/poll.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <limits.h>
+#include <poll.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
+#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <urcu/list.h>
-#include <poll.h>
+#include <ulimit.h>
#include <unistd.h>
-#include <sys/mman.h>
#include <urcu/compiler.h>
-#include <ulimit.h>
-
-#include <common/defaults.hpp>
-#include <common/common.hpp>
-#include <common/consumer/consumer.hpp>
-#include <common/consumer/consumer-timer.hpp>
-#include <common/compat/poll.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
-
-#include "lttng-consumerd.hpp"
-#include "health-consumerd.hpp"
+#include <urcu/list.h>
/* threads (channel handling, poll, metadata, sessiond) */
-static pthread_t channel_thread, data_thread, metadata_thread,
- sessiond_thread, metadata_timer_thread, health_thread;
+static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread,
+ metadata_timer_thread, health_thread;
static bool metadata_timer_thread_online;
/* to count the number of times the user pressed ctrl+c */
static int sigintcount = 0;
/* Argument variables */
-int lttng_opt_quiet; /* not static in error.h */
-int lttng_opt_verbose; /* not static in error.h */
-int lttng_opt_mi; /* not static in error.h */
+int lttng_opt_quiet; /* not static in error.h */
+int lttng_opt_verbose; /* not static in error.h */
+int lttng_opt_mi; /* not static in error.h */
static int opt_daemon;
static const char *progname;
/*
* Signal handler for the daemon
*/
-static void sighandler(int sig, siginfo_t *siginfo,
- void *arg __attribute__((unused)))
+static void sighandler(int sig, siginfo_t *siginfo, void *arg __attribute__((unused)))
{
if (sig == SIGINT && sigintcount++ == 0) {
DBG("ignoring first SIGINT");
static void usage(FILE *fp)
{
fprintf(fp, "Usage: %s OPTIONS\n\nOptions:\n", progname);
- fprintf(fp, " -h, --help "
- "Display this usage.\n");
- fprintf(fp, " -c, --consumerd-cmd-sock PATH "
- "Specify path for the command socket\n");
- fprintf(fp, " -e, --consumerd-err-sock PATH "
- "Specify path for the error socket\n");
- fprintf(fp, " -d, --daemonize "
- "Start as a daemon.\n");
- fprintf(fp, " -q, --quiet "
- "No output at all.\n");
- fprintf(fp, " -v, --verbose "
- "Verbose mode. Activate DBG() macro.\n");
- fprintf(fp, " -V, --version "
- "Show version number.\n");
- fprintf(fp, " -g, --group NAME "
- "Specify the tracing group name. (default: tracing)\n");
- fprintf(fp, " -k, --kernel "
- "Consumer kernel buffers (default).\n");
- fprintf(fp, " -u, --ust "
- "Consumer UST buffers.%s\n",
+ fprintf(fp,
+ " -h, --help "
+ "Display this usage.\n");
+ fprintf(fp,
+ " -c, --consumerd-cmd-sock PATH "
+ "Specify path for the command socket\n");
+ fprintf(fp,
+ " -e, --consumerd-err-sock PATH "
+ "Specify path for the error socket\n");
+ fprintf(fp,
+ " -d, --daemonize "
+ "Start as a daemon.\n");
+ fprintf(fp,
+ " -q, --quiet "
+ "No output at all.\n");
+ fprintf(fp,
+ " -v, --verbose "
+ "Verbose mode. Activate DBG() macro.\n");
+ fprintf(fp,
+ " -V, --version "
+ "Show version number.\n");
+ fprintf(fp,
+ " -g, --group NAME "
+ "Specify the tracing group name. (default: tracing)\n");
+ fprintf(fp,
+ " -k, --kernel "
+ "Consumer kernel buffers (default).\n");
+ fprintf(fp,
+ " -u, --ust "
+ "Consumer UST buffers.%s\n",
#ifdef HAVE_LIBLTTNG_UST_CTL
- ""
+ ""
#else
- " (support not compiled in)"
+ " (support not compiled in)"
#endif
- );
+ );
}
/*
{
int c, ret = 0;
- static struct option long_options[] = {
- { "consumerd-cmd-sock", 1, 0, 'c' },
- { "consumerd-err-sock", 1, 0, 'e' },
- { "daemonize", 0, 0, 'd' },
- { "group", 1, 0, 'g' },
- { "help", 0, 0, 'h' },
- { "quiet", 0, 0, 'q' },
- { "verbose", 0, 0, 'v' },
- { "version", 0, 0, 'V' },
- { "kernel", 0, 0, 'k' },
+ static struct option long_options[] = { { "consumerd-cmd-sock", 1, 0, 'c' },
+ { "consumerd-err-sock", 1, 0, 'e' },
+ { "daemonize", 0, 0, 'd' },
+ { "group", 1, 0, 'g' },
+ { "help", 0, 0, 'h' },
+ { "quiet", 0, 0, 'q' },
+ { "verbose", 0, 0, 'v' },
+ { "version", 0, 0, 'V' },
+ { "kernel", 0, 0, 'k' },
#ifdef HAVE_LIBLTTNG_UST_CTL
- { "ust", 0, 0, 'u' },
+ { "ust", 0, 0, 'u' },
#endif
- { NULL, 0, 0, 0 }
- };
+ { NULL, 0, 0, 0 } };
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "dhqvVku" "c:e:g:",
- long_options, &option_index);
+ c = getopt_long(argc,
+ argv,
+ "dhqvVku"
+ "c:e:g:",
+ long_options,
+ &option_index);
if (c == -1) {
break;
}
switch (c) {
case 0:
- fprintf(stderr, "option %s",
- long_options[option_index].name);
+ fprintf(stderr, "option %s", long_options[option_index].name);
if (optarg) {
fprintf(stderr, " with arg %s\n", optarg);
ret = -1;
case 'c':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-c, --consumerd-cmd-sock");
+ "-c, --consumerd-cmd-sock");
} else {
snprintf(command_sock_path, PATH_MAX, "%s", optarg);
}
case 'e':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-e, --consumerd-err-sock");
+ "-e, --consumerd-err-sock");
} else {
snprintf(error_sock_path, PATH_MAX, "%s", optarg);
}
case 'g':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-g, --group");
+ "-g, --group");
} else {
tracing_group_name = optarg;
}
break;
#ifdef HAVE_LIBLTTNG_UST_CTL
case 'u':
-# if (CAA_BITS_PER_LONG == 64)
+#if (CAA_BITS_PER_LONG == 64)
opt_type = LTTNG_CONSUMER64_UST;
-# elif (CAA_BITS_PER_LONG == 32)
+#elif (CAA_BITS_PER_LONG == 32)
opt_type = LTTNG_CONSUMER32_UST;
-# else
-# error "Unknown bitness"
-# endif
+#else
+#error "Unknown bitness"
+#endif
break;
#endif
default:
if (*command_sock_path == '\0') {
switch (opt_type) {
case LTTNG_CONSUMER_KERNEL:
- ret = snprintf(command_sock_path, PATH_MAX,
- DEFAULT_KCONSUMERD_CMD_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(command_sock_path,
+ PATH_MAX,
+ DEFAULT_KCONSUMERD_CMD_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
break;
case LTTNG_CONSUMER64_UST:
- ret = snprintf(command_sock_path, PATH_MAX,
- DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(command_sock_path,
+ PATH_MAX,
+ DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
break;
case LTTNG_CONSUMER32_UST:
- ret = snprintf(command_sock_path, PATH_MAX,
- DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(command_sock_path,
+ PATH_MAX,
+ DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
/* create the consumer instance with and assign the callbacks */
- the_consumer_context = lttng_consumer_create(opt_type, lttng_consumer_read_subbuffer,
- NULL, lttng_consumer_on_recv_stream, NULL);
+ the_consumer_context = lttng_consumer_create(
+ opt_type, lttng_consumer_read_subbuffer, NULL, lttng_consumer_on_recv_stream, NULL);
if (!the_consumer_context) {
retval = -1;
goto exit_init_data;
if (*error_sock_path == '\0') {
switch (opt_type) {
case LTTNG_CONSUMER_KERNEL:
- ret = snprintf(error_sock_path, PATH_MAX,
- DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(error_sock_path,
+ PATH_MAX,
+ DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
break;
case LTTNG_CONSUMER64_UST:
- ret = snprintf(error_sock_path, PATH_MAX,
- DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(error_sock_path,
+ PATH_MAX,
+ DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
break;
case LTTNG_CONSUMER32_UST:
- ret = snprintf(error_sock_path, PATH_MAX,
- DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH,
- DEFAULT_LTTNG_RUNDIR);
+ ret = snprintf(error_sock_path,
+ PATH_MAX,
+ DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH,
+ DEFAULT_LTTNG_RUNDIR);
if (ret < 0) {
retval = -1;
goto exit_init_data;
}
/* Create thread to manage the client socket */
- ret = pthread_create(&health_thread, default_pthread_attr(),
- thread_manage_health_consumerd, (void *) NULL);
+ ret = pthread_create(&health_thread,
+ default_pthread_attr(),
+ thread_manage_health_consumerd,
+ (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create health");
while (uatomic_read(<tng_consumer_ready)) {
usleep(100000);
}
- cmm_smp_mb(); /* Read ready before following operations */
+ cmm_smp_mb(); /* Read ready before following operations */
/*
* Create the thread to manage the UST metadata periodic timer and
* live timer.
*/
- ret = pthread_create(&metadata_timer_thread, NULL,
- consumer_timer_thread, (void *) the_consumer_context);
+ ret = pthread_create(
+ &metadata_timer_thread, NULL, consumer_timer_thread, (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
metadata_timer_thread_online = true;
/* Create thread to manage channels */
- ret = pthread_create(&channel_thread, default_pthread_attr(),
- consumer_thread_channel_poll,
- (void *) the_consumer_context);
+ ret = pthread_create(&channel_thread,
+ default_pthread_attr(),
+ consumer_thread_channel_poll,
+ (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
}
/* Create thread to manage the polling/writing of trace metadata */
- ret = pthread_create(&metadata_thread, default_pthread_attr(),
- consumer_thread_metadata_poll,
- (void *) the_consumer_context);
+ ret = pthread_create(&metadata_thread,
+ default_pthread_attr(),
+ consumer_thread_metadata_poll,
+ (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
}
/* Create thread to manage the polling/writing of trace data */
- ret = pthread_create(&data_thread, default_pthread_attr(),
- consumer_thread_data_poll, (void *) the_consumer_context);
+ ret = pthread_create(&data_thread,
+ default_pthread_attr(),
+ consumer_thread_data_poll,
+ (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
}
/* Create the thread to manage the reception of fds */
- ret = pthread_create(&sessiond_thread, default_pthread_attr(),
- consumer_thread_sessiond_poll,
- (void *) the_consumer_context);
+ ret = pthread_create(&sessiond_thread,
+ default_pthread_attr(),
+ consumer_thread_sessiond_poll,
+ (void *) the_consumer_context);
if (ret) {
errno = ret;
PERROR("pthread_create");
goto exit_sessiond_thread;
}
-
/*
* This is where we start awaiting program completion (e.g. through
* signal that asks threads to teardown.
}
tmp_ctx = the_consumer_context;
the_consumer_context = NULL;
- cmm_barrier(); /* Clear ctx for signal handler. */
+ cmm_barrier(); /* Clear ctx for signal handler. */
lttng_consumer_destroy(tmp_ctx);
if (health_consumerd) {
*
*/
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/spawn-viewer.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <fcntl.h>
#include <getopt.h>
+#include <inttypes.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <common/compat/endian.hpp>
-#include <inttypes.h>
-#include <stdbool.h>
-
#include <version.hpp>
-#include <lttng/lttng.h>
-#include <common/common.hpp>
-#include <common/spawn-viewer.hpp>
-#include <common/utils.hpp>
-#define COPY_BUFLEN 4096
-#define RB_CRASH_DUMP_ABI_LEN 32
+#define COPY_BUFLEN 4096
+#define RB_CRASH_DUMP_ABI_LEN 32
-#define RB_CRASH_DUMP_ABI_MAGIC_LEN 16
+#define RB_CRASH_DUMP_ABI_MAGIC_LEN 16
/*
* The 128-bit magic number is xor'd in the process data so it does not
* 0x17, 0x7B, 0xF1, 0x77, 0xBF, 0x17, 0x7B, 0xF1,
* 0x77, 0xBF, 0x17, 0x7B, 0xF1, 0x77, 0xBF, 0x17,
*/
-#define RB_CRASH_DUMP_ABI_MAGIC_XOR \
- { \
- 0x17 ^ 0xFF, 0x7B ^ 0xFF, 0xF1 ^ 0xFF, 0x77 ^ 0xFF, \
- 0xBF ^ 0xFF, 0x17 ^ 0xFF, 0x7B ^ 0xFF, 0xF1 ^ 0xFF, \
- 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, 0x7B ^ 0xFF, \
- 0xF1 ^ 0xFF, 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, \
+#define RB_CRASH_DUMP_ABI_MAGIC_XOR \
+ { \
+ 0x17 ^ 0xFF, 0x7B ^ 0xFF, 0xF1 ^ 0xFF, 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, \
+ 0x7B ^ 0xFF, 0xF1 ^ 0xFF, 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, \
+ 0x7B ^ 0xFF, 0xF1 ^ 0xFF, 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, \
}
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
#include <lttng-crash.1.h>
#else
-NULL
+ NULL
#endif
-;
+ ;
/*
* Non-static to ensure the compiler does not optimize away the xor.
*/
uint8_t lttng_crash_expected_magic_xor[] = RB_CRASH_DUMP_ABI_MAGIC_XOR;
-#define RB_CRASH_ENDIAN 0x1234
-#define RB_CRASH_ENDIAN_REVERSE 0x3412
+#define RB_CRASH_ENDIAN 0x1234
+#define RB_CRASH_ENDIAN_REVERSE 0x3412
enum lttng_crash_type {
LTTNG_CRASH_TYPE_UST = 0,
/* LTTng ring buffer defines (copied) */
-#define HALF_ULONG_BITS(wl) (((wl) * CHAR_BIT) >> 1)
+#define HALF_ULONG_BITS(wl) (((wl) *CHAR_BIT) >> 1)
-#define SB_ID_OFFSET_SHIFT(wl) (HALF_ULONG_BITS(wl) + 1)
-#define SB_ID_OFFSET_COUNT(wl) (1UL << SB_ID_OFFSET_SHIFT(wl))
-#define SB_ID_OFFSET_MASK(wl) (~(SB_ID_OFFSET_COUNT(wl) - 1))
+#define SB_ID_OFFSET_SHIFT(wl) (HALF_ULONG_BITS(wl) + 1)
+#define SB_ID_OFFSET_COUNT(wl) (1UL << SB_ID_OFFSET_SHIFT(wl))
+#define SB_ID_OFFSET_MASK(wl) (~(SB_ID_OFFSET_COUNT(wl) - 1))
/*
* Lowest bit of top word half belongs to noref. Used only for overwrite mode.
*/
-#define SB_ID_NOREF_SHIFT(wl) (SB_ID_OFFSET_SHIFT(wl) - 1)
-#define SB_ID_NOREF_COUNT(wl) (1UL << SB_ID_NOREF_SHIFT(wl))
-#define SB_ID_NOREF_MASK(wl) SB_ID_NOREF_COUNT(wl)
+#define SB_ID_NOREF_SHIFT(wl) (SB_ID_OFFSET_SHIFT(wl) - 1)
+#define SB_ID_NOREF_COUNT(wl) (1UL << SB_ID_NOREF_SHIFT(wl))
+#define SB_ID_NOREF_MASK(wl) SB_ID_NOREF_COUNT(wl)
/*
* In overwrite mode: lowest half of word is used for index.
* Limit of 2^16 subbuffers per buffer on 32-bit, 2^32 on 64-bit.
* In producer-consumer mode: whole word used for index.
*/
-#define SB_ID_INDEX_SHIFT(wl) 0
-#define SB_ID_INDEX_COUNT(wl) (1UL << SB_ID_INDEX_SHIFT(wl))
-#define SB_ID_INDEX_MASK(wl) (SB_ID_NOREF_COUNT(wl) - 1)
+#define SB_ID_INDEX_SHIFT(wl) 0
+#define SB_ID_INDEX_COUNT(wl) (1UL << SB_ID_INDEX_SHIFT(wl))
+#define SB_ID_INDEX_MASK(wl) (SB_ID_NOREF_COUNT(wl) - 1)
enum rb_modes {
- RING_BUFFER_OVERWRITE = 0, /* Overwrite when buffer full */
- RING_BUFFER_DISCARD = 1, /* Discard when buffer full */
+ RING_BUFFER_OVERWRITE = 0, /* Overwrite when buffer full */
+ RING_BUFFER_DISCARD = 1, /* Discard when buffer full */
};
namespace {
struct crash_abi_unknown {
uint8_t magic[RB_CRASH_DUMP_ABI_MAGIC_LEN];
- uint64_t mmap_length; /* Overall length of crash record */
- uint16_t endian; /*
- * { 0x12, 0x34 }: big endian
- * { 0x34, 0x12 }: little endian
- */
- uint16_t major; /* Major number. */
- uint16_t minor; /* Minor number. */
- uint8_t word_size; /* Word size (bytes). */
- uint8_t layout_type; /* enum lttng_crash_layout */
+ uint64_t mmap_length; /* Overall length of crash record */
+ uint16_t endian; /*
+ * { 0x12, 0x34 }: big endian
+ * { 0x34, 0x12 }: little endian
+ */
+ uint16_t major; /* Major number. */
+ uint16_t minor; /* Minor number. */
+ uint8_t word_size; /* Word size (bytes). */
+ uint8_t layout_type; /* enum lttng_crash_layout */
} __attribute__((packed));
struct crash_abi_0_0 {
uint32_t sb_array;
} __attribute__((packed)) stride;
- uint64_t buf_size; /* Size of the buffer */
- uint64_t subbuf_size; /* Sub-buffer size */
- uint64_t num_subbuf; /* Number of sub-buffers for writer */
- uint32_t mode; /* Buffer mode: 0: overwrite, 1: discard */
+ uint64_t buf_size; /* Size of the buffer */
+ uint64_t subbuf_size; /* Sub-buffer size */
+ uint64_t num_subbuf; /* Number of sub-buffers for writer */
+ uint32_t mode; /* Buffer mode: 0: overwrite, 1: discard */
} __attribute__((packed));
struct lttng_crash_layout {
struct {
- int prod_offset, consumed_offset,
- commit_hot_array, commit_hot_seq,
- buf_wsb_array, buf_wsb_id,
- sb_array, sb_array_shmp_offset,
- sb_backend_p_offset, content_size,
- packet_size;
+ int prod_offset, consumed_offset, commit_hot_array, commit_hot_seq, buf_wsb_array,
+ buf_wsb_id, sb_array, sb_array_shmp_offset, sb_backend_p_offset,
+ content_size, packet_size;
} offset;
struct {
- int prod_offset, consumed_offset,
- commit_hot_seq, buf_wsb_id,
- sb_array_shmp_offset, sb_backend_p_offset,
- content_size, packet_size;
+ int prod_offset, consumed_offset, commit_hot_seq, buf_wsb_id, sb_array_shmp_offset,
+ sb_backend_p_offset, content_size, packet_size;
} length;
struct {
int commit_hot_array, buf_wsb_array, sb_array;
int reverse_byte_order;
int word_size;
- uint64_t mmap_length; /* Length of crash record */
- uint64_t buf_size; /* Size of the buffer */
- uint64_t subbuf_size; /* Sub-buffer size */
- uint64_t num_subbuf; /* Number of sub-buffers for writer */
- uint32_t mode; /* Buffer mode: 0: overwrite, 1: discard */
+ uint64_t mmap_length; /* Length of crash record */
+ uint64_t buf_size; /* Size of the buffer */
+ uint64_t subbuf_size; /* Sub-buffer size */
+ uint64_t num_subbuf; /* Number of sub-buffers for writer */
+ uint32_t mode; /* Buffer mode: 0: overwrite, 1: discard */
};
} /* namespace */
/* Getopt options. No first level command. */
static struct option long_options[] = {
- { "version", 0, NULL, 'V' },
- { "help", 0, NULL, 'h' },
- { "verbose", 0, NULL, 'v' },
- { "viewer", 1, NULL, 'e' },
- { "extract", 1, NULL, 'x' },
- { "list-options", 0, NULL, OPT_DUMP_OPTIONS },
+ { "version", 0, NULL, 'V' }, { "help", 0, NULL, 'h' },
+ { "verbose", 0, NULL, 'v' }, { "viewer", 1, NULL, 'e' },
+ { "extract", 1, NULL, 'x' }, { "list-options", 0, NULL, OPT_DUMP_OPTIONS },
{ NULL, 0, NULL, 0 },
};
static void version(FILE *ofp)
{
- fprintf(ofp, "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME
- "%s%s\n",
- progname,
- GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
- EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+ fprintf(ofp,
+ "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME "%s%s\n",
+ progname,
+ GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+ EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
}
/*
return -1;
}
-static
-int copy_file(const char *file_dest, const char *file_src)
+static int copy_file(const char *file_dest, const char *file_src)
{
int fd_src = -1, fd_dest = -1;
ssize_t readlen, writelen;
ret = -errno;
goto error;
}
- fd_dest = open(file_dest, O_RDWR | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ fd_dest = open(file_dest, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (fd_dest < 0) {
PERROR("Error opening %s for writing", file_dest);
ret = -errno;
return ret;
}
-static
-uint64_t _crash_get_field(const struct lttng_crash_layout *layout,
- const char *ptr, size_t size)
+static uint64_t
+_crash_get_field(const struct lttng_crash_layout *layout, const char *ptr, size_t size)
{
switch (size) {
- case 1: return *(uint8_t *) ptr;
- case 2: if (layout->reverse_byte_order) {
+ case 1:
+ return *(uint8_t *) ptr;
+ case 2:
+ if (layout->reverse_byte_order) {
return bswap_16(*(uint16_t *) ptr);
} else {
return *(uint16_t *) ptr;
-
}
- case 4: if (layout->reverse_byte_order) {
+ case 4:
+ if (layout->reverse_byte_order) {
return bswap_32(*(uint32_t *) ptr);
} else {
return *(uint32_t *) ptr;
-
}
- case 8: if (layout->reverse_byte_order) {
+ case 8:
+ if (layout->reverse_byte_order) {
return bswap_64(*(uint64_t *) ptr);
} else {
return *(uint64_t *) ptr;
abort();
return -1;
}
-
}
-#define crash_get_field(layout, map, name) \
- _crash_get_field(layout, (map) + (layout)->offset.name, \
- layout->length.name)
-
-#define crash_get_array_field(layout, map, array_name, idx, field_name) \
- _crash_get_field(layout, \
- (map) + (layout)->offset.array_name \
- + (idx * (layout)->stride.array_name) \
- + (layout)->offset.field_name, \
- (layout)->length.field_name)
-
-#define crash_get_hdr_raw_field(layout, hdr, name) ((hdr)->name)
-
-#define crash_get_hdr_field(layout, hdr, name) \
- _crash_get_field(layout, (const char *) &(hdr)->name, \
- sizeof((hdr)->name))
-
-#define crash_get_layout(layout, hdr, name) \
- do { \
- (layout)->name = crash_get_hdr_field(layout, hdr, \
- name); \
- DBG("layout.%s = %" PRIu64, #name, \
- (uint64_t) (layout)->name); \
+#define crash_get_field(layout, map, name) \
+ _crash_get_field(layout, (map) + (layout)->offset.name, layout->length.name)
+
+#define crash_get_array_field(layout, map, array_name, idx, field_name) \
+ _crash_get_field(layout, \
+ (map) + (layout)->offset.array_name + \
+ (idx * (layout)->stride.array_name) + \
+ (layout)->offset.field_name, \
+ (layout)->length.field_name)
+
+#define crash_get_hdr_raw_field(layout, hdr, name) ((hdr)->name)
+
+#define crash_get_hdr_field(layout, hdr, name) \
+ _crash_get_field(layout, (const char *) &(hdr)->name, sizeof((hdr)->name))
+
+#define crash_get_layout(layout, hdr, name) \
+ do { \
+ (layout)->name = crash_get_hdr_field(layout, hdr, name); \
+ DBG("layout.%s = %" PRIu64, #name, (uint64_t) (layout)->name); \
} while (0)
-static
-int get_crash_layout_0_0(struct lttng_crash_layout *layout,
- char *map)
+static int get_crash_layout_0_0(struct lttng_crash_layout *layout, char *map)
{
const struct crash_abi_0_0 *abi = (const struct crash_abi_0_0 *) map;
return 0;
}
-static
-void print_dbg_magic(const uint8_t *magic)
+static void print_dbg_magic(const uint8_t *magic)
{
DBG("magic: 0x%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X",
- magic[0], magic[1], magic[2], magic[3],
- magic[4], magic[5], magic[6], magic[7],
- magic[8], magic[9], magic[10], magic[11],
- magic[12], magic[13], magic[14], magic[15]);
+ magic[0],
+ magic[1],
+ magic[2],
+ magic[3],
+ magic[4],
+ magic[5],
+ magic[6],
+ magic[7],
+ magic[8],
+ magic[9],
+ magic[10],
+ magic[11],
+ magic[12],
+ magic[13],
+ magic[14],
+ magic[15]);
}
-static
-int check_magic(const uint8_t *magic)
+static int check_magic(const uint8_t *magic)
{
int i;
return 0;
}
-static
-int get_crash_layout(struct lttng_crash_layout *layout, int fd,
- const char *input_file)
+static int get_crash_layout(struct lttng_crash_layout *layout, int fd, const char *input_file)
{
char *map;
int ret = 0, unmapret;
}
if (stat.st_size < RB_CRASH_DUMP_ABI_LEN) {
ERR("File '%s' truncated: file length of %" PRIi64
- " bytes does not meet the minimal expected "
- "length of %d bytes",
- input_file, (int64_t) stat.st_size,
- RB_CRASH_DUMP_ABI_LEN);
+ " bytes does not meet the minimal expected "
+ "length of %d bytes",
+ input_file,
+ (int64_t) stat.st_size,
+ RB_CRASH_DUMP_ABI_LEN);
return -1;
}
- map = (char *) mmap(NULL, RB_CRASH_DUMP_ABI_LEN, PROT_READ, MAP_PRIVATE,
- fd, 0);
+ map = (char *) mmap(NULL, RB_CRASH_DUMP_ABI_LEN, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) {
PERROR("Mapping file");
return -1;
print_dbg_magic(magic);
if (check_magic(magic)) {
DBG("Unknown magic number");
- ret = 1; /* positive return value, skip */
+ ret = 1; /* positive return value, skip */
goto end;
}
endian = crash_get_hdr_field(layout, abi, endian);
break;
default:
DBG("Unknown endianness value: 0x%X", (unsigned int) endian);
- ret = 1; /* positive return value, skip */
+ ret = 1; /* positive return value, skip */
goto end;
}
layout_type = (enum lttng_crash_type) crash_get_hdr_field(layout, abi, layout_type);
break;
case LTTNG_CRASH_TYPE_KERNEL:
ERR("lttng-modules buffer layout support not implemented");
- ret = 1; /* positive return value, skip */
+ ret = 1; /* positive return value, skip */
goto end;
default:
ERR("Unknown layout type %u", (unsigned int) layout_type);
- ret = 1; /* positive return value, skip */
+ ret = 1; /* positive return value, skip */
goto end;
}
mmap_length = crash_get_hdr_field(layout, abi, mmap_length);
}
/* buf_trunc mask selects only the buffer number. */
-static inline
-uint64_t buf_trunc(uint64_t offset, uint64_t buf_size)
+static inline uint64_t buf_trunc(uint64_t offset, uint64_t buf_size)
{
return offset & ~(buf_size - 1);
}
/* subbuf_trunc mask selects the subbuffer number. */
-static inline
-uint64_t subbuf_trunc(uint64_t offset, uint64_t subbuf_size)
+static inline uint64_t subbuf_trunc(uint64_t offset, uint64_t subbuf_size)
{
return offset & ~(subbuf_size - 1);
}
/* buf_offset mask selects only the offset within the current buffer. */
-static inline
-uint64_t buf_offset(uint64_t offset, uint64_t buf_size)
+static inline uint64_t buf_offset(uint64_t offset, uint64_t buf_size)
{
return offset & (buf_size - 1);
}
/* subbuf_offset mask selects the offset within the current subbuffer. */
-static inline
-uint64_t subbuf_offset(uint64_t offset, uint64_t subbuf_size)
+static inline uint64_t subbuf_offset(uint64_t offset, uint64_t subbuf_size)
{
return offset & (subbuf_size - 1);
}
/* subbuf_index returns the index of the current subbuffer within the buffer. */
-static inline
-uint64_t subbuf_index(uint64_t offset, uint64_t buf_size, uint64_t subbuf_size)
+static inline uint64_t subbuf_index(uint64_t offset, uint64_t buf_size, uint64_t subbuf_size)
{
return buf_offset(offset, buf_size) / subbuf_size;
}
-static inline
-uint64_t subbuffer_id_get_index(uint32_t mode, uint64_t id,
- unsigned int wl)
+static inline uint64_t subbuffer_id_get_index(uint32_t mode, uint64_t id, unsigned int wl)
{
if (mode == RING_BUFFER_OVERWRITE)
return id & SB_ID_INDEX_MASK(wl);
return id;
}
-static
-int copy_crash_subbuf(const struct lttng_crash_layout *layout,
- int fd_dest, char *buf, uint64_t offset)
+static int
+copy_crash_subbuf(const struct lttng_crash_layout *layout, int fd_dest, char *buf, uint64_t offset)
{
- uint64_t buf_size, subbuf_size, num_subbuf, sbidx, id,
- sb_bindex, rpages_offset, p_offset, seq_cc,
- committed, commit_count_mask, consumed_cur,
- packet_size;
+ uint64_t buf_size, subbuf_size, num_subbuf, sbidx, id, sb_bindex, rpages_offset, p_offset,
+ seq_cc, committed, commit_count_mask, consumed_cur, packet_size;
char *subbuf_ptr;
ssize_t writelen;
num_subbuf = layout->num_subbuf;
switch (layout->word_size) {
- case 4: commit_count_mask = 0xFFFFFFFFULL / num_subbuf;
+ case 4:
+ commit_count_mask = 0xFFFFFFFFULL / num_subbuf;
break;
- case 8: commit_count_mask = 0xFFFFFFFFFFFFFFFFULL / num_subbuf;
+ case 8:
+ commit_count_mask = 0xFFFFFFFFFFFFFFFFULL / num_subbuf;
break;
default:
- ERR("Unsupported word size: %u",
- (unsigned int) layout->word_size);
+ ERR("Unsupported word size: %u", (unsigned int) layout->word_size);
return -EINVAL;
}
* Find where the seq cc is located. Compute length of data to
* copy.
*/
- seq_cc = crash_get_array_field(layout, buf, commit_hot_array,
- sbidx, commit_hot_seq);
+ seq_cc = crash_get_array_field(layout, buf, commit_hot_array, sbidx, commit_hot_seq);
consumed_cur = crash_get_field(layout, buf, consumed_offset);
/*
* Check that the buffer we are getting is after or at
* consumed_cur position.
*/
- if ((long) subbuf_trunc(offset, subbuf_size)
- - (long) subbuf_trunc(consumed_cur, subbuf_size) < 0) {
+ if ((long) subbuf_trunc(offset, subbuf_size) -
+ (long) subbuf_trunc(consumed_cur, subbuf_size) <
+ 0) {
DBG("No data: position is before consumed_cur");
goto nodata;
}
/*
* Check if subbuffer has been fully committed.
*/
- if (((seq_cc - subbuf_size) & commit_count_mask)
- - (buf_trunc(offset, buf_size) / num_subbuf)
- == 0) {
+ if (((seq_cc - subbuf_size) & commit_count_mask) -
+ (buf_trunc(offset, buf_size) / num_subbuf) ==
+ 0) {
committed = subbuf_size;
} else {
committed = subbuf_offset(seq_cc, subbuf_size);
}
/* Find actual physical offset in subbuffer table */
- id = crash_get_array_field(layout, buf, buf_wsb_array,
- sbidx, buf_wsb_id);
- sb_bindex = subbuffer_id_get_index(layout->mode, id,
- layout->word_size);
- rpages_offset = crash_get_array_field(layout, buf, sb_array,
- sb_bindex, sb_array_shmp_offset);
- p_offset = crash_get_field(layout, buf + rpages_offset,
- sb_backend_p_offset);
+ id = crash_get_array_field(layout, buf, buf_wsb_array, sbidx, buf_wsb_id);
+ sb_bindex = subbuffer_id_get_index(layout->mode, id, layout->word_size);
+ rpages_offset =
+ crash_get_array_field(layout, buf, sb_array, sb_bindex, sb_array_shmp_offset);
+ p_offset = crash_get_field(layout, buf + rpages_offset, sb_backend_p_offset);
subbuf_ptr = buf + p_offset;
if (committed == subbuf_size) {
*/
if (layout->length.packet_size) {
memcpy(&packet_size,
- subbuf_ptr + layout->offset.packet_size,
- layout->length.packet_size);
+ subbuf_ptr + layout->offset.packet_size,
+ layout->length.packet_size);
if (layout->reverse_byte_order) {
packet_size = bswap_64(packet_size);
}
}
if (layout->length.content_size) {
memcpy(subbuf_ptr + layout->offset.content_size,
- &patch_size, layout->length.content_size);
+ &patch_size,
+ layout->length.content_size);
}
if (layout->length.packet_size) {
memcpy(subbuf_ptr + layout->offset.packet_size,
- &patch_size, layout->length.packet_size);
+ &patch_size,
+ layout->length.packet_size);
}
packet_size = committed;
}
return -ENODATA;
}
-static
-int copy_crash_data(const struct lttng_crash_layout *layout, int fd_dest,
- int fd_src)
+static int copy_crash_data(const struct lttng_crash_layout *layout, int fd_dest, int fd_src)
{
char *buf;
int ret = 0, has_data = 0;
DBG("consumed_offset: 0x%" PRIx64, consumed_offset);
subbuf_size = layout->subbuf_size;
- for (offset = consumed_offset; offset < prod_offset;
- offset += subbuf_size) {
+ for (offset = consumed_offset; offset < prod_offset; offset += subbuf_size) {
ret = copy_crash_subbuf(layout, fd_dest, buf, offset);
if (!ret) {
has_data = 1;
}
}
-static
-int extract_file(int output_dir_fd, const char *output_file,
- int input_dir_fd, const char *input_file)
+static int
+extract_file(int output_dir_fd, const char *output_file, int input_dir_fd, const char *input_file)
{
int fd_dest, fd_src, ret = 0, closeret;
struct lttng_crash_layout layout;
- layout.reverse_byte_order = 0; /* For reading magic number */
+ layout.reverse_byte_order = 0; /* For reading magic number */
DBG("Extract file '%s'", input_file);
fd_src = openat(input_dir_fd, input_file, O_RDONLY);
if (fd_src < 0) {
- PERROR("Error opening '%s' for reading",
- input_file);
+ PERROR("Error opening '%s' for reading", input_file);
ret = -1;
goto end;
}
goto close_src;
}
- fd_dest = openat(output_dir_fd, output_file,
- O_RDWR | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ fd_dest = openat(output_dir_fd,
+ output_file,
+ O_RDWR | O_CREAT | O_EXCL,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (fd_dest < 0) {
- PERROR("Error opening '%s' for writing",
- output_file);
+ PERROR("Error opening '%s' for writing", output_file);
ret = -1;
goto close_src;
}
return ret;
}
-static
-int extract_all_files(const char *output_path,
- const char *input_path)
+static int extract_all_files(const char *output_path, const char *input_path)
{
DIR *input_dir, *output_dir;
int input_dir_fd, output_dir_fd, ret = 0, closeret;
- struct dirent *entry; /* input */
+ struct dirent *entry; /* input */
/* Open input directory */
input_dir = opendir(input_path);
}
while ((entry = readdir(input_dir))) {
- if (!strcmp(entry->d_name, ".")
- || !strcmp(entry->d_name, ".."))
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
continue;
- ret = extract_file(output_dir_fd, entry->d_name,
- input_dir_fd, entry->d_name);
+ ret = extract_file(output_dir_fd, entry->d_name, input_dir_fd, entry->d_name);
if (ret == -ENODATA) {
DBG("No data in file '%s', skipping", entry->d_name);
ret = 0;
return ret;
}
-static
-int extract_one_trace(const char *output_path,
- const char *input_path)
+static int extract_one_trace(const char *output_path, const char *input_path)
{
char dest[PATH_MAX], src[PATH_MAX];
int ret;
return extract_all_files(output_path, input_path);
}
-static
-int extract_trace_recursive(const char *output_path,
- const char *input_path)
+static int extract_trace_recursive(const char *output_path, const char *input_path)
{
DIR *dir;
int dir_fd, ret = 0, closeret;
size_t name_len;
char filename[PATH_MAX];
- if (!strcmp(entry->d_name, ".")
- || !strcmp(entry->d_name, "..")) {
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
name_len = strlen(entry->d_name);
if (path_len + name_len + 2 > sizeof(filename)) {
ERR("Failed to remove file: path name too long (%s/%s)",
- input_path, entry->d_name);
+ input_path,
+ entry->d_name);
continue;
}
- if (snprintf(filename, sizeof(filename), "%s/%s",
- input_path, entry->d_name) < 0) {
+ if (snprintf(filename, sizeof(filename), "%s/%s", input_path, entry->d_name) < 0) {
ERR("Failed to format path.");
continue;
}
char output_subpath[PATH_MAX];
char input_subpath[PATH_MAX];
- strncpy(output_subpath, output_path,
- sizeof(output_subpath));
+ strncpy(output_subpath, output_path, sizeof(output_subpath));
output_subpath[sizeof(output_subpath) - 1] = '\0';
- strncat(output_subpath, "/",
+ strncat(output_subpath,
+ "/",
sizeof(output_subpath) - strlen(output_subpath) - 1);
- strncat(output_subpath, entry->d_name,
+ strncat(output_subpath,
+ entry->d_name,
sizeof(output_subpath) - strlen(output_subpath) - 1);
ret = mkdir(output_subpath, S_IRWXU | S_IRWXG);
goto end;
}
- strncpy(input_subpath, input_path,
- sizeof(input_subpath));
+ strncpy(input_subpath, input_path, sizeof(input_subpath));
input_subpath[sizeof(input_subpath) - 1] = '\0';
- strncat(input_subpath, "/",
+ strncat(input_subpath,
+ "/",
sizeof(input_subpath) - strlen(input_subpath) - 1);
- strncat(input_subpath, entry->d_name,
+ strncat(input_subpath,
+ entry->d_name,
sizeof(input_subpath) - strlen(input_subpath) - 1);
- ret = extract_trace_recursive(output_subpath,
- input_subpath);
+ ret = extract_trace_recursive(output_subpath, input_subpath);
if (ret) {
has_warning = 1;
}
} else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
if (!strcmp(entry->d_name, "metadata")) {
- ret = extract_one_trace(output_path,
- input_path);
+ ret = extract_one_trace(output_path, input_path);
if (ret) {
WARN("Error extracting trace '%s', continuing anyway.",
- input_path);
+ input_path);
has_warning = 1;
}
}
return has_warning;
}
-static
-int delete_dir_recursive(const char *path)
+static int delete_dir_recursive(const char *path)
{
DIR *dir;
int dir_fd, ret = 0, closeret;
if (!dir) {
PERROR("Cannot open '%s' path", path);
ret = -errno;
- goto end_no_closedir;
+ goto end_no_closedir;
}
path_len = strlen(path);
size_t name_len;
char filename[PATH_MAX];
- if (!strcmp(entry->d_name, ".")
- || !strcmp(entry->d_name, "..")) {
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
name_len = strlen(entry->d_name);
if (path_len + name_len + 2 > sizeof(filename)) {
ERR("Failed to remove file: path name too long (%s/%s)",
- path, entry->d_name);
+ path,
+ entry->d_name);
continue;
}
- if (snprintf(filename, sizeof(filename), "%s/%s",
- path, entry->d_name) < 0) {
+ if (snprintf(filename, sizeof(filename), "%s/%s", path, entry->d_name) < 0) {
ERR("Failed to format path.");
continue;
}
}
strncpy(subpath, path, PATH_MAX);
subpath[PATH_MAX - 1] = '\0';
- strncat(subpath, "/",
- PATH_MAX - strlen(subpath) - 1);
- strncat(subpath, entry->d_name,
- PATH_MAX - strlen(subpath) - 1);
+ strncat(subpath, "/", PATH_MAX - strlen(subpath) - 1);
+ strncat(subpath, entry->d_name, PATH_MAX - strlen(subpath) - 1);
ret = delete_dir_recursive(subpath);
free(subpath);
return ret;
}
-static
-int view_trace(const char *trace_path, char *viewer_path)
+static int view_trace(const char *trace_path, char *viewer_path)
{
pid_t pid;
*
*/
+#include "backward-compatibility-group-by.hpp"
#include "common/time.hpp"
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <common/common.hpp>
#include <common/defaults.hpp>
#include <common/utils.hpp>
-#include "backward-compatibility-group-by.hpp"
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#define DATETIME_REGEX \
- ".*-[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]-[0-2][0-9][0-5][0-9][0-5][0-9]$"
+#define DATETIME_REGEX ".*-[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]-[0-2][0-9][0-5][0-9][0-5][0-9]$"
/*
* Provide support for --group-output-by-session for producer >= 2.4 and < 2.11.
* Return the allocated string containing the new stream path or else NULL.
*/
char *backward_compat_group_by_session(const char *path,
- const char *local_session_name,
- time_t relay_session_creation_time)
+ const char *local_session_name,
+ time_t relay_session_creation_time)
{
int ret;
size_t len;
LTTNG_ASSERT(local_session_name[0] != '\0');
DBG("Parsing path \"%s\" of session \"%s\" to create a new path that is grouped by session",
- path, local_session_name);
+ path,
+ local_session_name);
/* Get a local copy for strtok */
local_copy = strdup(path);
*/
hostname_ptr = strtok_r(local_copy, "/", &leftover_ptr);
if (!hostname_ptr) {
- ERR("Failed to parse session path \"%s\": couldn't identify hostname",
- path);
+ ERR("Failed to parse session path \"%s\": couldn't identify hostname", path);
goto error;
}
second_token_ptr = strtok_r(NULL, "/", &leftover_ptr);
if (!second_token_ptr) {
- ERR("Failed to parse session path \"%s\": couldn't identify session name",
- path);
+ ERR("Failed to parse session path \"%s\": couldn't identify session name", path);
goto error;
}
* <session_name>-<date>-<time>
* <auto>-<date>-<time>
*/
- if (strncmp(second_token_ptr, local_session_name,
- strlen(local_session_name)) != 0) {
+ if (strncmp(second_token_ptr, local_session_name, strlen(local_session_name)) != 0) {
/*
* Token does not start with session name.
* This mean this is an extra path scenario.
goto error;
}
- leftover_second_token_ptr =
- second_token_ptr + strlen(local_session_name);
+ leftover_second_token_ptr = second_token_ptr + strlen(local_session_name);
len = strlen(leftover_second_token_ptr);
if (len == 0) {
/*
ret = regexec(®ex, local_session_name, 0, NULL, 0);
if (ret == 0) {
const ssize_t local_session_name_offset =
- strlen(local_session_name) - DATETIME_STR_LEN + 1;
+ strlen(local_session_name) - DATETIME_STR_LEN + 1;
LTTNG_ASSERT(local_session_name_offset >= 0);
- datetime = strdup(local_session_name +
- local_session_name_offset);
+ datetime = strdup(local_session_name + local_session_name_offset);
if (!datetime) {
PERROR("Failed to parse session path: couldn't copy datetime on regex match");
goto error_regex;
goto error;
}
- ret = time_to_datetime_str(relay_session_creation_time,
- datetime, DATETIME_STR_LEN);
+ ret = time_to_datetime_str(
+ relay_session_creation_time, datetime, DATETIME_STR_LEN);
if (ret) {
/* time_to_datetime_str already logs errors. */
goto error;
}
}
} else if (len == DATETIME_STR_LEN &&
- !regexec(®ex, leftover_second_token_ptr, 0, NULL,
- 0)) {
+ !regexec(®ex, leftover_second_token_ptr, 0, NULL, 0)) {
/*
* The leftover from the second token is of format
* "-<datetime>", use it as the creation time.
}
}
- ret = asprintf(&filepath_per_session, "%s/%s%s%s/%s%s%s",
- local_session_name, hostname_ptr, datetime ? "-" : "",
- datetime ? datetime : "",
- partial_base_path ? partial_base_path : "",
- partial_base_path ? "/" : "", leftover_ptr);
+ ret = asprintf(&filepath_per_session,
+ "%s/%s%s%s/%s%s%s",
+ local_session_name,
+ hostname_ptr,
+ datetime ? "-" : "",
+ datetime ? datetime : "",
+ partial_base_path ? partial_base_path : "",
+ partial_base_path ? "/" : "",
+ leftover_ptr);
if (ret < 0) {
filepath_per_session = NULL;
goto error;
#define _LGPL_SOURCE
+#include "cmd-2-1.hpp"
+#include "utils.hpp"
+
#include <common/common.hpp>
-#include <common/sessiond-comm/relayd.hpp>
#include <common/compat/string.hpp>
-#include <lttng/constant.h>
+#include <common/sessiond-comm/relayd.hpp>
-#include "cmd-2-1.hpp"
-#include "utils.hpp"
+#include <lttng/constant.h>
/*
* cmd_recv_stream_2_1 allocates path_name and channel_name.
*/
int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload,
- char **ret_path_name, char **ret_channel_name)
+ char **ret_path_name,
+ char **ret_channel_name)
{
int ret;
struct lttcomm_relayd_add_stream stream_info;
if (payload->size < sizeof(stream_info)) {
ERR("Unexpected payload size in \"cmd_recv_stream_2_1\": expected >= %zu bytes, got %zu bytes",
- sizeof(stream_info), payload->size);
+ sizeof(stream_info),
+ payload->size);
ret = -1;
goto error;
}
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
+#include "cmd-2-11.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
-#include <common/sessiond-comm/relayd.hpp>
-
#include <common/compat/endian.hpp>
#include <common/compat/string.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+
#include <lttng/constant.h>
-#include "cmd-2-11.hpp"
-#include "utils.hpp"
+#include <inttypes.h>
int cmd_create_session_2_11(const struct lttng_buffer_view *payload,
- char *session_name, char *hostname, char *base_path,
- uint32_t *live_timer, bool *snapshot,
- uint64_t *id_sessiond,
- lttng_uuid& sessiond_uuid,
- bool *has_current_chunk, uint64_t *current_chunk_id,
- time_t *creation_time,
- bool *session_name_contains_creation_time)
+ char *session_name,
+ char *hostname,
+ char *base_path,
+ uint32_t *live_timer,
+ bool *snapshot,
+ uint64_t *id_sessiond,
+ lttng_uuid& sessiond_uuid,
+ bool *has_current_chunk,
+ uint64_t *current_chunk_id,
+ time_t *creation_time,
+ bool *session_name_contains_creation_time)
{
int ret;
struct lttcomm_relayd_create_session_2_11 header;
if (payload->size < header_len) {
ERR("Unexpected payload size in \"cmd_create_session_2_11\": expected >= %zu bytes, got %zu bytes",
- header_len, payload->size);
+ header_len,
+ payload->size);
ret = -1;
goto error;
}
header.creation_time = be64toh(header.creation_time);
header.session_id = be64toh(header.session_id);
- std::copy(std::begin(header.sessiond_uuid), std::end(header.sessiond_uuid), sessiond_uuid.begin());
+ std::copy(std::begin(header.sessiond_uuid),
+ std::end(header.sessiond_uuid),
+ sessiond_uuid.begin());
- received_names_size = header.session_name_len + header.hostname_len +
- header.base_path_len;
+ received_names_size = header.session_name_len + header.hostname_len + header.base_path_len;
if (payload->size < header_len + received_names_size) {
ERR("Unexpected payload size in \"cmd_create_session_2_11\": expected >= %zu bytes, got %zu bytes",
- header_len + received_names_size, payload->size);
+ header_len + received_names_size,
+ payload->size);
ret = -1;
goto error;
}
/* Validate length against defined constant. */
if (header.session_name_len > LTTNG_NAME_MAX) {
ret = -ENAMETOOLONG;
- ERR("Length of session name (%" PRIu32 " bytes) received in create_session command exceeds maximum length (%d bytes)", header.session_name_len, LTTNG_NAME_MAX);
+ ERR("Length of session name (%" PRIu32
+ " bytes) received in create_session command exceeds maximum length (%d bytes)",
+ header.session_name_len,
+ LTTNG_NAME_MAX);
goto error;
} else if (header.session_name_len == 0) {
ret = -EINVAL;
}
if (header.hostname_len > LTTNG_HOST_NAME_MAX) {
ret = -ENAMETOOLONG;
- ERR("Length of hostname (%" PRIu32 " bytes) received in create_session command exceeds maximum length (%d bytes)", header.hostname_len, LTTNG_HOST_NAME_MAX);
+ ERR("Length of hostname (%" PRIu32
+ " bytes) received in create_session command exceeds maximum length (%d bytes)",
+ header.hostname_len,
+ LTTNG_HOST_NAME_MAX);
goto error;
}
if (header.base_path_len > LTTNG_PATH_MAX) {
ret = -ENAMETOOLONG;
- ERR("Length of base_path (%" PRIu32 " bytes) received in create_session command exceeds maximum length (%d bytes)", header.base_path_len, PATH_MAX);
+ ERR("Length of base_path (%" PRIu32
+ " bytes) received in create_session command exceeds maximum length (%d bytes)",
+ header.base_path_len,
+ PATH_MAX);
goto error;
}
offset = header_len;
- session_name_view = lttng_buffer_view_from_view(payload, offset,
- header.session_name_len);
+ session_name_view = lttng_buffer_view_from_view(payload, offset, header.session_name_len);
if (!lttng_buffer_view_is_valid(&session_name_view)) {
ERR("Invalid payload in \"cmd_create_session_2_11\": buffer too short to contain session name");
ret = -1;
}
offset += header.session_name_len;
- hostname_view = lttng_buffer_view_from_view(payload,
- offset, header.hostname_len);
+ hostname_view = lttng_buffer_view_from_view(payload, offset, header.hostname_len);
if (!lttng_buffer_view_is_valid(&hostname_view)) {
ERR("Invalid payload in \"cmd_create_session_2_11\": buffer too short to contain hostname");
ret = -1;
}
offset += header.hostname_len;
- base_path_view = lttng_buffer_view_from_view(payload,
- offset, header.base_path_len);
+ base_path_view = lttng_buffer_view_from_view(payload, offset, header.base_path_len);
if (header.base_path_len > 0 && !lttng_buffer_view_is_valid(&base_path_view)) {
ERR("Invalid payload in \"cmd_create_session_2_11\": buffer too short to contain base path");
ret = -1;
goto error;
}
- if (base_path_view.size != 0 &&
- base_path_view.data[base_path_view.size - 1] != '\0') {
+ if (base_path_view.size != 0 && base_path_view.data[base_path_view.size - 1] != '\0') {
ERR("cmd_create_session_2_11 base_path is invalid (not NULL terminated)");
ret = -1;
goto error;
*current_chunk_id = header.current_chunk_id.value;
*has_current_chunk = header.current_chunk_id.is_set;
*creation_time = (time_t) header.creation_time;
- *session_name_contains_creation_time =
- header.session_name_contains_creation_time;
+ *session_name_contains_creation_time = header.session_name_contains_creation_time;
*id_sessiond = header.session_id;
ret = 0;
* cmd_recv_stream_2_11 allocates path_name and channel_name.
*/
int cmd_recv_stream_2_11(const struct lttng_buffer_view *payload,
- char **ret_path_name, char **ret_channel_name,
- uint64_t *tracefile_size, uint64_t *tracefile_count,
- uint64_t *trace_archive_id)
+ char **ret_path_name,
+ char **ret_channel_name,
+ uint64_t *tracefile_size,
+ uint64_t *tracefile_count,
+ uint64_t *trace_archive_id)
{
int ret;
struct lttcomm_relayd_add_stream_2_11 header;
if (payload->size < header_len) {
ERR("Unexpected payload size in \"cmd_recv_stream_2_11\": expected >= %zu bytes, got %zu bytes",
- header_len, payload->size);
+ header_len,
+ payload->size);
ret = -1;
goto error;
}
received_names_size = header.channel_name_len + header.pathname_len;
if (payload->size < header_len + received_names_size) {
ERR("Unexpected payload size in \"cmd_recv_stream_2_11\": expected >= %zu bytes, got %zu bytes",
- header_len + received_names_size, payload->size);
+ header_len + received_names_size,
+ payload->size);
ret = -1;
goto error;
}
}
/* Validate that names are (NULL terminated. */
- channel_name_view = lttng_buffer_view_from_view(payload, header_len,
- header.channel_name_len);
+ channel_name_view =
+ lttng_buffer_view_from_view(payload, header_len, header.channel_name_len);
if (!lttng_buffer_view_is_valid(&channel_name_view)) {
ERR("Invalid payload received in \"cmd_recv_stream_2_11\": buffer too short for channel name");
ret = -1;
goto error;
}
- pathname_view = lttng_buffer_view_from_view(payload,
- header_len + header.channel_name_len, header.pathname_len);
+ pathname_view = lttng_buffer_view_from_view(
+ payload, header_len + header.channel_name_len, header.pathname_len);
if (!lttng_buffer_view_is_valid(&pathname_view)) {
ERR("Invalid payload received in \"cmd_recv_stream_2_11\": buffer too short for path name");
ret = -1;
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/sessiond-comm/relayd.hpp>
+#include "cmd-2-1.hpp"
+#include "cmd-2-2.hpp"
+#include "utils.hpp"
+#include <common/common.hpp>
#include <common/compat/endian.hpp>
#include <common/compat/string.hpp>
-#include <lttng/constant.h>
+#include <common/sessiond-comm/relayd.hpp>
-#include "cmd-2-2.hpp"
-#include "cmd-2-1.hpp"
-#include "utils.hpp"
+#include <lttng/constant.h>
/*
* cmd_recv_stream_2_2 allocates path_name and channel_name.
*/
int cmd_recv_stream_2_2(const struct lttng_buffer_view *payload,
- char **ret_path_name, char **ret_channel_name,
- uint64_t *tracefile_size, uint64_t *tracefile_count)
+ char **ret_path_name,
+ char **ret_channel_name,
+ uint64_t *tracefile_size,
+ uint64_t *tracefile_count)
{
int ret;
struct lttcomm_relayd_add_stream_2_2 stream_info;
if (payload->size < sizeof(stream_info)) {
ERR("Unexpected payload size in \"cmd_recv_stream_2_2\": expected >= %zu bytes, got %zu bytes",
- sizeof(stream_info), payload->size);
+ sizeof(stream_info),
+ payload->size);
ret = -1;
goto error;
}
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/sessiond-comm/relayd.hpp>
+#include "cmd-2-4.hpp"
+#include "lttng-relayd.hpp"
+#include <common/common.hpp>
#include <common/compat/endian.hpp>
#include <common/compat/string.hpp>
-#include <lttng/constant.h>
+#include <common/sessiond-comm/relayd.hpp>
-#include "cmd-2-4.hpp"
-#include "lttng-relayd.hpp"
+#include <lttng/constant.h>
int cmd_create_session_2_4(const struct lttng_buffer_view *payload,
- char *session_name, char *hostname,
- uint32_t *live_timer, bool *snapshot)
+ char *session_name,
+ char *hostname,
+ uint32_t *live_timer,
+ bool *snapshot)
{
int ret;
struct lttcomm_relayd_create_session_2_4 session_info;
if (payload->size < sizeof(session_info)) {
ERR("Unexpected payload size in \"cmd_create_session_2_4\": expected >= %zu bytes, got %zu bytes",
- sizeof(session_info), payload->size);
+ sizeof(session_info),
+ payload->size);
ret = -1;
goto error;
}
*/
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <urcu/rculist.h>
-
#include "connection.hpp"
#include "stream.hpp"
#include "viewer-session.hpp"
+#include <common/common.hpp>
+
+#include <urcu/rculist.h>
+
bool connection_get(struct relay_connection *conn)
{
return urcu_ref_get_unless_zero(&conn->ref);
}
-struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht,
- int sock)
+struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht, int sock)
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
LTTNG_ASSERT(sock >= 0);
rcu_read_lock();
- lttng_ht_lookup(relay_connections_ht, (void *)((unsigned long) sock),
- &iter);
+ lttng_ht_lookup(relay_connections_ht, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (!node) {
DBG2("Relay connection by sock %d not found", sock);
switch (connection->type) {
case RELAY_DATA:
- connection->protocol.data.state_id =
- DATA_CONNECTION_STATE_RECEIVE_HEADER;
+ connection->protocol.data.state_id = DATA_CONNECTION_STATE_RECEIVE_HEADER;
memset(&connection->protocol.data.state.receive_header,
- 0,
- sizeof(connection->protocol.data.state.receive_header));
+ 0,
+ sizeof(connection->protocol.data.state.receive_header));
connection->protocol.data.state.receive_header.left_to_receive =
- sizeof(struct lttcomm_relayd_data_hdr);
+ sizeof(struct lttcomm_relayd_data_hdr);
break;
case RELAY_CONTROL:
- connection->protocol.ctrl.state_id =
- CTRL_CONNECTION_STATE_RECEIVE_HEADER;
+ connection->protocol.ctrl.state_id = CTRL_CONNECTION_STATE_RECEIVE_HEADER;
memset(&connection->protocol.ctrl.state.receive_header,
- 0,
- sizeof(connection->protocol.ctrl.state.receive_header));
+ 0,
+ sizeof(connection->protocol.ctrl.state.receive_header));
connection->protocol.data.state.receive_header.left_to_receive =
- sizeof(struct lttcomm_relayd_hdr);
- ret = lttng_dynamic_buffer_set_size(
- &connection->protocol.ctrl.reception_buffer,
- sizeof(struct lttcomm_relayd_hdr));
+ sizeof(struct lttcomm_relayd_hdr);
+ ret = lttng_dynamic_buffer_set_size(&connection->protocol.ctrl.reception_buffer,
+ sizeof(struct lttcomm_relayd_hdr));
if (ret) {
- ERR("Failed to reinitialize control connection reception buffer size to %zu bytes.", sizeof(struct lttcomm_relayd_hdr));
+ ERR("Failed to reinitialize control connection reception buffer size to %zu bytes.",
+ sizeof(struct lttcomm_relayd_hdr));
goto end;
}
break;
default:
goto end;
}
- DBG("Reset communication state of relay connection (fd = %i)",
- connection->sock->fd);
+ DBG("Reset communication state of relay connection (fd = %i)", connection->sock->fd);
end:
return ret;
}
-struct relay_connection *connection_create(struct lttcomm_sock *sock,
- enum connection_type type)
+struct relay_connection *connection_create(struct lttcomm_sock *sock, enum connection_type type)
{
struct relay_connection *conn;
conn->viewer_session = NULL;
}
if (conn->type == RELAY_CONTROL) {
- lttng_dynamic_buffer_reset(
- &conn->protocol.ctrl.reception_buffer);
+ lttng_dynamic_buffer_reset(&conn->protocol.ctrl.reception_buffer);
}
free(conn);
}
static void connection_release(struct urcu_ref *ref)
{
- struct relay_connection *conn =
- lttng::utils::container_of(ref, &relay_connection::ref);
+ struct relay_connection *conn = lttng::utils::container_of(ref, &relay_connection::ref);
if (conn->in_socket_ht) {
struct lttng_ht_iter iter;
rcu_read_unlock();
}
-void connection_ht_add(struct lttng_ht *relay_connections_ht,
- struct relay_connection *conn)
+void connection_ht_add(struct lttng_ht *relay_connections_ht, struct relay_connection *conn)
{
LTTNG_ASSERT(!conn->in_socket_ht);
lttng_ht_add_unique_ulong(relay_connections_ht, &conn->sock_n);
conn->socket_ht = relay_connections_ht;
}
-int connection_set_session(struct relay_connection *conn,
- struct relay_session *session)
+int connection_set_session(struct relay_connection *conn, struct relay_session *session)
{
int ret = 0;
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/utils.hpp>
-#include <urcu/rculist.h>
-
#include "ctf-trace.hpp"
#include "lttng-relayd.hpp"
#include "stream.hpp"
+#include <common/common.hpp>
+#include <common/utils.hpp>
+
+#include <urcu/rculist.h>
+
static uint64_t last_relay_ctf_trace_id;
static pthread_mutex_t last_relay_ctf_trace_id_lock = PTHREAD_MUTEX_INITIALIZER;
static void rcu_destroy_ctf_trace(struct rcu_head *rcu_head)
{
- struct ctf_trace *trace =
- lttng::utils::container_of(rcu_head, &ctf_trace::rcu_node);
+ struct ctf_trace *trace = lttng::utils::container_of(rcu_head, &ctf_trace::rcu_node);
free(trace);
}
static void ctf_trace_release(struct urcu_ref *ref)
{
- struct ctf_trace *trace =
- lttng::utils::container_of(ref, &ctf_trace::ref);
+ struct ctf_trace *trace = lttng::utils::container_of(ref, &ctf_trace::ref);
int ret;
struct lttng_ht_iter iter;
* create and refcounting. Whenever all the streams belonging to a trace
* put their reference, its refcount drops to 0.
*/
-static struct ctf_trace *ctf_trace_create(struct relay_session *session,
- const char *subpath)
+static struct ctf_trace *ctf_trace_create(struct relay_session *session, const char *subpath)
{
struct ctf_trace *trace;
lttng_ht_add_str(session->ctf_traces_ht, &trace->node);
DBG("Created ctf_trace %" PRIu64 " of session \"%s\" from host \"%s\" with path: %s",
- trace->id, session->session_name, session->hostname,
- subpath);
+ trace->id,
+ session->session_name,
+ session->hostname,
+ subpath);
end:
return trace;
* ctf_trace_put().
*/
struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session,
- const char *subpath)
+ const char *subpath)
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
struct relay_stream *stream;
rcu_read_lock();
- cds_list_for_each_entry_rcu(stream, &trace->stream_list,
- stream_node) {
+ cds_list_for_each_entry_rcu(stream, &trace->stream_list, stream_node)
+ {
/*
* Close stream since the connection owning the trace is being
* torn down.
*/
#define _LGPL_SOURCE
+#include "health-relayd.hpp"
+#include "lttng-relayd.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/poll.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/defaults.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
+#include <inttypes.h>
#include <limits.h>
+#include <poll.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
+#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <urcu/list.h>
-#include <poll.h>
#include <unistd.h>
-#include <sys/mman.h>
#include <urcu/compiler.h>
-#include <inttypes.h>
-
-#include <common/defaults.hpp>
-#include <common/common.hpp>
-#include <common/consumer/consumer.hpp>
-#include <common/consumer/consumer-timer.hpp>
-#include <common/compat/poll.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/fd-tracker/utils.hpp>
-
-#include "lttng-relayd.hpp"
-#include "health-relayd.hpp"
+#include <urcu/list.h>
/* Global health check unix path */
-static
-char health_unix_sock_path[PATH_MAX];
+static char health_unix_sock_path[PATH_MAX];
int health_quit_pipe[2] = { -1, -1 };
}
ret = chmod(rundir,
- S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
+ S_IXOTH);
if (ret < 0) {
ERR("Unable to set permissions on %s", rundir);
PERROR("chmod");
return ret;
}
-static
-int parse_health_env(void)
+static int parse_health_env(void)
{
const char *health_path;
health_path = lttng_secure_getenv(LTTNG_RELAYD_HEALTH_ENV);
if (health_path) {
- strncpy(health_unix_sock_path, health_path,
- PATH_MAX);
+ strncpy(health_unix_sock_path, health_path, PATH_MAX);
health_unix_sock_path[PATH_MAX - 1] = '\0';
}
return 0;
}
-static
-int setup_health_path(void)
+static int setup_health_path(void)
{
int is_root, ret = 0;
const char *home_path = NULL;
if (strlen(health_unix_sock_path) != 0) {
goto end;
}
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK,
- (int) getpid());
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK,
+ (int) getpid());
} else {
/* Set health check Unix path */
if (strlen(health_unix_sock_path) != 0) {
goto end;
}
- snprintf(health_unix_sock_path, sizeof(health_unix_sock_path),
- DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK,
- home_path, (int) getpid());
+ snprintf(health_unix_sock_path,
+ sizeof(health_unix_sock_path),
+ DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK,
+ home_path,
+ (int) getpid());
}
end:
return ret;
}
-static
-int accept_unix_socket(void *data, int *out_fd)
+static int accept_unix_socket(void *data, int *out_fd)
{
int ret;
int accepting_sock = *((int *) data);
return ret;
}
-static
-int open_unix_socket(void *data, int *out_fd)
+static int open_unix_socket(void *data, int *out_fd)
{
int ret;
const char *path = (const char *) data;
err = -1;
goto error;
}
- ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &sock,
- (const char **) &sock_name, 1, open_unix_socket,
- health_unix_sock_path);
+ ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
+ &sock,
+ (const char **) &sock_name,
+ 1,
+ open_unix_socket,
+ health_unix_sock_path);
free(sock_name);
if (ret < 0) {
ERR("Unable to create health check Unix socket");
goto error;
}
- ret = chmod(health_unix_sock_path,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ ret = chmod(health_unix_sock_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
ERR("Unable to set permissions on %s", health_unix_sock_path);
PERROR("chmod");
}
/* Size is set to 2 for the unix socket and quit pipe. */
- ret = fd_tracker_util_poll_create(the_fd_tracker,
- "Health management thread epoll", &events, 2,
- LTTNG_CLOEXEC);
+ ret = fd_tracker_util_poll_create(
+ the_fd_tracker, "Health management thread epoll", &events, 2, LTTNG_CLOEXEC);
if (ret < 0) {
ERR("Poll set creation failed");
goto error;
DBG("Health check ready");
/* Inifinite blocking call, waiting for transmission */
-restart:
+ restart:
ret = lttng_poll_wait(&events, -1);
if (ret < 0) {
/*
ERR("Health socket poll error");
goto error;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
}
}
- ret = asprintf(&accepted_socket_name, "Socket accepted from unix socket @ %s",
- health_unix_sock_path);
+ ret = asprintf(&accepted_socket_name,
+ "Socket accepted from unix socket @ %s",
+ health_unix_sock_path);
if (ret == -1) {
PERROR("Failed to allocate name of accepted socket from unix socket @ %s",
- health_unix_sock_path);
+ health_unix_sock_path);
goto error;
}
- ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &new_sock,
- (const char **) &accepted_socket_name, 1,
- accept_unix_socket, &sock);
+ ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
+ &new_sock,
+ (const char **) &accepted_socket_name,
+ 1,
+ accept_unix_socket,
+ &sock);
free(accepted_socket_name);
if (ret < 0) {
goto error;
(void) utils_set_fd_cloexec(new_sock);
DBG("Receiving data from client for health...");
- ret = lttcomm_recv_unix_sock(new_sock, (void *)&msg, sizeof(msg));
+ ret = lttcomm_recv_unix_sock(new_sock, (void *) &msg, sizeof(msg));
if (ret <= 0) {
DBG("Nothing recv() from client... continuing");
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- &new_sock, 1, fd_tracker_util_close_fd,
- NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, NULL);
if (ret) {
PERROR("close");
}
}
/* End of transmission */
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- &new_sock, 1, fd_tracker_util_close_fd,
- NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &new_sock, 1, fd_tracker_util_close_fd, NULL);
if (ret) {
PERROR("close");
}
DBG("Health check thread dying");
unlink(health_unix_sock_path);
if (sock >= 0) {
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker, &sock,
- 1, fd_tracker_util_close_fd, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &sock, 1, fd_tracker_util_close_fd, NULL);
if (ret) {
PERROR("close");
}
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/utils.hpp>
-#include <common/compat/endian.hpp>
-
+#include "connection.hpp"
+#include "index.hpp"
#include "lttng-relayd.hpp"
#include "stream.hpp"
-#include "index.hpp"
-#include "connection.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/utils.hpp>
/*
* Allocate a new relay index object. Pass the stream in which it is
* Called with stream mutex held.
* Return allocated object or else NULL on error.
*/
-static struct relay_index *relay_index_create(struct relay_stream *stream,
- uint64_t net_seq_num)
+static struct relay_index *relay_index_create(struct relay_stream *stream, uint64_t net_seq_num)
{
struct relay_index *index;
DBG2("Creating relay index for stream id %" PRIu64 " and seqnum %" PRIu64,
- stream->stream_handle, net_seq_num);
+ stream->stream_handle,
+ net_seq_num);
index = zmalloc<relay_index>();
if (!index) {
* RCU read side lock MUST be acquired.
*/
static struct relay_index *relay_index_add_unique(struct relay_stream *stream,
- struct relay_index *index)
+ struct relay_index *index)
{
struct cds_lfht_node *node_ptr;
struct relay_index *_index;
ASSERT_RCU_READ_LOCKED();
DBG2("Adding relay index with stream id %" PRIu64 " and seqnum %" PRIu64,
- stream->stream_handle, index->index_n.key);
+ stream->stream_handle,
+ index->index_n.key);
node_ptr = cds_lfht_add_unique(stream->indexes_ht->ht,
- stream->indexes_ht->hash_fct(&index->index_n, lttng_ht_seed),
- stream->indexes_ht->match_fct, &index->index_n,
- &index->index_n.node);
+ stream->indexes_ht->hash_fct(&index->index_n, lttng_ht_seed),
+ stream->indexes_ht->match_fct,
+ &index->index_n,
+ &index->index_n.node);
if (node_ptr != &index->index_n.node) {
- _index = caa_container_of(node_ptr, struct relay_index,
- index_n.node);
+ _index = caa_container_of(node_ptr, struct relay_index, index_n.node);
} else {
_index = NULL;
}
ASSERT_RCU_READ_LOCKED();
DBG2("index get for stream id %" PRIu64 " and seqnum %" PRIu64 " refcount %d",
- index->stream->stream_handle, index->index_n.key,
- (int) index->ref.refcount);
+ index->stream->stream_handle,
+ index->index_n.key,
+ (int) index->ref.refcount);
return urcu_ref_get_unless_zero(&index->ref);
}
* Return index object or else NULL on error.
*/
struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
- uint64_t net_seq_num)
+ uint64_t net_seq_num)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
struct relay_index *index = NULL;
DBG3("Finding index for stream id %" PRIu64 " and seq_num %" PRIu64,
- stream->stream_handle, net_seq_num);
+ stream->stream_handle,
+ net_seq_num);
rcu_read_lock();
lttng_ht_lookup(stream->indexes_ht, &net_seq_num, &iter);
index = relay_index_create(stream, net_seq_num);
if (!index) {
ERR("Cannot create index for stream id %" PRIu64 " and seq_num %" PRIu64,
- stream->stream_handle, net_seq_num);
+ stream->stream_handle,
+ net_seq_num);
goto end;
}
oldindex = relay_index_add_unique(stream, index);
end:
rcu_read_unlock();
DBG2("Index %sfound or created in HT for stream ID %" PRIu64 " and seqnum %" PRIu64,
- (index == NULL) ? "NOT " : "", stream->stream_handle, net_seq_num);
+ (index == NULL) ? "NOT " : "",
+ stream->stream_handle,
+ net_seq_num);
return index;
}
int relay_index_set_file(struct relay_index *index,
- struct lttng_index_file *index_file,
- uint64_t data_offset)
+ struct lttng_index_file *index_file,
+ uint64_t data_offset)
{
int ret = 0;
return ret;
}
-int relay_index_set_data(struct relay_index *index,
- const struct ctf_packet_index *data)
+int relay_index_set_data(struct relay_index *index, const struct ctf_packet_index *data)
{
int ret = 0;
static void index_destroy_rcu(struct rcu_head *rcu_head)
{
- struct relay_index *index =
- lttng::utils::container_of(rcu_head, &relay_index::rcu_node);
+ struct relay_index *index = lttng::utils::container_of(rcu_head, &relay_index::rcu_node);
index_destroy(index);
}
void relay_index_put(struct relay_index *index)
{
DBG2("index put for stream id %" PRIu64 " and seqnum %" PRIu64 " refcount %d",
- index->stream->stream_handle, index->index_n.key,
- (int) index->ref.refcount);
+ index->stream->stream_handle,
+ index->index_n.key,
+ (int) index->ref.refcount);
/*
* Ensure existence of index->lock for index unlock.
*/
}
DBG2("Writing index for stream ID %" PRIu64 " and seq num %" PRIu64,
- index->stream->stream_handle, index->index_n.key);
+ index->stream->stream_handle,
+ index->index_n.key);
flushed = true;
index->flushed = true;
ret = lttng_index_file_write(index->index_file, &index->index_data);
struct relay_index *index;
rcu_read_lock();
- cds_lfht_for_each_entry(stream->indexes_ht->ht, &iter.iter,
- index, index_n.node) {
+ cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
/* Put self-ref from index. */
relay_index_put(index);
}
struct relay_index *index;
rcu_read_lock();
- cds_lfht_for_each_entry(stream->indexes_ht->ht, &iter.iter,
- index, index_n.node) {
+ cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
if (!index->index_file) {
continue;
}
uint64_t net_seq_num = -1ULL;
rcu_read_lock();
- cds_lfht_for_each_entry(stream->indexes_ht->ht, &iter.iter,
- index, index_n.node) {
- if (net_seq_num == -1ULL ||
- index->index_n.key > net_seq_num) {
+ cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
+ if (net_seq_num == -1ULL || index->index_n.key > net_seq_num) {
net_seq_num = index->index_n.key;
}
}
* Update the index file of an already existing relay_index.
* Offsets by 'removed_data_count' the offset field of an index.
*/
-static
-int relay_index_switch_file(struct relay_index *index,
- struct lttng_index_file *new_index_file,
- uint64_t removed_data_count)
+static int relay_index_switch_file(struct relay_index *index,
+ struct lttng_index_file *new_index_file,
+ uint64_t removed_data_count)
{
int ret = 0;
uint64_t offset;
int ret = 0;
rcu_read_lock();
- cds_lfht_for_each_entry(stream->indexes_ht->ht, &iter.iter,
- index, index_n.node) {
- ret = relay_index_switch_file(index, stream->index_file,
- stream->pos_after_last_complete_data_index);
+ cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
+ ret = relay_index_switch_file(
+ index, stream->index_file, stream->pos_after_last_complete_data_index);
if (ret) {
goto end;
}
* Set index data from the control port to a given index object.
*/
int relay_index_set_control_data(struct relay_index *index,
- const struct lttcomm_relayd_index *data,
- unsigned int minor_version)
+ const struct lttcomm_relayd_index *data,
+ unsigned int minor_version)
{
/* The index on disk is encoded in big endian. */
- ctf_packet_index index_data {};
+ ctf_packet_index index_data{};
index_data.packet_size = htobe64(data->packet_size);
index_data.content_size = htobe64(data->content_size);
*/
#define _LGPL_SOURCE
+#include "cmd.hpp"
+#include "connection.hpp"
+#include "ctf-trace.hpp"
+#include "health-relayd.hpp"
+#include "live.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "stream.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+#include "viewer-session.hpp"
+#include "viewer-stream.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/defaults.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/fs-handle.hpp>
+#include <common/futex.hpp>
+#include <common/index/index.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/resource.h>
#include <urcu/futex.h>
#include <urcu/rculist.h>
#include <urcu/uatomic.h>
-#include <string>
-#include <common/common.hpp>
-#include <common/compat/endian.hpp>
-#include <common/compat/poll.hpp>
-#include <common/compat/socket.hpp>
-#include <common/defaults.hpp>
-#include <common/fd-tracker/utils.hpp>
-#include <common/fs-handle.hpp>
-#include <common/futex.hpp>
-#include <common/index/index.hpp>
-#include <common/sessiond-comm/inet.hpp>
-#include <common/sessiond-comm/relayd.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/uri.hpp>
-#include <common/utils.hpp>
-#include <lttng/lttng.h>
-
-#include "cmd.hpp"
-#include "connection.hpp"
-#include "ctf-trace.hpp"
-#include "health-relayd.hpp"
-#include "live.hpp"
-#include "lttng-relayd.hpp"
-#include "session.hpp"
-#include "stream.hpp"
-#include "testpoint.hpp"
-#include "utils.hpp"
-#include "viewer-session.hpp"
-#include "viewer-stream.hpp"
-
-#define SESSION_BUF_DEFAULT_COUNT 16
+#define SESSION_BUF_DEFAULT_COUNT 16
static struct lttng_uri *live_uri;
static struct relay_conn_queue viewer_conn_queue;
static uint64_t last_relay_viewer_session_id;
-static pthread_mutex_t last_relay_viewer_session_id_lock =
- PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t last_relay_viewer_session_id_lock = PTHREAD_MUTEX_INITIALIZER;
-static
-const char *lttng_viewer_command_str(lttng_viewer_command cmd)
+static const char *lttng_viewer_command_str(lttng_viewer_command cmd)
{
switch (cmd) {
case LTTNG_VIEWER_CONNECT:
}
}
-static
-const char *lttng_viewer_next_index_return_code_str(
- enum lttng_viewer_next_index_return_code code)
+static const char *
+lttng_viewer_next_index_return_code_str(enum lttng_viewer_next_index_return_code code)
{
switch (code) {
case LTTNG_VIEWER_INDEX_OK:
}
}
-static
-const char *lttng_viewer_attach_return_code_str(
- enum lttng_viewer_attach_return_code code)
+static const char *lttng_viewer_attach_return_code_str(enum lttng_viewer_attach_return_code code)
{
switch (code) {
case LTTNG_VIEWER_ATTACH_OK:
}
};
-static
-const char *lttng_viewer_get_packet_return_code_str(
- enum lttng_viewer_get_packet_return_code code)
+static const char *
+lttng_viewer_get_packet_return_code_str(enum lttng_viewer_get_packet_return_code code)
{
switch (code) {
case LTTNG_VIEWER_GET_PACKET_OK:
/*
* Cleanup the daemon
*/
-static
-void cleanup_relayd_live(void)
+static void cleanup_relayd_live(void)
{
DBG("Cleaning up");
* Return the size of the received message or else a negative value on error
* with errno being set by recvmsg() syscall.
*/
-static
-ssize_t recv_request(struct lttcomm_sock *sock, void *buf, size_t size)
+static ssize_t recv_request(struct lttcomm_sock *sock, void *buf, size_t size)
{
ssize_t ret;
* Return the size of the sent message or else a negative value on error with
* errno being set by sendmsg() syscall.
*/
-static
-ssize_t send_response(struct lttcomm_sock *sock, void *buf, size_t size)
+static ssize_t send_response(struct lttcomm_sock *sock, void *buf, size_t size)
{
ssize_t ret;
* Returns 1 if new streams got added, 0 if nothing changed, a negative value
* on error.
*/
-static
-int check_new_streams(struct relay_connection *conn)
+static int check_new_streams(struct relay_connection *conn)
{
struct relay_session *session;
unsigned long current_val;
goto end;
}
rcu_read_lock();
- cds_list_for_each_entry_rcu(session,
- &conn->viewer_session->session_list,
- viewer_session_node) {
+ cds_list_for_each_entry_rcu(
+ session, &conn->viewer_session->session_list, viewer_session_node)
+ {
if (!session_get(session)) {
continue;
}
*
* Return 0 on success or else a negative value.
*/
-static
-ssize_t send_viewer_streams(struct lttcomm_sock *sock,
- uint64_t session_id, unsigned int ignore_sent_flag)
+static ssize_t
+send_viewer_streams(struct lttcomm_sock *sock, uint64_t session_id, unsigned int ignore_sent_flag)
{
ssize_t ret;
struct lttng_ht_iter iter;
rcu_read_lock();
- cds_lfht_for_each_entry(viewer_streams_ht->ht, &iter.iter, vstream,
- stream_n.node) {
+ cds_lfht_for_each_entry (viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
struct ctf_trace *ctf_trace;
struct lttng_viewer_stream send_stream = {};
pthread_mutex_lock(&vstream->stream->lock);
/* Ignore if not the same session. */
if (vstream->stream->trace->session->id != session_id ||
- (!ignore_sent_flag && vstream->sent_flag)) {
+ (!ignore_sent_flag && vstream->sent_flag)) {
pthread_mutex_unlock(&vstream->stream->lock);
viewer_stream_put(vstream);
continue;
ctf_trace = vstream->stream->trace;
send_stream.id = htobe64(vstream->stream->stream_handle);
send_stream.ctf_trace_id = htobe64(ctf_trace->id);
- send_stream.metadata_flag = htobe32(
- vstream->stream->is_metadata);
- if (lttng_strncpy(send_stream.path_name, vstream->path_name,
- sizeof(send_stream.path_name))) {
+ send_stream.metadata_flag = htobe32(vstream->stream->is_metadata);
+ if (lttng_strncpy(send_stream.path_name,
+ vstream->path_name,
+ sizeof(send_stream.path_name))) {
pthread_mutex_unlock(&vstream->stream->lock);
viewer_stream_put(vstream);
- ret = -1; /* Error. */
+ ret = -1; /* Error. */
goto end_unlock;
}
if (lttng_strncpy(send_stream.channel_name,
- vstream->channel_name,
- sizeof(send_stream.channel_name))) {
+ vstream->channel_name,
+ sizeof(send_stream.channel_name))) {
pthread_mutex_unlock(&vstream->stream->lock);
viewer_stream_put(vstream);
- ret = -1; /* Error. */
+ ret = -1; /* Error. */
goto end_unlock;
}
- DBG("Sending stream %" PRIu64 " to viewer",
- vstream->stream->stream_handle);
+ DBG("Sending stream %" PRIu64 " to viewer", vstream->stream->stream_handle);
vstream->sent_flag = 1;
pthread_mutex_unlock(&vstream->stream->lock);
* Return 0 on success or else a negative value.
*/
static int make_viewer_streams(struct relay_session *relay_session,
- struct relay_viewer_session *viewer_session,
- enum lttng_viewer_seek seek_t,
- uint32_t *nb_total,
- uint32_t *nb_unsent,
- uint32_t *nb_created,
- bool *closed)
+ struct relay_viewer_session *viewer_session,
+ enum lttng_viewer_seek seek_t,
+ uint32_t *nb_total,
+ uint32_t *nb_unsent,
+ uint32_t *nb_created,
+ bool *closed)
{
int ret;
struct lttng_ht_iter iter;
* used for a the given session id only.
*/
rcu_read_lock();
- cds_lfht_for_each_entry (relay_session->ctf_traces_ht->ht, &iter.iter,
- ctf_trace, node.node) {
+ cds_lfht_for_each_entry (
+ relay_session->ctf_traces_ht->ht, &iter.iter, ctf_trace, node.node) {
bool trace_has_metadata_stream = false;
health_code_update();
* Iterate over all the streams of the trace to see if we have a
* metadata stream.
*/
- cds_list_for_each_entry_rcu(relay_stream,
- &ctf_trace->stream_list, stream_node)
+ cds_list_for_each_entry_rcu(relay_stream, &ctf_trace->stream_list, stream_node)
{
bool is_metadata_stream;
* and we never sent one to the viewer, skip the trace. We
* accept that the viewer will not see this trace at all.
*/
- if (!trace_has_metadata_stream &&
- !ctf_trace->metadata_stream_sent_to_viewer) {
+ if (!trace_has_metadata_stream && !ctf_trace->metadata_stream_sent_to_viewer) {
ctf_trace_put(ctf_trace);
continue;
}
- cds_list_for_each_entry_rcu(relay_stream,
- &ctf_trace->stream_list, stream_node)
+ cds_list_for_each_entry_rcu(relay_stream, &ctf_trace->stream_list, stream_node)
{
struct relay_viewer_stream *viewer_stream;
if (!relay_stream->published) {
goto next;
}
- viewer_stream = viewer_stream_get_by_id(
- relay_stream->stream_handle);
+ viewer_stream = viewer_stream_get_by_id(relay_stream->stream_handle);
if (!viewer_stream) {
struct lttng_trace_chunk *viewer_stream_trace_chunk = NULL;
* chunk can be used safely.
*/
if ((relay_stream->ongoing_rotation.is_set ||
- session_has_ongoing_rotation(relay_session)) &&
- relay_stream->trace_chunk) {
- viewer_stream_trace_chunk = lttng_trace_chunk_copy(
- relay_stream->trace_chunk);
+ session_has_ongoing_rotation(relay_session)) &&
+ relay_stream->trace_chunk) {
+ viewer_stream_trace_chunk =
+ lttng_trace_chunk_copy(relay_stream->trace_chunk);
if (!viewer_stream_trace_chunk) {
ret = -1;
ctf_trace_put(ctf_trace);
}
} else {
/*
- * Transition the viewer session into the newest trace chunk available.
+ * Transition the viewer session into the newest trace chunk
+ * available.
*/
- if (!lttng_trace_chunk_ids_equal(viewer_session->current_trace_chunk,
- relay_stream->trace_chunk)) {
-
+ if (!lttng_trace_chunk_ids_equal(
+ viewer_session->current_trace_chunk,
+ relay_stream->trace_chunk)) {
ret = viewer_session_set_trace_chunk_copy(
- viewer_session,
- relay_stream->trace_chunk);
+ viewer_session, relay_stream->trace_chunk);
if (ret) {
ret = -1;
ctf_trace_put(ctf_trace);
* clear against a stopped
* session).
*/
- const bool reference_acquired = lttng_trace_chunk_get(
+ const bool reference_acquired =
+ lttng_trace_chunk_get(
viewer_session->current_trace_chunk);
LTTNG_ASSERT(reference_acquired);
viewer_stream_trace_chunk =
- viewer_session->current_trace_chunk;
+ viewer_session->current_trace_chunk;
}
}
viewer_stream = viewer_stream_create(
- relay_stream,
- viewer_stream_trace_chunk,
- seek_t);
+ relay_stream, viewer_stream_trace_chunk, seek_t);
lttng_trace_chunk_put(viewer_stream_trace_chunk);
viewer_stream_trace_chunk = NULL;
if (!viewer_stream) {
if (nb_total) {
if (relay_stream->is_metadata) {
if (!relay_stream->closed ||
- relay_stream->metadata_received >
- viewer_stream->metadata_sent) {
+ relay_stream->metadata_received >
+ viewer_stream->metadata_sent) {
(*nb_total)++;
}
} else {
if (!relay_stream->closed ||
- !(((int64_t)(relay_stream->prev_data_seq -
- relay_stream->last_net_seq_num)) >=
- 0)) {
+ !(((int64_t) (relay_stream->prev_data_seq -
+ relay_stream->last_net_seq_num)) >= 0)) {
(*nb_total)++;
}
}
return 0;
}
-static
-int create_sock(void *data, int *out_fd)
+static int create_sock(void *data, int *out_fd)
{
int ret;
struct lttcomm_sock *sock = (lttcomm_sock *) data;
return ret;
}
-static
-int close_sock(void *data, int *in_fd __attribute__((unused)))
+static int close_sock(void *data, int *in_fd __attribute__((unused)))
{
struct lttcomm_sock *sock = (lttcomm_sock *) data;
return ret;
}
-static
-struct lttcomm_sock *accept_live_sock(struct lttcomm_sock *listening_sock,
- const char *name)
+static struct lttcomm_sock *accept_live_sock(struct lttcomm_sock *listening_sock, const char *name)
{
int out_fd, ret;
struct lttcomm_sock *socks[2] = { listening_sock, NULL };
struct lttcomm_sock *new_sock = NULL;
- ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &out_fd,
- (const char **) &name, 1, accept_sock, &socks);
+ ret = fd_tracker_open_unsuspendable_fd(
+ the_fd_tracker, &out_fd, (const char **) &name, 1, accept_sock, &socks);
if (ret) {
goto end;
}
/*
* Create and init socket from uri.
*/
-static
-struct lttcomm_sock *init_socket(struct lttng_uri *uri, const char *name)
+static struct lttcomm_sock *init_socket(struct lttng_uri *uri, const char *name)
{
int ret, sock_fd;
struct lttcomm_sock *sock = NULL;
ret = uri_to_str_url(uri, uri_str, sizeof(uri_str));
uri_str[sizeof(uri_str) - 1] = '\0';
if (ret >= 0) {
- ret = asprintf(&formated_name, "%s socket @ %s", name,
- uri_str);
+ ret = asprintf(&formated_name, "%s socket @ %s", name, uri_str);
if (ret < 0) {
formated_name = NULL;
}
}
- ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &sock_fd,
- (const char **) (formated_name ? &formated_name : NULL),
- 1, create_sock, sock);
+ ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
+ &sock_fd,
+ (const char **) (formated_name ? &formated_name :
+ NULL),
+ 1,
+ create_sock,
+ sock);
if (ret) {
- PERROR("Failed to create \"%s\" socket",
- formated_name ?: "Unknown");
+ PERROR("Failed to create \"%s\" socket", formated_name ?: "Unknown");
goto error;
}
DBG("Listening on %s socket %d", name, sock->fd);
ret = sock->ops->listen(sock, -1);
if (ret < 0) {
goto error;
-
}
free(formated_name);
/*
* This thread manages the listening for new connections on the network
*/
-static
-void *thread_listener(void *data __attribute__((unused)))
+static void *thread_listener(void *data __attribute__((unused)))
{
int i, ret, err = -1;
uint32_t nb_fd;
}
/* Pass 2 as size here for the thread quit pipe and control sockets. */
- ret = create_named_thread_poll_set(&events, 2,
- "Live listener thread epoll");
+ ret = create_named_thread_poll_set(&events, 2, "Live listener thread epoll");
if (ret < 0) {
goto error_create_poll;
}
DBG("Listener accepting live viewers connections");
-restart:
+ restart:
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
health_poll_exit();
struct lttcomm_sock *newsock;
newsock = accept_live_sock(live_control_sock,
- "Live socket to client");
+ "Live socket to client");
if (!newsock) {
PERROR("accepting control sock");
goto error;
}
DBG("Relay viewer connection accepted socket %d", newsock->fd);
- ret = setsockopt(newsock->fd, SOL_SOCKET, SO_REUSEADDR, &val,
- sizeof(val));
+ ret = setsockopt(
+ newsock->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (ret < 0) {
PERROR("setsockopt inet");
lttcomm_destroy_sock(newsock);
/* Enqueue request for the dispatcher thread. */
cds_wfcq_head_ptr_t head;
head.h = &viewer_conn_queue.head;
- cds_wfcq_enqueue(head, &viewer_conn_queue.tail,
- &new_conn->qnode);
+ cds_wfcq_enqueue(head, &viewer_conn_queue.tail, &new_conn->qnode);
/*
* Wake the dispatch queue futex.
if (live_control_sock->fd >= 0) {
int sock_fd = live_control_sock->fd;
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- &sock_fd, 1, close_sock,
- live_control_sock);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &sock_fd, 1, close_sock, live_control_sock);
if (ret) {
PERROR("close");
}
/*
* This thread manages the dispatching of the requests to worker threads
*/
-static
-void *thread_dispatcher(void *data __attribute__((unused)))
+static void *thread_dispatcher(void *data __attribute__((unused)))
{
int err = -1;
ssize_t ret;
&viewer_conn_queue.tail);
if (node == NULL) {
DBG("Woken up but nothing in the live-viewer "
- "relay command queue");
+ "relay command queue");
/* Continue thread execution */
break;
}
conn = lttng::utils::container_of(node, &relay_connection::qnode);
- DBG("Dispatching viewer request waiting on sock %d",
- conn->sock->fd);
+ DBG("Dispatching viewer request waiting on sock %d", conn->sock->fd);
/*
* Inform worker thread of the new request. This
*
* Return 0 on success or else negative value.
*/
-static
-int viewer_connect(struct relay_connection *conn)
+static int viewer_connect(struct relay_connection *conn)
{
int ret;
struct lttng_viewer_connect reply, msg;
/* Major versions must be the same */
if (reply.major != be32toh(msg.major)) {
DBG("Incompatible major versions ([relayd] %u vs [client] %u)",
- reply.major, be32toh(msg.major));
+ reply.major,
+ be32toh(msg.major));
ret = -1;
goto end;
}
*
* Return 0 on success or else a negative value.
*/
-static
-int viewer_list_sessions(struct relay_connection *conn)
+static int viewer_list_sessions(struct relay_connection *conn)
{
int ret = 0;
struct lttng_viewer_list_sessions session_list;
}
rcu_read_lock();
- cds_lfht_for_each_entry(sessions_ht->ht, &iter.iter, session,
- session_n.node) {
+ cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, session, session_n.node) {
struct lttng_viewer_session *send_session;
health_code_update();
struct lttng_viewer_session *newbuf;
uint32_t new_buf_count = buf_count << 1;
- newbuf = (lttng_viewer_session *) realloc(send_session_buf,
- new_buf_count * sizeof(*send_session_buf));
+ newbuf = (lttng_viewer_session *) realloc(
+ send_session_buf, new_buf_count * sizeof(*send_session_buf));
if (!newbuf) {
ret = -1;
goto break_loop;
}
send_session = &send_session_buf[count];
if (lttng_strncpy(send_session->session_name,
- session->session_name,
- sizeof(send_session->session_name))) {
+ session->session_name,
+ sizeof(send_session->session_name))) {
ret = -1;
goto break_loop;
}
- if (lttng_strncpy(send_session->hostname, session->hostname,
- sizeof(send_session->hostname))) {
+ if (lttng_strncpy(send_session->hostname,
+ session->hostname,
+ sizeof(send_session->hostname))) {
ret = -1;
goto break_loop;
}
health_code_update();
- ret = send_response(conn->sock, send_session_buf,
- count * sizeof(*send_session_buf));
+ ret = send_response(conn->sock, send_session_buf, count * sizeof(*send_session_buf));
if (ret < 0) {
goto end_free;
}
/*
* Send the viewer the list of current streams.
*/
-static
-int viewer_get_new_streams(struct relay_connection *conn)
+static int viewer_get_new_streams(struct relay_connection *conn)
{
int ret, send_streams = 0;
uint32_t nb_created = 0, nb_unsent = 0, nb_streams = 0, nb_total = 0;
goto send_reply_unlock;
}
ret = make_viewer_streams(session,
- conn->viewer_session,
- LTTNG_VIEWER_SEEK_BEGINNING, &nb_total, &nb_unsent,
- &nb_created, &closed);
+ conn->viewer_session,
+ LTTNG_VIEWER_SEEK_BEGINNING,
+ &nb_total,
+ &nb_unsent,
+ &nb_created,
+ &closed);
if (ret < 0) {
/*
* This is caused by an internal error; propagate the negative
/*
* Send the viewer the list of current sessions.
*/
-static
-int viewer_attach_session(struct relay_connection *conn)
+static int viewer_attach_session(struct relay_connection *conn)
{
int send_streams = 0;
ssize_t ret;
if (!conn->viewer_session) {
viewer_attach_status = LTTNG_VIEWER_ATTACH_NO_SESSION;
DBG("Client trying to attach before creating a live viewer session, returning status=%s",
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
goto send_reply;
}
if (!session) {
viewer_attach_status = LTTNG_VIEWER_ATTACH_UNK;
DBG("Relay session %" PRIu64 " not found, returning status=%s",
- session_id,
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ session_id,
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
goto send_reply;
}
DBG("Attach relay session ID %" PRIu64 " received", session_id);
if (session->live_timer == 0) {
viewer_attach_status = LTTNG_VIEWER_ATTACH_NOT_LIVE;
DBG("Relay session ID %" PRIu64 " is not a live session, returning status=%s",
- session_id,
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ session_id,
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
goto send_reply;
}
send_streams = 1;
- viewer_attach_status = viewer_session_attach(conn->viewer_session,
- session);
+ viewer_attach_status = viewer_session_attach(conn->viewer_session, session);
if (viewer_attach_status != LTTNG_VIEWER_ATTACH_OK) {
DBG("Error attaching to relay session %" PRIu64 ", returning status=%s",
- session_id,
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ session_id,
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
goto send_reply;
}
seek_type = (lttng_viewer_seek) be32toh(request.seek);
break;
default:
- ERR("Wrong seek parameter for relay session %" PRIu64
- ", returning status=%s", session_id,
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ ERR("Wrong seek parameter for relay session %" PRIu64 ", returning status=%s",
+ session_id,
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
viewer_attach_status = LTTNG_VIEWER_ATTACH_SEEK_ERR;
send_streams = 0;
goto send_reply;
goto send_reply;
}
- ret = make_viewer_streams(session,
- conn->viewer_session, seek_type,
- &nb_streams, NULL, NULL, &closed);
+ ret = make_viewer_streams(
+ session, conn->viewer_session, seek_type, &nb_streams, NULL, NULL, &closed);
if (ret < 0) {
goto end_put_session;
}
response.streams_count = 0;
viewer_attach_status = LTTNG_VIEWER_ATTACH_UNK;
ERR("Session %" PRIu64 " is closed, returning status=%s",
- session_id,
- lttng_viewer_attach_return_code_str(viewer_attach_status));
+ session_id,
+ lttng_viewer_attach_return_code_str(viewer_attach_status));
goto send_reply;
}
*
* Called with rstream lock held.
*/
-static int try_open_index(struct relay_viewer_stream *vstream,
- struct relay_stream *rstream)
+static int try_open_index(struct relay_viewer_stream *vstream, struct relay_stream *rstream)
{
int ret = 0;
const uint32_t connection_major = rstream->trace->session->major;
/*
* First time, we open the index file and at least one index is ready.
*/
- if (rstream->index_received_seqcount == 0 ||
- !vstream->stream_file.trace_chunk) {
+ if (rstream->index_received_seqcount == 0 || !vstream->stream_file.trace_chunk) {
ret = -ENOENT;
goto end;
}
chunk_status = lttng_index_file_create_from_trace_chunk_read_only(
- vstream->stream_file.trace_chunk, rstream->path_name,
- rstream->channel_name, rstream->tracefile_size,
- vstream->current_tracefile_id,
- lttng_to_index_major(connection_major, connection_minor),
- lttng_to_index_minor(connection_major, connection_minor),
- true, &vstream->index_file);
+ vstream->stream_file.trace_chunk,
+ rstream->path_name,
+ rstream->channel_name,
+ rstream->tracefile_size,
+ vstream->current_tracefile_id,
+ lttng_to_index_major(connection_major, connection_minor),
+ lttng_to_index_minor(connection_major, connection_minor),
+ true,
+ &vstream->index_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) {
ret = -ENOENT;
* Called with rstream lock held.
*/
static int check_index_status(struct relay_viewer_stream *vstream,
- struct relay_stream *rstream, struct ctf_trace *trace,
- struct lttng_viewer_index *index)
+ struct relay_stream *rstream,
+ struct ctf_trace *trace,
+ struct lttng_viewer_index *index)
{
int ret;
DBG("Check index status: index_received_seqcount %" PRIu64 " "
- "index_sent_seqcount %" PRIu64 " "
- "for stream %" PRIu64,
- rstream->index_received_seqcount,
- vstream->index_sent_seqcount,
- vstream->stream->stream_handle);
- if ((trace->session->connection_closed || rstream->closed)
- && rstream->index_received_seqcount
- == vstream->index_sent_seqcount) {
+ "index_sent_seqcount %" PRIu64 " "
+ "for stream %" PRIu64,
+ rstream->index_received_seqcount,
+ vstream->index_sent_seqcount,
+ vstream->stream->stream_handle);
+ if ((trace->session->connection_closed || rstream->closed) &&
+ rstream->index_received_seqcount == vstream->index_sent_seqcount) {
/*
* Last index sent and session connection or relay
* stream are closed.
*/
index->status = LTTNG_VIEWER_INDEX_HUP;
DBG("Check index status: Connection or stream are closed, stream %" PRIu64
- ",connection-closed=%d, relay-stream-closed=%d, returning status=%s",
- vstream->stream->stream_handle,
- trace->session->connection_closed, rstream->closed,
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) index->status));
+ ",connection-closed=%d, relay-stream-closed=%d, returning status=%s",
+ vstream->stream->stream_handle,
+ trace->session->connection_closed,
+ rstream->closed,
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) index->status));
goto hup;
} else if (rstream->beacon_ts_end != -1ULL &&
- (rstream->index_received_seqcount == 0 ||
- (vstream->index_sent_seqcount != 0 &&
- rstream->index_received_seqcount
- <= vstream->index_sent_seqcount))) {
+ (rstream->index_received_seqcount == 0 ||
+ (vstream->index_sent_seqcount != 0 &&
+ rstream->index_received_seqcount <= vstream->index_sent_seqcount))) {
/*
* We've received a synchronization beacon and the last index
* available has been sent, the index for now is inactive.
index->timestamp_end = htobe64(rstream->beacon_ts_end);
index->stream_id = htobe64(rstream->ctf_stream_id);
DBG("Check index status: inactive with beacon, for stream %" PRIu64
- ", returning status=%s",
- vstream->stream->stream_handle,
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) index->status));
+ ", returning status=%s",
+ vstream->stream->stream_handle,
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) index->status));
goto index_ready;
} else if (rstream->index_received_seqcount == 0 ||
- (vstream->index_sent_seqcount != 0 &&
- rstream->index_received_seqcount
- <= vstream->index_sent_seqcount)) {
+ (vstream->index_sent_seqcount != 0 &&
+ rstream->index_received_seqcount <= vstream->index_sent_seqcount)) {
/*
* This checks whether received <= sent seqcount. In
* this case, we have not received a beacon. Therefore,
*/
index->status = LTTNG_VIEWER_INDEX_RETRY;
DBG("Check index status:"
- "did not received beacon for stream %" PRIu64
- ", returning status=%s",
- vstream->stream->stream_handle,
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) index->status));
+ "did not received beacon for stream %" PRIu64 ", returning status=%s",
+ vstream->stream->stream_handle,
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) index->status));
goto index_ready;
} else if (!tracefile_array_seq_in_file(rstream->tfa,
- vstream->current_tracefile_id,
- vstream->index_sent_seqcount)) {
+ vstream->current_tracefile_id,
+ vstream->index_sent_seqcount)) {
/*
* The next index we want to send cannot be read either
* because we need to perform a rotation, or due to
* the producer having overwritten its trace file.
*/
- DBG("Viewer stream %" PRIu64 " rotation",
- vstream->stream->stream_handle);
+ DBG("Viewer stream %" PRIu64 " rotation", vstream->stream->stream_handle);
ret = viewer_stream_rotate(vstream);
if (ret == 1) {
/* EOF across entire stream. */
index->status = LTTNG_VIEWER_INDEX_HUP;
DBG("Check index status:"
- "reached end of file for stream %" PRIu64
- ", returning status=%s",
- vstream->stream->stream_handle,
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) index->status));
+ "reached end of file for stream %" PRIu64 ", returning status=%s",
+ vstream->stream->stream_handle,
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) index->status));
goto hup;
}
/*
* still unavailable.
*/
if (rstream->tracefile_count == 1 &&
- !tracefile_array_seq_in_file(
- rstream->tfa,
- vstream->current_tracefile_id,
- vstream->index_sent_seqcount)) {
+ !tracefile_array_seq_in_file(rstream->tfa,
+ vstream->current_tracefile_id,
+ vstream->index_sent_seqcount)) {
index->status = LTTNG_VIEWER_INDEX_RETRY;
DBG("Check index status:"
- "tracefile array sequence number %" PRIu64
- " not in file for stream %" PRIu64
- ", returning status=%s",
- vstream->index_sent_seqcount,
- vstream->stream->stream_handle,
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) index->status));
+ "tracefile array sequence number %" PRIu64
+ " not in file for stream %" PRIu64 ", returning status=%s",
+ vstream->index_sent_seqcount,
+ vstream->stream->stream_handle,
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) index->status));
goto index_ready;
}
- LTTNG_ASSERT(tracefile_array_seq_in_file(rstream->tfa,
- vstream->current_tracefile_id,
- vstream->index_sent_seqcount));
+ LTTNG_ASSERT(tracefile_array_seq_in_file(
+ rstream->tfa, vstream->current_tracefile_id, vstream->index_sent_seqcount));
}
/* ret == 0 means successful so we continue. */
ret = 0;
return 1;
}
-static
-void viewer_stream_rotate_to_trace_chunk(struct relay_viewer_stream *vstream,
- struct lttng_trace_chunk *new_trace_chunk)
+static void viewer_stream_rotate_to_trace_chunk(struct relay_viewer_stream *vstream,
+ struct lttng_trace_chunk *new_trace_chunk)
{
lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
if (new_trace_chunk) {
- const bool acquired_reference = lttng_trace_chunk_get(
- new_trace_chunk);
+ const bool acquired_reference = lttng_trace_chunk_get(new_trace_chunk);
LTTNG_ASSERT(acquired_reference);
}
*
* Return 0 on success or else a negative value.
*/
-static
-int viewer_get_next_index(struct relay_connection *conn)
+static int viewer_get_next_index(struct relay_connection *conn)
{
int ret;
struct lttng_viewer_get_next_index request_index;
vstream = viewer_stream_get_by_id(be64toh(request_index.stream_id));
if (!vstream) {
viewer_index.status = LTTNG_VIEWER_INDEX_ERR;
- DBG("Client requested index of unknown stream id %" PRIu64", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Client requested index of unknown stream id %" PRIu64 ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
ctf_trace = rstream->trace;
/* metadata_viewer_stream may be NULL. */
- metadata_viewer_stream =
- ctf_trace_get_viewer_metadata_stream(ctf_trace);
+ metadata_viewer_stream = ctf_trace_get_viewer_metadata_stream(ctf_trace);
/*
* Hold the session lock to protect against concurrent changes
*/
if (rstream->is_metadata) {
viewer_index.status = LTTNG_VIEWER_INDEX_HUP;
- DBG("Client requested index of a metadata stream id %" PRIu64", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Client requested index of a metadata stream id %" PRIu64
+ ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
if (rstream->ongoing_rotation.is_set) {
/* Rotation is ongoing, try again later. */
viewer_index.status = LTTNG_VIEWER_INDEX_RETRY;
- DBG("Client requested index for stream id %" PRIu64" while a stream rotation is ongoing, returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Client requested index for stream id %" PRIu64
+ " while a stream rotation is ongoing, returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
if (session_has_ongoing_rotation(rstream->trace->session)) {
/* Rotation is ongoing, try again later. */
viewer_index.status = LTTNG_VIEWER_INDEX_RETRY;
- DBG("Client requested index for stream id %" PRIu64" while a session rotation is ongoing, returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Client requested index for stream id %" PRIu64
+ " while a session rotation is ongoing, returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
/*
* Transition the viewer session into the newest trace chunk available.
*/
- if (!lttng_trace_chunk_ids_equal(
- conn->viewer_session->current_trace_chunk,
- rstream->trace_chunk)) {
+ if (!lttng_trace_chunk_ids_equal(conn->viewer_session->current_trace_chunk,
+ rstream->trace_chunk)) {
DBG("Relay stream and viewer chunk ids differ");
- ret = viewer_session_set_trace_chunk_copy(
- conn->viewer_session,
- rstream->trace_chunk);
+ ret = viewer_session_set_trace_chunk_copy(conn->viewer_session,
+ rstream->trace_chunk);
if (ret) {
viewer_index.status = LTTNG_VIEWER_INDEX_ERR;
ERR("Error copying trace chunk for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
}
* after a session's destruction.
*/
if (vstream->stream_file.trace_chunk) {
- status = lttng_trace_chunk_get_id(
- vstream->stream_file.trace_chunk,
- &stream_file_chunk_id);
+ status = lttng_trace_chunk_get_id(vstream->stream_file.trace_chunk,
+ &stream_file_chunk_id);
LTTNG_ASSERT(status == LTTNG_TRACE_CHUNK_STATUS_OK);
}
if (conn->viewer_session->current_trace_chunk) {
- status = lttng_trace_chunk_get_id(
- conn->viewer_session->current_trace_chunk,
- &viewer_session_chunk_id);
+ status = lttng_trace_chunk_get_id(conn->viewer_session->current_trace_chunk,
+ &viewer_session_chunk_id);
LTTNG_ASSERT(status == LTTNG_TRACE_CHUNK_STATUS_OK);
}
viewer_stream_and_session_in_same_chunk = lttng_trace_chunk_ids_equal(
- conn->viewer_session->current_trace_chunk,
- vstream->stream_file.trace_chunk);
+ conn->viewer_session->current_trace_chunk, vstream->stream_file.trace_chunk);
viewer_stream_one_rotation_behind = rstream->completed_rotation_count ==
- vstream->last_seen_rotation_count + 1;
+ vstream->last_seen_rotation_count + 1;
if (viewer_stream_and_session_in_same_chunk) {
DBG("Transition to latest chunk check (%s -> %s): Same chunk, no need to rotate",
- vstream->stream_file.trace_chunk ?
- std::to_string(stream_file_chunk_id).c_str() :
- "None",
- conn->viewer_session->current_trace_chunk ?
- std::to_string(viewer_session_chunk_id).c_str() :
- "None");
+ vstream->stream_file.trace_chunk ?
+ std::to_string(stream_file_chunk_id).c_str() :
+ "None",
+ conn->viewer_session->current_trace_chunk ?
+ std::to_string(viewer_session_chunk_id).c_str() :
+ "None");
} else if (viewer_stream_one_rotation_behind && !rstream->trace_chunk) {
DBG("Transition to latest chunk check (%s -> %s): One chunk behind relay stream which is being destroyed, no need to rotate",
- vstream->stream_file.trace_chunk ?
- std::to_string(stream_file_chunk_id).c_str() :
- "None",
- conn->viewer_session->current_trace_chunk ?
- std::to_string(viewer_session_chunk_id).c_str() :
- "None");
+ vstream->stream_file.trace_chunk ?
+ std::to_string(stream_file_chunk_id).c_str() :
+ "None",
+ conn->viewer_session->current_trace_chunk ?
+ std::to_string(viewer_session_chunk_id).c_str() :
+ "None");
} else {
DBG("Transition to latest chunk check (%s -> %s): Viewer stream chunk ID and viewer session chunk ID differ, rotating viewer stream",
- vstream->stream_file.trace_chunk ?
- std::to_string(stream_file_chunk_id).c_str() :
- "None",
- conn->viewer_session->current_trace_chunk ?
- std::to_string(viewer_session_chunk_id).c_str() :
- "None");
+ vstream->stream_file.trace_chunk ?
+ std::to_string(stream_file_chunk_id).c_str() :
+ "None",
+ conn->viewer_session->current_trace_chunk ?
+ std::to_string(viewer_session_chunk_id).c_str() :
+ "None");
viewer_stream_rotate_to_trace_chunk(vstream,
- conn->viewer_session->current_trace_chunk);
- vstream->last_seen_rotation_count =
- rstream->completed_rotation_count;
+ conn->viewer_session->current_trace_chunk);
+ vstream->last_seen_rotation_count = rstream->completed_rotation_count;
}
ret = check_index_status(vstream, rstream, ctf_trace, &viewer_index);
/* Try to open an index if one is needed for that stream. */
ret = try_open_index(vstream, rstream);
if (ret == -ENOENT) {
- if (rstream->closed) {
+ if (rstream->closed) {
viewer_index.status = LTTNG_VIEWER_INDEX_HUP;
DBG("Cannot open index for stream id %" PRIu64
- "stream is closed, returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ "stream is closed, returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
- } else {
+ } else {
viewer_index.status = LTTNG_VIEWER_INDEX_RETRY;
- DBG("Cannot open index for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Cannot open index for stream id %" PRIu64 ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
- }
+ }
}
if (ret < 0) {
viewer_index.status = LTTNG_VIEWER_INDEX_ERR;
- ERR("Error opening index for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ ERR("Error opening index for stream id %" PRIu64 ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
}
struct fs_handle *fs_handle;
ret = utils_stream_file_path(rstream->path_name,
- rstream->channel_name, rstream->tracefile_size,
- vstream->current_tracefile_id, NULL, file_path,
- sizeof(file_path));
+ rstream->channel_name,
+ rstream->tracefile_size,
+ vstream->current_tracefile_id,
+ NULL,
+ file_path,
+ sizeof(file_path));
if (ret < 0) {
goto error_put;
}
* per-pid buffers) and a clear command has been performed.
*/
status = lttng_trace_chunk_open_fs_handle(
- vstream->stream_file.trace_chunk,
- file_path, O_RDONLY, 0, &fs_handle, true);
+ vstream->stream_file.trace_chunk, file_path, O_RDONLY, 0, &fs_handle, true);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
- if (status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE &&
- rstream->closed) {
+ if (status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE && rstream->closed) {
viewer_index.status = LTTNG_VIEWER_INDEX_HUP;
DBG("Cannot find trace chunk file and stream is closed for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code)
+ viewer_index.status));
goto send_reply;
}
PERROR("Failed to open trace file for viewer stream");
if (ret < 0) {
viewer_index.status = LTTNG_VIEWER_INDEX_ERR;
ERR("Error checking for new streams before sending new index to stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
} else if (ret == 1) {
viewer_index.flags |= LTTNG_VIEWER_FLAG_NEW_STREAM;
ret = lttng_index_file_read(vstream->index_file, &packet_index);
if (ret) {
viewer_index.status = LTTNG_VIEWER_INDEX_ERR;
- ERR("Relay error reading index file for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ ERR("Relay error reading index file for stream id %" PRIu64 ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
goto send_reply;
} else {
viewer_index.status = LTTNG_VIEWER_INDEX_OK;
- DBG("Read index file for stream id %" PRIu64
- ", returning status=%s",
- (uint64_t) be64toh(request_index.stream_id),
- lttng_viewer_next_index_return_code_str(
- (enum lttng_viewer_next_index_return_code) viewer_index.status));
+ DBG("Read index file for stream id %" PRIu64 ", returning status=%s",
+ (uint64_t) be64toh(request_index.stream_id),
+ lttng_viewer_next_index_return_code_str(
+ (enum lttng_viewer_next_index_return_code) viewer_index.status));
vstream->index_sent_seqcount++;
}
* Indexes are stored in big endian, no need to switch before sending.
*/
DBG("Sending viewer index for stream %" PRIu64 " offset %" PRIu64,
- rstream->stream_handle,
- (uint64_t) be64toh(packet_index.offset));
+ rstream->stream_handle,
+ (uint64_t) be64toh(packet_index.offset));
viewer_index.offset = packet_index.offset;
viewer_index.packet_size = packet_index.packet_size;
viewer_index.content_size = packet_index.content_size;
if (metadata_viewer_stream) {
pthread_mutex_lock(&metadata_viewer_stream->stream->lock);
- DBG("get next index metadata check: recv %" PRIu64
- " sent %" PRIu64,
- metadata_viewer_stream->stream->metadata_received,
- metadata_viewer_stream->metadata_sent);
+ DBG("get next index metadata check: recv %" PRIu64 " sent %" PRIu64,
+ metadata_viewer_stream->stream->metadata_received,
+ metadata_viewer_stream->metadata_sent);
if (!metadata_viewer_stream->stream->metadata_received ||
- metadata_viewer_stream->stream->metadata_received >
- metadata_viewer_stream->metadata_sent) {
+ metadata_viewer_stream->stream->metadata_received >
+ metadata_viewer_stream->metadata_sent) {
viewer_index.flags |= LTTNG_VIEWER_FLAG_NEW_METADATA;
}
pthread_mutex_unlock(&metadata_viewer_stream->stream->lock);
if (vstream) {
DBG("Index %" PRIu64 " for stream %" PRIu64 " sent",
- vstream->index_sent_seqcount,
- vstream->stream->stream_handle);
+ vstream->index_sent_seqcount,
+ vstream->stream->stream_handle);
}
end:
if (metadata_viewer_stream) {
*
* Return 0 on success or else a negative value.
*/
-static
-int viewer_get_packet(struct relay_connection *conn)
+static int viewer_get_packet(struct relay_connection *conn)
{
int ret;
off_t lseek_ret;
health_code_update();
- ret = recv_request(conn->sock, &get_packet_info,
- sizeof(get_packet_info));
+ ret = recv_request(conn->sock, &get_packet_info, sizeof(get_packet_info));
if (ret < 0) {
goto end;
}
vstream = viewer_stream_get_by_id(stream_id);
if (!vstream) {
get_packet_status = LTTNG_VIEWER_GET_PACKET_ERR;
- DBG("Client requested packet of unknown stream id %" PRIu64
- ", returning status=%s", stream_id,
- lttng_viewer_get_packet_return_code_str(get_packet_status));
+ DBG("Client requested packet of unknown stream id %" PRIu64 ", returning status=%s",
+ stream_id,
+ lttng_viewer_get_packet_return_code_str(get_packet_status));
goto send_reply_nolock;
} else {
packet_data_len = be32toh(get_packet_info.len);
if (!reply) {
get_packet_status = LTTNG_VIEWER_GET_PACKET_ERR;
PERROR("Falled to allocate reply, returning status=%s",
- lttng_viewer_get_packet_return_code_str(get_packet_status));
+ lttng_viewer_get_packet_return_code_str(get_packet_status));
goto error;
}
pthread_mutex_lock(&vstream->stream->lock);
- lseek_ret = fs_handle_seek(vstream->stream_file.handle,
- be64toh(get_packet_info.offset), SEEK_SET);
+ lseek_ret = fs_handle_seek(
+ vstream->stream_file.handle, be64toh(get_packet_info.offset), SEEK_SET);
if (lseek_ret < 0) {
get_packet_status = LTTNG_VIEWER_GET_PACKET_ERR;
PERROR("Failed to seek file system handle of viewer stream %" PRIu64
- " to offset %" PRIu64", returning status=%s", stream_id,
- (uint64_t) be64toh(get_packet_info.offset),
- lttng_viewer_get_packet_return_code_str(get_packet_status));
+ " to offset %" PRIu64 ", returning status=%s",
+ stream_id,
+ (uint64_t) be64toh(get_packet_info.offset),
+ lttng_viewer_get_packet_return_code_str(get_packet_status));
goto error;
}
- read_len = fs_handle_read(vstream->stream_file.handle,
- reply + sizeof(reply_header), packet_data_len);
+ read_len = fs_handle_read(
+ vstream->stream_file.handle, reply + sizeof(reply_header), packet_data_len);
if (read_len < packet_data_len) {
get_packet_status = LTTNG_VIEWER_GET_PACKET_ERR;
PERROR("Failed to read from file system handle of viewer stream id %" PRIu64
- ", offset: %" PRIu64 ", returning status=%s", stream_id,
+ ", offset: %" PRIu64 ", returning status=%s",
+ stream_id,
(uint64_t) be64toh(get_packet_info.offset),
- lttng_viewer_get_packet_return_code_str(get_packet_status));
+ lttng_viewer_get_packet_return_code_str(get_packet_status));
goto error;
}
ret = send_response(conn->sock, reply, reply_size);
} else {
/* No reply to send. */
- ret = send_response(conn->sock, &reply_header,
- reply_size);
+ ret = send_response(conn->sock, &reply_header, reply_size);
}
health_code_update();
*
* Return 0 on success else a negative value.
*/
-static
-int viewer_get_metadata(struct relay_connection *conn)
+static int viewer_get_metadata(struct relay_connection *conn)
{
int ret = 0;
int fd = -1;
* find it.
*/
DBG("Client requested metadata of unknown stream id %" PRIu64,
- (uint64_t) be64toh(request.stream_id));
+ (uint64_t) be64toh(request.stream_id));
reply.status = htobe32(LTTNG_VIEWER_METADATA_ERR);
goto send_reply;
}
}
if (vstream->stream->trace_chunk &&
- !lttng_trace_chunk_ids_equal(
- conn->viewer_session->current_trace_chunk,
- vstream->stream->trace_chunk)) {
+ !lttng_trace_chunk_ids_equal(conn->viewer_session->current_trace_chunk,
+ vstream->stream->trace_chunk)) {
/* A rotation has occurred on the relay stream. */
DBG("Metadata relay stream and viewer chunk ids differ");
- ret = viewer_session_set_trace_chunk_copy(
- conn->viewer_session,
- vstream->stream->trace_chunk);
+ ret = viewer_session_set_trace_chunk_copy(conn->viewer_session,
+ vstream->stream->trace_chunk);
if (ret) {
reply.status = htobe32(LTTNG_VIEWER_METADATA_ERR);
goto send_reply;
}
if (conn->viewer_session->current_trace_chunk &&
- !lttng_trace_chunk_ids_equal(conn->viewer_session->current_trace_chunk,
- vstream->stream_file.trace_chunk)) {
+ !lttng_trace_chunk_ids_equal(conn->viewer_session->current_trace_chunk,
+ vstream->stream_file.trace_chunk)) {
bool acquired_reference;
DBG("Viewer session and viewer stream chunk differ: "
- "vsession chunk %p vstream chunk %p",
- conn->viewer_session->current_trace_chunk,
- vstream->stream_file.trace_chunk);
+ "vsession chunk %p vstream chunk %p",
+ conn->viewer_session->current_trace_chunk,
+ vstream->stream_file.trace_chunk);
lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
- acquired_reference = lttng_trace_chunk_get(conn->viewer_session->current_trace_chunk);
+ acquired_reference =
+ lttng_trace_chunk_get(conn->viewer_session->current_trace_chunk);
LTTNG_ASSERT(acquired_reference);
- vstream->stream_file.trace_chunk =
- conn->viewer_session->current_trace_chunk;
+ vstream->stream_file.trace_chunk = conn->viewer_session->current_trace_chunk;
viewer_stream_close_files(vstream);
}
reply.status = htobe32(LTTNG_VIEWER_NO_NEW_METADATA);
len = 0;
goto send_reply;
- } else if (vstream->stream_file.trace_chunk &&
- !vstream->stream_file.handle && len > 0) {
+ } else if (vstream->stream_file.trace_chunk && !vstream->stream_file.handle && len > 0) {
/*
* Either this is the first time the metadata file is read, or a
* rotation of the corresponding relay stream has occurred.
struct relay_stream *rstream = vstream->stream;
ret = utils_stream_file_path(rstream->path_name,
- rstream->channel_name, rstream->tracefile_size,
- vstream->current_tracefile_id, NULL, file_path,
- sizeof(file_path));
+ rstream->channel_name,
+ rstream->tracefile_size,
+ vstream->current_tracefile_id,
+ NULL,
+ file_path,
+ sizeof(file_path));
if (ret < 0) {
goto error;
}
* per-pid buffers) and a clear command has been performed.
*/
status = lttng_trace_chunk_open_fs_handle(
- vstream->stream_file.trace_chunk,
- file_path, O_RDONLY, 0, &fs_handle, true);
+ vstream->stream_file.trace_chunk, file_path, O_RDONLY, 0, &fs_handle, true);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) {
reply.status = htobe32(LTTNG_VIEWER_NO_NEW_METADATA);
* safe to assume that
* `metadata_received` > `metadata_sent`.
*/
- const off_t seek_ret = fs_handle_seek(fs_handle,
- vstream->metadata_sent, SEEK_SET);
+ const off_t seek_ret =
+ fs_handle_seek(fs_handle, vstream->metadata_sent, SEEK_SET);
if (seek_ret < 0) {
PERROR("Failed to seek metadata viewer stream file to `sent` position: pos = %" PRId64,
- vstream->metadata_sent);
+ vstream->metadata_sent);
reply.status = htobe32(LTTNG_VIEWER_METADATA_ERR);
goto send_reply;
}
* attempt to parse an incomplete (incoherent) metadata
* stream, which would result in an error.
*/
- const off_t seek_ret = fs_handle_seek(
- vstream->stream_file.handle, -read_len,
- SEEK_CUR);
+ const off_t seek_ret =
+ fs_handle_seek(vstream->stream_file.handle, -read_len, SEEK_CUR);
DBG("Failed to read metadata: requested = %" PRIu64 ", got = %zd",
- len, read_len);
+ len,
+ read_len);
read_len = 0;
len = 0;
if (seek_ret < 0) {
}
}
- DBG("Sent %" PRIu64 " bytes of metadata for stream %" PRIu64, len,
- (uint64_t) be64toh(request.stream_id));
+ DBG("Sent %" PRIu64 " bytes of metadata for stream %" PRIu64,
+ len,
+ (uint64_t) be64toh(request.stream_id));
DBG("Metadata sent");
*
* Return 0 on success or else a negative value.
*/
-static
-int viewer_create_session(struct relay_connection *conn)
+static int viewer_create_session(struct relay_connection *conn)
{
int ret;
struct lttng_viewer_create_session_response resp;
*
* Return 0 on success or else a negative value.
*/
-static
-int viewer_detach_session(struct relay_connection *conn)
+static int viewer_detach_session(struct relay_connection *conn)
{
int ret;
struct lttng_viewer_detach_session_response response;
session = session_get_by_id(be64toh(request.session_id));
if (!session) {
- DBG("Relay session %" PRIu64 " not found",
- (uint64_t) be64toh(request.session_id));
+ DBG("Relay session %" PRIu64 " not found", (uint64_t) be64toh(request.session_id));
response.status = htobe32(LTTNG_VIEWER_DETACH_SESSION_UNK);
goto send_reply;
}
/*
* live_relay_unknown_command: send -1 if received unknown command
*/
-static
-void live_relay_unknown_command(struct relay_connection *conn)
+static void live_relay_unknown_command(struct relay_connection *conn)
{
struct lttcomm_relayd_generic_reply reply;
/*
* Process the commands received on the control socket
*/
-static
-int process_control(struct lttng_viewer_cmd *recv_hdr,
- struct relay_connection *conn)
+static int process_control(struct lttng_viewer_cmd *recv_hdr, struct relay_connection *conn)
{
int ret = 0;
- lttng_viewer_command cmd =
- (lttng_viewer_command) be32toh(recv_hdr->cmd);
+ lttng_viewer_command cmd = (lttng_viewer_command) be32toh(recv_hdr->cmd);
/*
* Make sure we've done the version check before any command other then
*/
if (cmd != LTTNG_VIEWER_CONNECT && !conn->version_check_done) {
ERR("Viewer on connection %d requested %s command before version check",
- conn->sock->fd, lttng_viewer_command_str(cmd));
+ conn->sock->fd,
+ lttng_viewer_command_str(cmd));
ret = -1;
goto end;
}
DBG("Processing %s viewer command from connection %d",
- lttng_viewer_command_str(cmd), conn->sock->fd);
+ lttng_viewer_command_str(cmd),
+ conn->sock->fd);
switch (cmd) {
case LTTNG_VIEWER_CONNECT:
ret = viewer_detach_session(conn);
break;
default:
- ERR("Received unknown viewer command (%u)",
- be32toh(recv_hdr->cmd));
+ ERR("Received unknown viewer command (%u)", be32toh(recv_hdr->cmd));
live_relay_unknown_command(conn);
ret = -1;
goto end;
return ret;
}
-static
-void cleanup_connection_pollfd(struct lttng_poll_event *events, int pollfd)
+static void cleanup_connection_pollfd(struct lttng_poll_event *events, int pollfd)
{
int ret;
(void) lttng_poll_del(events, pollfd);
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker, &pollfd, 1,
- fd_tracker_util_close_fd, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, NULL);
if (ret < 0) {
ERR("Closing pollfd %d", pollfd);
}
/*
* This thread does the actual work
*/
-static
-void *thread_worker(void *data __attribute__((unused)))
+static void *thread_worker(void *data __attribute__((unused)))
{
int ret, err = -1;
uint32_t nb_fd;
goto viewer_connections_ht_error;
}
- ret = create_named_thread_poll_set(&events, 2,
- "Live viewer worker thread epoll");
+ ret = create_named_thread_poll_set(&events, 2, "Live viewer worker thread epoll");
if (ret < 0) {
goto error_poll_create;
}
if (revents & LPOLLIN) {
struct relay_connection *conn;
- ret = lttng_read(live_conn_pipe[0],
- &conn, sizeof(conn));
+ ret = lttng_read(live_conn_pipe[0], &conn, sizeof(conn));
if (ret < 0) {
goto error;
}
- ret = lttng_poll_add(&events,
- conn->sock->fd,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(
+ &events, conn->sock->fd, LPOLLIN | LPOLLRDHUP);
if (ret) {
ERR("Failed to add new live connection file descriptor to poll set");
goto error;
ERR("Relay live pipe error");
goto error;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
} else {
}
if (revents & LPOLLIN) {
- ret = conn->sock->ops->recvmsg(conn->sock, &recv_hdr,
- sizeof(recv_hdr), 0);
+ ret = conn->sock->ops->recvmsg(
+ conn->sock, &recv_hdr, sizeof(recv_hdr), 0);
if (ret <= 0) {
/* Connection closed. */
cleanup_connection_pollfd(&events, pollfd);
cleanup_connection_pollfd(&events, pollfd);
/* Put "create" ownership reference. */
connection_put(conn);
- DBG("Viewer connection closed with %d", pollfd);
+ DBG("Viewer connection closed with %d",
+ pollfd);
}
}
} else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
/* Put "create" ownership reference. */
connection_put(conn);
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
connection_put(conn);
goto error;
}
/* Cleanup remaining connection object. */
rcu_read_lock();
- cds_lfht_for_each_entry(viewer_connections_ht->ht, &iter.iter,
- destroy_conn,
- sock_n.node) {
+ cds_lfht_for_each_entry (viewer_connections_ht->ht, &iter.iter, destroy_conn, sock_n.node) {
health_code_update();
connection_put(destroy_conn);
}
*/
static int create_conn_pipe(void)
{
- return fd_tracker_util_pipe_open_cloexec(the_fd_tracker,
- "Live connection pipe", live_conn_pipe);
+ return fd_tracker_util_pipe_open_cloexec(
+ the_fd_tracker, "Live connection pipe", live_conn_pipe);
}
int relayd_live_join(void)
}
/* Setup the dispatcher thread */
- ret = pthread_create(&live_dispatcher_thread, default_pthread_attr(),
- thread_dispatcher, (void *) NULL);
+ ret = pthread_create(
+ &live_dispatcher_thread, default_pthread_attr(), thread_dispatcher, (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create viewer dispatcher");
}
/* Setup the worker thread */
- ret = pthread_create(&live_worker_thread, default_pthread_attr(),
- thread_worker, NULL);
+ ret = pthread_create(&live_worker_thread, default_pthread_attr(), thread_worker, NULL);
if (ret) {
errno = ret;
PERROR("pthread_create viewer worker");
}
/* Setup the listener thread */
- ret = pthread_create(&live_listener_thread, default_pthread_attr(),
- thread_listener, (void *) NULL);
+ ret = pthread_create(
+ &live_listener_thread, default_pthread_attr(), thread_listener, (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create viewer listener");
*/
#define _LGPL_SOURCE
-#include <getopt.h>
-#include <grp.h>
-#include <limits.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/resource.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include <inttypes.h>
-#include <urcu/futex.h>
-#include <urcu/uatomic.h>
-#include <urcu/rculist.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <strings.h>
-#include <ctype.h>
-#include <algorithm>
-
-#include <lttng/lttng.h>
-#include <common/common.hpp>
-#include <common/compat/poll.hpp>
-#include <common/compat/socket.hpp>
-#include <common/compat/endian.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/defaults.hpp>
-#include <common/daemonize.hpp>
-#include <common/futex.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/sessiond-comm/inet.hpp>
-#include <common/sessiond-comm/relayd.hpp>
-#include <common/uri.hpp>
-#include <common/utils.hpp>
-#include <common/path.hpp>
-#include <common/align.hpp>
-#include <common/ini-config/ini-config.hpp>
-#include <common/dynamic-buffer.hpp>
-#include <common/buffer-view.hpp>
-#include <common/string-utils/format.hpp>
-#include <common/fd-tracker/fd-tracker.hpp>
-#include <common/fd-tracker/utils.hpp>
-
#include "backward-compatibility-group-by.hpp"
#include "cmd.hpp"
#include "connection.hpp"
#include "version.hpp"
#include "viewer-stream.hpp"
+#include <common/align.hpp>
+#include <common/buffer-view.hpp>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/poll.hpp>
+#include <common/compat/socket.hpp>
+#include <common/daemonize.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fd-tracker/utils.hpp>
+#include <common/futex.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/path.hpp>
+#include <common/sessiond-comm/inet.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/format.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
+#include <algorithm>
+#include <ctype.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <grp.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <urcu/futex.h>
+#include <urcu/rculist.h>
+#include <urcu/uatomic.h>
+
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
#include <lttng-relayd.8.h>
#else
-NULL
+ NULL
#endif
-;
+ ;
enum relay_connection_status {
RELAY_CONNECTION_STATUS_OK,
enum relay_group_output_by opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_UNKNOWN;
/* Argument variables */
-int lttng_opt_quiet; /* not static in error.h */
-int lttng_opt_verbose; /* not static in error.h */
-int lttng_opt_mi; /* not static in error.h */
+int lttng_opt_quiet; /* not static in error.h */
+int lttng_opt_verbose; /* not static in error.h */
+int lttng_opt_mi; /* not static in error.h */
/*
* We need to wait for listener and live listener threads, as well as
* health check thread, before being ready to signal readiness.
*/
-#define NR_LTTNG_RELAY_READY 3
+#define NR_LTTNG_RELAY_READY 3
static int lttng_relay_ready = NR_LTTNG_RELAY_READY;
/* Size of receive buffer. */
-#define RECV_DATA_BUFFER_SIZE 65536
+#define RECV_DATA_BUFFER_SIZE 65536
-static int recv_child_signal; /* Set to 1 when a SIGUSR1 signal is received. */
-static pid_t child_ppid; /* Internal parent PID use with daemonize. */
+static int recv_child_signal; /* Set to 1 when a SIGUSR1 signal is received. */
+static pid_t child_ppid; /* Internal parent PID use with daemonize. */
static struct lttng_uri *control_uri;
static struct lttng_uri *data_uri;
const char *tracing_group_name = DEFAULT_TRACING_GROUP;
static int tracing_group_name_override;
-const char * const config_section_name = "relayd";
+const char *const config_section_name = "relayd";
/*
* This pipe is used to inform the worker thread that a command is queued and
struct fd_tracker *the_fd_tracker;
static struct option long_options[] = {
- { "control-port", 1, 0, 'C', },
- { "data-port", 1, 0, 'D', },
- { "live-port", 1, 0, 'L', },
- { "daemonize", 0, 0, 'd', },
- { "background", 0, 0, 'b', },
- { "group", 1, 0, 'g', },
- { "fd-pool-size", 1, 0, '\0', },
- { "help", 0, 0, 'h', },
- { "output", 1, 0, 'o', },
- { "verbose", 0, 0, 'v', },
+ {
+ "control-port",
+ 1,
+ 0,
+ 'C',
+ },
+ {
+ "data-port",
+ 1,
+ 0,
+ 'D',
+ },
+ {
+ "live-port",
+ 1,
+ 0,
+ 'L',
+ },
+ {
+ "daemonize",
+ 0,
+ 0,
+ 'd',
+ },
+ {
+ "background",
+ 0,
+ 0,
+ 'b',
+ },
+ {
+ "group",
+ 1,
+ 0,
+ 'g',
+ },
+ {
+ "fd-pool-size",
+ 1,
+ 0,
+ '\0',
+ },
+ {
+ "help",
+ 0,
+ 0,
+ 'h',
+ },
+ {
+ "output",
+ 1,
+ 0,
+ 'o',
+ },
+ {
+ "verbose",
+ 0,
+ 0,
+ 'v',
+ },
{ "config", 1, 0, 'f' },
{ "version", 0, 0, 'V' },
- { "working-directory", 1, 0, 'w', },
- { "group-output-by-session", 0, 0, 's', },
- { "group-output-by-host", 0, 0, 'p', },
+ {
+ "working-directory",
+ 1,
+ 0,
+ 'w',
+ },
+ {
+ "group-output-by-session",
+ 0,
+ 0,
+ 's',
+ },
+ {
+ "group-output-by-host",
+ 0,
+ 0,
+ 'p',
+ },
{ "disallow-clear", 0, 0, 'x' },
- { NULL, 0, 0, 0, },
+ {
+ NULL,
+ 0,
+ 0,
+ 0,
+ },
};
static const char *config_ignore_options[] = { "help", "config", "version" };
-static void print_version(void) {
+static void print_version(void)
+{
fprintf(stdout, "%s\n", VERSION);
}
static void relayd_config_log(void)
{
DBG("LTTng-relayd " VERSION " - " VERSION_NAME "%s%s",
- GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
- EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+ GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+ EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
DBG("LTTng-relayd extra version description:\n\t" EXTRA_VERSION_DESCRIPTION "\n");
}
goto end;
}
if (v >= UINT_MAX) {
- ERR("File descriptor cap overflow in --fd-pool-size parameter: %s", arg);
+ ERR("File descriptor cap overflow in --fd-pool-size parameter: %s",
+ arg);
ret = -1;
goto end;
}
case 'C':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-C, --control-port");
+ "-C, --control-port");
} else {
ret = uri_parse(arg, &control_uri);
if (ret < 0) {
case 'D':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-D, -data-port");
+ "-D, -data-port");
} else {
ret = uri_parse(arg, &data_uri);
if (ret < 0) {
case 'L':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-L, -live-port");
+ "-L, -live-port");
} else {
ret = uri_parse(arg, &live_uri);
if (ret < 0) {
case 'g':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-g, --group");
+ "-g, --group");
} else {
tracing_group_name = strdup(arg);
if (tracing_group_name == NULL) {
case 'o':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-o, --output");
+ "-o, --output");
} else {
ret = asprintf(&opt_output_path, "%s", arg);
if (ret < 0) {
case 'w':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-w, --working-directory");
+ "-w, --working-directory");
} else {
ret = asprintf(&opt_working_directory, "%s", arg);
if (ret < 0) {
* return value conventions.
*/
static int config_entry_handler(const struct config_entry *entry,
- void *unused __attribute__((unused)))
+ void *unused __attribute__((unused)))
{
int ret = 0, i;
if (ret <= 0) {
if (ret) {
WARN("Invalid configuration value \"%s\" for option %s",
- entry->value, entry->name);
+ entry->value,
+ entry->name);
}
/* False, skip boolean config option. */
goto end;
goto end;
}
- WARN("Unrecognized option \"%s\" in daemon configuration file.",
- entry->name);
+ WARN("Unrecognized option \"%s\" in daemon configuration file.", entry->name);
end:
return ret;
if (value) {
opt_working_directory = strdup(value);
if (!opt_working_directory) {
- ERR("Failed to allocate working directory string (\"%s\")",
- value);
+ ERR("Failed to allocate working directory string (\"%s\")", value);
ret = -1;
}
}
}
DBG("File descriptor count limits are %" PRIu64 " (soft) and %" PRIu64 " (hard)",
- (uint64_t) rlimit.rlim_cur,
- (uint64_t) rlimit.rlim_max);
+ (uint64_t) rlimit.rlim_cur,
+ (uint64_t) rlimit.rlim_max);
if (lttng_opt_fd_pool_size == -1) {
/* Use default value (soft limit - reserve). */
if (rlimit.rlim_cur < DEFAULT_RELAYD_MIN_FD_POOL_SIZE) {
- ERR("The process' file number limit is too low (%" PRIu64 "). The process' file number limit must be set to at least %i.",
- (uint64_t) rlimit.rlim_cur, DEFAULT_RELAYD_MIN_FD_POOL_SIZE);
+ ERR("The process' file number limit is too low (%" PRIu64
+ "). The process' file number limit must be set to at least %i.",
+ (uint64_t) rlimit.rlim_cur,
+ DEFAULT_RELAYD_MIN_FD_POOL_SIZE);
ret = -1;
goto end;
}
- lttng_opt_fd_pool_size = rlimit.rlim_cur -
- DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE;
+ lttng_opt_fd_pool_size = rlimit.rlim_cur - DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE;
goto end;
}
if (lttng_opt_fd_pool_size < DEFAULT_RELAYD_MIN_FD_POOL_SIZE) {
ERR("File descriptor pool size must be set to at least %d",
- DEFAULT_RELAYD_MIN_FD_POOL_SIZE);
+ DEFAULT_RELAYD_MIN_FD_POOL_SIZE);
ret = -1;
goto end;
}
if (lttng_opt_fd_pool_size > rlimit.rlim_cur) {
- ERR("File descriptor pool size argument (%u) exceeds the process' soft limit (%" PRIu64 ").",
- lttng_opt_fd_pool_size, (uint64_t) rlimit.rlim_cur);
+ ERR("File descriptor pool size argument (%u) exceeds the process' soft limit (%" PRIu64
+ ").",
+ lttng_opt_fd_pool_size,
+ (uint64_t) rlimit.rlim_cur);
ret = -1;
goto end;
}
DBG("File descriptor pool size argument (%u) adjusted to %u to accommodates transient fd uses",
- lttng_opt_fd_pool_size,
- lttng_opt_fd_pool_size - DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE);
+ lttng_opt_fd_pool_size,
+ lttng_opt_fd_pool_size - DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE);
lttng_opt_fd_pool_size -= DEFAULT_RELAYD_FD_POOL_SIZE_RESERVE;
end:
return ret;
char *config_path = NULL;
optstring = utils_generate_optstring(long_options,
- sizeof(long_options) / sizeof(struct option));
+ sizeof(long_options) / sizeof(struct option));
if (!optstring) {
retval = -ENOMEM;
goto exit;
/* Check for the --config option */
- while ((c = getopt_long(argc, argv, optstring, long_options,
- &option_index)) != -1) {
+ while ((c = getopt_long(argc, argv, optstring, long_options, &option_index)) != -1) {
if (c == '?') {
retval = -EINVAL;
goto exit;
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-f, --config");
+ "-f, --config");
} else {
free(config_path);
config_path = utils_expand_path(optarg);
}
}
- ret = config_get_section_entries(config_path, config_section_name,
- config_entry_handler, NULL);
+ ret = config_get_section_entries(
+ config_path, config_section_name, config_entry_handler, NULL);
if (ret) {
if (ret > 0) {
ERR("Invalid configuration option at line %i", ret);
/* assign default values */
if (control_uri == NULL) {
ret = asprintf(&default_address,
- "tcp://" DEFAULT_NETWORK_CONTROL_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_CONTROL_PORT);
+ "tcp://" DEFAULT_NETWORK_CONTROL_BIND_ADDRESS ":%d",
+ DEFAULT_NETWORK_CONTROL_PORT);
if (ret < 0) {
PERROR("asprintf default data address");
retval = -1;
}
if (data_uri == NULL) {
ret = asprintf(&default_address,
- "tcp://" DEFAULT_NETWORK_DATA_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_DATA_PORT);
+ "tcp://" DEFAULT_NETWORK_DATA_BIND_ADDRESS ":%d",
+ DEFAULT_NETWORK_DATA_PORT);
if (ret < 0) {
PERROR("asprintf default data address");
retval = -1;
}
if (live_uri == NULL) {
ret = asprintf(&default_address,
- "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_VIEWER_PORT);
+ "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS ":%d",
+ DEFAULT_NETWORK_VIEWER_PORT);
if (ret < 0) {
PERROR("asprintf default viewer control address");
retval = -1;
if (value) {
ret = config_parse_value(value);
if (ret < 0) {
- ERR("Invalid value for %s specified", DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV);
+ ERR("Invalid value for %s specified",
+ DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV);
retval = -1;
goto exit;
}
print_sessions();
}
-static int noop_close(void *data __attribute__((unused)),
- int *fds __attribute__((unused)))
+static int noop_close(void *data __attribute__((unused)), int *fds __attribute__((unused)))
{
return 0;
}
* noop_close is used since we don't really want to close
* the stdio output fds; we merely want to stop tracking them.
*/
- (void) fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- fds, 2, noop_close, NULL);
+ (void) fd_tracker_close_unsuspendable_fd(the_fd_tracker, fds, 2, noop_close, NULL);
}
/*
}
/* Close thread quit pipes */
if (health_quit_pipe[0] != -1) {
- (void) fd_tracker_util_pipe_close(
- the_fd_tracker, health_quit_pipe);
+ (void) fd_tracker_util_pipe_close(the_fd_tracker, health_quit_pipe);
}
relayd_close_thread_quit_pipe();
if (sessiond_trace_chunk_registry) {
- sessiond_trace_chunk_registry_destroy(
- sessiond_trace_chunk_registry);
+ sessiond_trace_chunk_registry_destroy(sessiond_trace_chunk_registry);
}
if (the_fd_tracker) {
untrack_stdio();
*/
static int init_health_quit_pipe(void)
{
- return fd_tracker_util_pipe_open_cloexec(the_fd_tracker,
- "Health quit pipe", health_quit_pipe);
+ return fd_tracker_util_pipe_open_cloexec(
+ the_fd_tracker, "Health quit pipe", health_quit_pipe);
}
static int create_sock(void *data, int *out_fd)
/*
* Create and init socket from uri.
*/
-static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri,
- const char *name)
+static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri, const char *name)
{
int ret, sock_fd;
struct lttcomm_sock *sock = NULL;
ret = uri_to_str_url(uri, uri_str, sizeof(uri_str));
uri_str[sizeof(uri_str) - 1] = '\0';
if (ret >= 0) {
- ret = asprintf(&formated_name, "%s socket @ %s", name,
- uri_str);
+ ret = asprintf(&formated_name, "%s socket @ %s", name, uri_str);
if (ret < 0) {
formated_name = NULL;
}
}
- ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &sock_fd,
- (const char **) (formated_name ? &formated_name : NULL),
- 1, create_sock, sock);
+ ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker,
+ &sock_fd,
+ (const char **) (formated_name ? &formated_name :
+ NULL),
+ 1,
+ create_sock,
+ sock);
if (ret) {
- PERROR("Failed to open \"%s\" relay socket",
- formated_name ?: "Unknown");
+ PERROR("Failed to open \"%s\" relay socket", formated_name ?: "Unknown");
goto error;
}
DBG("Listening on %s socket %d", name, sock->fd);
ret = sock->ops->listen(sock, -1);
if (ret < 0) {
goto error;
-
}
free(formated_name);
return NULL;
}
-static
-struct lttcomm_sock *accept_relayd_sock(struct lttcomm_sock *listening_sock,
- const char *name)
+static struct lttcomm_sock *accept_relayd_sock(struct lttcomm_sock *listening_sock,
+ const char *name)
{
int out_fd, ret;
struct lttcomm_sock *socks[2] = { listening_sock, NULL };
struct lttcomm_sock *new_sock = NULL;
ret = fd_tracker_open_unsuspendable_fd(
- the_fd_tracker, &out_fd,
- (const char **) &name,
- 1, accept_sock, &socks);
+ the_fd_tracker, &out_fd, (const char **) &name, 1, accept_sock, &socks);
if (ret) {
goto end;
}
DBG("Listener accepting connections");
-restart:
+ restart:
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
health_poll_exit();
if (pollfd == data_sock->fd) {
type = RELAY_DATA;
newsock = accept_relayd_sock(data_sock,
- "Data socket to relayd");
+ "Data socket to relayd");
} else {
LTTNG_ASSERT(pollfd == control_sock->fd);
type = RELAY_CONTROL;
newsock = accept_relayd_sock(control_sock,
- "Control socket to relayd");
+ "Control socket to relayd");
}
if (!newsock) {
PERROR("accepting sock");
goto error;
}
- ret = setsockopt(newsock->fd, SOL_SOCKET, SO_REUSEADDR, &val,
- sizeof(val));
+ ret = setsockopt(
+ newsock->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (ret < 0) {
PERROR("setsockopt inet");
lttcomm_destroy_sock(newsock);
ret = socket_apply_keep_alive_config(newsock->fd);
if (ret < 0) {
ERR("Failed to apply TCP keep-alive configuration on socket (%i)",
- newsock->fd);
+ newsock->fd);
lttcomm_destroy_sock(newsock);
goto error;
}
/* Enqueue request for the dispatcher thread. */
cds_wfcq_head_ptr_t head;
head.h = &relay_conn_queue.head;
- cds_wfcq_enqueue(head, &relay_conn_queue.tail,
- &new_conn->qnode);
+ cds_wfcq_enqueue(head, &relay_conn_queue.tail, &new_conn->qnode);
/*
* Wake the dispatch queue futex.
if (data_sock->fd >= 0) {
int data_sock_fd = data_sock->fd;
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- &data_sock_fd, 1, close_sock,
- data_sock);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &data_sock_fd, 1, close_sock, data_sock);
if (ret) {
PERROR("Failed to close the data listener socket file descriptor");
}
if (control_sock->fd >= 0) {
int control_sock_fd = control_sock->fd;
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker,
- &control_sock_fd, 1, close_sock,
- control_sock);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &control_sock_fd, 1, close_sock, control_sock);
if (ret) {
PERROR("Failed to close the control listener socket file descriptor");
}
*
* On success, send back the session id or else return a negative value.
*/
-static int relay_create_session(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_create_session(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
ssize_t send_ret;
ret = 0;
} else if (conn->minor >= 4 && conn->minor < 11) {
/* From 2.4 to 2.10 */
- ret = cmd_create_session_2_4(payload, session_name,
- hostname, &live_timer, &snapshot);
+ ret = cmd_create_session_2_4(
+ payload, session_name, hostname, &live_timer, &snapshot);
} else {
bool has_current_chunk;
uint64_t current_chunk_id_value;
uint64_t id_sessiond_value;
/* From 2.11 to ... */
- ret = cmd_create_session_2_11(payload, session_name, hostname,
- base_path, &live_timer, &snapshot, &id_sessiond_value,
- sessiond_uuid, &has_current_chunk,
- ¤t_chunk_id_value, &creation_time_value,
- &session_name_contains_creation_timestamp);
+ ret = cmd_create_session_2_11(payload,
+ session_name,
+ hostname,
+ base_path,
+ &live_timer,
+ &snapshot,
+ &id_sessiond_value,
+ sessiond_uuid,
+ &has_current_chunk,
+ ¤t_chunk_id_value,
+ &creation_time_value,
+ &session_name_contains_creation_timestamp);
if (lttng_uuid_is_nil(sessiond_uuid)) {
/* The nil UUID is reserved for pre-2.11 clients. */
ERR("Illegal nil UUID announced by peer in create session command");
LTTNG_OPTIONAL_SET(&id_sessiond, id_sessiond_value);
LTTNG_OPTIONAL_SET(&creation_time, creation_time_value);
if (has_current_chunk) {
- LTTNG_OPTIONAL_SET(¤t_chunk_id,
- current_chunk_id_value);
+ LTTNG_OPTIONAL_SET(¤t_chunk_id, current_chunk_id_value);
}
}
goto send_reply;
}
- session = session_create(session_name, hostname, base_path, live_timer,
- snapshot, sessiond_uuid,
- id_sessiond.is_set ? &id_sessiond.value : NULL,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
- creation_time.is_set ? &creation_time.value : NULL,
- conn->major, conn->minor,
- session_name_contains_creation_timestamp);
+ session = session_create(session_name,
+ hostname,
+ base_path,
+ live_timer,
+ snapshot,
+ sessiond_uuid,
+ id_sessiond.is_set ? &id_sessiond.value : NULL,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ creation_time.is_set ? &creation_time.value : NULL,
+ conn->major,
+ conn->minor,
+ session_name_contains_creation_timestamp);
if (!session) {
ret = -1;
goto send_reply;
if (conn->minor < 11) {
/* From 2.1 to 2.10 */
- ret = lttng_dynamic_buffer_append(&reply_payload,
- &reply.generic, sizeof(reply.generic));
+ ret = lttng_dynamic_buffer_append(
+ &reply_payload, &reply.generic, sizeof(reply.generic));
if (ret) {
ERR("Failed to append \"create session\" command reply header to payload buffer");
ret = -1;
goto end;
}
} else {
- const uint32_t output_path_length =
- session ? strlen(session->output_path) + 1 : 0;
+ const uint32_t output_path_length = session ? strlen(session->output_path) + 1 : 0;
reply.output_path_length = htobe32(output_path_length);
- ret = lttng_dynamic_buffer_append(
- &reply_payload, &reply, sizeof(reply));
+ ret = lttng_dynamic_buffer_append(&reply_payload, &reply, sizeof(reply));
if (ret) {
ERR("Failed to append \"create session\" command reply header to payload buffer");
goto end;
}
if (output_path_length) {
- ret = lttng_dynamic_buffer_append(&reply_payload,
- session->output_path,
- output_path_length);
+ ret = lttng_dynamic_buffer_append(
+ &reply_payload, session->output_path, output_path_length);
if (ret) {
ERR("Failed to append \"create session\" command reply path to payload buffer");
goto end;
}
}
- send_ret = conn->sock->ops->sendmsg(conn->sock, reply_payload.data,
- reply_payload.size, 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, reply_payload.data, reply_payload.size, 0);
if (send_ret < (ssize_t) reply_payload.size) {
ERR("Failed to send \"create session\" command reply of %zu bytes (ret = %zd)",
- reply_payload.size, send_ret);
+ reply_payload.size,
+ send_ret);
ret = -1;
}
end:
*/
pthread_mutex_lock(&session->lock);
rcu_read_lock();
- cds_list_for_each_entry_rcu(stream, &session->recv_list,
- recv_node) {
+ cds_list_for_each_entry_rcu(stream, &session->recv_list, recv_node)
+ {
stream_publish(stream);
}
rcu_read_unlock();
if (strstr("../", channel_path)) {
ERR("Refusing channel path as it walks up the path hierarchy: \"%s\"",
- channel_path);
+ channel_path);
ret = -1;
goto end;
}
/*
* relay_add_stream: allocate a new stream for a session
*/
-static int relay_add_stream(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_add_stream(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (session->minor == 1) {
/* For 2.1 */
- ret = cmd_recv_stream_2_1(payload, &path_name,
- &channel_name);
+ ret = cmd_recv_stream_2_1(payload, &path_name, &channel_name);
} else if (session->minor > 1 && session->minor < 11) {
/* From 2.2 to 2.10 */
- ret = cmd_recv_stream_2_2(payload, &path_name,
- &channel_name, &tracefile_size, &tracefile_count);
+ ret = cmd_recv_stream_2_2(
+ payload, &path_name, &channel_name, &tracefile_size, &tracefile_count);
} else {
/* From 2.11 to ... */
- ret = cmd_recv_stream_2_11(payload, &path_name,
- &channel_name, &tracefile_size, &tracefile_count,
- &stream_chunk_id.value);
+ ret = cmd_recv_stream_2_11(payload,
+ &path_name,
+ &channel_name,
+ &tracefile_size,
+ &tracefile_count,
+ &stream_chunk_id.value);
stream_chunk_id.is_set = true;
}
*/
WARN("Unable to perform a --group-by-session transformation for session %" PRIu64
" for stream with path \"%s\" as it is produced by a peer using a protocol older than v2.4",
- session->id, path_name);
+ session->id,
+ path_name);
} else if (conn->minor >= 4 && conn->minor < 11) {
char *group_by_session_path_name;
LTTNG_ASSERT(session->session_name[0] != '\0');
- group_by_session_path_name =
- backward_compat_group_by_session(
- path_name,
- session->session_name,
- session->creation_time.value);
+ group_by_session_path_name = backward_compat_group_by_session(
+ path_name, session->session_name, session->creation_time.value);
if (!group_by_session_path_name) {
ERR("Failed to apply group by session to stream of session %" PRIu64,
- session->id);
+ session->id);
goto send_reply;
}
DBG("Transformed session path from \"%s\" to \"%s\" to honor per-session name grouping",
- path_name, group_by_session_path_name);
+ path_name,
+ group_by_session_path_name);
free(path_name);
path_name = group_by_session_path_name;
pthread_mutex_unlock(&last_relay_stream_id_lock);
/* We pass ownership of path_name and channel_name. */
- stream = stream_create(trace, stream_handle, path_name,
- channel_name, tracefile_size, tracefile_count);
+ stream = stream_create(
+ trace, stream_handle, path_name, channel_name, tracefile_size, tracefile_count);
path_name = NULL;
channel_name = NULL;
reply.ret_code = htobe32(LTTNG_OK);
}
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(struct lttcomm_relayd_status_stream), 0);
+ send_ret = conn->sock->ops->sendmsg(
+ conn->sock, &reply, sizeof(struct lttcomm_relayd_status_stream), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"add stream\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"add stream\" command reply (ret = %zd)", send_ret);
ret = -1;
}
/*
* relay_close_stream: close a specific stream
*/
-static int relay_close_stream(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_close_stream(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (payload->size < sizeof(stream_info)) {
ERR("Unexpected payload size in \"relay_close_stream\": expected >= %zu bytes, got %zu bytes",
- sizeof(stream_info), payload->size);
+ sizeof(stream_info),
+ payload->size);
ret = -1;
goto end_no_session;
}
} else {
reply.ret_code = htobe32(LTTNG_OK);
}
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(struct lttcomm_relayd_generic_reply), 0);
+ send_ret = conn->sock->ops->sendmsg(
+ conn->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"close stream\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"close stream\" command reply (ret = %zd)", send_ret);
ret = -1;
}
/*
* relay_reset_metadata: reset a metadata stream
*/
-static
-int relay_reset_metadata(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_reset_metadata(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (payload->size < sizeof(stream_info)) {
ERR("Unexpected payload size in \"relay_reset_metadata\": expected >= %zu bytes, got %zu bytes",
- sizeof(stream_info), payload->size);
+ sizeof(stream_info),
+ payload->size);
ret = -1;
goto end_no_session;
}
ret = stream_reset_file(stream);
if (ret < 0) {
- ERR("Failed to reset metadata stream %" PRIu64
- ": stream_path = %s, channel = %s",
- stream->stream_handle, stream->path_name,
- stream->channel_name);
+ ERR("Failed to reset metadata stream %" PRIu64 ": stream_path = %s, channel = %s",
+ stream->stream_handle,
+ stream->path_name,
+ stream->channel_name);
goto end_unlock;
}
end_unlock:
} else {
reply.ret_code = htobe32(LTTNG_OK);
}
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(struct lttcomm_relayd_generic_reply), 0);
+ send_ret = conn->sock->ops->sendmsg(
+ conn->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"reset metadata\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"reset metadata\" command reply (ret = %zd)", send_ret);
ret = -1;
}
* relay_start: send an acknowledgment to the client to tell if we are
* ready to receive data. We are ready if a session is established.
*/
-static int relay_start(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload __attribute__((unused)))
+static int relay_start(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload __attribute__((unused)))
{
int ret = 0;
ssize_t send_ret;
memset(&reply, 0, sizeof(reply));
reply.ret_code = htobe32(LTTNG_OK);
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(reply), 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"relay_start\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"relay_start\" command reply (ret = %zd)", send_ret);
ret = -1;
}
* relay_recv_metadata: receive the metadata for the session.
*/
static int relay_recv_metadata(const struct lttcomm_relayd_hdr *recv_hdr,
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
struct relay_session *session = conn->session;
ret = -1;
goto end;
}
- metadata_payload_size = recv_hdr->data_size -
- sizeof(struct lttcomm_relayd_metadata_payload);
+ metadata_payload_size =
+ recv_hdr->data_size - sizeof(struct lttcomm_relayd_metadata_payload);
- memcpy(&metadata_payload_header, payload->data,
- sizeof(metadata_payload_header));
- metadata_payload_header.stream_id = be64toh(
- metadata_payload_header.stream_id);
- metadata_payload_header.padding_size = be32toh(
- metadata_payload_header.padding_size);
+ memcpy(&metadata_payload_header, payload->data, sizeof(metadata_payload_header));
+ metadata_payload_header.stream_id = be64toh(metadata_payload_header.stream_id);
+ metadata_payload_header.padding_size = be32toh(metadata_payload_header.padding_size);
metadata_stream = stream_get_by_id(metadata_payload_header.stream_id);
if (!metadata_stream) {
goto end;
}
- packet_view = lttng_buffer_view_from_view(payload,
- sizeof(metadata_payload_header), metadata_payload_size);
+ packet_view = lttng_buffer_view_from_view(
+ payload, sizeof(metadata_payload_header), metadata_payload_size);
if (!lttng_buffer_view_is_valid(&packet_view)) {
ERR("Invalid metadata packet length announced by header");
ret = -1;
}
pthread_mutex_lock(&metadata_stream->lock);
- ret = stream_write(metadata_stream, &packet_view,
- metadata_payload_header.padding_size);
+ ret = stream_write(metadata_stream, &packet_view, metadata_payload_header.padding_size);
pthread_mutex_unlock(&metadata_stream->lock);
- if (ret){
+ if (ret) {
ret = -1;
goto end_put;
}
/*
* relay_send_version: send relayd version number
*/
-static int relay_send_version(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_send_version(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
/* Get version from the other side. */
if (payload->size < sizeof(msg)) {
ERR("Unexpected payload size in \"relay_send_version\": expected >= %zu bytes, got %zu bytes",
- sizeof(msg), payload->size);
+ sizeof(msg),
+ payload->size);
ret = -1;
goto end;
}
/* Major versions must be the same */
if (reply.major != msg.major) {
DBG("Incompatible major versions (%u vs %u), deleting session",
- reply.major, msg.major);
+ reply.major,
+ msg.major);
compatible = false;
}
reply.major = htobe32(reply.major);
reply.minor = htobe32(reply.minor);
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(reply), 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"send version\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"send version\" command reply (ret = %zd)", send_ret);
ret = -1;
goto end;
} else {
goto end;
}
- DBG("Version check done using protocol %u.%u", conn->major,
- conn->minor);
+ DBG("Version check done using protocol %u.%u", conn->major, conn->minor);
end:
return ret;
/*
* Check for data pending for a given stream id from the session daemon.
*/
-static int relay_data_pending(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_data_pending(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
struct relay_session *session = conn->session;
struct lttcomm_relayd_data_pending msg;
if (payload->size < sizeof(msg)) {
ERR("Unexpected payload size in \"relay_data_pending\": expected >= %zu bytes, got %zu bytes",
- sizeof(msg), payload->size);
+ sizeof(msg),
+ payload->size);
ret = -1;
goto end_no_session;
}
stream_seq = stream->prev_data_seq;
}
DBG("Data pending for stream id %" PRIu64 ": prev_data_seq %" PRIu64
- ", prev_index_seq %" PRIu64
- ", and last_seq %" PRIu64, msg.stream_id,
- stream->prev_data_seq, stream->prev_index_seq,
- msg.last_net_seq_num);
+ ", prev_index_seq %" PRIu64 ", and last_seq %" PRIu64,
+ msg.stream_id,
+ stream->prev_data_seq,
+ stream->prev_index_seq,
+ msg.last_net_seq_num);
/* Avoid wrapping issue */
if (((int64_t) (stream_seq - msg.last_net_seq_num)) >= 0) {
reply.ret_code = htobe32(ret);
send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"data pending\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"data pending\" command reply (ret = %zd)", send_ret);
ret = -1;
}
* the control socket has been handled. So, this is why we simply return
* OK here.
*/
-static int relay_quiescent_control(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_quiescent_control(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (payload->size < sizeof(msg)) {
ERR("Unexpected payload size in \"relay_quiescent_control\": expected >= %zu bytes, got %zu bytes",
- sizeof(msg), payload->size);
+ sizeof(msg),
+ payload->size);
ret = -1;
goto end_no_session;
}
reply.ret_code = htobe32(LTTNG_OK);
send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"quiescent control\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"quiescent control\" command reply (ret = %zd)", send_ret);
ret = -1;
} else {
ret = 0;
* This command returns to the client a LTTNG_OK code.
*/
static int relay_begin_data_pending(const struct lttcomm_relayd_hdr *recv_hdr,
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (payload->size < sizeof(msg)) {
ERR("Unexpected payload size in \"relay_begin_data_pending\": expected >= %zu bytes, got %zu bytes",
- sizeof(msg), payload->size);
+ sizeof(msg),
+ payload->size);
ret = -1;
goto end_no_session;
}
* the right session_id.
*/
rcu_read_lock();
- cds_lfht_for_each_entry(relay_streams_ht->ht, &iter.iter, stream,
- node.node) {
+ cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) {
if (!stream_get(stream)) {
continue;
}
stream->data_pending_check_done = false;
pthread_mutex_unlock(&stream->lock);
DBG("Set begin data pending flag to stream %" PRIu64,
- stream->stream_handle);
+ stream->stream_handle);
}
stream_put(stream);
}
send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"begin data pending\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"begin data pending\" command reply (ret = %zd)", send_ret);
ret = -1;
} else {
ret = 0;
*
* Return to the client if there is data in flight or not with a ret_code.
*/
-static int relay_end_data_pending(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_end_data_pending(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
if (payload->size < sizeof(msg)) {
ERR("Unexpected payload size in \"relay_end_data_pending\": expected >= %zu bytes, got %zu bytes",
- sizeof(msg), payload->size);
+ sizeof(msg),
+ payload->size);
ret = -1;
goto end_no_session;
}
* flag is set.
*/
rcu_read_lock();
- cds_lfht_for_each_entry(relay_streams_ht->ht, &iter.iter, stream,
- node.node) {
+ cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) {
if (!stream_get(stream)) {
continue;
}
* Ensure that both the index and stream data have been
* flushed up to the requested point.
*/
- stream_seq = std::min(stream->prev_data_seq, stream->prev_index_seq);
+ stream_seq =
+ std::min(stream->prev_data_seq, stream->prev_index_seq);
} else {
stream_seq = stream->prev_data_seq;
}
- if (!stream->closed || !(((int64_t) (stream_seq - stream->last_net_seq_num)) >= 0)) {
+ if (!stream->closed ||
+ !(((int64_t) (stream_seq - stream->last_net_seq_num)) >= 0)) {
is_data_inflight = 1;
DBG("Data is still in flight for stream %" PRIu64,
- stream->stream_handle);
+ stream->stream_handle);
pthread_mutex_unlock(&stream->lock);
stream_put(stream);
break;
send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"end data pending\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"end data pending\" command reply (ret = %zd)", send_ret);
ret = -1;
} else {
ret = 0;
*
* Return 0 on success else a negative value.
*/
-static int relay_recv_index(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_recv_index(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret;
ssize_t send_ret;
goto end_no_session;
}
- msg_len = lttcomm_relayd_index_len(
- lttng_to_index_major(conn->major, conn->minor),
- lttng_to_index_minor(conn->major, conn->minor));
+ msg_len = lttcomm_relayd_index_len(lttng_to_index_major(conn->major, conn->minor),
+ lttng_to_index_minor(conn->major, conn->minor));
if (payload->size < msg_len) {
ERR("Unexpected payload size in \"relay_recv_index\": expected >= %zu bytes, got %zu bytes",
- msg_len, payload->size);
+ msg_len,
+ payload->size);
ret = -1;
goto end_no_session;
}
index_info.stream_id = be64toh(index_info.stream_id);
if (conn->minor >= 8) {
- index_info.stream_instance_id =
- be64toh(index_info.stream_instance_id);
+ index_info.stream_instance_id = be64toh(index_info.stream_instance_id);
index_info.packet_seq_num = be64toh(index_info.packet_seq_num);
} else {
index_info.stream_instance_id = -1ULL;
*
* Return 0 on success else a negative value.
*/
-static int relay_streams_sent(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload __attribute__((unused)))
+static int relay_streams_sent(const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload __attribute__((unused)))
{
int ret;
ssize_t send_ret;
reply.ret_code = htobe32(LTTNG_OK);
send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"streams sent\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"streams sent\" command reply (ret = %zd)", send_ret);
ret = -1;
} else {
/* Success. */
return ret;
}
-static ssize_t relay_unpack_rotate_streams_header(
- const struct lttng_buffer_view *payload,
- struct lttcomm_relayd_rotate_streams *_rotate_streams)
+static ssize_t
+relay_unpack_rotate_streams_header(const struct lttng_buffer_view *payload,
+ struct lttcomm_relayd_rotate_streams *_rotate_streams)
{
struct lttcomm_relayd_rotate_streams rotate_streams;
/*
* See comment at the declaration of this structure for more information.
*/
ssize_t header_len = sizeof(struct lttcomm_relayd_rotate_streams_packed);
- size_t expected_payload_size_no_padding,
- expected_payload_size_3_bytes_padding,
+ size_t expected_payload_size_no_padding, expected_payload_size_3_bytes_padding,
expected_payload_size_7_bytes_padding;
if (payload->size < header_len) {
ERR("Unexpected payload size in \"relay_rotate_session_stream\": expected >= %zu bytes, got %zu bytes",
- header_len, payload->size);
+ header_len,
+ payload->size);
goto error;
}
* Payload size expected given the possible padding lengths in
* `struct lttcomm_relayd_rotate_streams`.
*/
- expected_payload_size_no_padding = (rotate_streams.stream_count *
- sizeof(*rotate_streams.rotation_positions)) +
+ expected_payload_size_no_padding =
+ (rotate_streams.stream_count * sizeof(*rotate_streams.rotation_positions)) +
sizeof(lttcomm_relayd_rotate_streams_packed);
- expected_payload_size_3_bytes_padding = (rotate_streams.stream_count *
- sizeof(*rotate_streams.rotation_positions)) +
+ expected_payload_size_3_bytes_padding =
+ (rotate_streams.stream_count * sizeof(*rotate_streams.rotation_positions)) +
sizeof(lttcomm_relayd_rotate_streams_3_bytes_padding);
- expected_payload_size_7_bytes_padding = (rotate_streams.stream_count *
- sizeof(*rotate_streams.rotation_positions)) +
+ expected_payload_size_7_bytes_padding =
+ (rotate_streams.stream_count * sizeof(*rotate_streams.rotation_positions)) +
sizeof(lttcomm_relayd_rotate_streams_7_bytes_padding);
if (payload->size == expected_payload_size_no_padding) {
header_len = sizeof(padded_rotate_streams);
} else {
ERR("Unexpected payload size in \"relay_rotate_session_stream\": expected %zu, %zu or %zu bytes, got %zu bytes",
- expected_payload_size_no_padding,
- expected_payload_size_3_bytes_padding,
- expected_payload_size_7_bytes_padding,
- payload->size);
+ expected_payload_size_no_padding,
+ expected_payload_size_3_bytes_padding,
+ expected_payload_size_7_bytes_padding,
+ payload->size);
goto error;
}
* relay_rotate_session_stream: rotate a stream to a new tracefile for the
* session rotation feature (not the tracefile rotation feature).
*/
-static int relay_rotate_session_streams(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_rotate_session_streams(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
uint32_t i;
* before this command is received.
*/
next_trace_chunk = sessiond_trace_chunk_registry_get_chunk(
- sessiond_trace_chunk_registry,
- session->sessiond_uuid,
- conn->session->id_sessiond.is_set ?
- conn->session->id_sessiond.value :
- conn->session->id,
- rotate_streams.new_chunk_id.value);
+ sessiond_trace_chunk_registry,
+ session->sessiond_uuid,
+ conn->session->id_sessiond.is_set ? conn->session->id_sessiond.value :
+ conn->session->id,
+ rotate_streams.new_chunk_id.value);
if (!next_trace_chunk) {
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(session->sessiond_uuid, uuid_str);
ERR("Unknown next trace chunk in ROTATE_STREAMS command: sessiond_uuid = {%s}, session_id = %" PRIu64
- ", trace_chunk_id = %" PRIu64,
- uuid_str, session->id,
- rotate_streams.new_chunk_id.value);
+ ", trace_chunk_id = %" PRIu64,
+ uuid_str,
+ session->id,
+ rotate_streams.new_chunk_id.value);
reply_code = LTTNG_ERR_INVALID_PROTOCOL;
ret = -1;
goto end;
}
- ret = snprintf(chunk_id_buf, sizeof(chunk_id_buf), "%" PRIu64,
- rotate_streams.new_chunk_id.value);
+ ret = snprintf(chunk_id_buf,
+ sizeof(chunk_id_buf),
+ "%" PRIu64,
+ rotate_streams.new_chunk_id.value);
if (ret < 0 || ret >= sizeof(chunk_id_buf)) {
chunk_id_str = "formatting error";
} else {
}
DBG("Rotate %" PRIu32 " streams of session \"%s\" to chunk \"%s\"",
- rotate_streams.stream_count, session->session_name,
- chunk_id_str);
+ rotate_streams.stream_count,
+ session->session_name,
+ chunk_id_str);
- stream_positions = lttng_buffer_view_from_view(payload,
- header_len, -1);
+ stream_positions = lttng_buffer_view_from_view(payload, header_len, -1);
if (!stream_positions.data ||
- stream_positions.size <
- (rotate_streams.stream_count *
- sizeof(struct lttcomm_relayd_stream_rotation_position))) {
+ stream_positions.size < (rotate_streams.stream_count *
+ sizeof(struct lttcomm_relayd_stream_rotation_position))) {
reply_code = LTTNG_ERR_INVALID_PROTOCOL;
ret = -1;
goto end;
for (i = 0; i < rotate_streams.stream_count; i++) {
struct lttcomm_relayd_stream_rotation_position *position_comm =
- &((typeof(position_comm)) stream_positions.data)[i];
+ &((typeof(position_comm)) stream_positions.data)[i];
const struct lttcomm_relayd_stream_rotation_position pos = {
.stream_id = be64toh(position_comm->stream_id),
- .rotate_at_seq_num = be64toh(
- position_comm->rotate_at_seq_num),
+ .rotate_at_seq_num = be64toh(position_comm->rotate_at_seq_num),
};
stream = stream_get_by_id(pos.stream_id);
}
pthread_mutex_lock(&stream->lock);
- ret = stream_set_pending_rotation(stream, next_trace_chunk,
- pos.rotate_at_seq_num);
+ ret = stream_set_pending_rotation(stream, next_trace_chunk, pos.rotate_at_seq_num);
pthread_mutex_unlock(&stream->lock);
if (ret) {
reply_code = LTTNG_ERR_FILE_CREATION_ERROR;
}
reply.ret_code = htobe32((uint32_t) reply_code);
- send_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
- sizeof(struct lttcomm_relayd_generic_reply), 0);
+ send_ret = conn->sock->ops->sendmsg(
+ conn->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"rotate session stream\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"rotate session stream\" command reply (ret = %zd)", send_ret);
ret = -1;
}
end_no_reply:
/*
* relay_create_trace_chunk: create a new trace chunk
*/
-static int relay_create_trace_chunk(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_create_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
ssize_t send_ret;
pthread_mutex_lock(&conn->session->lock);
session->ongoing_rotation = true;
if (session->current_trace_chunk &&
- !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
+ !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
chunk_status = lttng_trace_chunk_rename_path(session->current_trace_chunk,
- DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
+ DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to rename old chunk");
ret = -1;
} else {
new_path = DEFAULT_CHUNK_TMP_NEW_DIRECTORY;
}
- chunk = lttng_trace_chunk_create(
- msg->chunk_id, msg->creation_timestamp, new_path);
+ chunk = lttng_trace_chunk_create(msg->chunk_id, msg->creation_timestamp, new_path);
if (!chunk) {
ERR("Failed to create trace chunk in trace chunk creation command");
ret = -1;
if (msg->override_name_length) {
const char *name;
- const struct lttng_buffer_view chunk_name_view =
- lttng_buffer_view_from_view(payload,
- sizeof(*msg),
- msg->override_name_length);
+ const struct lttng_buffer_view chunk_name_view = lttng_buffer_view_from_view(
+ payload, sizeof(*msg), msg->override_name_length);
if (!lttng_buffer_view_is_valid(&chunk_name_view)) {
ERR("Invalid payload of chunk creation command (protocol error): buffer too short for expected name length");
goto end;
}
- chunk_status = lttng_trace_chunk_override_name(
- chunk, chunk_name_view.data);
+ chunk_status = lttng_trace_chunk_override_name(chunk, chunk_name_view.data);
switch (chunk_status) {
case LTTNG_TRACE_CHUNK_STATUS_OK:
break;
}
LTTNG_ASSERT(conn->session->output_directory);
- chunk_status = lttng_trace_chunk_set_as_owner(chunk,
- conn->session->output_directory);
+ chunk_status = lttng_trace_chunk_set_as_owner(chunk, conn->session->output_directory);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
reply_code = LTTNG_ERR_UNK;
ret = -1;
}
published_chunk = sessiond_trace_chunk_registry_publish_chunk(
- sessiond_trace_chunk_registry,
- conn->session->sessiond_uuid,
- conn->session->id_sessiond.is_set ?
- conn->session->id_sessiond.value :
- conn->session->id,
- chunk);
+ sessiond_trace_chunk_registry,
+ conn->session->sessiond_uuid,
+ conn->session->id_sessiond.is_set ? conn->session->id_sessiond.value :
+ conn->session->id,
+ chunk);
if (!published_chunk) {
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(conn->session->sessiond_uuid, uuid_str);
- ERR("Failed to publish chunk: sessiond_uuid = %s, session_id = %" PRIu64 ", chunk_id = %" PRIu64,
- uuid_str,
- conn->session->id,
- msg->chunk_id);
+ ERR("Failed to publish chunk: sessiond_uuid = %s, session_id = %" PRIu64
+ ", chunk_id = %" PRIu64,
+ uuid_str,
+ conn->session->id,
+ msg->chunk_id);
ret = -1;
reply_code = LTTNG_ERR_NOMEM;
goto end;
ret = -1;
goto end;
}
- conn->session->pending_closure_trace_chunk =
- conn->session->current_trace_chunk;
+ conn->session->pending_closure_trace_chunk = conn->session->current_trace_chunk;
conn->session->current_trace_chunk = published_chunk;
published_chunk = NULL;
if (!conn->session->pending_closure_trace_chunk) {
end:
pthread_mutex_unlock(&conn->session->lock);
reply.ret_code = htobe32((uint32_t) reply_code);
- send_ret = conn->sock->ops->sendmsg(conn->sock,
- &reply,
- sizeof(struct lttcomm_relayd_generic_reply),
- 0);
+ send_ret = conn->sock->ops->sendmsg(
+ conn->sock, &reply, sizeof(struct lttcomm_relayd_generic_reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"create trace chunk\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"create trace chunk\" command reply (ret = %zd)", send_ret);
ret = -1;
}
end_no_reply:
/*
* relay_close_trace_chunk: close a trace chunk
*/
-static int relay_close_trace_chunk(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_close_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0, buf_ret;
ssize_t send_ret;
close_command.value = (lttng_trace_chunk_command_type) be32toh(msg->close_command.value);
close_command.is_set = msg->close_command.is_set;
- chunk = sessiond_trace_chunk_registry_get_chunk(
- sessiond_trace_chunk_registry,
- conn->session->sessiond_uuid,
- conn->session->id_sessiond.is_set ?
- conn->session->id_sessiond.value :
- conn->session->id,
- chunk_id);
+ chunk = sessiond_trace_chunk_registry_get_chunk(sessiond_trace_chunk_registry,
+ conn->session->sessiond_uuid,
+ conn->session->id_sessiond.is_set ?
+ conn->session->id_sessiond.value :
+ conn->session->id,
+ chunk_id);
if (!chunk) {
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(conn->session->sessiond_uuid, uuid_str);
- ERR("Failed to find chunk to close: sessiond_uuid = %s, session_id = %" PRIu64 ", chunk_id = %" PRIu64,
- uuid_str,
- conn->session->id,
- msg->chunk_id);
+ ERR("Failed to find chunk to close: sessiond_uuid = %s, session_id = %" PRIu64
+ ", chunk_id = %" PRIu64,
+ uuid_str,
+ conn->session->id,
+ msg->chunk_id);
ret = -1;
reply_code = LTTNG_ERR_NOMEM;
goto end;
}
pthread_mutex_lock(&session->lock);
- if (close_command.is_set &&
- close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE) {
+ if (close_command.is_set && close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE) {
/*
* Clear command. It is a protocol error to ask for a
* clear on a relay which does not allow it. Querying
goto end_unlock_session;
}
}
- if (session->pending_closure_trace_chunk &&
- session->pending_closure_trace_chunk != chunk) {
+ if (session->pending_closure_trace_chunk && session->pending_closure_trace_chunk != chunk) {
ERR("Trace chunk close command for session \"%s\" does not target the trace chunk pending closure",
- session->session_name);
+ session->session_name);
reply_code = LTTNG_ERR_INVALID_PROTOCOL;
ret = -1;
goto end_unlock_session;
}
if (session->current_trace_chunk && session->current_trace_chunk != chunk &&
- !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
+ !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
if (close_command.is_set &&
- close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE &&
- !session->has_rotated) {
+ close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE &&
+ !session->has_rotated) {
/* New chunk stays in session output directory. */
new_path = "";
} else {
new_path = NULL;
}
/* Rename new chunk path. */
- chunk_status = lttng_trace_chunk_rename_path(session->current_trace_chunk,
- new_path);
+ chunk_status =
+ lttng_trace_chunk_rename_path(session->current_trace_chunk, new_path);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end_unlock_session;
session->ongoing_rotation = false;
}
if ((!close_command.is_set ||
- close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION) &&
- !lttng_trace_chunk_get_name_overridden(chunk)) {
+ close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION) &&
+ !lttng_trace_chunk_get_name_overridden(chunk)) {
const char *old_path;
if (!session->has_rotated) {
goto end_unlock_session;
}
}
- chunk_status = lttng_trace_chunk_set_close_timestamp(
- chunk, close_timestamp);
+ chunk_status = lttng_trace_chunk_set_close_timestamp(chunk, close_timestamp);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to set trace chunk close timestamp");
ret = -1;
}
if (close_command.is_set) {
- chunk_status = lttng_trace_chunk_set_close_command(
- chunk, close_command.value);
+ chunk_status = lttng_trace_chunk_set_close_command(chunk, close_command.value);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
reply_code = LTTNG_ERR_INVALID;
}
if (!session->has_rotated && !session->snapshot) {
ret = lttng_strncpy(closed_trace_chunk_path,
- session->output_path,
- sizeof(closed_trace_chunk_path));
+ session->output_path,
+ sizeof(closed_trace_chunk_path));
if (ret) {
ERR("Failed to send trace chunk path: path length of %zu bytes exceeds the maximal allowed length of %zu bytes",
- strlen(session->output_path),
- sizeof(closed_trace_chunk_path));
+ strlen(session->output_path),
+ sizeof(closed_trace_chunk_path));
reply_code = LTTNG_ERR_NOMEM;
ret = -1;
goto end_unlock_session;
} else {
if (session->snapshot) {
ret = snprintf(closed_trace_chunk_path,
- sizeof(closed_trace_chunk_path),
- "%s/%s", session->output_path,
- chunk_name);
+ sizeof(closed_trace_chunk_path),
+ "%s/%s",
+ session->output_path,
+ chunk_name);
} else {
ret = snprintf(closed_trace_chunk_path,
- sizeof(closed_trace_chunk_path),
- "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY
- "/%s",
- session->output_path, chunk_name);
+ sizeof(closed_trace_chunk_path),
+ "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
+ session->output_path,
+ chunk_name);
}
if (ret < 0 || ret == sizeof(closed_trace_chunk_path)) {
ERR("Failed to format closed trace chunk resulting path");
}
}
if (close_command.is_set &&
- close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED) {
+ close_command.value == LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED) {
session->has_rotated = true;
}
DBG("Reply chunk path on close: %s", closed_trace_chunk_path);
end:
reply.generic.ret_code = htobe32((uint32_t) reply_code);
reply.path_length = htobe32((uint32_t) path_length);
- buf_ret = lttng_dynamic_buffer_append(
- &reply_payload, &reply, sizeof(reply));
+ buf_ret = lttng_dynamic_buffer_append(&reply_payload, &reply, sizeof(reply));
if (buf_ret) {
ERR("Failed to append \"close trace chunk\" command reply header to payload buffer");
goto end_no_reply;
}
if (reply_code == LTTNG_OK) {
- buf_ret = lttng_dynamic_buffer_append(&reply_payload,
- closed_trace_chunk_path, path_length);
+ buf_ret = lttng_dynamic_buffer_append(
+ &reply_payload, closed_trace_chunk_path, path_length);
if (buf_ret) {
ERR("Failed to append \"close trace chunk\" command reply path to payload buffer");
goto end_no_reply;
}
}
- send_ret = conn->sock->ops->sendmsg(conn->sock,
- reply_payload.data,
- reply_payload.size,
- 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, reply_payload.data, reply_payload.size, 0);
if (send_ret < reply_payload.size) {
ERR("Failed to send \"close trace chunk\" command reply of %zu bytes (ret = %zd)",
- reply_payload.size, send_ret);
+ reply_payload.size,
+ send_ret);
ret = -1;
goto end_no_reply;
}
/*
* relay_trace_chunk_exists: check if a trace chunk exists
*/
-static int relay_trace_chunk_exists(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_trace_chunk_exists(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
ssize_t send_ret;
msg = (typeof(msg)) header_view.data;
chunk_id = be64toh(msg->chunk_id);
- ret = sessiond_trace_chunk_registry_chunk_exists(
- sessiond_trace_chunk_registry,
- conn->session->sessiond_uuid,
- conn->session->id,
- chunk_id, &chunk_exists);
+ ret = sessiond_trace_chunk_registry_chunk_exists(sessiond_trace_chunk_registry,
+ conn->session->sessiond_uuid,
+ conn->session->id,
+ chunk_id,
+ &chunk_exists);
/*
* If ret is not 0, send the reply and report the error to the caller.
* It is a protocol (or internal) error and the session/connection
* should be torn down.
*/
- reply.generic.ret_code = htobe32((uint32_t) (ret == 0 ? LTTNG_OK : LTTNG_ERR_INVALID_PROTOCOL));
+ reply.generic.ret_code =
+ htobe32((uint32_t) (ret == 0 ? LTTNG_OK : LTTNG_ERR_INVALID_PROTOCOL));
reply.trace_chunk_exists = ret == 0 ? chunk_exists : 0;
- send_ret = conn->sock->ops->sendmsg(
- conn->sock, &reply, sizeof(reply), 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"create trace chunk\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"create trace chunk\" command reply (ret = %zd)", send_ret);
ret = -1;
}
end_no_reply:
/*
* relay_get_configuration: query whether feature is available
*/
-static int relay_get_configuration(
- const struct lttcomm_relayd_hdr *recv_hdr __attribute__((unused)),
- struct relay_connection *conn,
- const struct lttng_buffer_view *payload)
+static int relay_get_configuration(const struct lttcomm_relayd_hdr *recv_hdr
+ __attribute__((unused)),
+ struct relay_connection *conn,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
ssize_t send_ret;
}
ret = 0;
reply:
- reply.generic.ret_code = htobe32((uint32_t) (ret == 0 ? LTTNG_OK : LTTNG_ERR_INVALID_PROTOCOL));
+ reply.generic.ret_code =
+ htobe32((uint32_t) (ret == 0 ? LTTNG_OK : LTTNG_ERR_INVALID_PROTOCOL));
reply.relayd_configuration_flags = htobe64(result_flags);
- send_ret = conn->sock->ops->sendmsg(
- conn->sock, &reply, sizeof(reply), 0);
+ send_ret = conn->sock->ops->sendmsg(conn->sock, &reply, sizeof(reply), 0);
if (send_ret < (ssize_t) sizeof(reply)) {
- ERR("Failed to send \"get configuration\" command reply (ret = %zd)",
- send_ret);
+ ERR("Failed to send \"get configuration\" command reply (ret = %zd)", send_ret);
ret = -1;
}
end_no_reply:
}
static int relay_process_control_command(struct relay_connection *conn,
- const struct lttcomm_relayd_hdr *header,
- const struct lttng_buffer_view *payload)
+ const struct lttcomm_relayd_hdr *header,
+ const struct lttng_buffer_view *payload)
{
int ret = 0;
DBG3("Processing \"%s\" command for socket %i",
- lttcomm_relayd_command_str((lttcomm_relayd_command) header->cmd),
- conn->sock->fd);
+ lttcomm_relayd_command_str((lttcomm_relayd_command) header->cmd),
+ conn->sock->fd);
switch (header->cmd) {
case RELAYD_CREATE_SESSION:
ret = relay_create_session(header, conn, payload);
return ret;
}
-static enum relay_connection_status relay_process_control_receive_payload(
- struct relay_connection *conn)
+static enum relay_connection_status
+relay_process_control_receive_payload(struct relay_connection *conn)
{
int ret = 0;
enum relay_connection_status status = RELAY_CONNECTION_STATUS_OK;
- struct lttng_dynamic_buffer *reception_buffer =
- &conn->protocol.ctrl.reception_buffer;
+ struct lttng_dynamic_buffer *reception_buffer = &conn->protocol.ctrl.reception_buffer;
struct ctrl_connection_state_receive_payload *state =
- &conn->protocol.ctrl.state.receive_payload;
+ &conn->protocol.ctrl.state.receive_payload;
struct lttng_buffer_view payload_view;
if (state->left_to_receive == 0) {
}
ret = conn->sock->ops->recvmsg(conn->sock,
- reception_buffer->data + state->received,
- state->left_to_receive, MSG_DONTWAIT);
+ reception_buffer->data + state->received,
+ state->left_to_receive,
+ MSG_DONTWAIT);
if (ret < 0) {
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- DIAGNOSTIC_POP
- PERROR("Unable to receive command payload on sock %d",
- conn->sock->fd);
+ DIAGNOSTIC_POP
+ PERROR("Unable to receive command payload on sock %d", conn->sock->fd);
status = RELAY_CONNECTION_STATUS_ERROR;
}
goto end;
* Can't transition to the protocol's next state, wait to
* receive the rest of the header.
*/
- DBG3("Partial reception of control connection protocol payload (received %" PRIu64 " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
- state->received, state->left_to_receive,
- conn->sock->fd);
+ DBG3("Partial reception of control connection protocol payload (received %" PRIu64
+ " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
+ state->received,
+ state->left_to_receive,
+ conn->sock->fd);
goto end;
}
reception_complete:
DBG("Done receiving control command payload: fd = %i, payload size = %" PRIu64 " bytes",
- conn->sock->fd, state->received);
+ conn->sock->fd,
+ state->received);
/*
* The payload required to process the command has been received.
* A view to the reception buffer is forwarded to the various
*
* Commands are responsible for sending their reply to the peer.
*/
- payload_view = lttng_buffer_view_from_dynamic_buffer(reception_buffer,
- 0, -1);
- ret = relay_process_control_command(conn,
- &state->header, &payload_view);
+ payload_view = lttng_buffer_view_from_dynamic_buffer(reception_buffer, 0, -1);
+ ret = relay_process_control_command(conn, &state->header, &payload_view);
if (ret < 0) {
status = RELAY_CONNECTION_STATUS_ERROR;
goto end;
return status;
}
-static enum relay_connection_status relay_process_control_receive_header(
- struct relay_connection *conn)
+static enum relay_connection_status
+relay_process_control_receive_header(struct relay_connection *conn)
{
int ret = 0;
enum relay_connection_status status = RELAY_CONNECTION_STATUS_OK;
struct lttcomm_relayd_hdr header;
- struct lttng_dynamic_buffer *reception_buffer =
- &conn->protocol.ctrl.reception_buffer;
+ struct lttng_dynamic_buffer *reception_buffer = &conn->protocol.ctrl.reception_buffer;
struct ctrl_connection_state_receive_header *state =
- &conn->protocol.ctrl.state.receive_header;
+ &conn->protocol.ctrl.state.receive_header;
LTTNG_ASSERT(state->left_to_receive != 0);
ret = conn->sock->ops->recvmsg(conn->sock,
- reception_buffer->data + state->received,
- state->left_to_receive, MSG_DONTWAIT);
+ reception_buffer->data + state->received,
+ state->left_to_receive,
+ MSG_DONTWAIT);
if (ret < 0) {
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
PERROR("Unable to receive control command header on sock %d",
- conn->sock->fd);
+ conn->sock->fd);
status = RELAY_CONNECTION_STATUS_ERROR;
}
goto end;
* Can't transition to the protocol's next state, wait to
* receive the rest of the header.
*/
- DBG3("Partial reception of control connection protocol header (received %" PRIu64 " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
- state->received, state->left_to_receive,
- conn->sock->fd);
+ DBG3("Partial reception of control connection protocol header (received %" PRIu64
+ " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
+ state->received,
+ state->left_to_receive,
+ conn->sock->fd);
goto end;
}
/* Transition to next state: receiving the command's payload. */
- conn->protocol.ctrl.state_id =
- CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD;
+ conn->protocol.ctrl.state_id = CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD;
memcpy(&header, reception_buffer->data, sizeof(header));
header.circuit_id = be64toh(header.circuit_id);
header.data_size = be64toh(header.data_size);
header.cmd = be32toh(header.cmd);
header.cmd_version = be32toh(header.cmd_version);
- memcpy(&conn->protocol.ctrl.state.receive_payload.header,
- &header, sizeof(header));
+ memcpy(&conn->protocol.ctrl.state.receive_payload.header, &header, sizeof(header));
- DBG("Done receiving control command header: fd = %i, cmd = %s, cmd_version = %" PRIu32 ", payload size = %" PRIu64 " bytes",
- conn->sock->fd, lttcomm_relayd_command_str((enum lttcomm_relayd_command) header.cmd),
- header.cmd_version, header.data_size);
+ DBG("Done receiving control command header: fd = %i, cmd = %s, cmd_version = %" PRIu32
+ ", payload size = %" PRIu64 " bytes",
+ conn->sock->fd,
+ lttcomm_relayd_command_str((enum lttcomm_relayd_command) header.cmd),
+ header.cmd_version,
+ header.data_size);
if (header.data_size > DEFAULT_NETWORK_RELAYD_CTRL_MAX_PAYLOAD_SIZE) {
- ERR("Command header indicates a payload (%" PRIu64 " bytes) that exceeds the maximal payload size allowed on a control connection.",
- header.data_size);
+ ERR("Command header indicates a payload (%" PRIu64
+ " bytes) that exceeds the maximal payload size allowed on a control connection.",
+ header.data_size);
status = RELAY_CONNECTION_STATUS_ERROR;
goto end;
}
- conn->protocol.ctrl.state.receive_payload.left_to_receive =
- header.data_size;
+ conn->protocol.ctrl.state.receive_payload.left_to_receive = header.data_size;
conn->protocol.ctrl.state.receive_payload.received = 0;
- ret = lttng_dynamic_buffer_set_size(reception_buffer,
- header.data_size);
+ ret = lttng_dynamic_buffer_set_size(reception_buffer, header.data_size);
if (ret) {
status = RELAY_CONNECTION_STATUS_ERROR;
goto end;
/*
* Process the commands received on the control socket
*/
-static enum relay_connection_status relay_process_control(
- struct relay_connection *conn)
+static enum relay_connection_status relay_process_control(struct relay_connection *conn)
{
enum relay_connection_status status;
return status;
}
-static enum relay_connection_status relay_process_data_receive_header(
- struct relay_connection *conn)
+static enum relay_connection_status relay_process_data_receive_header(struct relay_connection *conn)
{
int ret;
enum relay_connection_status status = RELAY_CONNECTION_STATUS_OK;
struct data_connection_state_receive_header *state =
- &conn->protocol.data.state.receive_header;
+ &conn->protocol.data.state.receive_header;
struct lttcomm_relayd_data_hdr header;
struct relay_stream *stream;
LTTNG_ASSERT(state->left_to_receive != 0);
ret = conn->sock->ops->recvmsg(conn->sock,
- state->header_reception_buffer + state->received,
- state->left_to_receive, MSG_DONTWAIT);
+ state->header_reception_buffer + state->received,
+ state->left_to_receive,
+ MSG_DONTWAIT);
if (ret < 0) {
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
PERROR("Unable to receive data header on sock %d", conn->sock->fd);
status = RELAY_CONNECTION_STATUS_ERROR;
}
* Can't transition to the protocol's next state, wait to
* receive the rest of the header.
*/
- DBG3("Partial reception of data connection header (received %" PRIu64 " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
- state->received, state->left_to_receive,
- conn->sock->fd);
+ DBG3("Partial reception of data connection header (received %" PRIu64
+ " bytes, %" PRIu64 " bytes left to receive, fd = %i)",
+ state->received,
+ state->left_to_receive,
+ conn->sock->fd);
goto end;
}
header.padding_size = be32toh(header.padding_size);
memcpy(&conn->protocol.data.state.receive_payload.header, &header, sizeof(header));
- conn->protocol.data.state.receive_payload.left_to_receive =
- header.data_size;
+ conn->protocol.data.state.receive_payload.left_to_receive = header.data_size;
conn->protocol.data.state.receive_payload.received = 0;
conn->protocol.data.state.receive_payload.rotate_index = false;
- DBG("Received data connection header on fd %i: circuit_id = %" PRIu64 ", stream_id = %" PRIu64 ", data_size = %" PRIu32 ", net_seq_num = %" PRIu64 ", padding_size = %" PRIu32,
- conn->sock->fd, header.circuit_id,
- header.stream_id, header.data_size,
- header.net_seq_num, header.padding_size);
+ DBG("Received data connection header on fd %i: circuit_id = %" PRIu64
+ ", stream_id = %" PRIu64 ", data_size = %" PRIu32 ", net_seq_num = %" PRIu64
+ ", padding_size = %" PRIu32,
+ conn->sock->fd,
+ header.circuit_id,
+ header.stream_id,
+ header.data_size,
+ header.net_seq_num,
+ header.padding_size);
stream = stream_get_by_id(header.stream_id);
if (!stream) {
DBG("relay_process_data_receive_payload: Cannot find stream %" PRIu64,
- header.stream_id);
+ header.stream_id);
/* Protocol error. */
status = RELAY_CONNECTION_STATUS_ERROR;
goto end;
pthread_mutex_lock(&stream->lock);
/* Prepare stream for the reception of a new packet. */
- ret = stream_init_packet(stream, header.data_size,
- &conn->protocol.data.state.receive_payload.rotate_index);
+ ret = stream_init_packet(
+ stream, header.data_size, &conn->protocol.data.state.receive_payload.rotate_index);
pthread_mutex_unlock(&stream->lock);
if (ret) {
ERR("Failed to rotate stream output file");
return status;
}
-static enum relay_connection_status relay_process_data_receive_payload(
- struct relay_connection *conn)
+static enum relay_connection_status
+relay_process_data_receive_payload(struct relay_connection *conn)
{
int ret;
enum relay_connection_status status = RELAY_CONNECTION_STATUS_OK;
struct relay_stream *stream;
struct data_connection_state_receive_payload *state =
- &conn->protocol.data.state.receive_payload;
+ &conn->protocol.data.state.receive_payload;
const size_t chunk_size = RECV_DATA_BUFFER_SIZE;
char data_buffer[chunk_size];
bool partial_recv = false;
uint64_t left_to_receive = state->left_to_receive;
struct relay_session *session;
- DBG3("Receiving data for stream id %" PRIu64 " seqnum %" PRIu64 ", %" PRIu64" bytes received, %" PRIu64 " bytes left to receive",
- state->header.stream_id, state->header.net_seq_num,
- state->received, left_to_receive);
+ DBG3("Receiving data for stream id %" PRIu64 " seqnum %" PRIu64 ", %" PRIu64
+ " bytes received, %" PRIu64 " bytes left to receive",
+ state->header.stream_id,
+ state->header.net_seq_num,
+ state->received,
+ left_to_receive);
stream = stream_get_by_id(state->header.stream_id);
if (!stream) {
/* Protocol error. */
ERR("relay_process_data_receive_payload: cannot find stream %" PRIu64,
- state->header.stream_id);
+ state->header.stream_id);
status = RELAY_CONNECTION_STATUS_ERROR;
goto end;
}
size_t recv_size = std::min<uint64_t>(left_to_receive, chunk_size);
struct lttng_buffer_view packet_chunk;
- ret = conn->sock->ops->recvmsg(conn->sock, data_buffer,
- recv_size, MSG_DONTWAIT);
+ ret = conn->sock->ops->recvmsg(conn->sock, data_buffer, recv_size, MSG_DONTWAIT);
if (ret < 0) {
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno != EAGAIN && errno != EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
PERROR("Socket %d error", conn->sock->fd);
status = RELAY_CONNECTION_STATUS_ERROR;
}
} else if (ret == 0) {
/* No more data ready to be consumed on socket. */
DBG3("No more data ready for consumption on data socket of stream id %" PRIu64,
- state->header.stream_id);
+ state->header.stream_id);
status = RELAY_CONNECTION_STATUS_CLOSED;
break;
} else if (ret < (int) recv_size) {
recv_size = ret;
}
- packet_chunk = lttng_buffer_view_init(data_buffer,
- 0, recv_size);
+ packet_chunk = lttng_buffer_view_init(data_buffer, 0, recv_size);
LTTNG_ASSERT(packet_chunk.data);
ret = stream_write(stream, &packet_chunk, 0);
* Did not receive all the data expected, wait for more data to
* become available on the socket.
*/
- DBG3("Partial receive on data connection of stream id %" PRIu64 ", %" PRIu64 " bytes received, %" PRIu64 " bytes left to receive",
- state->header.stream_id, state->received,
- state->left_to_receive);
+ DBG3("Partial receive on data connection of stream id %" PRIu64 ", %" PRIu64
+ " bytes received, %" PRIu64 " bytes left to receive",
+ state->header.stream_id,
+ state->received,
+ state->left_to_receive);
goto end_stream_unlock;
}
}
if (session_streams_have_index(session)) {
- ret = stream_update_index(stream, state->header.net_seq_num,
- state->rotate_index, &index_flushed,
- state->header.data_size + state->header.padding_size);
+ ret = stream_update_index(stream,
+ state->header.net_seq_num,
+ state->rotate_index,
+ &index_flushed,
+ state->header.data_size + state->header.padding_size);
if (ret < 0) {
- ERR("Failed to update index: stream %" PRIu64 " net_seq_num %" PRIu64 " ret %d",
- stream->stream_handle,
- state->header.net_seq_num, ret);
+ ERR("Failed to update index: stream %" PRIu64 " net_seq_num %" PRIu64
+ " ret %d",
+ stream->stream_handle,
+ state->header.net_seq_num,
+ ret);
status = RELAY_CONNECTION_STATUS_ERROR;
goto end_stream_unlock;
}
new_stream = true;
}
- ret = stream_complete_packet(stream, state->header.data_size +
- state->header.padding_size, state->header.net_seq_num,
- index_flushed);
+ ret = stream_complete_packet(stream,
+ state->header.data_size + state->header.padding_size,
+ state->header.net_seq_num,
+ index_flushed);
if (ret) {
status = RELAY_CONNECTION_STATUS_ERROR;
goto end_stream_unlock;
/*
* relay_process_data: Process the data received on the data socket
*/
-static enum relay_connection_status relay_process_data(
- struct relay_connection *conn)
+static enum relay_connection_status relay_process_data(struct relay_connection *conn)
{
enum relay_connection_status status;
(void) lttng_poll_del(events, pollfd);
- ret = fd_tracker_close_unsuspendable_fd(the_fd_tracker, &pollfd, 1,
- fd_tracker_util_close_fd, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(
+ the_fd_tracker, &pollfd, 1, fd_tracker_util_close_fd, NULL);
if (ret < 0) {
ERR("Closing pollfd %d", pollfd);
}
}
static void relay_thread_close_connection(struct lttng_poll_event *events,
- int pollfd, struct relay_connection *conn)
+ int pollfd,
+ struct relay_connection *conn)
{
const char *type_str;
if (ret < 0) {
goto error;
}
- ret = lttng_poll_add(&events,
- conn->sock->fd,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(
+ &events, conn->sock->fd, LPOLLIN | LPOLLRDHUP);
if (ret) {
ERR("Failed to add new connection file descriptor to poll set");
goto error;
ERR("Relay connection pipe error");
goto error;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
} else {
if (ctrl_conn->type == RELAY_DATA) {
if (revents & LPOLLIN) {
/*
- * Flag the last seen data fd not deleted. It will be
- * used as the last seen fd if any fd gets deleted in
- * this first loop.
+ * Flag the last seen data fd not deleted. It will
+ * be used as the last seen fd if any fd gets
+ * deleted in this first loop.
*/
last_notdel_data_fd = pollfd;
}
status = relay_process_control(ctrl_conn);
if (status != RELAY_CONNECTION_STATUS_OK) {
/*
- * On socket error flag the session as aborted to force
- * the cleanup of its stream otherwise it can leak
- * during the lifetime of the relayd.
+ * On socket error flag the session as aborted to
+ * force the cleanup of its stream otherwise it can
+ * leak during the lifetime of the relayd.
*
* This prevents situations in which streams can be
* left opened because an index was received, the
* control connection is closed, and the data
- * connection is closed (uncleanly) before the packet's
- * data provided.
+ * connection is closed (uncleanly) before the
+ * packet's data provided.
*
- * Since the control connection encountered an error,
- * it is okay to be conservative and close the
- * session right now as we can't rely on the protocol
- * being respected anymore.
+ * Since the control connection encountered an
+ * error, it is okay to be conservative and close
+ * the session right now as we can't rely on the
+ * protocol being respected anymore.
*/
if (status == RELAY_CONNECTION_STATUS_ERROR) {
session_abort(ctrl_conn->session);
}
/* Clear the connection on error or close. */
- relay_thread_close_connection(&events,
- pollfd,
- ctrl_conn);
+ relay_thread_close_connection(
+ &events, pollfd, ctrl_conn);
}
seen_control = 1;
} else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
- relay_thread_close_connection(&events,
- pollfd, ctrl_conn);
+ relay_thread_close_connection(&events, pollfd, ctrl_conn);
if (last_seen_data_fd == pollfd) {
last_seen_data_fd = last_notdel_data_fd;
}
} else {
ERR("Unexpected poll events %u for control sock %d",
- revents, pollfd);
+ revents,
+ pollfd);
connection_put(ctrl_conn);
goto error;
}
if (status == RELAY_CONNECTION_STATUS_ERROR) {
session_abort(data_conn->session);
}
- relay_thread_close_connection(&events, pollfd,
- data_conn);
+ relay_thread_close_connection(&events, pollfd, data_conn);
/*
* Every goto restart call sets the last seen fd where
* here we don't really care since we gracefully
goto restart;
}
} else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
- relay_thread_close_connection(&events, pollfd,
- data_conn);
+ relay_thread_close_connection(&events, pollfd, data_conn);
} else {
- ERR("Unknown poll events %u for data sock %d",
- revents, pollfd);
+ ERR("Unknown poll events %u for data sock %d", revents, pollfd);
}
put_data_connection:
connection_put(data_conn);
error:
/* Cleanup remaining connection object. */
rcu_read_lock();
- cds_lfht_for_each_entry(relay_connections_ht->ht, &iter.iter,
- destroy_conn,
- sock_n.node) {
+ cds_lfht_for_each_entry (relay_connections_ht->ht, &iter.iter, destroy_conn, sock_n.node) {
health_code_update();
session_abort(destroy_conn->session);
* No need to grab another ref, because we own
* destroy_conn.
*/
- relay_thread_close_connection(&events, destroy_conn->sock->fd,
- destroy_conn);
+ relay_thread_close_connection(&events, destroy_conn->sock->fd, destroy_conn);
}
rcu_read_unlock();
lttng_ht_destroy(relay_connections_ht);
relay_connections_ht_error:
/* Close relay conn pipes */
- (void) fd_tracker_util_pipe_close(the_fd_tracker,
- relay_conn_pipe);
+ (void) fd_tracker_util_pipe_close(the_fd_tracker, relay_conn_pipe);
if (err) {
DBG("Thread exited with error");
}
*/
static int create_relay_conn_pipe(void)
{
- return fd_tracker_util_pipe_open_cloexec(the_fd_tracker,
- "Relayd connection pipe", relay_conn_pipe);
+ return fd_tracker_util_pipe_open_cloexec(
+ the_fd_tracker, "Relayd connection pipe", relay_conn_pipe);
}
static int stdio_open(void *data __attribute__((unused)), int *fds)
int fds[2];
const char *names[] = { "stdout", "stderr" };
- return fd_tracker_open_unsuspendable_fd(the_fd_tracker, fds,
- names, 2, stdio_open, NULL);
+ return fd_tracker_open_unsuspendable_fd(the_fd_tracker, fds, names, 2, stdio_open, NULL);
}
/*
goto exit_options;
}
- ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG,
- -1, -1);
+ ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG, -1, -1);
if (ret < 0) {
ERR("Unable to create %s", opt_output_path);
retval = -1;
/* Daemonize */
if (opt_daemon || opt_background) {
- ret = lttng_daemonize(&child_ppid, &recv_child_signal,
- !opt_background);
+ ret = lttng_daemonize(&child_ppid, &recv_child_signal, !opt_background);
if (ret < 0) {
retval = -1;
goto exit_options;
retval = -1;
goto exit_options;
}
- ret = asprintf(&unlinked_file_directory_path, "%s/%s", output_path,
- DEFAULT_UNLINKED_FILES_DIRECTORY);
+ ret = asprintf(&unlinked_file_directory_path,
+ "%s/%s",
+ output_path,
+ DEFAULT_UNLINKED_FILES_DIRECTORY);
free(output_path);
if (ret < 0) {
ERR("Failed to format unlinked file directory path");
retval = -1;
goto exit_options;
}
- the_fd_tracker = fd_tracker_create(
- unlinked_file_directory_path, lttng_opt_fd_pool_size);
+ the_fd_tracker = fd_tracker_create(unlinked_file_directory_path, lttng_opt_fd_pool_size);
free(unlinked_file_directory_path);
if (!the_fd_tracker) {
retval = -1;
}
/* Create thread to manage the client socket */
- ret = pthread_create(&health_thread, default_pthread_attr(),
- thread_manage_health_relayd, (void *) NULL);
+ ret = pthread_create(
+ &health_thread, default_pthread_attr(), thread_manage_health_relayd, (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create health");
}
/* Setup the dispatcher thread */
- ret = pthread_create(&dispatcher_thread, default_pthread_attr(),
- relay_thread_dispatcher, (void *) NULL);
+ ret = pthread_create(
+ &dispatcher_thread, default_pthread_attr(), relay_thread_dispatcher, (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create dispatcher");
}
/* Setup the worker thread */
- ret = pthread_create(&worker_thread, default_pthread_attr(),
- relay_thread_worker, NULL);
+ ret = pthread_create(&worker_thread, default_pthread_attr(), relay_thread_worker, NULL);
if (ret) {
errno = ret;
PERROR("pthread_create worker");
}
/* Setup the listener thread */
- ret = pthread_create(&listener_thread, default_pthread_attr(),
- relay_thread_listener, (void *) NULL);
+ ret = pthread_create(
+ &listener_thread, default_pthread_attr(), relay_thread_listener, (void *) NULL);
if (ret) {
errno = ret;
PERROR("pthread_create listener");
*/
#define _LGPL_SOURCE
+#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
+#include "session.hpp"
+#include "sessiond-trace-chunks.hpp"
+#include "stream.hpp"
+#include "utils.hpp"
+
#include <common/common.hpp>
#include <common/compat/path.hpp>
+#include <common/defaults.hpp>
#include <common/fd-tracker/utils.hpp>
#include <common/time.hpp>
#include <common/utils.hpp>
#include <common/uuid.hpp>
-#include <urcu/rculist.h>
#include <sys/stat.h>
-
-#include "ctf-trace.hpp"
-#include "lttng-relayd.hpp"
-#include "session.hpp"
-#include "sessiond-trace-chunks.hpp"
-#include "stream.hpp"
-#include <common/defaults.hpp>
-#include "utils.hpp"
+#include <urcu/rculist.h>
/* Global session id used in the session creation. */
static uint64_t last_relay_session_id;
* Otherwise, generate the path with session_name-<timestamp>.
*/
if (session->base_path[0] != '\0') {
- ret = asprintf(&session_directory, "%s/%s", session->hostname,
- session->base_path);
+ ret = asprintf(&session_directory, "%s/%s", session->hostname, session->base_path);
} else if (session->session_name_contains_creation_time) {
- ret = asprintf(&session_directory, "%s/%s", session->hostname,
- session->session_name);
+ ret = asprintf(
+ &session_directory, "%s/%s", session->hostname, session->session_name);
} else {
char session_creation_datetime[DATETIME_STR_LEN];
- ret = time_to_datetime_str(
- LTTNG_OPTIONAL_GET(session->creation_time),
- session_creation_datetime,
- sizeof(session_creation_datetime));
+ ret = time_to_datetime_str(LTTNG_OPTIONAL_GET(session->creation_time),
+ session_creation_datetime,
+ sizeof(session_creation_datetime));
if (ret) {
ERR("Failed to format session creation timestamp while initializing session output directory handle");
ret = -1;
goto end;
}
- ret = asprintf(&session_directory, "%s/%s-%s",
- session->hostname, session->session_name,
- session_creation_datetime);
+ ret = asprintf(&session_directory,
+ "%s/%s-%s",
+ session->hostname,
+ session->session_name,
+ session_creation_datetime);
}
if (ret < 0) {
PERROR("Failed to format session directory name");
return ret;
}
-static int init_session_output_path_group_by_session(
- struct relay_session *session)
+static int init_session_output_path_group_by_session(struct relay_session *session)
{
/*
* session_directory:
}
ret = time_to_datetime_str(LTTNG_OPTIONAL_GET(session->creation_time),
- creation_datetime, sizeof(creation_datetime));
+ creation_datetime,
+ sizeof(creation_datetime));
if (ret) {
ERR("Failed to format session creation timestamp while initializing session output directory handle");
ret = -1;
goto end;
}
- ret = asprintf(&session_directory, "%s/%s-%s%s%s",
- session->session_name, session->hostname,
- creation_datetime,
- session->base_path[0] != '\0' ? "/" : "",
- session->base_path);
+ ret = asprintf(&session_directory,
+ "%s/%s-%s%s%s",
+ session->session_name,
+ session->hostname,
+ creation_datetime,
+ session->base_path[0] != '\0' ? "/" : "",
+ session->base_path);
if (ret < 0) {
PERROR("Failed to format session directory name");
goto end;
return ret;
}
-static struct lttng_directory_handle *session_create_output_directory_handle(
- struct relay_session *session)
+static struct lttng_directory_handle *
+session_create_output_directory_handle(struct relay_session *session)
{
int ret;
/*
goto end;
}
- ret = utils_mkdir_recursive(
- full_session_path, S_IRWXU | S_IRWXG, -1, -1);
+ ret = utils_mkdir_recursive(full_session_path, S_IRWXU | S_IRWXG, -1, -1);
if (ret) {
- ERR("Failed to create session output path \"%s\"",
- full_session_path);
+ ERR("Failed to create session output path \"%s\"", full_session_path);
goto end;
}
}
/* Does not start with '.'. */
if (name[0] == '.') {
- WARN("Name \"%s\" is not allowed to be used in a path since it starts with '.'", name);
+ WARN("Name \"%s\" is not allowed to be used in a path since it starts with '.'",
+ name);
return false;
}
/* Does not contain a path-separator. */
if (strchr(name, LTTNG_PATH_SEPARATOR)) {
- WARN("Name \"%s\" is not allowed to be used in a path since it contains a path separator", name);
+ WARN("Name \"%s\" is not allowed to be used in a path since it contains a path separator",
+ name);
return false;
}
* Return allocated session or else NULL.
*/
struct relay_session *session_create(const char *session_name,
- const char *hostname, const char *base_path,
- uint32_t live_timer,
- bool snapshot,
- const lttng_uuid& sessiond_uuid,
- const uint64_t *id_sessiond,
- const uint64_t *current_chunk_id,
- const time_t *creation_time,
- uint32_t major,
- uint32_t minor,
- bool session_name_contains_creation_time)
+ const char *hostname,
+ const char *base_path,
+ uint32_t live_timer,
+ bool snapshot,
+ const lttng_uuid& sessiond_uuid,
+ const uint64_t *id_sessiond,
+ const uint64_t *current_chunk_id,
+ const time_t *creation_time,
+ uint32_t major,
+ uint32_t minor,
+ bool session_name_contains_creation_time)
{
int ret;
struct relay_session *session = NULL;
goto error;
}
if (strstr(base_path, "../")) {
- ERR("Invalid session base path walks up the path hierarchy: \"%s\"",
- base_path);
+ ERR("Invalid session base path walks up the path hierarchy: \"%s\"", base_path);
goto error;
}
pthread_mutex_init(&session->lock, NULL);
pthread_mutex_init(&session->recv_list_lock, NULL);
- if (lttng_strncpy(session->session_name, session_name,
- sizeof(session->session_name))) {
+ if (lttng_strncpy(session->session_name, session_name, sizeof(session->session_name))) {
WARN("Session name exceeds maximal allowed length");
goto error;
}
- if (lttng_strncpy(session->hostname, hostname,
- sizeof(session->hostname))) {
+ if (lttng_strncpy(session->hostname, hostname, sizeof(session->hostname))) {
WARN("Hostname exceeds maximal allowed length");
goto error;
}
- if (lttng_strncpy(session->base_path, base_path,
- sizeof(session->base_path))) {
+ if (lttng_strncpy(session->base_path, base_path, sizeof(session->base_path))) {
WARN("Base path exceeds maximal allowed length");
goto error;
}
goto error;
}
}
- session->session_name_contains_creation_time =
- session_name_contains_creation_time;
+ session->session_name_contains_creation_time = session_name_contains_creation_time;
session->ctf_traces_ht = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
if (!session->ctf_traces_ht) {
}
}
- ret = sessiond_trace_chunk_registry_session_created(
- sessiond_trace_chunk_registry, sessiond_uuid);
+ ret = sessiond_trace_chunk_registry_session_created(sessiond_trace_chunk_registry,
+ sessiond_uuid);
if (ret) {
goto error;
}
struct lttng_directory_handle *session_output_directory;
session->current_trace_chunk =
- sessiond_trace_chunk_registry_get_chunk(
- sessiond_trace_chunk_registry,
- session->sessiond_uuid,
- session->id_sessiond.value,
- *current_chunk_id);
+ sessiond_trace_chunk_registry_get_chunk(sessiond_trace_chunk_registry,
+ session->sessiond_uuid,
+ session->id_sessiond.value,
+ *current_chunk_id);
if (!session->current_trace_chunk) {
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(sessiond_uuid, uuid_str);
- ERR("Could not find trace chunk: sessiond = {%s}, sessiond session id = %" PRIu64 ", trace chunk id = %" PRIu64,
- uuid_str, *id_sessiond,
- *current_chunk_id);
+ ERR("Could not find trace chunk: sessiond = {%s}, sessiond session id = %" PRIu64
+ ", trace chunk id = %" PRIu64,
+ uuid_str,
+ *id_sessiond,
+ *current_chunk_id);
goto error;
}
chunk_status = lttng_trace_chunk_get_session_output_directory_handle(
- session->current_trace_chunk,
- &session_output_directory);
+ session->current_trace_chunk, &session_output_directory);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
goto error;
}
} else {
- session->output_directory =
- session_create_output_directory_handle(session);
+ session->output_directory = session_create_output_directory_handle(session);
if (!session->output_directory) {
goto error;
}
* Sample the 'ongoing_rotation' status of all relay sessions that
* originate from the same session daemon session.
*/
- cds_lfht_for_each_entry(sessions_ht->ht, &iter.iter, iterated_session,
- session_n.node) {
+ cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, iterated_session, session_n.node) {
if (!session_get(iterated_session)) {
continue;
}
}
if (LTTNG_OPTIONAL_GET(session->id_sessiond) !=
- LTTNG_OPTIONAL_GET(iterated_session->id_sessiond)) {
+ LTTNG_OPTIONAL_GET(iterated_session->id_sessiond)) {
/*
* Sessions do not originate from the same sessiond
* session.
ongoing_rotation = iterated_session->ongoing_rotation;
-next_session:
+ next_session:
pthread_mutex_unlock(&iterated_session->lock);
-next_session_no_unlock:
+ next_session_no_unlock:
session_put(iterated_session);
if (ongoing_rotation) {
static void rcu_destroy_session(struct rcu_head *rcu_head)
{
- struct relay_session *session =
- caa_container_of(rcu_head, struct relay_session,
- rcu_node);
+ struct relay_session *session = caa_container_of(rcu_head, struct relay_session, rcu_node);
/*
* Since each trace has a reference on the session, it means
* that if we are at the point where we teardown the session, no
return lttng_ht_del(sessions_ht, &iter);
}
-
static void destroy_session(struct relay_session *session)
{
int ret;
session->current_trace_chunk = NULL;
lttng_trace_chunk_put(session->pending_closure_trace_chunk);
session->pending_closure_trace_chunk = NULL;
- ret = sessiond_trace_chunk_registry_session_destroyed(
- sessiond_trace_chunk_registry, session->sessiond_uuid);
+ ret = sessiond_trace_chunk_registry_session_destroyed(sessiond_trace_chunk_registry,
+ session->sessiond_uuid);
LTTNG_ASSERT(!ret);
lttng_directory_handle_put(session->output_directory);
session->output_directory = NULL;
static void session_release(struct urcu_ref *ref)
{
- struct relay_session *session =
- lttng::utils::container_of(ref, &relay_session::ref);
+ struct relay_session *session = lttng::utils::container_of(ref, &relay_session::ref);
destroy_session(session);
}
pthread_mutex_lock(&session->lock);
DBG("closing session %" PRIu64 ": is conn already closed %d",
- session->id, session->connection_closed);
+ session->id,
+ session->connection_closed);
session->connection_closed = true;
pthread_mutex_unlock(&session->lock);
rcu_read_lock();
- cds_lfht_for_each_entry(session->ctf_traces_ht->ht,
- &iter.iter, trace, node.node) {
+ cds_lfht_for_each_entry (session->ctf_traces_ht->ht, &iter.iter, trace, node.node) {
ret = ctf_trace_close(trace);
if (ret) {
goto rcu_unlock;
}
}
- cds_list_for_each_entry_rcu(stream, &session->recv_list,
- recv_node) {
+ cds_list_for_each_entry_rcu(stream, &session->recv_list, recv_node)
+ {
/* Close streams which have not been published yet. */
try_stream_close(stream);
}
}
rcu_read_lock();
- cds_lfht_for_each_entry(sessions_ht->ht, &iter.iter, session,
- session_n.node) {
+ cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, session, session_n.node) {
if (!session_get(session)) {
continue;
}
DBG("session %p refcount %ld session %" PRIu64,
- session,
- session->ref.refcount,
- session->id);
+ session,
+ session->ref.refcount,
+ session->id);
session_put(session);
}
rcu_read_unlock();
*/
#include "sessiond-trace-chunks.hpp"
-#include <urcu.h>
-#include <urcu/rculfhash.h>
-#include <urcu/ref.h>
-#include <common/macros.hpp>
-#include <common/hashtable/hashtable.hpp>
-#include <common/hashtable/utils.hpp>
-#include <common/trace-chunk-registry.hpp>
+
#include <common/defaults.hpp>
#include <common/error.hpp>
+#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
+#include <common/macros.hpp>
#include <common/string-utils/format.hpp>
-#include <stdio.h>
+#include <common/trace-chunk-registry.hpp>
+
#include <inttypes.h>
+#include <stdio.h>
+#include <urcu.h>
+#include <urcu/rculfhash.h>
+#include <urcu/ref.h>
/*
* Lifetime of trace chunks within the relay daemon.
};
} /* namespace */
-static
-unsigned long trace_chunk_registry_ht_key_hash(
- const struct trace_chunk_registry_ht_key *key)
+static unsigned long trace_chunk_registry_ht_key_hash(const struct trace_chunk_registry_ht_key *key)
{
const uint64_t uuid_h1 = *reinterpret_cast<const uint64_t *>(&key->sessiond_uuid[0]);
const uint64_t uuid_h2 = *reinterpret_cast<const uint64_t *>(&key->sessiond_uuid[1]);
- return hash_key_u64(&uuid_h1, lttng_ht_seed) ^
- hash_key_u64(&uuid_h2, lttng_ht_seed);
+ return hash_key_u64(&uuid_h1, lttng_ht_seed) ^ hash_key_u64(&uuid_h2, lttng_ht_seed);
}
/* cds_lfht match function */
-static
-int trace_chunk_registry_ht_key_match(struct cds_lfht_node *node,
- const void *_key)
+static int trace_chunk_registry_ht_key_match(struct cds_lfht_node *node, const void *_key)
{
- const struct trace_chunk_registry_ht_key *key =
- (struct trace_chunk_registry_ht_key *) _key;
+ const struct trace_chunk_registry_ht_key *key = (struct trace_chunk_registry_ht_key *) _key;
struct trace_chunk_registry_ht_element *registry;
registry = lttng::utils::container_of(node, &trace_chunk_registry_ht_element::ht_node);
return key->sessiond_uuid == registry->key.sessiond_uuid;
}
-static
-void trace_chunk_registry_ht_element_free(struct rcu_head *node)
+static void trace_chunk_registry_ht_element_free(struct rcu_head *node)
{
- struct trace_chunk_registry_ht_element *element = lttng::utils::container_of(
- node, &trace_chunk_registry_ht_element::rcu_node);
+ struct trace_chunk_registry_ht_element *element =
+ lttng::utils::container_of(node, &trace_chunk_registry_ht_element::rcu_node);
free(element);
}
-static
-void trace_chunk_registry_ht_element_release(struct urcu_ref *ref)
+static void trace_chunk_registry_ht_element_release(struct urcu_ref *ref)
{
struct trace_chunk_registry_ht_element *element =
- lttng::utils::container_of(ref, &trace_chunk_registry_ht_element::ref);
+ lttng::utils::container_of(ref, &trace_chunk_registry_ht_element::ref);
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(element->key.sessiond_uuid, uuid_str);
- DBG("Destroying trace chunk registry associated to sessiond {%s}",
- uuid_str);
+ DBG("Destroying trace chunk registry associated to sessiond {%s}", uuid_str);
if (element->sessiond_trace_chunk_registry) {
/* Unpublish. */
rcu_read_lock();
- cds_lfht_del(element->sessiond_trace_chunk_registry->ht,
- &element->ht_node);
+ cds_lfht_del(element->sessiond_trace_chunk_registry->ht, &element->ht_node);
rcu_read_unlock();
element->sessiond_trace_chunk_registry = NULL;
}
call_rcu(&element->rcu_node, trace_chunk_registry_ht_element_free);
}
-static
-bool trace_chunk_registry_ht_element_get(
- struct trace_chunk_registry_ht_element *element)
+static bool trace_chunk_registry_ht_element_get(struct trace_chunk_registry_ht_element *element)
{
return urcu_ref_get_unless_zero(&element->ref);
}
-static
-void trace_chunk_registry_ht_element_put(
- struct trace_chunk_registry_ht_element *element)
+static void trace_chunk_registry_ht_element_put(struct trace_chunk_registry_ht_element *element)
{
if (!element) {
return;
}
/* Acquires a reference to the returned element on behalf of the caller. */
-static
-struct trace_chunk_registry_ht_element *trace_chunk_registry_ht_element_find(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const struct trace_chunk_registry_ht_key *key)
+static struct trace_chunk_registry_ht_element *
+trace_chunk_registry_ht_element_find(struct sessiond_trace_chunk_registry *sessiond_registry,
+ const struct trace_chunk_registry_ht_key *key)
{
struct trace_chunk_registry_ht_element *element = NULL;
struct cds_lfht_node *node;
&iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
- element = lttng::utils::container_of(
- node, &trace_chunk_registry_ht_element::ht_node);
+ element =
+ lttng::utils::container_of(node, &trace_chunk_registry_ht_element::ht_node);
/*
* Only consider the look-up as successful if a reference
* could be acquired.
return element;
}
-static
-int trace_chunk_registry_ht_element_create(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const struct trace_chunk_registry_ht_key *key)
+static int
+trace_chunk_registry_ht_element_create(struct sessiond_trace_chunk_registry *sessiond_registry,
+ const struct trace_chunk_registry_ht_key *key)
{
int ret = 0;
struct trace_chunk_registry_ht_element *new_element;
struct cds_lfht_node *published_node;
struct trace_chunk_registry_ht_element *published_element;
- published_node = cds_lfht_add_unique(sessiond_registry->ht,
- trace_chunk_registry_ht_key_hash(&new_element->key),
- trace_chunk_registry_ht_key_match,
- &new_element->key,
- &new_element->ht_node);
+ published_node =
+ cds_lfht_add_unique(sessiond_registry->ht,
+ trace_chunk_registry_ht_key_hash(&new_element->key),
+ trace_chunk_registry_ht_key_match,
+ &new_element->key,
+ &new_element->ht_node);
if (published_node == &new_element->ht_node) {
/* New element published successfully. */
- DBG("Created trace chunk registry for sessiond {%s}",
- uuid_str);
- new_element->sessiond_trace_chunk_registry =
- sessiond_registry;
+ DBG("Created trace chunk registry for sessiond {%s}", uuid_str);
+ new_element->sessiond_trace_chunk_registry = sessiond_registry;
break;
}
* was already published and release the reference to the copy
* we created if successful.
*/
- published_element = lttng::utils::container_of(published_node,
- &trace_chunk_registry_ht_element::ht_node);
+ published_element = lttng::utils::container_of(
+ published_node, &trace_chunk_registry_ht_element::ht_node);
if (trace_chunk_registry_ht_element_get(published_element)) {
DBG("Acquired reference to trace chunk registry of sessiond {%s}",
- uuid_str);
+ uuid_str);
trace_chunk_registry_ht_element_put(new_element);
new_element = NULL;
break;
rcu_read_unlock();
end:
if (ret < 0) {
- ERR("Failed to create trace chunk registry for session daemon {%s}",
- uuid_str);
+ ERR("Failed to create trace chunk registry for session daemon {%s}", uuid_str);
}
lttng_trace_chunk_registry_destroy(trace_chunk_registry);
return ret;
struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry_create(void)
{
struct sessiond_trace_chunk_registry *sessiond_registry =
- zmalloc<sessiond_trace_chunk_registry>();
+ zmalloc<sessiond_trace_chunk_registry>();
if (!sessiond_registry) {
goto end;
}
- sessiond_registry->ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ sessiond_registry->ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!sessiond_registry->ht) {
goto error;
}
return NULL;
}
-void sessiond_trace_chunk_registry_destroy(
- struct sessiond_trace_chunk_registry *sessiond_registry)
+void sessiond_trace_chunk_registry_destroy(struct sessiond_trace_chunk_registry *sessiond_registry)
{
int ret = cds_lfht_destroy(sessiond_registry->ht, NULL);
}
int sessiond_trace_chunk_registry_session_created(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid)
+ struct sessiond_trace_chunk_registry *sessiond_registry, const lttng_uuid& sessiond_uuid)
{
int ret = 0;
struct trace_chunk_registry_ht_key key;
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(sessiond_uuid, uuid_str);
- DBG("Acquired reference to trace chunk registry of sessiond {%s}",
- uuid_str);
+ DBG("Acquired reference to trace chunk registry of sessiond {%s}", uuid_str);
goto end;
} else {
- ret = trace_chunk_registry_ht_element_create(
- sessiond_registry, &key);
+ ret = trace_chunk_registry_ht_element_create(sessiond_registry, &key);
}
end:
return ret;
}
int sessiond_trace_chunk_registry_session_destroyed(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid)
+ struct sessiond_trace_chunk_registry *sessiond_registry, const lttng_uuid& sessiond_uuid)
{
int ret = 0;
struct trace_chunk_registry_ht_key key;
element = trace_chunk_registry_ht_element_find(sessiond_registry, &key);
if (element) {
- DBG("Releasing reference to trace chunk registry of sessiond {%s}",
- uuid_str);
+ DBG("Releasing reference to trace chunk registry of sessiond {%s}", uuid_str);
/*
* Release the reference held by the session and the reference
* acquired through the "find" operation.
trace_chunk_registry_ht_element_put(element);
trace_chunk_registry_ht_element_put(element);
} else {
- ERR("Failed to find trace chunk registry of sessiond {%s}",
- uuid_str);
+ ERR("Failed to find trace chunk registry of sessiond {%s}", uuid_str);
ret = -1;
}
return ret;
}
-struct lttng_trace_chunk *sessiond_trace_chunk_registry_publish_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid, uint64_t session_id,
- struct lttng_trace_chunk *new_chunk)
+struct lttng_trace_chunk *
+sessiond_trace_chunk_registry_publish_chunk(struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid& sessiond_uuid,
+ uint64_t session_id,
+ struct lttng_trace_chunk *new_chunk)
{
enum lttng_trace_chunk_status status;
uint64_t chunk_id;
if (status == LTTNG_TRACE_CHUNK_STATUS_OK) {
int ret;
- ret = snprintf(chunk_id_str, sizeof(chunk_id_str), "%" PRIu64,
- chunk_id);
+ ret = snprintf(chunk_id_str, sizeof(chunk_id_str), "%" PRIu64, chunk_id);
if (ret < 0) {
lttng_strncpy(chunk_id_str, "-1", sizeof(chunk_id_str));
WARN("Failed to format trace chunk id");
}
DBG("Attempting to publish trace chunk: sessiond {%s}, session_id = "
- "%" PRIu64 ", chunk_id = %s",
- uuid_str, session_id,
- is_anonymous_chunk ? "anonymous" : chunk_id_str);
+ "%" PRIu64 ", chunk_id = %s",
+ uuid_str,
+ session_id,
+ is_anonymous_chunk ? "anonymous" : chunk_id_str);
element = trace_chunk_registry_ht_element_find(sessiond_registry, &key);
if (!element) {
goto end;
}
- published_chunk = lttng_trace_chunk_registry_publish_chunk(
- element->trace_chunk_registry, session_id, new_chunk,
- &trace_chunk_already_published);
+ published_chunk = lttng_trace_chunk_registry_publish_chunk(element->trace_chunk_registry,
+ session_id,
+ new_chunk,
+ &trace_chunk_already_published);
/*
* When the trace chunk is first published, two references to the
* published chunks exist. One is taken by the registry while the other
return published_chunk;
}
-struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_anonymous_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid,
- uint64_t session_id)
+struct lttng_trace_chunk *sessiond_trace_chunk_registry_get_anonymous_chunk(
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid& sessiond_uuid,
+ uint64_t session_id)
{
struct lttng_trace_chunk *chunk = NULL;
struct trace_chunk_registry_ht_element *element;
key.sessiond_uuid = sessiond_uuid;
element = trace_chunk_registry_ht_element_find(sessiond_registry, &key);
if (!element) {
- ERR("Failed to find trace chunk registry of sessiond {%s}",
- uuid_str);
+ ERR("Failed to find trace chunk registry of sessiond {%s}", uuid_str);
goto end;
}
- chunk = lttng_trace_chunk_registry_find_anonymous_chunk(
- element->trace_chunk_registry,
- session_id);
+ chunk = lttng_trace_chunk_registry_find_anonymous_chunk(element->trace_chunk_registry,
+ session_id);
trace_chunk_registry_ht_element_put(element);
end:
return chunk;
}
struct lttng_trace_chunk *
-sessiond_trace_chunk_registry_get_chunk(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid,
- uint64_t session_id, uint64_t chunk_id)
+sessiond_trace_chunk_registry_get_chunk(struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid& sessiond_uuid,
+ uint64_t session_id,
+ uint64_t chunk_id)
{
struct lttng_trace_chunk *chunk = NULL;
struct trace_chunk_registry_ht_element *element;
key.sessiond_uuid = sessiond_uuid;
element = trace_chunk_registry_ht_element_find(sessiond_registry, &key);
if (!element) {
- ERR("Failed to find trace chunk registry of sessiond {%s}",
- uuid_str);
+ ERR("Failed to find trace chunk registry of sessiond {%s}", uuid_str);
goto end;
}
chunk = lttng_trace_chunk_registry_find_chunk(
- element->trace_chunk_registry,
- session_id, chunk_id);
+ element->trace_chunk_registry, session_id, chunk_id);
trace_chunk_registry_ht_element_put(element);
end:
return chunk;
}
int sessiond_trace_chunk_registry_chunk_exists(
- struct sessiond_trace_chunk_registry *sessiond_registry,
- const lttng_uuid& sessiond_uuid,
- uint64_t session_id, uint64_t chunk_id, bool *chunk_exists)
+ struct sessiond_trace_chunk_registry *sessiond_registry,
+ const lttng_uuid& sessiond_uuid,
+ uint64_t session_id,
+ uint64_t chunk_id,
+ bool *chunk_exists)
{
int ret;
struct trace_chunk_registry_ht_element *element;
* connection/registry. This would indicate a protocol
* (or internal) error.
*/
- ERR("Failed to find trace chunk registry of sessiond {%s}",
- uuid_str);
+ ERR("Failed to find trace chunk registry of sessiond {%s}", uuid_str);
ret = -1;
goto end;
}
ret = lttng_trace_chunk_registry_chunk_exists(
- element->trace_chunk_registry,
- session_id, chunk_id, chunk_exists);
+ element->trace_chunk_registry, session_id, chunk_id, chunk_exists);
trace_chunk_registry_ht_element_put(element);
end:
return ret;
*/
#define _LGPL_SOURCE
-#include <algorithm>
+#include "index.hpp"
+#include "lttng-relayd.hpp"
+#include "stream.hpp"
+#include "viewer-stream.hpp"
+
#include <common/common.hpp>
#include <common/defaults.hpp>
#include <common/fs-handle.hpp>
#include <common/sessiond-comm/relayd.hpp>
#include <common/utils.hpp>
-#include <sys/stat.h>
-#include <urcu/rculist.h>
-
-#include "lttng-relayd.hpp"
-#include "index.hpp"
-#include "stream.hpp"
-#include "viewer-stream.hpp"
-#include <sys/types.h>
+#include <algorithm>
#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <urcu/rculist.h>
-#define FILE_IO_STACK_BUFFER_SIZE 65536
+#define FILE_IO_STACK_BUFFER_SIZE 65536
/* Should be called with RCU read-side lock held. */
bool stream_get(struct relay_stream *stream)
DBG("Rotation completed for stream %" PRIu64, stream->stream_handle);
if (stream->ongoing_rotation.value.next_trace_chunk) {
tracefile_array_reset(stream->tfa);
- tracefile_array_commit_seq(stream->tfa,
- stream->index_received_seqcount);
+ tracefile_array_commit_seq(stream->tfa, stream->index_received_seqcount);
}
lttng_trace_chunk_put(stream->trace_chunk);
stream->trace_chunk = stream->ongoing_rotation.value.next_trace_chunk;
stream->completed_rotation_count++;
}
-static int stream_create_data_output_file_from_trace_chunk(
- struct relay_stream *stream,
- struct lttng_trace_chunk *trace_chunk,
- bool force_unlink,
- struct fs_handle **out_file)
+static int stream_create_data_output_file_from_trace_chunk(struct relay_stream *stream,
+ struct lttng_trace_chunk *trace_chunk,
+ bool force_unlink,
+ struct fs_handle **out_file)
{
int ret;
char stream_path[LTTNG_PATH_MAX];
ASSERT_LOCKED(stream->lock);
- ret = utils_stream_file_path(stream->path_name, stream->channel_name,
- stream->tracefile_size, stream->tracefile_current_index,
- NULL, stream_path, sizeof(stream_path));
+ ret = utils_stream_file_path(stream->path_name,
+ stream->channel_name,
+ stream->tracefile_size,
+ stream->tracefile_current_index,
+ NULL,
+ stream_path,
+ sizeof(stream_path));
if (ret < 0) {
goto end;
}
* content.
*/
status = (lttng_trace_chunk_status) lttng_trace_chunk_unlink_file(trace_chunk,
- stream_path);
+ stream_path);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
PERROR("Failed to unlink stream file \"%s\" during trace file rotation",
- stream_path);
+ stream_path);
/*
* Don't abort if the file doesn't exist, it is
* unexpected, but should not be a fatal error.
}
}
- status = lttng_trace_chunk_open_fs_handle(trace_chunk, stream_path,
- flags, mode, out_file, false);
+ status = lttng_trace_chunk_open_fs_handle(
+ trace_chunk, stream_path, flags, mode, out_file, false);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to open stream file \"%s\"", stream->channel_name);
ret = -1;
int ret = 0;
DBG("Rotating stream %" PRIu64 " data file with size %" PRIu64,
- stream->stream_handle, stream->tracefile_size_current);
+ stream->stream_handle,
+ stream->tracefile_size_current);
if (stream->file) {
fs_handle_close(stream->file);
enum lttng_trace_chunk_status chunk_status;
chunk_status = lttng_trace_chunk_create_subdirectory(
- stream->ongoing_rotation.value.next_trace_chunk,
- stream->path_name);
+ stream->ongoing_rotation.value.next_trace_chunk, stream->path_name);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
}
/* Rotate the data file. */
- ret = stream_create_data_output_file_from_trace_chunk(stream,
- stream->ongoing_rotation.value.next_trace_chunk,
- false, &stream->file);
+ ret = stream_create_data_output_file_from_trace_chunk(
+ stream,
+ stream->ongoing_rotation.value.next_trace_chunk,
+ false,
+ &stream->file);
if (ret < 0) {
ERR("Failed to rotate stream data file");
goto end;
}
}
DBG("%s: reset tracefile_size_current for stream %" PRIu64 " was %" PRIu64,
- __func__, stream->stream_handle, stream->tracefile_size_current);
+ __func__,
+ stream->stream_handle,
+ stream->tracefile_size_current);
stream->tracefile_size_current = 0;
stream->pos_after_last_complete_data_index = 0;
stream->ongoing_rotation.value.data_rotated = true;
if (!LTTNG_OPTIONAL_GET(stream->ongoing_rotation).next_trace_chunk) {
ERR("Protocol error encoutered in %s(): stream rotation "
- "sequence number is before the current sequence number "
- "and the next trace chunk is unset. Honoring this "
- "rotation command would result in data loss",
- __FUNCTION__);
+ "sequence number is before the current sequence number "
+ "and the next trace chunk is unset. Honoring this "
+ "rotation command would result in data loss",
+ __FUNCTION__);
ret = -1;
goto end;
}
stream->file = NULL;
LTTNG_ASSERT(!stream->is_metadata);
- LTTNG_ASSERT(stream->tracefile_size_current >
- stream->pos_after_last_complete_data_index);
- misplaced_data_size = stream->tracefile_size_current -
- stream->pos_after_last_complete_data_index;
+ LTTNG_ASSERT(stream->tracefile_size_current > stream->pos_after_last_complete_data_index);
+ misplaced_data_size =
+ stream->tracefile_size_current - stream->pos_after_last_complete_data_index;
copy_bytes_left = misplaced_data_size;
previous_stream_copy_origin = stream->pos_after_last_complete_data_index;
if (lseek_ret < 0) {
PERROR("Failed to seek to offset %" PRIu64
" while copying extra data received before a stream rotation",
- (uint64_t) previous_stream_copy_origin);
+ (uint64_t) previous_stream_copy_origin);
ret = -1;
goto end;
}
while (copy_bytes_left) {
ssize_t io_ret;
char copy_buffer[FILE_IO_STACK_BUFFER_SIZE];
- const off_t copy_size_this_pass = std::min<uint64_t>(copy_bytes_left, sizeof(copy_buffer));
+ const off_t copy_size_this_pass =
+ std::min<uint64_t>(copy_bytes_left, sizeof(copy_buffer));
- io_ret = fs_handle_read(previous_stream_file, copy_buffer,
- copy_size_this_pass);
+ io_ret = fs_handle_read(previous_stream_file, copy_buffer, copy_size_this_pass);
if (io_ret < (ssize_t) copy_size_this_pass) {
if (io_ret == -1) {
PERROR("Failed to read %" PRIu64
" bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
- copy_size_this_pass,
- __FUNCTION__, io_ret,
- stream->stream_handle);
+ copy_size_this_pass,
+ __FUNCTION__,
+ io_ret,
+ stream->stream_handle);
} else {
ERR("Failed to read %" PRIu64
- " bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
- copy_size_this_pass,
- __FUNCTION__, io_ret,
- stream->stream_handle);
+ " bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
+ copy_size_this_pass,
+ __FUNCTION__,
+ io_ret,
+ stream->stream_handle);
}
ret = -1;
goto end;
}
- io_ret = fs_handle_write(
- stream->file, copy_buffer, copy_size_this_pass);
+ io_ret = fs_handle_write(stream->file, copy_buffer, copy_size_this_pass);
if (io_ret < (ssize_t) copy_size_this_pass) {
if (io_ret == -1) {
PERROR("Failed to write %" PRIu64
" bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
- copy_size_this_pass,
- __FUNCTION__, io_ret,
- stream->stream_handle);
+ copy_size_this_pass,
+ __FUNCTION__,
+ io_ret,
+ stream->stream_handle);
} else {
ERR("Failed to write %" PRIu64
- " bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
- copy_size_this_pass,
- __FUNCTION__, io_ret,
- stream->stream_handle);
+ " bytes from previous stream file in %s(), returned %zi: stream id = %" PRIu64,
+ copy_size_this_pass,
+ __FUNCTION__,
+ io_ret,
+ stream->stream_handle);
}
ret = -1;
goto end;
}
/* Truncate the file to get rid of the excess data. */
- ret = fs_handle_truncate(
- previous_stream_file, previous_stream_copy_origin);
+ ret = fs_handle_truncate(previous_stream_file, previous_stream_copy_origin);
if (ret) {
PERROR("Failed to truncate current stream file to offset %" PRIu64,
- previous_stream_copy_origin);
+ previous_stream_copy_origin);
goto end;
}
goto end;
}
- DBG("%s: Stream %" PRIu64
- " (rotate_at_index_packet_seq_num = %" PRIu64
- ", rotate_at_prev_data_net_seq = %" PRIu64
- ", prev_data_seq = %" PRIu64 ")",
- __func__, stream->stream_handle,
- stream->ongoing_rotation.value.packet_seq_num,
- stream->ongoing_rotation.value.prev_data_net_seq,
- stream->prev_data_seq);
+ DBG("%s: Stream %" PRIu64 " (rotate_at_index_packet_seq_num = %" PRIu64
+ ", rotate_at_prev_data_net_seq = %" PRIu64 ", prev_data_seq = %" PRIu64 ")",
+ __func__,
+ stream->stream_handle,
+ stream->ongoing_rotation.value.packet_seq_num,
+ stream->ongoing_rotation.value.prev_data_net_seq,
+ stream->prev_data_seq);
if (stream->prev_data_seq == -1ULL ||
- stream->ongoing_rotation.value.prev_data_net_seq == -1ULL ||
- stream->prev_data_seq <
- stream->ongoing_rotation.value.prev_data_net_seq) {
+ stream->ongoing_rotation.value.prev_data_net_seq == -1ULL ||
+ stream->prev_data_seq < stream->ongoing_rotation.value.prev_data_net_seq) {
/*
* The next packet that will be written is not part of the next
* chunk yet.
*/
DBG("Stream %" PRIu64 " data not yet ready for rotation "
- "(rotate_at_index_packet_seq_num = %" PRIu64
- ", rotate_at_prev_data_net_seq = %" PRIu64
- ", prev_data_seq = %" PRIu64 ")",
- stream->stream_handle,
- stream->ongoing_rotation.value.packet_seq_num,
- stream->ongoing_rotation.value.prev_data_net_seq,
- stream->prev_data_seq);
+ "(rotate_at_index_packet_seq_num = %" PRIu64
+ ", rotate_at_prev_data_net_seq = %" PRIu64 ", prev_data_seq = %" PRIu64 ")",
+ stream->stream_handle,
+ stream->ongoing_rotation.value.packet_seq_num,
+ stream->ongoing_rotation.value.prev_data_net_seq,
+ stream->prev_data_seq);
goto end;
} else if (stream->prev_data_seq > stream->ongoing_rotation.value.prev_data_net_seq) {
/*
* commands are serialized with respect to each other.
*/
DBG("Rotation after too much data has been written in tracefile "
- "for stream %" PRIu64 ", need to truncate before "
- "rotating", stream->stream_handle);
+ "for stream %" PRIu64 ", need to truncate before "
+ "rotating",
+ stream->stream_handle);
ret = rotate_truncate_stream(stream);
if (ret) {
ERR("Failed to truncate stream");
*
* Return 0 on success, -1 on error.
*/
-static int create_index_file(struct relay_stream *stream,
- struct lttng_trace_chunk *chunk)
+static int create_index_file(struct relay_stream *stream, struct lttng_trace_chunk *chunk)
{
int ret;
uint32_t major, minor;
ret = 0;
goto end;
}
- ret = asprintf(&index_subpath, "%s/%s", stream->path_name,
- DEFAULT_INDEX_DIR);
+ ret = asprintf(&index_subpath, "%s/%s", stream->path_name, DEFAULT_INDEX_DIR);
if (ret < 0) {
goto end;
}
- status = lttng_trace_chunk_create_subdirectory(chunk,
- index_subpath);
+ status = lttng_trace_chunk_create_subdirectory(chunk, index_subpath);
free(index_subpath);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_index_file_create_from_trace_chunk(
- chunk, stream->path_name,
- stream->channel_name, stream->tracefile_size,
- stream->tracefile_current_index,
- lttng_to_index_major(major, minor),
- lttng_to_index_minor(major, minor), true,
- &stream->index_file);
+ status = lttng_index_file_create_from_trace_chunk(chunk,
+ stream->path_name,
+ stream->channel_name,
+ stream->tracefile_size,
+ stream->tracefile_current_index,
+ lttng_to_index_major(major, minor),
+ lttng_to_index_minor(major, minor),
+ true,
+ &stream->index_file);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
goto end;
}
- DBG("%s: Stream %" PRIu64
- " (rotate_at_packet_seq_num = %" PRIu64
- ", received_packet_seq_num = "
- "(value = %" PRIu64 ", is_set = %" PRIu8 "))",
- __func__, stream->stream_handle,
- stream->ongoing_rotation.value.packet_seq_num,
- stream->received_packet_seq_num.value,
- stream->received_packet_seq_num.is_set);
+ DBG("%s: Stream %" PRIu64 " (rotate_at_packet_seq_num = %" PRIu64
+ ", received_packet_seq_num = "
+ "(value = %" PRIu64 ", is_set = %" PRIu8 "))",
+ __func__,
+ stream->stream_handle,
+ stream->ongoing_rotation.value.packet_seq_num,
+ stream->received_packet_seq_num.value,
+ stream->received_packet_seq_num.is_set);
if (!stream->received_packet_seq_num.is_set ||
- LTTNG_OPTIONAL_GET(stream->received_packet_seq_num) + 1 <
- stream->ongoing_rotation.value.packet_seq_num) {
+ LTTNG_OPTIONAL_GET(stream->received_packet_seq_num) + 1 <
+ stream->ongoing_rotation.value.packet_seq_num) {
DBG("Stream %" PRIu64 " index not yet ready for rotation "
- "(rotate_at_packet_seq_num = %" PRIu64
- ", received_packet_seq_num = "
- "(value = %" PRIu64 ", is_set = %" PRIu8 "))",
- stream->stream_handle,
- stream->ongoing_rotation.value.packet_seq_num,
- stream->received_packet_seq_num.value,
- stream->received_packet_seq_num.is_set);
+ "(rotate_at_packet_seq_num = %" PRIu64 ", received_packet_seq_num = "
+ "(value = %" PRIu64 ", is_set = %" PRIu8 "))",
+ stream->stream_handle,
+ stream->ongoing_rotation.value.packet_seq_num,
+ stream->received_packet_seq_num.value,
+ stream->received_packet_seq_num.is_set);
goto end;
} else {
/*
* rotation position.
*/
LTTNG_ASSERT(LTTNG_OPTIONAL_GET(stream->received_packet_seq_num) + 1 >=
- stream->ongoing_rotation.value.packet_seq_num);
- DBG("Rotating stream %" PRIu64 " index file",
- stream->stream_handle);
+ stream->ongoing_rotation.value.packet_seq_num);
+ DBG("Rotating stream %" PRIu64 " index file", stream->stream_handle);
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
stream->index_file = NULL;
* Set the rotation pivot position for the data, now that we have the
* net_seq_num matching the packet_seq_num index pivot position.
*/
- stream->ongoing_rotation.value.prev_data_net_seq =
- stream->prev_index_seq;
+ stream->ongoing_rotation.value.prev_data_net_seq = stream->prev_index_seq;
if (stream->ongoing_rotation.value.data_rotated &&
- stream->ongoing_rotation.value.index_rotated) {
+ stream->ongoing_rotation.value.index_rotated) {
/* Rotation completed; reset its state. */
- DBG("Rotation completed for stream %" PRIu64,
- stream->stream_handle);
+ DBG("Rotation completed for stream %" PRIu64, stream->stream_handle);
stream_complete_rotation(stream);
}
}
return ret;
}
-static int stream_set_trace_chunk(struct relay_stream *stream,
- struct lttng_trace_chunk *chunk)
+static int stream_set_trace_chunk(struct relay_stream *stream, struct lttng_trace_chunk *chunk)
{
int ret = 0;
enum lttng_trace_chunk_status status;
bool acquired_reference;
- status = lttng_trace_chunk_create_subdirectory(chunk,
- stream->path_name);
+ status = lttng_trace_chunk_create_subdirectory(chunk, stream->path_name);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
fs_handle_close(stream->file);
stream->file = NULL;
}
- ret = stream_create_data_output_file_from_trace_chunk(stream, chunk,
- false, &stream->file);
+ ret = stream_create_data_output_file_from_trace_chunk(stream, chunk, false, &stream->file);
end:
return ret;
}
* We keep ownership of path_name and channel_name.
*/
struct relay_stream *stream_create(struct ctf_trace *trace,
- uint64_t stream_handle, char *path_name,
- char *channel_name, uint64_t tracefile_size,
- uint64_t tracefile_count)
+ uint64_t stream_handle,
+ char *path_name,
+ char *channel_name,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count)
{
int ret;
struct relay_stream *stream = NULL;
pthread_mutex_unlock(&trace->session->lock);
if (!acquired_reference) {
ERR("Cannot create stream for channel \"%s\" as a reference to the session's current trace chunk could not be acquired",
- channel_name);
+ channel_name);
ret = -1;
goto end;
}
pthread_mutex_unlock(&stream->lock);
if (ret) {
ERR("Failed to set the current trace chunk of session \"%s\" on newly created stream of channel \"%s\"",
- trace->session->session_name,
- stream->channel_name);
+ trace->session->session_name,
+ stream->channel_name);
ret = -1;
goto end;
}
goto end;
}
- stream->is_metadata = !strcmp(stream->channel_name,
- DEFAULT_METADATA_NAME);
+ stream->is_metadata = !strcmp(stream->channel_name, DEFAULT_METADATA_NAME);
stream->in_recv_list = true;
/*
lttng_ht_add_unique_u64(relay_streams_ht, &stream->node);
stream->in_stream_ht = true;
- DBG("Relay new stream added %s with ID %" PRIu64, stream->channel_name,
- stream->stream_handle);
+ DBG("Relay new stream added %s with ID %" PRIu64,
+ stream->channel_name,
+ stream->stream_handle);
ret = 0;
end:
if (ret) {
if (stream->file) {
- fs_handle_close(stream->file);
+ fs_handle_close(stream->file);
stream->file = NULL;
}
stream_put(stream);
static void stream_destroy_rcu(struct rcu_head *rcu_head)
{
- struct relay_stream *stream =
- lttng::utils::container_of(rcu_head, &relay_stream::rcu_node);
+ struct relay_stream *stream = lttng::utils::container_of(rcu_head, &relay_stream::rcu_node);
stream_destroy(stream);
}
*/
static void stream_release(struct urcu_ref *ref)
{
- struct relay_stream *stream =
- lttng::utils::container_of(ref, &relay_stream::ref);
+ struct relay_stream *stream = lttng::utils::container_of(ref, &relay_stream::ref);
struct relay_session *session;
session = stream->trace->session;
}
int stream_set_pending_rotation(struct relay_stream *stream,
- struct lttng_trace_chunk *next_trace_chunk,
- uint64_t rotation_sequence_number)
+ struct lttng_trace_chunk *next_trace_chunk,
+ uint64_t rotation_sequence_number)
{
int ret = 0;
const struct relay_stream_rotation rotation = {
}
if (next_trace_chunk) {
- const bool reference_acquired =
- lttng_trace_chunk_get(next_trace_chunk);
+ const bool reference_acquired = lttng_trace_chunk_get(next_trace_chunk);
LTTNG_ASSERT(reference_acquired);
}
LTTNG_OPTIONAL_SET(&stream->ongoing_rotation, rotation);
DBG("Setting pending rotation: stream_id = %" PRIu64
- ", rotate_at_packet_seq_num = %" PRIu64,
- stream->stream_handle, rotation_sequence_number);
+ ", rotate_at_packet_seq_num = %" PRIu64,
+ stream->stream_handle,
+ rotation_sequence_number);
if (stream->is_metadata) {
/*
* A metadata stream has no index; consider it already rotated.
*/
if (stream->closed) {
pthread_mutex_unlock(&stream->lock);
- DBG("closing stream %" PRIu64 " aborted since it is already marked as closed", stream->stream_handle);
+ DBG("closing stream %" PRIu64 " aborted since it is already marked as closed",
+ stream->stream_handle);
return;
}
}
if (stream->last_net_seq_num != -1ULL &&
- ((int64_t) (stream->prev_data_seq - stream->last_net_seq_num)) < 0
- && !session_aborted) {
+ ((int64_t) (stream->prev_data_seq - stream->last_net_seq_num)) < 0 &&
+ !session_aborted) {
/*
* Don't close since we still have data pending. This
* handles cases where an explicit close command has
* expected behavior.
*/
pthread_mutex_unlock(&stream->lock);
- DBG("closing stream %" PRIu64 " aborted since it still has data pending", stream->stream_handle);
+ DBG("closing stream %" PRIu64 " aborted since it still has data pending",
+ stream->stream_handle);
return;
}
/*
stream_put(stream);
}
-int stream_init_packet(struct relay_stream *stream, size_t packet_size,
- bool *file_rotated)
+int stream_init_packet(struct relay_stream *stream, size_t packet_size, bool *file_rotated)
{
int ret = 0;
ASSERT_LOCKED(stream->lock);
if (!stream->file || !stream->trace_chunk) {
- ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64 ", channel_name = %s",
- stream->stream_handle, stream->channel_name);
+ ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64
+ ", channel_name = %s",
+ stream->stream_handle,
+ stream->channel_name);
ret = -1;
goto end;
}
/*
* Check if writing the new packet would exceed the maximal file size.
*/
- if (caa_unlikely((stream->tracefile_size_current + packet_size) >
- stream->tracefile_size)) {
+ if (caa_unlikely((stream->tracefile_size_current + packet_size) > stream->tracefile_size)) {
const uint64_t new_file_index =
- (stream->tracefile_current_index + 1) %
- stream->tracefile_count;
+ (stream->tracefile_current_index + 1) % stream->tracefile_count;
if (new_file_index < stream->tracefile_current_index) {
stream->tracefile_wrapped_around = true;
}
DBG("New stream packet causes stream file rotation: stream_id = %" PRIu64
- ", current_file_size = %" PRIu64
- ", packet_size = %zu, current_file_index = %" PRIu64
- " new_file_index = %" PRIu64,
- stream->stream_handle,
- stream->tracefile_size_current, packet_size,
- stream->tracefile_current_index, new_file_index);
+ ", current_file_size = %" PRIu64
+ ", packet_size = %zu, current_file_index = %" PRIu64
+ " new_file_index = %" PRIu64,
+ stream->stream_handle,
+ stream->tracefile_size_current,
+ packet_size,
+ stream->tracefile_current_index,
+ new_file_index);
tracefile_array_file_rotate(stream->tfa, TRACEFILE_ROTATE_WRITE);
stream->tracefile_current_index = new_file_index;
if (stream->file) {
- fs_handle_close(stream->file);
+ fs_handle_close(stream->file);
stream->file = NULL;
}
- ret = stream_create_data_output_file_from_trace_chunk(stream,
- stream->trace_chunk, false, &stream->file);
+ ret = stream_create_data_output_file_from_trace_chunk(
+ stream, stream->trace_chunk, false, &stream->file);
if (ret) {
ERR("Failed to perform trace file rotation of stream %" PRIu64,
- stream->stream_handle);
+ stream->stream_handle);
goto end;
}
* rotation.
*/
DBG("%s: reset tracefile_size_current for stream %" PRIu64 " was %" PRIu64,
- __func__, stream->stream_handle, stream->tracefile_size_current);
+ __func__,
+ stream->stream_handle,
+ stream->tracefile_size_current);
stream->tracefile_size_current = 0;
*file_rotated = true;
} else {
/* Note that the packet is not necessarily complete. */
int stream_write(struct relay_stream *stream,
- const struct lttng_buffer_view *packet, size_t padding_len)
+ const struct lttng_buffer_view *packet,
+ size_t padding_len)
{
int ret = 0;
ssize_t write_ret;
char padding_buffer[FILE_IO_STACK_BUFFER_SIZE];
ASSERT_LOCKED(stream->lock);
- memset(padding_buffer, 0,
- std::min(sizeof(padding_buffer), padding_to_write));
+ memset(padding_buffer, 0, std::min(sizeof(padding_buffer), padding_to_write));
if (!stream->file || !stream->trace_chunk) {
- ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64 ", channel_name = %s",
- stream->stream_handle, stream->channel_name);
+ ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64
+ ", channel_name = %s",
+ stream->stream_handle,
+ stream->channel_name);
ret = -1;
goto end;
}
if (packet) {
- write_ret = fs_handle_write(
- stream->file, packet->data, packet->size);
+ write_ret = fs_handle_write(stream->file, packet->data, packet->size);
if (write_ret != packet->size) {
PERROR("Failed to write to stream file of %sstream %" PRIu64,
- stream->is_metadata ? "metadata " : "",
- stream->stream_handle);
+ stream->is_metadata ? "metadata " : "",
+ stream->stream_handle);
ret = -1;
goto end;
}
while (padding_to_write > 0) {
const size_t padding_to_write_this_pass =
- std::min(padding_to_write, sizeof(padding_buffer));
+ std::min(padding_to_write, sizeof(padding_buffer));
- write_ret = fs_handle_write(stream->file, padding_buffer,
- padding_to_write_this_pass);
+ write_ret =
+ fs_handle_write(stream->file, padding_buffer, padding_to_write_this_pass);
if (write_ret != padding_to_write_this_pass) {
PERROR("Failed to write padding to file of %sstream %" PRIu64,
- stream->is_metadata ? "metadata " : "",
- stream->stream_handle);
+ stream->is_metadata ? "metadata " : "",
+ stream->stream_handle);
ret = -1;
goto end;
}
}
DBG("Wrote to %sstream %" PRIu64 ": data_length = %zu, padding_length = %zu",
- stream->is_metadata ? "metadata " : "",
- stream->stream_handle,
- packet ? packet->size : (size_t) 0, padding_len);
+ stream->is_metadata ? "metadata " : "",
+ stream->stream_handle,
+ packet ? packet->size : (size_t) 0,
+ padding_len);
end:
return ret;
}
*
* Return 0 on success else a negative value.
*/
-int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
- bool rotate_index, bool *flushed, uint64_t total_size)
+int stream_update_index(struct relay_stream *stream,
+ uint64_t net_seq_num,
+ bool rotate_index,
+ bool *flushed,
+ uint64_t total_size)
{
int ret = 0;
uint64_t data_offset;
data_offset = htobe64(stream->tracefile_size_current);
DBG("handle_index_data: stream %" PRIu64 " net_seq_num %" PRIu64 " data offset %" PRIu64,
- stream->stream_handle, net_seq_num, stream->tracefile_size_current);
+ stream->stream_handle,
+ net_seq_num,
+ stream->tracefile_size_current);
/*
* Lookup for an existing index for that stream id/sequence
ret = create_index_file(stream, stream->trace_chunk);
if (ret) {
ERR("Failed to create index file for stream %" PRIu64,
- stream->stream_handle);
+ stream->stream_handle);
/* Put self-ref for this index due to error. */
relay_index_put(index);
index = NULL;
tracefile_array_commit_seq(stream->tfa, stream->index_received_seqcount);
stream->index_received_seqcount++;
LTTNG_OPTIONAL_SET(&stream->received_packet_seq_num,
- be64toh(index->index_data.packet_seq_num));
+ be64toh(index->index_data.packet_seq_num));
*flushed = true;
} else if (ret > 0) {
index->total_size = total_size;
return ret;
}
-int stream_complete_packet(struct relay_stream *stream, size_t packet_total_size,
- uint64_t sequence_number, bool index_flushed)
+int stream_complete_packet(struct relay_stream *stream,
+ size_t packet_total_size,
+ uint64_t sequence_number,
+ bool index_flushed)
{
int ret = 0;
stream->tracefile_size_current += packet_total_size;
if (index_flushed) {
- stream->pos_after_last_complete_data_index =
- stream->tracefile_size_current;
+ stream->pos_after_last_complete_data_index = stream->tracefile_size_current;
stream->prev_index_seq = sequence_number;
ret = try_rotate_stream_index(stream);
if (ret < 0) {
return ret;
}
-int stream_add_index(struct relay_stream *stream,
- const struct lttcomm_relayd_index *index_info)
+int stream_add_index(struct relay_stream *stream, const struct lttcomm_relayd_index *index_info)
{
int ret = 0;
struct relay_index *index;
/* Live beacon handling */
if (index_info->packet_size == 0) {
- DBG("Received live beacon for stream %" PRIu64,
- stream->stream_handle);
+ DBG("Received live beacon for stream %" PRIu64, stream->stream_handle);
/*
* Only flag a stream inactive when it has already
* received data and no indexes are in flight.
*/
- if (stream->index_received_seqcount > 0
- && stream->indexes_in_flight == 0) {
+ if (stream->index_received_seqcount > 0 && stream->indexes_in_flight == 0) {
stream->beacon_ts_end = index_info->timestamp_end;
}
ret = 0;
index = relay_index_get_by_id_or_create(stream, index_info->net_seq_num);
if (!index) {
ret = -1;
- ERR("Failed to get or create index %" PRIu64,
- index_info->net_seq_num);
+ ERR("Failed to get or create index %" PRIu64, index_info->net_seq_num);
goto end;
}
- if (relay_index_set_control_data(index, index_info,
- stream->trace->session->minor)) {
+ if (relay_index_set_control_data(index, index_info, stream->trace->session->minor)) {
ERR("set_index_control_data error");
relay_index_put(index);
ret = -1;
stream->index_received_seqcount++;
stream->pos_after_last_complete_data_index += index->total_size;
stream->prev_index_seq = index_info->net_seq_num;
- LTTNG_OPTIONAL_SET(&stream->received_packet_seq_num,
- index_info->packet_seq_num);
+ LTTNG_OPTIONAL_SET(&stream->received_packet_seq_num, index_info->packet_seq_num);
ret = try_rotate_stream_index(stream);
if (ret < 0) {
struct relay_index *index;
rcu_read_lock();
- cds_lfht_for_each_entry(stream->indexes_ht->ht, &iter.iter, index,
- index_n.node) {
+ cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
DBG("index %p net_seq_num %" PRIu64 " refcount %ld"
- " stream %" PRIu64 " trace %" PRIu64
- " session %" PRIu64,
- index,
- index->index_n.key,
- stream->ref.refcount,
- index->stream->stream_handle,
- index->stream->trace->id,
- index->stream->trace->session->id);
+ " stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
+ index,
+ index->index_n.key,
+ stream->ref.refcount,
+ index->stream->stream_handle,
+ index->stream->trace->id,
+ index->stream->trace->session->id);
}
rcu_read_unlock();
}
ret = fs_handle_close(stream->file);
if (ret) {
ERR("Failed to close stream file handle: channel name = \"%s\", id = %" PRIu64,
- stream->channel_name,
- stream->stream_handle);
+ stream->channel_name,
+ stream->stream_handle);
}
stream->file = NULL;
}
DBG("%s: reset tracefile_size_current for stream %" PRIu64 " was %" PRIu64,
- __func__, stream->stream_handle, stream->tracefile_size_current);
+ __func__,
+ stream->stream_handle,
+ stream->tracefile_size_current);
stream->tracefile_size_current = 0;
stream->prev_data_seq = 0;
stream->prev_index_seq = 0;
stream->tracefile_current_index = 0;
stream->pos_after_last_complete_data_index = 0;
- return stream_create_data_output_file_from_trace_chunk(stream,
- stream->trace_chunk, true, &stream->file);
+ return stream_create_data_output_file_from_trace_chunk(
+ stream, stream->trace_chunk, true, &stream->file);
}
void print_relay_streams(void)
}
rcu_read_lock();
- cds_lfht_for_each_entry(relay_streams_ht->ht, &iter.iter, stream,
- node.node) {
+ cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) {
if (!stream_get(stream)) {
continue;
}
- DBG("stream %p refcount %ld stream %" PRIu64 " trace %" PRIu64
- " session %" PRIu64,
- stream,
- stream->ref.refcount,
- stream->stream_handle,
- stream->trace->id,
- stream->trace->session->id);
+ DBG("stream %p refcount %ld stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
+ stream,
+ stream->ref.refcount,
+ stream->stream_handle,
+ stream->trace->id,
+ stream->trace->session->id);
print_stream_indexes(stream);
stream_put(stream);
}
*
*/
-#include <sys/types.h>
-#include <netinet/tcp.h>
-#include <stdbool.h>
-#include <sys/socket.h>
-#include <limits.h>
+#include "tcp_keep_alive.hpp"
#include <common/compat/getenv.hpp>
-#include <common/time.hpp>
#include <common/defaults.hpp>
#include <common/ini-config/ini-config.hpp>
+#include <common/time.hpp>
-#include "tcp_keep_alive.hpp"
+#include <limits.h>
+#include <netinet/tcp.h>
+#include <stdbool.h>
+#include <sys/socket.h>
+#include <sys/types.h>
-#define SOLARIS_IDLE_TIME_MIN_S 10
-#define SOLARIS_IDLE_TIME_MAX_S 864000 /* 10 days */
+#define SOLARIS_IDLE_TIME_MIN_S 10
+#define SOLARIS_IDLE_TIME_MAX_S 864000 /* 10 days */
#define SOLARIS_ABORT_THRESHOLD_MIN_S 1
#define SOLARIS_ABORT_THRESHOLD_MAX_S 480 /* 8 minutes */
/* Per-platform definitions of TCP socket options. */
-#if defined (__linux__)
+#if defined(__linux__)
-#define COMPAT_TCP_LEVEL SOL_TCP
+#define COMPAT_TCP_LEVEL SOL_TCP
#define COMPAT_TCP_ABORT_THRESHOLD 0 /* Does not exist on linux. */
-#define COMPAT_TCP_KEEPIDLE TCP_KEEPIDLE
-#define COMPAT_TCP_KEEPINTVL TCP_KEEPINTVL
-#define COMPAT_TCP_KEEPCNT TCP_KEEPCNT
+#define COMPAT_TCP_KEEPIDLE TCP_KEEPIDLE
+#define COMPAT_TCP_KEEPINTVL TCP_KEEPINTVL
+#define COMPAT_TCP_KEEPCNT TCP_KEEPCNT
-#elif defined (__sun__) /* ! defined (__linux__) */
+#elif defined(__sun__) /* ! defined (__linux__) */
#define COMPAT_TCP_LEVEL IPPROTO_TCP
#endif /* TCP_KEEPALIVE_ABORT_THRESHOLD */
#define COMPAT_TCP_KEEPINTVL 0 /* Does not exist on Solaris. */
-#define COMPAT_TCP_KEEPCNT 0 /* Does not exist on Solaris. */
+#define COMPAT_TCP_KEEPCNT 0 /* Does not exist on Solaris. */
#else /* ! defined (__linux__) && ! defined (__sun__) */
-#define COMPAT_TCP_LEVEL 0
+#define COMPAT_TCP_LEVEL 0
#define COMPAT_TCP_ABORT_THRESHOLD 0
-#define COMPAT_TCP_KEEPIDLE 0
-#define COMPAT_TCP_KEEPINTVL 0
-#define COMPAT_TCP_KEEPCNT 0
+#define COMPAT_TCP_KEEPIDLE 0
+#define COMPAT_TCP_KEEPINTVL 0
+#define COMPAT_TCP_KEEPCNT 0
#endif /* ! defined (__linux__) && ! defined (__sun__) */
int abort_threshold;
};
-struct tcp_keep_alive_config the_config = {.enabled = false,
- .idle_time = -1,
- .probe_interval = -1,
- .max_probe_count = -1,
- .abort_threshold = -1};
-
-struct tcp_keep_alive_support the_support = {.supported = false,
- .idle_time_supported = false,
- .probe_interval_supported = false,
- .max_probe_count_supported = false,
- .abort_threshold_supported = false};
+struct tcp_keep_alive_config the_config = { .enabled = false,
+ .idle_time = -1,
+ .probe_interval = -1,
+ .max_probe_count = -1,
+ .abort_threshold = -1 };
+
+struct tcp_keep_alive_support the_support = { .supported = false,
+ .idle_time_supported = false,
+ .probe_interval_supported = false,
+ .max_probe_count_supported = false,
+ .abort_threshold_supported = false };
} /* namespace */
/*
*
* Returns -2 on invalid value.
*/
-static
-int get_env_int(const char *env_var,
- const char *value)
+static int get_env_int(const char *env_var, const char *value)
{
int ret;
long tmp;
}
if (endptr == value || *endptr != '\0') {
- ERR("%s is not a valid number", env_var);
- ret = -1;
- goto end;
+ ERR("%s is not a valid number", env_var);
+ ret = -1;
+ goto end;
}
if (tmp < -1) {
ret = -2;
goto end;
}
- if (tmp > INT_MAX){
+ if (tmp > INT_MAX) {
ERR("%s is too big. Maximum value is %d", env_var, INT_MAX);
ret = -2;
goto end;
*/
#ifdef __sun__
-static
-int convert_idle_time(int value)
+static int convert_idle_time(int value)
{
int ret;
unsigned int tmp_ms;
* Minimum 10s, maximum 10 days. Defined by
* https://docs.oracle.com/cd/E23824_01/html/821-1475/tcp-7p.html#REFMAN7tcp-7p
*/
- if ((value < SOLARIS_IDLE_TIME_MIN_S ||
- value > SOLARIS_IDLE_TIME_MAX_S)) {
+ if ((value < SOLARIS_IDLE_TIME_MIN_S || value > SOLARIS_IDLE_TIME_MAX_S)) {
ERR("%s must be comprised between %d and %d inclusively on Solaris",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
- SOLARIS_IDLE_TIME_MIN_S,
- SOLARIS_IDLE_TIME_MAX_S);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
+ SOLARIS_IDLE_TIME_MIN_S,
+ SOLARIS_IDLE_TIME_MAX_S);
ret = -2;
goto end;
}
/* On Solaris idle time is given in milliseconds. */
tmp_ms = ((unsigned int) value) * MSEC_PER_SEC;
- if ((value != 0 && (tmp_ms / ((unsigned int) value)) != MSEC_PER_SEC)
- || tmp_ms > INT_MAX) {
+ if ((value != 0 && (tmp_ms / ((unsigned int) value)) != MSEC_PER_SEC) || tmp_ms > INT_MAX) {
/* Overflow. */
const int max_value = INT_MAX / MSEC_PER_SEC;
ERR("%s is too big: maximum supported value is %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
- max_value);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
+ max_value);
ret = -2;
goto end;
}
#else /* ! defined(__sun__) */
-static
-int convert_idle_time(int value)
+static int convert_idle_time(int value)
{
return value;
}
#endif /* ! defined(__sun__) */
/* Per-platform support of tcp_keep_alive functionality. */
-#if defined (__linux__)
+#if defined(__linux__)
-static
-void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
+static void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
{
support->supported = true;
support->idle_time_supported = true;
#elif defined(__sun__) /* ! defined (__linux__) */
-static
-void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
+static void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
{
support->supported = true;
#ifdef TCP_KEEPALIVE_THRESHOLD
support->idle_time_supported = true;
#else
- support->idle_time_supported = false;;
+ support->idle_time_supported = false;
+ ;
#endif /* TCP_KEEPALIVE_THRESHOLD */
/*
#else /* ! defined(__sun__) && ! defined(__linux__) */
/* Assume nothing is supported on other platforms. */
-static
-void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
+static void tcp_keep_alive_init_support(struct tcp_keep_alive_support *support)
{
support->supported = false;
support->idle_time_supported = false;
* Solaris specific modifier for abort threshold.
* Return -2 on error.
*/
-static
-int convert_abort_threshold(int value)
+static int convert_abort_threshold(int value)
{
int ret;
unsigned int tmp_ms;
*/
if ((value < SOLARIS_ABORT_THRESHOLD_MIN_S || value > SOLARIS_ABORT_THRESHOLD_MAX_S)) {
ERR("%s must be comprised between %d and %d inclusively on Solaris",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
- SOLARIS_ABORT_THRESHOLD_MIN_S,
- SOLARIS_ABORT_THRESHOLD_MAX_S);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
+ SOLARIS_ABORT_THRESHOLD_MIN_S,
+ SOLARIS_ABORT_THRESHOLD_MAX_S);
ret = -2;
goto end;
}
/* Abort threshold is given in milliseconds. */
tmp_ms = ((unsigned int) value) * MSEC_PER_SEC;
- if ((value != 0 && (tmp_ms / ((unsigned int) value)) != MSEC_PER_SEC)
- || tmp_ms > INT_MAX) {
+ if ((value != 0 && (tmp_ms / ((unsigned int) value)) != MSEC_PER_SEC) || tmp_ms > INT_MAX) {
/* Overflow */
const int max_value = INT_MAX / MSEC_PER_SEC;
ERR("%s is too big: maximum supported value is %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
- max_value);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
+ max_value);
ret = -2;
goto end;
}
#else
-static
-int convert_abort_threshold(int value)
+static int convert_abort_threshold(int value)
{
return value;
}
* Retrieve settings from environment variables and warn for settings not
* supported by the platform.
*/
-static
-int tcp_keep_alive_init_config(struct tcp_keep_alive_support *support,
- struct tcp_keep_alive_config *config)
+static int tcp_keep_alive_init_config(struct tcp_keep_alive_support *support,
+ struct tcp_keep_alive_config *config)
{
int ret;
const char *value;
if (!support->supported) {
if (value) {
WARN("Using per-socket TCP keep-alive mechanism is not supported by this platform. Ignoring the %s environment variable.",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ENV);
}
config->enabled = false;
} else if (value) {
}
config->enabled = ret;
}
- DBG("TCP keep-alive mechanism %s", config->enabled ? "enabled": "disabled");
+ DBG("TCP keep-alive mechanism %s", config->enabled ? "enabled" : "disabled");
/* Get value for tcp_keepalive_time in seconds. */
value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV);
if (!support->idle_time_supported && value) {
WARN("Overriding the TCP keep-alive idle time threshold per-socket is not supported by this platform. Ignoring the %s environment variable.",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV);
config->idle_time = -1;
} else if (value) {
int idle_time_platform;
int idle_time_seconds;
- idle_time_seconds = get_env_int(
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
- value);
+ idle_time_seconds =
+ get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV, value);
if (idle_time_seconds < -1) {
ret = 1;
goto error;
config->idle_time = idle_time_platform;
DBG("Overriding %s to %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
- idle_time_seconds);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_IDLE_TIME_ENV,
+ idle_time_seconds);
}
/* Get value for tcp_keepalive_intvl in seconds. */
- value = lttng_secure_getenv(
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV);
+ value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV);
if (!support->probe_interval_supported && value) {
WARN("Overriding the TCP keep-alive probe interval time per-socket is not supported by this platform. Ignoring the %s environment variable.",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV);
config->probe_interval = -1;
} else if (value) {
int probe_interval;
- probe_interval = get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV,
- value);
+ probe_interval =
+ get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV, value);
if (probe_interval < -1) {
ret = 1;
goto error;
config->probe_interval = probe_interval;
DBG("Overriding %s to %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV,
- config->probe_interval);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV,
+ config->probe_interval);
}
/* Get value for tcp_keepalive_probes. */
value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV);
if (!support->max_probe_count_supported && value) {
WARN("Overriding the TCP keep-alive maximum probe count per-socket is not supported by this platform. Ignoring the %s environment variable.",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV);
config->max_probe_count = -1;
} else if (value) {
int max_probe_count;
- max_probe_count = get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV,
- value);
+ max_probe_count =
+ get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV, value);
if (max_probe_count < -1) {
ret = 1;
goto error;
config->max_probe_count = max_probe_count;
DBG("Overriding %s to %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV,
- config->max_probe_count);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV,
+ config->max_probe_count);
}
/* Get value for tcp_keepalive_abort_interval. */
- value = lttng_secure_getenv(
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV);
+ value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV);
if (!support->abort_threshold_supported && value) {
WARN("Overriding the TCP keep-alive abort threshold per-socket is not supported by this platform. Ignoring the %s environment variable.",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV);
config->abort_threshold = -1;
} else if (value) {
int abort_threshold_platform;
int abort_threshold_seconds;
- abort_threshold_seconds = get_env_int(
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV,
- value);
+ abort_threshold_seconds =
+ get_env_int(DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_MAX_PROBE_COUNT_ENV, value);
if (abort_threshold_seconds < -1) {
ret = 1;
goto error;
}
- abort_threshold_platform = convert_abort_threshold(
- abort_threshold_seconds);
+ abort_threshold_platform = convert_abort_threshold(abort_threshold_seconds);
if (abort_threshold_platform < -1) {
ret = 1;
goto error;
config->abort_threshold = abort_threshold_platform;
DBG("Overriding %s to %d",
- DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
- config->abort_threshold);
+ DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV,
+ config->abort_threshold);
}
ret = 0;
}
/* Initialize the TCP keep-alive configuration. */
-__attribute__((constructor)) static
-void tcp_keep_alive_init(void)
+__attribute__((constructor)) static void tcp_keep_alive_init(void)
{
tcp_keep_alive_init_support(&the_support);
(void) tcp_keep_alive_init_config(&the_support, &the_config);
}
DBG("TCP keep-alive enabled for socket %d", socket_fd);
- ret = setsockopt(socket_fd, SOL_SOCKET, SO_KEEPALIVE, &val,
- sizeof(val));
+ ret = setsockopt(socket_fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
if (ret < 0) {
PERROR("setsockopt so_keepalive");
goto end;
/* TCP keep-alive idle time */
if (the_support.idle_time_supported && the_config.idle_time > 0) {
DBG("TCP keep-alive keep idle: %d enabled for socket %d",
- the_config.idle_time, socket_fd);
- ret = setsockopt(socket_fd, COMPAT_TCP_LEVEL,
- COMPAT_TCP_KEEPIDLE, &the_config.idle_time,
- sizeof(the_config.idle_time));
+ the_config.idle_time,
+ socket_fd);
+ ret = setsockopt(socket_fd,
+ COMPAT_TCP_LEVEL,
+ COMPAT_TCP_KEEPIDLE,
+ &the_config.idle_time,
+ sizeof(the_config.idle_time));
if (ret < 0) {
PERROR("setsockopt TCP_KEEPIDLE");
goto end;
}
}
/* TCP keep-alive probe interval */
- if (the_support.probe_interval_supported &&
- the_config.probe_interval > 0) {
+ if (the_support.probe_interval_supported && the_config.probe_interval > 0) {
DBG("TCP keep-alive probe_interval: %d enabled for socket %d",
- the_config.probe_interval, socket_fd);
- ret = setsockopt(socket_fd, COMPAT_TCP_LEVEL,
- COMPAT_TCP_KEEPINTVL,
- &the_config.probe_interval,
- sizeof(the_config.probe_interval));
+ the_config.probe_interval,
+ socket_fd);
+ ret = setsockopt(socket_fd,
+ COMPAT_TCP_LEVEL,
+ COMPAT_TCP_KEEPINTVL,
+ &the_config.probe_interval,
+ sizeof(the_config.probe_interval));
if (ret < 0) {
PERROR("setsockopt TCP_KEEPINTVL");
goto end;
}
/* TCP keep-alive max probe count */
- if (the_support.max_probe_count_supported &&
- the_config.max_probe_count > 0) {
+ if (the_support.max_probe_count_supported && the_config.max_probe_count > 0) {
DBG("TCP keep-alive max_probe: %d enabled for socket %d",
- the_config.max_probe_count, socket_fd);
- ret = setsockopt(socket_fd, COMPAT_TCP_LEVEL,
- COMPAT_TCP_KEEPCNT, &the_config.max_probe_count,
- sizeof(the_config.max_probe_count));
+ the_config.max_probe_count,
+ socket_fd);
+ ret = setsockopt(socket_fd,
+ COMPAT_TCP_LEVEL,
+ COMPAT_TCP_KEEPCNT,
+ &the_config.max_probe_count,
+ sizeof(the_config.max_probe_count));
if (ret < 0) {
PERROR("setsockopt TCP_KEEPCNT");
goto end;
}
/* TCP keep-alive abort threshold */
- if (the_support.abort_threshold_supported &&
- the_config.abort_threshold > 0) {
+ if (the_support.abort_threshold_supported && the_config.abort_threshold > 0) {
DBG("TCP keep-alive abort threshold: %d enabled for socket %d",
- the_config.abort_threshold, socket_fd);
- ret = setsockopt(socket_fd, COMPAT_TCP_LEVEL,
- COMPAT_TCP_ABORT_THRESHOLD,
- &the_config.abort_threshold,
- sizeof(the_config.max_probe_count));
+ the_config.abort_threshold,
+ socket_fd);
+ ret = setsockopt(socket_fd,
+ COMPAT_TCP_LEVEL,
+ COMPAT_TCP_ABORT_THRESHOLD,
+ &the_config.abort_threshold,
+ sizeof(the_config.max_probe_count));
if (ret < 0) {
PERROR("setsockopt TCP_KEEPALIVE_ABORT_THRESHOLD");
goto end;
int relayd_init_thread_quit_pipe(void)
{
return fd_tracker_util_pipe_open_cloexec(
- the_fd_tracker, "Thread quit pipe", thread_quit_pipe);
+ the_fd_tracker, "Thread quit pipe", thread_quit_pipe);
}
/*
void relayd_close_thread_quit_pipe(void)
{
if (thread_quit_pipe[0] != -1) {
- (void) fd_tracker_util_pipe_close(
- the_fd_tracker, thread_quit_pipe);
+ (void) fd_tracker_util_pipe_close(the_fd_tracker, thread_quit_pipe);
}
}
/*
* Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
*/
-int create_named_thread_poll_set(struct lttng_poll_event *events,
- int size, const char *name)
+int create_named_thread_poll_set(struct lttng_poll_event *events, int size, const char *name)
{
if (events == NULL || size == 0) {
return -1;
}
- const auto create_ret = fd_tracker_util_poll_create(the_fd_tracker,
- name, events, 1, LTTNG_CLOEXEC);
+ const auto create_ret =
+ fd_tracker_util_poll_create(the_fd_tracker, name, events, 1, LTTNG_CLOEXEC);
if (create_ret) {
PERROR("Failed to create \"%s\" poll file descriptor", name);
return -1;
*/
#define _LGPL_SOURCE
+#include "tracefile-array.hpp"
+
#include <common/common.hpp>
-#include <common/utils.hpp>
#include <common/defaults.hpp>
-
-#include "tracefile-array.hpp"
+#include <common/utils.hpp>
struct tracefile_array *tracefile_array_create(size_t count)
{
tfa->file_tail = 0;
}
-void tracefile_array_file_rotate(struct tracefile_array *tfa,
- enum tracefile_rotate_type type)
+void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type)
{
uint64_t *headp, *tailp;
}
}
-void tracefile_array_commit_seq(struct tracefile_array *tfa,
- uint64_t new_seq_head)
+void tracefile_array_commit_seq(struct tracefile_array *tfa, uint64_t new_seq_head)
{
uint64_t *headp, *tailp;
return tfa->seq_tail;
}
-bool tracefile_array_seq_in_file(struct tracefile_array *tfa,
- uint64_t file_index, uint64_t seq)
+bool tracefile_array_seq_in_file(struct tracefile_array *tfa, uint64_t file_index, uint64_t seq)
{
if (!tfa->count) {
/*
if (seq == -1ULL) {
return false;
}
- if (seq >= tfa->tf[file_index].seq_tail
- && seq <= tfa->tf[file_index].seq_head) {
+ if (seq >= tfa->tf[file_index].seq_tail && seq <= tfa->tf[file_index].seq_head) {
return true;
} else {
return false;
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "lttng-relayd.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/defaults.hpp>
-#include <common/utils.hpp>
#include <common/path.hpp>
+#include <common/utils.hpp>
-#include "lttng-relayd.hpp"
-#include "utils.hpp"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
static char *create_output_path_auto(const char *path_name)
{
Please specify an output path using -o, --output PATH");
goto exit;
}
- ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME
- "/%s", default_path, path_name);
+ ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME "/%s", default_path, path_name);
if (ret < 0) {
PERROR("asprintf trace dir name");
goto exit;
*/
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <urcu/rculist.h>
-
-#include "lttng-relayd.hpp"
#include "ctf-trace.hpp"
+#include "lttng-relayd.hpp"
#include "session.hpp"
+#include "stream.hpp"
#include "viewer-session.hpp"
#include "viewer-stream.hpp"
-#include "stream.hpp"
+
+#include <common/common.hpp>
+
+#include <urcu/rculist.h>
struct relay_viewer_session *viewer_session_create(void)
{
}
int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
- struct lttng_trace_chunk *relay_session_trace_chunk)
+ struct lttng_trace_chunk *relay_session_trace_chunk)
{
int ret = 0;
struct lttng_trace_chunk *viewer_chunk;
}
/* The existence of session must be guaranteed by the caller. */
-enum lttng_viewer_attach_return_code viewer_session_attach(
- struct relay_viewer_session *vsession,
- struct relay_session *session)
+enum lttng_viewer_attach_return_code viewer_session_attach(struct relay_viewer_session *vsession,
+ struct relay_session *session)
{
- enum lttng_viewer_attach_return_code viewer_attach_status =
- LTTNG_VIEWER_ATTACH_OK;
+ enum lttng_viewer_attach_return_code viewer_attach_status = LTTNG_VIEWER_ATTACH_OK;
ASSERT_LOCKED(session->lock);
session->viewer_attached = true;
- ret = viewer_session_set_trace_chunk_copy(vsession,
- session->current_trace_chunk);
+ ret = viewer_session_set_trace_chunk_copy(vsession, session->current_trace_chunk);
if (ret) {
/*
* The live protocol does not define a generic error
* failure as if the session didn't exist anymore.
*/
DBG("Failed to create a viewer trace chunk from the current trace chunk of session \"%s\", returning LTTNG_VIEWER_ATTACH_UNK",
- session->session_name);
+ session->session_name);
viewer_attach_status = LTTNG_VIEWER_ATTACH_UNK;
}
}
if (viewer_attach_status == LTTNG_VIEWER_ATTACH_OK) {
pthread_mutex_lock(&vsession->session_list_lock);
/* Ownership is transfered to the list. */
- cds_list_add_rcu(&session->viewer_session_node,
- &vsession->session_list);
+ cds_list_add_rcu(&session->viewer_session_node, &vsession->session_list);
pthread_mutex_unlock(&vsession->session_list_lock);
} else {
/* Put our local ref. */
/* The existence of session must be guaranteed by the caller. */
static int viewer_session_detach(struct relay_viewer_session *vsession,
- struct relay_session *session)
+ struct relay_session *session)
{
int ret = 0;
* Release ownership of all the streams of one session and detach the viewer.
*/
void viewer_session_close_one_session(struct relay_viewer_session *vsession,
- struct relay_session *session)
+ struct relay_session *session)
{
struct lttng_ht_iter iter;
struct relay_viewer_stream *vstream;
* TODO: improvement: create more efficient list of
* vstream per session.
*/
- cds_lfht_for_each_entry(viewer_streams_ht->ht, &iter.iter,
- vstream, stream_n.node) {
+ cds_lfht_for_each_entry (viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
if (!viewer_stream_get(vstream)) {
continue;
}
struct relay_session *session;
rcu_read_lock();
- cds_list_for_each_entry_rcu(session,
- &vsession->session_list, viewer_session_node) {
+ cds_list_for_each_entry_rcu(session, &vsession->session_list, viewer_session_node)
+ {
viewer_session_close_one_session(vsession, session);
}
rcu_read_unlock();
* Check if a connection is attached to a session.
* Return 1 if attached, 0 if not attached, a negative value on error.
*/
-int viewer_session_is_attached(struct relay_viewer_session *vsession,
- struct relay_session *session)
+int viewer_session_is_attached(struct relay_viewer_session *vsession, struct relay_session *session)
{
struct relay_session *iter;
int found = 0;
goto end;
}
rcu_read_lock();
- cds_list_for_each_entry_rcu(iter,
- &vsession->session_list,
- viewer_session_node) {
+ cds_list_for_each_entry_rcu(iter, &vsession->session_list, viewer_session_node)
+ {
if (session == iter) {
found = 1;
goto end_rcu_unlock;
*/
#define _LGPL_SOURCE
+#include "lttng-relayd.hpp"
+#include "viewer-stream.hpp"
+
#include <common/common.hpp>
-#include <common/index/index.hpp>
#include <common/compat/string.hpp>
+#include <common/index/index.hpp>
#include <common/utils.hpp>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <algorithm>
-#include "lttng-relayd.hpp"
-#include "viewer-stream.hpp"
+#include <algorithm>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
static void viewer_stream_release_composite_objects(struct relay_viewer_stream *vstream)
{
/* Relay stream's lock must be held by the caller. */
struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
- struct lttng_trace_chunk *trace_chunk,
- enum lttng_viewer_seek seek_t)
+ struct lttng_trace_chunk *trace_chunk,
+ enum lttng_viewer_seek seek_t)
{
struct relay_viewer_stream *vstream = NULL;
}
if (trace_chunk) {
- const bool acquired_reference = lttng_trace_chunk_get(
- trace_chunk);
+ const bool acquired_reference = lttng_trace_chunk_get(trace_chunk);
LTTNG_ASSERT(acquired_reference);
}
PERROR("relay viewer path_name alloc");
goto error;
}
- vstream->channel_name = lttng_strndup(stream->channel_name,
- LTTNG_VIEWER_NAME_MAX);
+ vstream->channel_name = lttng_strndup(stream->channel_name, LTTNG_VIEWER_NAME_MAX);
if (vstream->channel_name == NULL) {
PERROR("relay viewer channel_name alloc");
goto error;
*/
seq_tail = 0;
}
- vstream->current_tracefile_id =
- tracefile_array_get_file_index_tail(stream->tfa);
+ vstream->current_tracefile_id = tracefile_array_get_file_index_tail(stream->tfa);
vstream->index_sent_seqcount = seq_tail;
break;
}
* We don't need to check the head position for -1ULL since the
* increment will set it to 0.
*/
- vstream->index_sent_seqcount =
- tracefile_array_get_seq_head(stream->tfa) + 1;
+ vstream->index_sent_seqcount = tracefile_array_get_seq_head(stream->tfa) + 1;
break;
default:
goto error;
enum lttng_trace_chunk_status chunk_status;
chunk_status = lttng_index_file_create_from_trace_chunk_read_only(
- vstream->stream_file.trace_chunk,
- stream->path_name,
- stream->channel_name, stream->tracefile_size,
- vstream->current_tracefile_id,
- lttng_to_index_major(connection_major,
- connection_minor),
- lttng_to_index_minor(connection_major,
- connection_minor),
- true, &vstream->index_file);
+ vstream->stream_file.trace_chunk,
+ stream->path_name,
+ stream->channel_name,
+ stream->tracefile_size,
+ vstream->current_tracefile_id,
+ lttng_to_index_major(connection_major, connection_minor),
+ lttng_to_index_minor(connection_major, connection_minor),
+ true,
+ &vstream->index_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) {
vstream->index_file = NULL;
enum lttng_trace_chunk_status status;
ret = utils_stream_file_path(stream->path_name,
- stream->channel_name, stream->tracefile_size,
- vstream->current_tracefile_id, NULL, file_path,
- sizeof(file_path));
+ stream->channel_name,
+ stream->tracefile_size,
+ vstream->current_tracefile_id,
+ NULL,
+ file_path,
+ sizeof(file_path));
if (ret < 0) {
goto error;
}
- status = lttng_trace_chunk_open_fs_handle(
- vstream->stream_file.trace_chunk, file_path,
- O_RDONLY, 0, &vstream->stream_file.handle,
- true);
+ status = lttng_trace_chunk_open_fs_handle(vstream->stream_file.trace_chunk,
+ file_path,
+ O_RDONLY,
+ 0,
+ &vstream->stream_file.handle,
+ true);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
if (seek_t == LTTNG_VIEWER_SEEK_LAST && vstream->index_file) {
off_t lseek_ret;
- lseek_ret = fs_handle_seek(
- vstream->index_file->file, 0, SEEK_END);
+ lseek_ret = fs_handle_seek(vstream->index_file->file, 0, SEEK_END);
if (lseek_ret < 0) {
goto error;
}
}
if (stream->is_metadata) {
- rcu_assign_pointer(stream->trace->viewer_metadata_stream,
- vstream);
+ rcu_assign_pointer(stream->trace->viewer_metadata_stream, vstream);
}
vstream->last_seen_rotation_count = stream->completed_rotation_count;
static void viewer_stream_release(struct urcu_ref *ref)
{
- struct relay_viewer_stream *vstream = caa_container_of(ref,
- struct relay_viewer_stream, ref);
+ struct relay_viewer_stream *vstream =
+ caa_container_of(ref, struct relay_viewer_stream, ref);
if (vstream->stream->is_metadata) {
rcu_assign_pointer(vstream->stream->trace->viewer_metadata_stream, NULL);
vstream->index_file = NULL;
}
if (vstream->stream_file.handle) {
- fs_handle_close(vstream->stream_file.handle);
+ fs_handle_close(vstream->stream_file.handle);
vstream->stream_file.handle = NULL;
}
}
* index_sent_seqcount is already further than the tracefile
* array tail position, keep its current position.
*/
- vstream->index_sent_seqcount =
- std::max(seq_tail, vstream->index_sent_seqcount);
+ vstream->index_sent_seqcount = std::max(seq_tail, vstream->index_sent_seqcount);
}
/*
const struct relay_stream *stream = vstream->stream;
/* Detect the last tracefile to open. */
- if (stream->index_received_seqcount
- == vstream->index_sent_seqcount
- && stream->trace->session->connection_closed) {
+ if (stream->index_received_seqcount == vstream->index_sent_seqcount &&
+ stream->trace->session->connection_closed) {
ret = 1;
goto end;
}
/*
* Try to move to the next file.
*/
- new_id = (vstream->current_tracefile_id + 1)
- % stream->tracefile_count;
- if (tracefile_array_seq_in_file(stream->tfa, new_id,
- vstream->index_sent_seqcount)) {
+ new_id = (vstream->current_tracefile_id + 1) % stream->tracefile_count;
+ if (tracefile_array_seq_in_file(stream->tfa, new_id, vstream->index_sent_seqcount)) {
vstream->current_tracefile_id = new_id;
} else {
uint64_t seq_tail = tracefile_array_get_seq_tail(stream->tfa);
/*
* We need to resync because we lag behind tail.
*/
- vstream->current_tracefile_id =
- tracefile_array_get_file_index_tail(stream->tfa);
+ vstream->current_tracefile_id = tracefile_array_get_file_index_tail(stream->tfa);
vstream->index_sent_seqcount = seq_tail;
}
viewer_stream_close_files(vstream);
}
rcu_read_lock();
- cds_lfht_for_each_entry(viewer_streams_ht->ht, &iter.iter, vstream,
- stream_n.node) {
+ cds_lfht_for_each_entry (viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
if (!viewer_stream_get(vstream)) {
continue;
}
- DBG("vstream %p refcount %ld stream %" PRIu64 " trace %" PRIu64
- " session %" PRIu64,
- vstream,
- vstream->ref.refcount,
- vstream->stream->stream_handle,
- vstream->stream->trace->id,
- vstream->stream->trace->session->id);
+ DBG("vstream %p refcount %ld stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
+ vstream,
+ vstream->ref.refcount,
+ vstream->stream->stream_handle,
+ vstream->stream->trace->id,
+ vstream->stream->trace->session->id);
viewer_stream_put(vstream);
}
rcu_read_unlock();
#include "notification-thread-internal.hpp"
#include "session.hpp"
#include "thread.hpp"
+
#include <common/dynamic-array.hpp>
#include <common/macros.hpp>
#include <common/optional.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
#include <lttng/action/list.h>
#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/lttng-error.h>
#include <lttng/trigger/trigger-internal.hpp>
+
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
#include <urcu/list.h>
-#define THREAD_NAME "Action Executor"
+#define THREAD_NAME "Action Executor"
#define MAX_QUEUED_WORK_COUNT 8192
struct action_executor {
};
} /* namespace */
-
/*
* Only return non-zero on a fatal error that should shut down the action
* executor.
*/
typedef int (*action_executor_handler)(struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *item);
+ const struct action_work_item *,
+ struct action_work_subitem *item);
static int action_executor_notify_handler(struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
-static int action_executor_start_session_handler(
- struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
-static int action_executor_stop_session_handler(
- struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
-static int action_executor_rotate_session_handler(
- struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
-static int action_executor_snapshot_session_handler(
- struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
+ const struct action_work_item *,
+ struct action_work_subitem *);
+static int action_executor_start_session_handler(struct action_executor *executor,
+ const struct action_work_item *,
+ struct action_work_subitem *);
+static int action_executor_stop_session_handler(struct action_executor *executor,
+ const struct action_work_item *,
+ struct action_work_subitem *);
+static int action_executor_rotate_session_handler(struct action_executor *executor,
+ const struct action_work_item *,
+ struct action_work_subitem *);
+static int action_executor_snapshot_session_handler(struct action_executor *executor,
+ const struct action_work_item *,
+ struct action_work_subitem *);
static int action_executor_list_handler(struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
+ const struct action_work_item *,
+ struct action_work_subitem *);
static int action_executor_generic_handler(struct action_executor *executor,
- const struct action_work_item *,
- struct action_work_subitem *);
+ const struct action_work_item *,
+ struct action_work_subitem *);
static const action_executor_handler action_executors[] = {
- action_executor_notify_handler,
- action_executor_start_session_handler,
- action_executor_stop_session_handler,
- action_executor_rotate_session_handler,
- action_executor_snapshot_session_handler,
- action_executor_list_handler,
+ action_executor_notify_handler, action_executor_start_session_handler,
+ action_executor_stop_session_handler, action_executor_rotate_session_handler,
+ action_executor_snapshot_session_handler, action_executor_list_handler,
};
/* Forward declaration */
static int add_action_to_subitem_array(struct lttng_action *action,
- struct lttng_dynamic_array *subitems);
+ struct lttng_dynamic_array *subitems);
static int populate_subitem_array_from_trigger(struct lttng_trigger *trigger,
- struct lttng_dynamic_array *subitems);
+ struct lttng_dynamic_array *subitems);
static void action_work_subitem_destructor(void *element)
{
/* Check if this trigger allowed to interect with a given session. */
static bool is_trigger_allowed_for_session(const struct lttng_trigger *trigger,
- struct ltt_session *session)
+ struct ltt_session *session)
{
bool is_allowed = false;
const struct lttng_credentials session_creds = {
.gid = LTTNG_OPTIONAL_INIT_VALUE(session->gid),
};
/* Can never be NULL. */
- const struct lttng_credentials *trigger_creds =
- lttng_trigger_get_credentials(trigger);
+ const struct lttng_credentials *trigger_creds = lttng_trigger_get_credentials(trigger);
is_allowed = (lttng_credentials_is_equal_uid(trigger_creds, &session_creds)) ||
- (lttng_credentials_get_uid(trigger_creds) == 0);
+ (lttng_credentials_get_uid(trigger_creds) == 0);
if (!is_allowed) {
WARN("Trigger is not allowed to interact with session `%s`: session uid = %ld, session gid = %ld, trigger uid = %ld",
- session->name,
- (long int) session->uid,
- (long int) session->gid,
- (long int) lttng_credentials_get_uid(trigger_creds));
+ session->name,
+ (long int) session->uid,
+ (long int) session->gid,
+ (long int) lttng_credentials_get_uid(trigger_creds));
}
return is_allowed;
return trigger_name;
}
-static int client_handle_transmission_status(
- struct notification_client *client,
- enum client_transmission_status status,
- void *user_data)
+static int client_handle_transmission_status(struct notification_client *client,
+ enum client_transmission_status status,
+ void *user_data)
{
int ret = 0;
struct action_executor *executor = (action_executor *) user_data;
switch (status) {
case CLIENT_TRANSMISSION_STATUS_COMPLETE:
DBG("Successfully sent full notification to client, client_id = %" PRIu64,
- client->id);
+ client->id);
/*
* There is no need to wake the (e)poll thread. If it was waiting for
* "out" events on the client's socket, it will see that no payload
break;
case CLIENT_TRANSMISSION_STATUS_QUEUED:
DBG("Queued notification in client outgoing buffer, client_id = %" PRIu64,
- client->id);
+ client->id);
break;
case CLIENT_TRANSMISSION_STATUS_FAIL:
DBG("Communication error occurred while sending notification to client, client_id = %" PRIu64,
- client->id);
+ client->id);
break;
default:
ERR("Fatal error encoutered while sending notification to client, client_id = %" PRIu64,
- client->id);
+ client->id);
ret = -1;
goto end;
}
/* Safe to read client's id without locking as it is immutable. */
ret = notification_thread_client_communication_update(
- executor->notification_thread_handle, client->id,
- status);
+ executor->notification_thread_handle, client->id, status);
end:
return ret;
}
static int action_executor_notify_handler(struct action_executor *executor,
- const struct action_work_item *work_item,
- struct action_work_subitem *item __attribute__((unused)))
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item __attribute__((unused)))
{
- return notification_client_list_send_evaluation(work_item->client_list,
- work_item->trigger,
- work_item->evaluation,
- work_item->object_creds.is_set ?
- &(work_item->object_creds.value) :
- NULL,
- client_handle_transmission_status, executor);
+ return notification_client_list_send_evaluation(
+ work_item->client_list,
+ work_item->trigger,
+ work_item->evaluation,
+ work_item->object_creds.is_set ? &(work_item->object_creds.value) : NULL,
+ client_handle_transmission_status,
+ executor);
}
-static int action_executor_start_session_handler(
- struct action_executor *executor __attribute__((unused)),
- const struct action_work_item *work_item,
- struct action_work_subitem *item)
+static int action_executor_start_session_handler(struct action_executor *executor
+ __attribute__((unused)),
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item)
{
int ret = 0;
const char *session_name;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
- action_status = lttng_action_start_session_get_session_name(
- action, &session_name);
+ action_status = lttng_action_start_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
- ERR("Failed to get session name from `%s` action",
- get_action_name(action));
+ ERR("Failed to get session name from `%s` action", get_action_name(action));
ret = -1;
goto end;
}
*/
if (!item->context.session_id.is_set) {
DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto end;
}
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto error_unlock_list;
}
session_lock(session);
if (session->destroyed) {
- DBG("Session `%s` with id = %" PRIu64 " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
- session->name, session->id,
- get_action_name(action),
- get_trigger_name(work_item->trigger));
+ DBG("Session `%s` with id = %" PRIu64
+ " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
+ session->name,
+ session->id,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
goto error_unlock_session;
}
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully started session `%s` on behalf of trigger `%s`",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
case LTTNG_ERR_TRACE_ALREADY_STARTED:
DBG("Attempted to start session `%s` on behalf of trigger `%s` but it was already started",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
default:
WARN("Failed to start session `%s` on behalf of trigger `%s`: %s",
- session_name, get_trigger_name(work_item->trigger),
- lttng_strerror(-cmd_ret));
+ session_name,
+ get_trigger_name(work_item->trigger),
+ lttng_strerror(-cmd_ret));
lttng_action_increase_execution_failure_count(action);
break;
}
return ret;
}
-static int action_executor_stop_session_handler(
- struct action_executor *executor __attribute__((unused)),
- const struct action_work_item *work_item,
- struct action_work_subitem *item)
+static int action_executor_stop_session_handler(struct action_executor *executor
+ __attribute__((unused)),
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item)
{
int ret = 0;
const char *session_name;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
- action_status = lttng_action_stop_session_get_session_name(
- action, &session_name);
+ action_status = lttng_action_stop_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
- ERR("Failed to get session name from `%s` action",
- get_action_name(action));
+ ERR("Failed to get session name from `%s` action", get_action_name(action));
ret = -1;
goto end;
}
*/
if (!item->context.session_id.is_set) {
DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto end;
}
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto error_unlock_list;
}
session_lock(session);
if (session->destroyed) {
- DBG("Session `%s` with id = %" PRIu64 " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
- session->name, session->id,
- get_action_name(action),
- get_trigger_name(work_item->trigger));
+ DBG("Session `%s` with id = %" PRIu64
+ " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
+ session->name,
+ session->id,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
goto error_unlock_session;
}
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully stopped session `%s` on behalf of trigger `%s`",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
case LTTNG_ERR_TRACE_ALREADY_STOPPED:
DBG("Attempted to stop session `%s` on behalf of trigger `%s` but it was already stopped",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
default:
WARN("Failed to stop session `%s` on behalf of trigger `%s`: %s",
- session_name, get_trigger_name(work_item->trigger),
- lttng_strerror(-cmd_ret));
+ session_name,
+ get_trigger_name(work_item->trigger),
+ lttng_strerror(-cmd_ret));
lttng_action_increase_execution_failure_count(action);
break;
}
return ret;
}
-static int action_executor_rotate_session_handler(
- struct action_executor *executor __attribute__((unused)),
- const struct action_work_item *work_item,
- struct action_work_subitem *item)
+static int action_executor_rotate_session_handler(struct action_executor *executor
+ __attribute__((unused)),
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item)
{
int ret = 0;
const char *session_name;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
- action_status = lttng_action_rotate_session_get_session_name(
- action, &session_name);
+ action_status = lttng_action_rotate_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
- ERR("Failed to get session name from `%s` action",
- get_action_name(action));
+ ERR("Failed to get session name from `%s` action", get_action_name(action));
ret = -1;
goto end;
}
*/
if (!item->context.session_id.is_set) {
DBG("Session `%s` was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto end;
}
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto error_unlock_list;
}
session_lock(session);
if (session->destroyed) {
- DBG("Session `%s` with id = %" PRIu64 " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
- session->name, session->id,
- get_action_name(action),
- get_trigger_name(work_item->trigger));
+ DBG("Session `%s` with id = %" PRIu64
+ " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
+ session->name,
+ session->id,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
goto error_unlock_session;
}
goto error_unlock_session;
}
- cmd_ret = (lttng_error_code) cmd_rotate_session(session, NULL, false,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ cmd_ret = (lttng_error_code) cmd_rotate_session(
+ session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully started rotation of session `%s` on behalf of trigger `%s`",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
case LTTNG_ERR_ROTATION_PENDING:
DBG("Attempted to start a rotation of session `%s` on behalf of trigger `%s` but a rotation is already ongoing",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
break;
case LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP:
case LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR:
DBG("Attempted to start a rotation of session `%s` on behalf of trigger `%s` but a rotation has already been completed since the last stop or clear",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
default:
WARN("Failed to start a rotation of session `%s` on behalf of trigger `%s`: %s",
- session_name, get_trigger_name(work_item->trigger),
- lttng_strerror(-cmd_ret));
+ session_name,
+ get_trigger_name(work_item->trigger),
+ lttng_strerror(-cmd_ret));
lttng_action_increase_execution_failure_count(action);
break;
}
return ret;
}
-static int action_executor_snapshot_session_handler(
- struct action_executor *executor __attribute__((unused)),
- const struct action_work_item *work_item,
- struct action_work_subitem *item)
+static int action_executor_snapshot_session_handler(struct action_executor *executor
+ __attribute__((unused)),
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item)
{
int ret = 0;
const char *session_name;
enum lttng_action_status action_status;
struct ltt_session *session;
lttng_snapshot_output default_snapshot_output;
- const struct lttng_snapshot_output *snapshot_output =
- &default_snapshot_output;
+ const struct lttng_snapshot_output *snapshot_output = &default_snapshot_output;
enum lttng_error_code cmd_ret;
struct lttng_action *action = item->action;
*/
if (!item->context.session_id.is_set) {
DBG("Session was not present at the moment the work item was enqueued for `%s` action of trigger `%s`",
- get_action_name(action),
- get_trigger_name(work_item->trigger));
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto end;
}
- action_status = lttng_action_snapshot_session_get_session_name(
- action, &session_name);
+ action_status = lttng_action_snapshot_session_get_session_name(action, &session_name);
if (action_status != LTTNG_ACTION_STATUS_OK) {
- ERR("Failed to get session name from `%s` action",
- get_action_name(action));
+ ERR("Failed to get session name from `%s` action", get_action_name(action));
ret = -1;
goto end;
}
- action_status = lttng_action_snapshot_session_get_output(
- action, &snapshot_output);
- if (action_status != LTTNG_ACTION_STATUS_OK &&
- action_status != LTTNG_ACTION_STATUS_UNSET) {
- ERR("Failed to get output from `%s` action",
- get_action_name(action));
+ action_status = lttng_action_snapshot_session_get_output(action, &snapshot_output);
+ if (action_status != LTTNG_ACTION_STATUS_OK && action_status != LTTNG_ACTION_STATUS_UNSET) {
+ ERR("Failed to get output from `%s` action", get_action_name(action));
ret = -1;
goto end;
}
session = session_find_by_id(LTTNG_OPTIONAL_GET(item->context.session_id));
if (!session) {
DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`",
- session_name, get_action_name(action),
- get_trigger_name(work_item->trigger));
+ session_name,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
lttng_action_increase_execution_failure_count(action);
goto error_unlock_list;
}
session_lock(session);
if (session->destroyed) {
- DBG("Session `%s` with id = %" PRIu64 " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
- session->name, session->id,
- get_action_name(action),
- get_trigger_name(work_item->trigger));
+ DBG("Session `%s` with id = %" PRIu64
+ " is flagged as destroyed. Skipping: action = `%s`, trigger = `%s`",
+ session->name,
+ session->id,
+ get_action_name(action),
+ get_trigger_name(work_item->trigger));
goto error_unlock_session;
}
switch (cmd_ret) {
case LTTNG_OK:
DBG("Successfully recorded snapshot of session `%s` on behalf of trigger `%s`",
- session_name, get_trigger_name(work_item->trigger));
+ session_name,
+ get_trigger_name(work_item->trigger));
break;
default:
WARN("Failed to record snapshot of session `%s` on behalf of trigger `%s`: %s",
- session_name, get_trigger_name(work_item->trigger),
- lttng_strerror(-cmd_ret));
+ session_name,
+ get_trigger_name(work_item->trigger),
+ lttng_strerror(-cmd_ret));
lttng_action_increase_execution_failure_count(action);
break;
}
return ret;
}
-static int action_executor_list_handler(
- struct action_executor *executor __attribute__((unused)),
- const struct action_work_item *work_item __attribute__((unused)),
- struct action_work_subitem *item __attribute__((unused)))
+static int action_executor_list_handler(struct action_executor *executor __attribute__((unused)),
+ const struct action_work_item *work_item
+ __attribute__((unused)),
+ struct action_work_subitem *item __attribute__((unused)))
{
ERR("Execution of a list action by the action executor should never occur");
abort();
}
static int action_executor_generic_handler(struct action_executor *executor,
- const struct action_work_item *work_item,
- struct action_work_subitem *item)
+ const struct action_work_item *work_item,
+ struct action_work_subitem *item)
{
int ret;
struct lttng_action *action = item->action;
lttng_action_increase_execution_request_count(action);
if (!lttng_action_should_execute(action)) {
DBG("Policy prevented execution of action `%s` of trigger `%s` action work item %" PRIu64,
- get_action_name(action),
- get_trigger_name(work_item->trigger),
- work_item->id);
+ get_action_name(action),
+ get_trigger_name(work_item->trigger),
+ work_item->id);
ret = 0;
goto end;
}
lttng_action_increase_execution_count(action);
DBG("Executing action `%s` of trigger `%s` action work item %" PRIu64,
- get_action_name(action),
- get_trigger_name(work_item->trigger),
- work_item->id);
+ get_action_name(action),
+ get_trigger_name(work_item->trigger),
+ work_item->id);
ret = action_executors[action_type](executor, work_item, item);
end:
return ret;
}
static int action_work_item_execute(struct action_executor *executor,
- struct action_work_item *work_item)
+ struct action_work_item *work_item)
{
int ret;
size_t count, i;
DBG("Starting execution of action work item %" PRIu64 " of trigger `%s`",
- work_item->id, get_trigger_name(work_item->trigger));
+ work_item->id,
+ get_trigger_name(work_item->trigger));
count = lttng_dynamic_array_get_count(&work_item->subitems);
for (i = 0; i < count; i++) {
struct action_work_subitem *item;
- item = (action_work_subitem *) lttng_dynamic_array_get_element(&work_item->subitems, i);
- ret = action_executor_generic_handler(
- executor, work_item, item);
+ item = (action_work_subitem *) lttng_dynamic_array_get_element(&work_item->subitems,
+ i);
+ ret = action_executor_generic_handler(executor, work_item, item);
if (ret) {
goto end;
}
}
end:
DBG("Completed execution of action work item %" PRIu64 " of trigger `%s`",
- work_item->id, get_trigger_name(work_item->trigger));
+ work_item->id,
+ get_trigger_name(work_item->trigger));
return ret;
}
LTTNG_ASSERT(executor);
- health_register(the_health_sessiond,
- HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR);
+ health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR);
rcu_register_thread();
rcu_thread_online();
if (executor->work.pending_count == 0) {
health_poll_entry();
DBG("No work items enqueued, entering wait");
- pthread_cond_wait(&executor->work.cond,
- &executor->work.lock);
+ pthread_cond_wait(&executor->work.cond, &executor->work.lock);
DBG("Woke-up from wait");
health_poll_exit();
continue;
}
/* Pop item from front of the list with work lock held. */
- work_item = cds_list_first_entry(&executor->work.list,
- struct action_work_item, list_node);
+ work_item = cds_list_first_entry(
+ &executor->work.list, struct action_work_item, list_node);
cds_list_del(&work_item->list_node);
executor->work.pending_count--;
trigger_name = get_trigger_name(work_item->trigger);
- trigger_status = lttng_trigger_get_owner_uid(
- work_item->trigger, &trigger_owner_uid);
+ trigger_status =
+ lttng_trigger_get_owner_uid(work_item->trigger, &trigger_owner_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64 ", trigger name = `%s`, trigger owner uid = %d",
- work_item->id, trigger_name,
- (int) trigger_owner_uid);
+ DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64
+ ", trigger name = `%s`, trigger owner uid = %d",
+ work_item->id,
+ trigger_name,
+ (int) trigger_owner_uid);
ret = 0;
goto skip_execute;
}
free(executor);
}
-struct action_executor *action_executor_create(
- struct notification_thread_handle *handle)
+struct action_executor *action_executor_create(struct notification_thread_handle *handle)
{
struct action_executor *executor = zmalloc<action_executor>();
executor->notification_thread_handle = handle;
executor->thread = lttng_thread_create(THREAD_NAME,
- action_executor_thread, shutdown_action_executor_thread,
- clean_up_action_executor_thread, executor);
+ action_executor_thread,
+ shutdown_action_executor_thread,
+ clean_up_action_executor_thread,
+ executor);
end:
return executor;
}
pthread_mutex_lock(&executor->work.lock);
if (executor->work.pending_count != 0) {
WARN("%" PRIu64
- " trigger action%s still queued for execution and will be discarded",
- executor->work.pending_count,
- executor->work.pending_count == 1 ? " is" :
- "s are");
+ " trigger action%s still queued for execution and will be discarded",
+ executor->work.pending_count,
+ executor->work.pending_count == 1 ? " is" : "s are");
}
- cds_list_for_each_entry_safe (
- work_item, tmp, &executor->work.list, list_node) {
- WARN("Discarding action work item %" PRIu64
- " associated to trigger `%s`",
- work_item->id, get_trigger_name(work_item->trigger));
+ cds_list_for_each_entry_safe (work_item, tmp, &executor->work.list, list_node) {
+ WARN("Discarding action work item %" PRIu64 " associated to trigger `%s`",
+ work_item->id,
+ get_trigger_name(work_item->trigger));
cds_list_del(&work_item->list_node);
action_work_item_destroy(work_item);
}
}
/* RCU read-lock must be held by the caller. */
-enum action_executor_status action_executor_enqueue_trigger(
- struct action_executor *executor,
- struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation,
- const struct lttng_credentials *object_creds,
- struct notification_client_list *client_list)
+enum action_executor_status
+action_executor_enqueue_trigger(struct action_executor *executor,
+ struct lttng_trigger *trigger,
+ struct lttng_evaluation *evaluation,
+ const struct lttng_credentials *object_creds,
+ struct notification_client_list *client_list)
{
int ret;
enum action_executor_status executor_status = ACTION_EXECUTOR_STATUS_OK;
if (executor->work.pending_count >= MAX_QUEUED_WORK_COUNT) {
/* Most likely spammy, remove if it is the case. */
DBG("Refusing to enqueue action for trigger (overflow): trigger name = `%s`, work item id = %" PRIu64,
- get_trigger_name(trigger), work_item_id);
+ get_trigger_name(trigger),
+ work_item_id);
executor_status = ACTION_EXECUTOR_STATUS_OVERFLOW;
goto error_unlock;
}
work_item = zmalloc<action_work_item>();
if (!work_item) {
PERROR("Failed to allocate action executor work item: trigger name = `%s`",
- get_trigger_name(trigger));
+ get_trigger_name(trigger));
executor_status = ACTION_EXECUTOR_STATUS_ERROR;
goto error_unlock;
}
lttng_trigger_get(trigger);
if (client_list) {
- const bool reference_acquired =
- notification_client_list_get(client_list);
+ const bool reference_acquired = notification_client_list_get(client_list);
LTTNG_ASSERT(reference_acquired);
}
/* Build the array of action work subitems for the passed trigger. */
lttng_dynamic_array_init(&work_item->subitems,
- sizeof(struct action_work_subitem),
- action_work_subitem_destructor);
+ sizeof(struct action_work_subitem),
+ action_work_subitem_destructor);
- ret = populate_subitem_array_from_trigger(
- trigger, &work_item->subitems);
+ ret = populate_subitem_array_from_trigger(trigger, &work_item->subitems);
if (ret) {
ERR("Failed to populate work item sub items on behalf of trigger: trigger name = `%s`",
- get_trigger_name(trigger));
+ get_trigger_name(trigger));
executor_status = ACTION_EXECUTOR_STATUS_ERROR;
goto error_unlock;
}
cds_list_add_tail(&work_item->list_node, &executor->work.list);
executor->work.pending_count++;
DBG("Enqueued action for trigger: trigger name = `%s`, work item id = %" PRIu64,
- get_trigger_name(trigger), work_item_id);
+ get_trigger_name(trigger),
+ work_item_id);
signal = true;
error_unlock:
}
static int add_action_to_subitem_array(struct lttng_action *action,
- struct lttng_dynamic_array *subitems)
+ struct lttng_dynamic_array *subitems)
{
int ret = 0;
enum lttng_action_type type = lttng_action_get_type(action);
for (i = 0; i < count; i++) {
struct lttng_action *inner_action = NULL;
- inner_action = lttng_action_list_borrow_mutable_at_index(
- action, i);
+ inner_action = lttng_action_list_borrow_mutable_at_index(action, i);
LTTNG_ASSERT(inner_action);
- ret = add_action_to_subitem_array(
- inner_action, subitems);
+ ret = add_action_to_subitem_array(inner_action, subitems);
if (ret) {
goto end;
}
case LTTNG_ACTION_TYPE_NOTIFY:
break;
case LTTNG_ACTION_TYPE_START_SESSION:
- status = lttng_action_start_session_get_session_name(
- action, &session_name);
+ status = lttng_action_start_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
break;
case LTTNG_ACTION_TYPE_STOP_SESSION:
- status = lttng_action_stop_session_get_session_name(
- action, &session_name);
+ status = lttng_action_stop_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
break;
case LTTNG_ACTION_TYPE_ROTATE_SESSION:
- status = lttng_action_rotate_session_get_session_name(
- action, &session_name);
+ status = lttng_action_rotate_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
break;
case LTTNG_ACTION_TYPE_SNAPSHOT_SESSION:
- status = lttng_action_snapshot_session_get_session_name(
- action, &session_name);
+ status = lttng_action_snapshot_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
break;
case LTTNG_ACTION_TYPE_LIST:
* execution time.
*/
if (sample_session_id_by_name(session_name, &session_id)) {
- LTTNG_OPTIONAL_SET(&subitem.context.session_id,
- session_id);
+ LTTNG_OPTIONAL_SET(&subitem.context.session_id, session_id);
}
}
}
static int populate_subitem_array_from_trigger(struct lttng_trigger *trigger,
- struct lttng_dynamic_array *subitems)
+ struct lttng_dynamic_array *subitems)
{
struct lttng_action *action;
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/uri.hpp>
-#include <common/utils.hpp>
-
-#include <common/compat/endian.hpp>
-
-#include "fd-limit.hpp"
#include "agent-thread.hpp"
#include "agent.hpp"
+#include "fd-limit.hpp"
#include "lttng-sessiond.hpp"
#include "session.hpp"
-#include "utils.hpp"
#include "thread.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
namespace {
struct thread_notifiers {
list = session_get_list();
LTTNG_ASSERT(list);
- cds_list_for_each_entry_safe(session, stmp, &list->head, list) {
+ cds_list_for_each_entry_safe (session, stmp, &list->head, list) {
if (!session_get(session)) {
continue;
}
* We are protected against the addition of new events by the session
* list lock being held.
*/
- cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht,
- &iter.iter, trigger_agent, node.node) {
+ cds_lfht_for_each_entry (
+ the_trigger_agents_ht_by_domain->ht, &iter.iter, trigger_agent, node.node) {
agent_update(trigger_agent, app);
}
rcu_read_unlock();
goto error;
}
- for (port = the_config.agent_tcp_port.begin;
- port <= the_config.agent_tcp_port.end; port++) {
+ for (port = the_config.agent_tcp_port.begin; port <= the_config.agent_tcp_port.end;
+ port++) {
ret = lttcomm_sock_set_port(sock, (uint16_t) port);
if (ret) {
- ERR("Failed to set port %u on socket",
- port);
+ ERR("Failed to set port %u on socket", port);
goto error;
}
DBG3("Trying to bind on port %u", port);
}
if (errno == EADDRINUSE) {
- DBG("Failed to bind to port %u since it is already in use",
- port);
+ DBG("Failed to bind to port %u since it is already in use", port);
} else {
PERROR("Failed to bind to port %u", port);
goto error;
}
if (!bind_succeeded) {
- if (the_config.agent_tcp_port.begin ==
- the_config.agent_tcp_port.end) {
+ if (the_config.agent_tcp_port.begin == the_config.agent_tcp_port.end) {
WARN("Another process is already using the agent port %i. "
"Agent support will be deactivated.",
- the_config.agent_tcp_port.begin);
+ the_config.agent_tcp_port.begin);
goto error;
} else {
WARN("All ports in the range [%i, %i] are already in use. "
"Agent support will be deactivated.",
- the_config.agent_tcp_port.begin,
- the_config.agent_tcp_port.end);
+ the_config.agent_tcp_port.begin,
+ the_config.agent_tcp_port.end);
goto error;
}
}
goto error;
}
- DBG("Listening on TCP port %u and socket %d",
- port, sock->fd);
+ DBG("Listening on TCP port %u and socket %d", port, sock->fd);
return sock;
port = 0;
}
- DBG3("Destroy TCP socket on port %" PRIu16,
- port);
+ DBG3("Destroy TCP socket on port %" PRIu16, port);
/* This will return gracefully if fd is invalid. */
sock->ops->close(sock);
}
}
-static bool is_agent_protocol_version_supported(
- const struct agent_protocol_version *version)
+static bool is_agent_protocol_version_supported(const struct agent_protocol_version *version)
{
const bool is_supported = version->major == AGENT_MAJOR_VERSION &&
- version->minor == AGENT_MINOR_VERSION;
+ version->minor == AGENT_MINOR_VERSION;
if (!is_supported) {
WARN("Refusing agent connection: unsupported protocol version %ui.%ui, expected %i.%i",
- version->major, version->minor,
- AGENT_MAJOR_VERSION, AGENT_MINOR_VERSION);
+ version->major,
+ version->minor,
+ AGENT_MAJOR_VERSION,
+ AGENT_MINOR_VERSION);
}
return is_supported;
* On success, the resulting socket is returned through `agent_app_socket`
* and the application's reported id is updated through `agent_app_id`.
*/
-static int accept_agent_connection(
- struct lttcomm_sock *reg_sock,
- struct agent_app_id *agent_app_id,
- struct lttcomm_sock **agent_app_socket)
+static int accept_agent_connection(struct lttcomm_sock *reg_sock,
+ struct agent_app_id *agent_app_id,
+ struct lttcomm_sock **agent_app_socket)
{
int ret;
struct agent_protocol_version agent_version;
PERROR("Failed to register new agent application");
} else if (size != 0) {
ERR("Failed to register new agent application: invalid registration message length: expected length = %zu, message length = %zd",
- sizeof(msg), size);
+ sizeof(msg),
+ size);
} else {
DBG("Failed to register new agent application: connection closed");
}
goto error_close_socket;
}
- agent_version = (struct agent_protocol_version) {
+ agent_version = (struct agent_protocol_version){
be32toh(msg.major_version),
be32toh(msg.minor_version),
};
goto error_close_socket;
}
- *agent_app_id = (struct agent_app_id) {
+ *agent_app_id = (struct agent_app_id){
.pid = (pid_t) be32toh(msg.pid),
.domain = (lttng_domain_type) be32toh(msg.domain),
};
DBG2("New registration for agent application: pid = %ld, domain = %s, socket fd = %d",
- (long) agent_app_id->pid,
- domain_type_str(agent_app_id->domain), new_sock->fd);
+ (long) agent_app_id->pid,
+ domain_type_str(agent_app_id->domain),
+ new_sock->fd);
*agent_app_socket = new_sock;
new_sock = NULL;
*/
static int write_agent_port(uint16_t port)
{
- return utils_create_pid_file(
- (pid_t) port, the_config.agent_port_file_path.value);
+ return utils_create_pid_file((pid_t) port, the_config.agent_port_file_path.value);
}
-static
-void mark_thread_as_ready(struct thread_notifiers *notifiers)
+static void mark_thread_as_ready(struct thread_notifiers *notifiers)
{
DBG("Marking agent management thread as ready");
sem_post(¬ifiers->ready);
}
-static
-void wait_until_thread_is_ready(struct thread_notifiers *notifiers)
+static void wait_until_thread_is_ready(struct thread_notifiers *notifiers)
{
DBG("Waiting for agent management thread to be ready");
sem_wait(¬ifiers->ready);
struct lttng_poll_event events;
struct lttcomm_sock *reg_sock;
struct thread_notifiers *notifiers = (thread_notifiers *) data;
- const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(
- notifiers->quit_pipe);
+ const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
DBG("Manage agent application registration.");
DBG3("Manage agent polling");
/* Inifinite blocking call, waiting for transmission */
-restart:
+ restart:
ret = lttng_poll_wait(&events, -1);
- DBG3("Manage agent return from poll on %d fds",
- LTTNG_POLL_GETNB(&events));
+ DBG3("Manage agent return from poll on %d fds", LTTNG_POLL_GETNB(&events));
if (ret < 0) {
/*
* Restart interrupted system call.
* new_app_socket's ownership has been
* transferred to the new agent app.
*/
- new_app = agent_create_app(new_app_id.pid,
- new_app_id.domain,
- new_app_socket);
+ new_app = agent_create_app(
+ new_app_id.pid, new_app_id.domain, new_app_socket);
if (!new_app) {
- new_app_socket->ops->close(
- new_app_socket);
+ new_app_socket->ops->close(new_app_socket);
continue;
}
new_app_socket_fd = new_app_socket->fd;
if (ret < 0) {
agent_destroy_app(new_app);
/* Removing from the poll set. */
- ret = lttng_poll_del(&events,
- new_app_socket_fd);
+ ret = lttng_poll_del(&events, new_app_socket_fd);
if (ret < 0) {
session_unlock_list();
goto error;
goto error;
}
thread = lttng_thread_create("Agent management",
- thread_agent_management,
- shutdown_agent_management_thread,
- cleanup_agent_management_thread,
- notifiers);
+ thread_agent_management,
+ shutdown_agent_management_thread,
+ cleanup_agent_management_thread,
+ notifiers);
if (!thread) {
goto error;
}
*/
#define _LGPL_SOURCE
-#include <urcu/uatomic.h>
-#include <urcu/rculist.h>
+#include "agent.hpp"
+#include "common/error.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
-#include <lttng/event-rule/event-rule.h>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/sessiond-comm/agent.hpp>
+
+#include <lttng/condition/condition.h>
+#include <lttng/condition/event-rule-matches.h>
+#include <lttng/domain-internal.hpp>
#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/jul-logging.h>
#include <lttng/event-rule/log4j-logging.h>
#include <lttng/event-rule/python-logging.h>
-#include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-matches.h>
-#include <lttng/domain-internal.hpp>
#include <lttng/log-level-rule-internal.hpp>
-#include <common/common.hpp>
-#include <common/sessiond-comm/agent.hpp>
-
-#include <common/compat/endian.hpp>
-
-#include "agent.hpp"
-#include "ust-app.hpp"
-#include "utils.hpp"
-#include "common/error.hpp"
+#include <urcu/rculist.h>
+#include <urcu/uatomic.h>
typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
- const struct lttng_event_rule *rule, const char **pattern);
+ const struct lttng_event_rule *rule, const char **pattern);
typedef enum lttng_event_rule_status (*event_rule_logging_get_log_level_rule)(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule);
+ const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule);
/*
* Agent application context representation.
/*
* Human readable agent return code.
*/
-static
-const char *lttcomm_agent_ret_code_str(lttcomm_agent_ret_code code)
+static const char *lttcomm_agent_ret_code_str(lttcomm_agent_ret_code code)
{
switch (code) {
case AGENT_RET_CODE_SUCCESS:
}
};
-static
-void log_reply_code(uint32_t in_reply_ret_code)
+static void log_reply_code(uint32_t in_reply_ret_code)
{
int level = PRINT_DBG3;
/*
*/
uint32_t reply_ret_code = in_reply_ret_code;
- if (reply_ret_code < AGENT_RET_CODE_SUCCESS ||
- reply_ret_code >= AGENT_RET_CODE_NR) {
+ if (reply_ret_code < AGENT_RET_CODE_SUCCESS || reply_ret_code >= AGENT_RET_CODE_NR) {
reply_ret_code = AGENT_RET_CODE_NR;
level = PRINT_ERR;
}
- LOG(level, "Agent replied with retcode: %s (%" PRIu32 ")",
- lttcomm_agent_ret_code_str((lttcomm_agent_ret_code) reply_ret_code),
- in_reply_ret_code);
+ LOG(level,
+ "Agent replied with retcode: %s (%" PRIu32 ")",
+ lttcomm_agent_ret_code_str((lttcomm_agent_ret_code) reply_ret_code),
+ in_reply_ret_code);
}
/*
* Match function for the events hash table lookup by name.
*/
-static int ht_match_event_by_name(struct cds_lfht_node *node,
- const void *_key)
+static int ht_match_event_by_name(struct cds_lfht_node *node, const void *_key)
{
struct agent_event *event;
const struct agent_ht_key *key;
* Match function for the events hash table lookup by name, log level and
* filter expression.
*/
-static int ht_match_event(struct cds_lfht_node *node,
- const void *_key)
+static int ht_match_event(struct cds_lfht_node *node, const void *_key)
{
struct agent_event *event;
const struct agent_ht_key *key;
/* Event loglevel value and type. */
ll_match = loglevels_match(event->loglevel_type,
- event->loglevel_value, key->loglevel_type,
- key->loglevel_value, LTTNG_EVENT_LOGLEVEL_ALL);
+ event->loglevel_value,
+ key->loglevel_type,
+ key->loglevel_value,
+ LTTNG_EVENT_LOGLEVEL_ALL);
if (!ll_match) {
goto no_match;
}
if (event->filter_expression) {
- if (strncmp(event->filter_expression, key->filter_expression,
- strlen(event->filter_expression)) != 0) {
+ if (strncmp(event->filter_expression,
+ key->filter_expression,
+ strlen(event->filter_expression)) != 0) {
goto no_match;
}
}
/*
* Add unique agent event based on the event name and loglevel.
*/
-static void add_unique_agent_event(struct lttng_ht *ht,
- struct agent_event *event)
+static void add_unique_agent_event(struct lttng_ht *ht, struct agent_event *event)
{
struct cds_lfht_node *node_ptr;
struct agent_ht_key key;
key.filter_expression = event->filter_expression;
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct(event->node.key, lttng_ht_seed),
- ht_match_event, &key, &event->node.node);
+ ht->hash_fct(event->node.key, lttng_ht_seed),
+ ht_match_event,
+ &key,
+ &event->node.node);
LTTNG_ASSERT(node_ptr == &event->node.node);
}
*/
static void destroy_event_agent_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_str *node =
- lttng::utils::container_of(head, <tng_ht_node_str::head);
- struct agent_event *event =
- lttng::utils::container_of(node, &agent_event::node);
+ struct lttng_ht_node_str *node = lttng::utils::container_of(head, <tng_ht_node_str::head);
+ struct agent_event *event = lttng::utils::container_of(node, &agent_event::node);
agent_destroy_event(event);
}
{
struct lttng_ht_node_ulong *node =
lttng::utils::container_of(head, <tng_ht_node_ulong::head);
- struct agent_app *app =
- lttng::utils::container_of(node, &agent_app::node);
+ struct agent_app *app = lttng::utils::container_of(node, &agent_app::node);
free(app);
}
*
* Return 0 on success or else a negative errno message of sendmsg() op.
*/
-static int send_header(struct lttcomm_sock *sock, uint64_t data_size,
- uint32_t cmd, uint32_t cmd_version)
+static int
+send_header(struct lttcomm_sock *sock, uint64_t data_size, uint32_t cmd, uint32_t cmd_version)
{
int ret;
ssize_t size;
*
* Return 0 on success or else a negative errno value of sendmsg() op.
*/
-static int send_payload(struct lttcomm_sock *sock, const void *data,
- size_t size)
+static int send_payload(struct lttcomm_sock *sock, const void *data, size_t size)
{
int ret;
ssize_t len;
LTTNG_ASSERT(app->sock);
LTTNG_ASSERT(events);
- DBG2("Agent listing events for app pid: %d and socket %d", app->pid,
- app->sock->fd);
+ DBG2("Agent listing events for app pid: %d and socket %d", app->pid, app->sock->fd);
ret = send_header(app->sock, 0, AGENT_CMD_LIST, 0);
if (ret < 0) {
for (i = 0; i < nb_event; i++) {
offset += len;
- if (lttng_strncpy(tmp_events[i].name, reply->payload + offset,
- sizeof(tmp_events[i].name))) {
+ if (lttng_strncpy(tmp_events[i].name,
+ reply->payload + offset,
+ sizeof(tmp_events[i].name))) {
ret = LTTNG_ERR_INVALID;
goto error;
}
free(reply);
free(tmp_events);
return -ret;
-
}
/*
LTTNG_ASSERT(app->sock);
LTTNG_ASSERT(event);
- DBG2("Agent enabling event %s for app pid: %d and socket %d", event->name,
- app->pid, app->sock->fd);
+ DBG2("Agent enabling event %s for app pid: %d and socket %d",
+ event->name,
+ app->pid,
+ app->sock->fd);
/*
* Calculate the payload's size, which is the fixed-size struct followed
memcpy(bytes_to_send, &msg, sizeof(msg));
if (filter_expression_length > 0) {
- memcpy(bytes_to_send + sizeof(msg), event->filter_expression,
- filter_expression_length);
+ memcpy(bytes_to_send + sizeof(msg),
+ event->filter_expression,
+ filter_expression_length);
}
ret = send_payload(app->sock, bytes_to_send, data_size);
/*
* Send Pascal-style string. Size is sent as a 32-bit big endian integer.
*/
-static
-int send_pstring(struct lttcomm_sock *sock, const char *str, uint32_t len)
+static int send_pstring(struct lttcomm_sock *sock, const char *str, uint32_t len)
{
int ret;
uint32_t len_be;
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
static int app_context_op(const struct agent_app *app,
- const struct agent_app_ctx *ctx, enum lttcomm_agent_command cmd)
+ const struct agent_app_ctx *ctx,
+ enum lttcomm_agent_command cmd)
{
int ret;
uint32_t reply_ret_code;
LTTNG_ASSERT(app);
LTTNG_ASSERT(app->sock);
LTTNG_ASSERT(ctx);
- LTTNG_ASSERT(cmd == AGENT_CMD_APP_CTX_ENABLE ||
- cmd == AGENT_CMD_APP_CTX_DISABLE);
+ LTTNG_ASSERT(cmd == AGENT_CMD_APP_CTX_ENABLE || cmd == AGENT_CMD_APP_CTX_DISABLE);
DBG2("Agent %s application %s:%s for app pid: %d and socket %d",
- cmd == AGENT_CMD_APP_CTX_ENABLE ? "enabling" : "disabling",
- ctx->provider_name, ctx->ctx_name,
- app->pid, app->sock->fd);
+ cmd == AGENT_CMD_APP_CTX_ENABLE ? "enabling" : "disabling",
+ ctx->provider_name,
+ ctx->ctx_name,
+ app->pid,
+ app->sock->fd);
/*
* Calculate the payload's size, which consists of the size (u32, BE)
*/
app_ctx_provider_name_len = strlen(ctx->provider_name) + 1;
app_ctx_name_len = strlen(ctx->ctx_name) + 1;
- data_size = sizeof(uint32_t) + app_ctx_provider_name_len +
- sizeof(uint32_t) + app_ctx_name_len;
+ data_size =
+ sizeof(uint32_t) + app_ctx_provider_name_len + sizeof(uint32_t) + app_ctx_name_len;
ret = send_header(app->sock, data_size, cmd, 0);
if (ret < 0) {
goto error_io;
}
- if (app_ctx_provider_name_len > UINT32_MAX ||
- app_ctx_name_len > UINT32_MAX) {
+ if (app_ctx_provider_name_len > UINT32_MAX || app_ctx_name_len > UINT32_MAX) {
ERR("Application context name > MAX_UINT32");
ret = LTTNG_ERR_INVALID;
goto error;
}
- ret = send_pstring(app->sock, ctx->provider_name,
- (uint32_t) app_ctx_provider_name_len);
+ ret = send_pstring(app->sock, ctx->provider_name, (uint32_t) app_ctx_provider_name_len);
if (ret < 0) {
goto error_io;
}
- ret = send_pstring(app->sock, ctx->ctx_name,
- (uint32_t) app_ctx_name_len);
+ ret = send_pstring(app->sock, ctx->ctx_name, (uint32_t) app_ctx_name_len);
if (ret < 0) {
goto error_io;
}
LTTNG_ASSERT(app->sock);
LTTNG_ASSERT(event);
- DBG2("Agent disabling event %s for app pid: %d and socket %d", event->name,
- app->pid, app->sock->fd);
+ DBG2("Agent disabling event %s for app pid: %d and socket %d",
+ event->name,
+ app->pid,
+ app->sock->fd);
data_size = sizeof(msg);
memset(&msg, 0, sizeof(msg));
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int agent_enable_event(struct agent_event *event,
- enum lttng_domain_type domain)
+int agent_enable_event(struct agent_event *event, enum lttng_domain_type domain)
{
int ret;
struct agent_app *app;
rcu_read_lock();
- cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app,
- node.node) {
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) {
if (app->domain != domain) {
continue;
}
return ret;
}
-static
-void destroy_app_ctx(struct agent_app_ctx *ctx)
+static void destroy_app_ctx(struct agent_app_ctx *ctx)
{
free(ctx->provider_name);
free(ctx->ctx_name);
free(ctx);
}
-static
-struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx)
+static struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx)
{
struct agent_app_ctx *agent_ctx = NULL;
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int agent_enable_context(const struct lttng_event_context *ctx,
- enum lttng_domain_type domain)
+int agent_enable_context(const struct lttng_event_context *ctx, enum lttng_domain_type domain)
{
int ret;
struct agent_app *app;
rcu_read_lock();
- cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app,
- node.node) {
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) {
struct agent_app_ctx *agent_ctx;
if (app->domain != domain) {
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int agent_disable_event(struct agent_event *event,
- enum lttng_domain_type domain)
+int agent_disable_event(struct agent_event *event, enum lttng_domain_type domain)
{
int ret = LTTNG_OK;
struct agent_app *app;
rcu_read_lock();
- cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app,
- node.node) {
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) {
if (app->domain != domain) {
continue;
}
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-static int disable_context(struct agent_app_ctx *ctx,
- enum lttng_domain_type domain)
+static int disable_context(struct agent_app_ctx *ctx, enum lttng_domain_type domain)
{
int ret = LTTNG_OK;
struct agent_app *app;
LTTNG_ASSERT(ctx);
rcu_read_lock();
- DBG2("Disabling agent application context %s:%s",
- ctx->provider_name, ctx->ctx_name);
- cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app,
- node.node) {
+ DBG2("Disabling agent application context %s:%s", ctx->provider_name, ctx->ctx_name);
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) {
if (app->domain != domain) {
continue;
}
*
* Return the number of events or else a negative value.
*/
-int agent_list_events(struct lttng_event **events,
- enum lttng_domain_type domain)
+int agent_list_events(struct lttng_event **events, enum lttng_domain_type domain)
{
int ret;
size_t nbmem, count = 0;
}
rcu_read_lock();
- cds_lfht_for_each_entry(the_agent_apps_ht_by_sock->ht, &iter.iter, app,
- node.node) {
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, app, node.node) {
ssize_t nb_ev;
struct lttng_event *agent_events;
new_nbmem = std::max(count + nb_ev, nbmem << 1);
DBG2("Reallocating agent event list from %zu to %zu entries",
- nbmem, new_nbmem);
- new_tmp_events = (lttng_event *) realloc(tmp_events,
- new_nbmem * sizeof(*new_tmp_events));
+ nbmem,
+ new_nbmem);
+ new_tmp_events = (lttng_event *) realloc(
+ tmp_events, new_nbmem * sizeof(*new_tmp_events));
if (!new_tmp_events) {
PERROR("realloc agent events");
ret = -ENOMEM;
goto error_unlock;
}
/* Zero the new memory */
- memset(new_tmp_events + nbmem, 0,
- (new_nbmem - nbmem) * sizeof(*new_tmp_events));
+ memset(new_tmp_events + nbmem,
+ 0,
+ (new_nbmem - nbmem) * sizeof(*new_tmp_events));
nbmem = new_nbmem;
tmp_events = new_tmp_events;
}
- memcpy(tmp_events + count, agent_events,
- nb_ev * sizeof(*tmp_events));
+ memcpy(tmp_events + count, agent_events, nb_ev * sizeof(*tmp_events));
free(agent_events);
count += nb_ev;
}
*
* Return newly allocated object or else NULL on error.
*/
-struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
- struct lttcomm_sock *sock)
+struct agent_app *
+agent_create_app(pid_t pid, enum lttng_domain_type domain, struct lttcomm_sock *sock)
{
struct agent_app *app;
LTTNG_ASSERT(sock >= 0);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(the_agent_apps_ht_by_sock,
- (void *) ((unsigned long) sock), &iter);
+ lttng_ht_lookup(the_agent_apps_ht_by_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
goto error;
* Return a new object else NULL on error.
*/
struct agent_event *agent_create_event(const char *name,
- enum lttng_loglevel_type loglevel_type, int loglevel_value,
- struct lttng_bytecode *filter, char *filter_expression)
+ enum lttng_loglevel_type loglevel_type,
+ int loglevel_value,
+ struct lttng_bytecode *filter,
+ char *filter_expression)
{
struct agent_event *event = NULL;
DBG3("Agent create new event with name %s, loglevel type %d, \
loglevel value %d and filter %s",
- name, loglevel_type, loglevel_value,
- filter_expression ? filter_expression : "NULL");
+ name,
+ loglevel_type,
+ loglevel_value,
+ filter_expression ? filter_expression : "NULL");
if (!name) {
ERR("Failed to create agent event; no name provided.");
goto end;
}
- DBG3("Agent adding context %s:%s", ctx->u.app_ctx.provider_name,
- ctx->u.app_ctx.ctx_name);
+ DBG3("Agent adding context %s:%s", ctx->u.app_ctx.provider_name, ctx->u.app_ctx.ctx_name);
cds_list_add_tail_rcu(&agent_ctx->list_node, &agt->app_ctx_list);
end:
return ret;
*
* Sets the given iterator.
*/
-void agent_find_events_by_name(const char *name, struct agent *agt,
- struct lttng_ht_iter* iter)
+void agent_find_events_by_name(const char *name, struct agent *agt, struct lttng_ht_iter *iter)
{
struct lttng_ht *ht;
struct agent_ht_key key;
ht = agt->events;
key.name = name;
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
- ht_match_event_by_name, &key, &iter->iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) name, lttng_ht_seed),
+ ht_match_event_by_name,
+ &key,
+ &iter->iter);
}
/*
*
* Return object if found else NULL.
*/
-struct agent_event *agent_find_event_by_trigger(
- const struct lttng_trigger *trigger, struct agent *agt)
+struct agent_event *agent_find_event_by_trigger(const struct lttng_trigger *trigger,
+ struct agent *agt)
{
enum lttng_condition_status c_status;
enum lttng_event_rule_status er_status;
condition = lttng_trigger_get_const_condition(trigger);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- c_status = lttng_condition_event_rule_matches_get_rule(
- condition, &rule);
+ c_status = lttng_condition_event_rule_matches_get_rule(condition, &rule);
LTTNG_ASSERT(c_status == LTTNG_CONDITION_STATUS_OK);
switch (lttng_event_rule_get_type(rule)) {
case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_jul_logging_get_name_pattern;
- logging_get_log_level_rule =
- lttng_event_rule_jul_logging_get_log_level_rule;
+ logging_get_name_pattern = lttng_event_rule_jul_logging_get_name_pattern;
+ logging_get_log_level_rule = lttng_event_rule_jul_logging_get_log_level_rule;
break;
case LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_log4j_logging_get_name_pattern;
- logging_get_log_level_rule =
- lttng_event_rule_log4j_logging_get_log_level_rule;
+ logging_get_name_pattern = lttng_event_rule_log4j_logging_get_name_pattern;
+ logging_get_log_level_rule = lttng_event_rule_log4j_logging_get_log_level_rule;
break;
case LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_python_logging_get_name_pattern;
- logging_get_log_level_rule =
- lttng_event_rule_python_logging_get_log_level_rule;
+ logging_get_name_pattern = lttng_event_rule_python_logging_get_name_pattern;
+ logging_get_log_level_rule = lttng_event_rule_python_logging_get_log_level_rule;
break;
default:
abort();
domain = lttng_event_rule_get_domain_type(rule);
LTTNG_ASSERT(domain == LTTNG_DOMAIN_JUL || domain == LTTNG_DOMAIN_LOG4J ||
- domain == LTTNG_DOMAIN_PYTHON);
+ domain == LTTNG_DOMAIN_PYTHON);
/* Get the event's pattern name ('name' in the legacy terminology). */
er_status = logging_get_name_pattern(rule, &name);
abort();
}
- return agent_find_event(name, loglevel_type, loglevel_value,
- filter_expression, agt);
+ return agent_find_event(name, loglevel_type, loglevel_value, filter_expression, agt);
}
/*
* The RCU read lock must be held during the iteration and for as long
* as the object the iterator points to remains in use.
*/
-void agent_event_next_duplicate(const char *name,
- struct agent *agt, struct lttng_ht_iter* iter)
+void agent_event_next_duplicate(const char *name, struct agent *agt, struct lttng_ht_iter *iter)
{
struct agent_ht_key key;
key.name = name;
- cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name,
- &key, &iter->iter);
+ cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name, &key, &iter->iter);
}
/*
* Return object if found else NULL.
*/
struct agent_event *agent_find_event(const char *name,
- enum lttng_loglevel_type loglevel_type,
- int loglevel_value,
- const char *filter_expression,
- struct agent *agt)
+ enum lttng_loglevel_type loglevel_type,
+ int loglevel_value,
+ const char *filter_expression,
+ struct agent *agt)
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
key.loglevel_type = loglevel_type;
key.filter_expression = filter_expression;
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
- ht_match_event, &key, &iter.iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) name, lttng_ht_seed),
+ ht_match_event,
+ &key,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (node == NULL) {
goto error;
free(event);
}
-static
-void destroy_app_ctx_rcu(struct rcu_head *head)
+static void destroy_app_ctx_rcu(struct rcu_head *head)
{
- struct agent_app_ctx *ctx =
- lttng::utils::container_of(head, &agent_app_ctx::rcu_node);
+ struct agent_app_ctx *ctx = lttng::utils::container_of(head, &agent_app_ctx::rcu_node);
destroy_app_ctx(ctx);
}
DBG3("Agent destroy");
rcu_read_lock();
- cds_lfht_for_each_entry(agt->events->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (agt->events->ht, &iter.iter, node, node) {
int ret;
struct agent_event *event;
call_rcu(&node->head, destroy_event_agent_rcu);
}
- cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
+ cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node)
+ {
(void) disable_context(ctx, agt->domain);
cds_list_del(&ctx->list_node);
call_rcu(&ctx->rcu_node, destroy_app_ctx_rcu);
return;
}
rcu_read_lock();
- cds_lfht_for_each_entry(
- the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) {
struct agent_app *app;
app = lttng::utils::container_of(node, &agent_app::node);
* there is a serious code flow error.
*/
- cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
+ cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) {
/* Skip event if disabled. */
if (!AGENT_EVENT_IS_ENABLED(event)) {
continue;
ret = enable_event(app, event);
if (ret != LTTNG_OK) {
DBG2("Agent update unable to enable event %s on app pid: %d sock %d",
- event->name, app->pid, app->sock->fd);
+ event->name,
+ app->pid,
+ app->sock->fd);
/* Let's try the others here and don't assume the app is dead. */
continue;
}
}
- cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
+ cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node)
+ {
ret = app_context_op(app, ctx, AGENT_CMD_APP_CTX_ENABLE);
if (ret != LTTNG_OK) {
DBG2("Agent update unable to add application context %s:%s on app pid: %d sock %d",
- ctx->provider_name, ctx->ctx_name,
- app->pid, app->sock->fd);
+ ctx->provider_name,
+ ctx->ctx_name,
+ app->pid,
+ app->sock->fd);
continue;
}
}
}
rcu_read_lock();
- cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht,
- &iter.iter, node, node) {
- struct agent *agent =
- lttng::utils::container_of(node, &agent::node);
- const int ret = lttng_ht_del(
- the_trigger_agents_ht_by_domain, &iter);
+ cds_lfht_for_each_entry (the_trigger_agents_ht_by_domain->ht, &iter.iter, node, node) {
+ struct agent *agent = lttng::utils::container_of(node, &agent::node);
+ const int ret = lttng_ht_del(the_trigger_agents_ht_by_domain, &iter);
LTTNG_ASSERT(ret == 0);
agent_destroy(agent);
lttng_ht_destroy(the_trigger_agents_ht_by_domain);
}
-struct agent *agent_find_by_event_notifier_domain(
- enum lttng_domain_type domain_type)
+struct agent *agent_find_by_event_notifier_domain(enum lttng_domain_type domain_type)
{
struct agent *agt = NULL;
struct lttng_ht_node_u64 *node;
LTTNG_ASSERT(the_trigger_agents_ht_by_domain);
DBG3("Per-event notifier domain agent lookup for domain '%s'",
- lttng_domain_type_str(domain_type));
+ lttng_domain_type_str(domain_type));
lttng_ht_lookup(the_trigger_agents_ht_by_domain, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-
-#include <common/common.hpp>
-#include <common/hashtable/utils.hpp>
-
#include "buffer-registry.hpp"
#include "fd-limit.hpp"
-#include "ust-consumer.hpp"
#include "lttng-ust-ctl.hpp"
#include "lttng-ust-error.hpp"
+#include "ust-consumer.hpp"
#include "utils.hpp"
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
+
+#include <inttypes.h>
+
/*
* Set in main.c during initialization process of the daemon. This contains
* buffer_reg_uid object which are global registry for per UID buffer. Object
LTTNG_ASSERT(reg);
key = (buffer_reg_uid *) _key;
- if (key->session_id != reg->session_id ||
- key->bits_per_long != reg->bits_per_long ||
- key->uid != reg->uid) {
+ if (key->session_id != reg->session_id || key->bits_per_long != reg->bits_per_long ||
+ key->uid != reg->uid) {
goto no_match;
}
LTTNG_ASSERT(key);
- xored_key = (uint64_t)(key->session_id ^ key->bits_per_long ^ key->uid);
+ xored_key = (uint64_t) (key->session_id ^ key->bits_per_long ^ key->uid);
return hash_key_u64(&xored_key, seed);
}
*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid,
- enum lttng_domain_type domain, struct buffer_reg_uid **regp,
- const char *root_shm_path, const char *shm_path)
+int buffer_reg_uid_create(uint64_t session_id,
+ uint32_t bits_per_long,
+ uid_t uid,
+ enum lttng_domain_type domain,
+ struct buffer_reg_uid **regp,
+ const char *root_shm_path,
+ const char *shm_path)
{
int ret = 0;
struct buffer_reg_uid *reg = NULL;
strncpy(reg->shm_path, shm_path, sizeof(reg->shm_path));
reg->shm_path[sizeof(reg->shm_path) - 1] = '\0';
DBG3("shm path '%s' is assigned to uid buffer registry for session id %" PRIu64,
- reg->shm_path, session_id);
+ reg->shm_path,
+ session_id);
}
reg->registry->channels = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!reg->registry->channels) {
*regp = reg;
DBG3("Buffer registry per UID created id: %" PRIu64 ", ABI: %u, uid: %d, domain: %d",
- session_id, bits_per_long, uid, domain);
+ session_id,
+ bits_per_long,
+ uid,
+ domain);
return 0;
LTTNG_ASSERT(reg);
- DBG3("Buffer registry per UID adding to global registry with id: %" PRIu64 ,
- reg->session_id);
+ DBG3("Buffer registry per UID adding to global registry with id: %" PRIu64,
+ reg->session_id);
rcu_read_lock();
- nodep = cds_lfht_add_unique(ht->ht, ht->hash_fct(reg, lttng_ht_seed),
- ht->match_fct, reg, ®->node.node);
+ nodep = cds_lfht_add_unique(
+ ht->ht, ht->hash_fct(reg, lttng_ht_seed), ht->match_fct, reg, ®->node.node);
LTTNG_ASSERT(nodep == ®->node.node);
rcu_read_unlock();
}
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
- uint32_t bits_per_long, uid_t uid)
+struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id, uint32_t bits_per_long, uid_t uid)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
key.uid = uid;
DBG3("Buffer registry per UID find id: %" PRIu64 ", ABI: %u, uid: %d",
- session_id, bits_per_long, uid);
+ session_id,
+ bits_per_long,
+ uid);
/* Custom lookup function since it's a different key. */
- cds_lfht_lookup(ht->ht, ht->hash_fct(&key, lttng_ht_seed), ht->match_fct,
- &key, &iter.iter);
+ cds_lfht_lookup(ht->ht, ht->hash_fct(&key, lttng_ht_seed), ht->match_fct, &key, &iter.iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (!node) {
goto end;
*
* Return 0 on success else a negative value and regp is untouched.
*/
-int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
- const char *root_shm_path, const char *shm_path)
+int buffer_reg_pid_create(uint64_t session_id,
+ struct buffer_reg_pid **regp,
+ const char *root_shm_path,
+ const char *shm_path)
{
int ret = 0;
struct buffer_reg_pid *reg = NULL;
strncpy(reg->shm_path, shm_path, sizeof(reg->shm_path));
reg->shm_path[sizeof(reg->shm_path) - 1] = '\0';
DBG3("shm path '%s' is assigned to pid buffer registry for session id %" PRIu64,
- reg->shm_path, session_id);
+ reg->shm_path,
+ session_id);
}
reg->registry->channels = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!reg->registry->channels) {
lttng_ht_node_init_u64(®->node, reg->session_id);
*regp = reg;
- DBG3("Buffer registry per PID created with session id: %" PRIu64,
- session_id);
+ DBG3("Buffer registry per PID created with session id: %" PRIu64, session_id);
return 0;
LTTNG_ASSERT(reg);
DBG3("Buffer registry per PID adding to global registry with id: %" PRIu64,
- reg->session_id);
+ reg->session_id);
rcu_read_lock();
lttng_ht_add_unique_u64(buffer_registry_pid, ®->node);
*
* Return the matching key or -1 if not found.
*/
-int buffer_reg_uid_consumer_channel_key(
- struct cds_list_head *buffer_reg_uid_list,
- uint64_t chan_key, uint64_t *consumer_chan_key)
+int buffer_reg_uid_consumer_channel_key(struct cds_list_head *buffer_reg_uid_list,
+ uint64_t chan_key,
+ uint64_t *consumer_chan_key)
{
struct lttng_ht_iter iter;
struct buffer_reg_uid *uid_reg = NULL;
* For the per-uid registry, we have to iterate since we don't have the
* uid and bitness key.
*/
- cds_list_for_each_entry(uid_reg, buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) {
session_reg = uid_reg->registry;
- cds_lfht_for_each_entry(session_reg->channels->ht,
- &iter.iter, reg_chan, node.node) {
+ cds_lfht_for_each_entry (
+ session_reg->channels->ht, &iter.iter, reg_chan, node.node) {
if (reg_chan->key == chan_key) {
*consumer_chan_key = reg_chan->consumer_key;
ret = 0;
/*
* Add stream to the list in the channel.
*/
-void buffer_reg_stream_add(struct buffer_reg_stream *stream,
- struct buffer_reg_channel *channel)
+void buffer_reg_stream_add(struct buffer_reg_stream *stream, struct buffer_reg_channel *channel)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(channel);
/*
* Add a buffer registry channel object to the given session.
*/
-void buffer_reg_channel_add(struct buffer_reg_session *session,
- struct buffer_reg_channel *channel)
+void buffer_reg_channel_add(struct buffer_reg_session *session, struct buffer_reg_channel *channel)
{
LTTNG_ASSERT(session);
LTTNG_ASSERT(channel);
*
* Return the object pointer or NULL on error.
*/
-struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
- struct buffer_reg_uid *reg)
+struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key, struct buffer_reg_uid *reg)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
/*
* Destroy a buffer registry stream with the given domain.
*/
-void buffer_reg_stream_destroy(struct buffer_reg_stream *regp,
- enum lttng_domain_type domain)
+void buffer_reg_stream_destroy(struct buffer_reg_stream *regp, enum lttng_domain_type domain)
{
if (!regp) {
return;
}
- DBG3("Buffer registry stream destroy with handle %d",
- regp->obj.ust->handle);
+ DBG3("Buffer registry stream destroy with handle %d", regp->obj.ust->handle);
switch (domain) {
case LTTNG_DOMAIN_UST:
ret = ust_app_release_object(NULL, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg stream release obj handle %d failed with ret %d",
- regp->obj.ust->handle, ret);
+ regp->obj.ust->handle,
+ ret);
}
free(regp->obj.ust);
lttng_fd_put(LTTNG_FD_APPS, 2);
* Remove buffer registry channel object from the session hash table. RCU read
* side lock MUST be acquired before calling this.
*/
-void buffer_reg_channel_remove(struct buffer_reg_session *session,
- struct buffer_reg_channel *regp)
+void buffer_reg_channel_remove(struct buffer_reg_session *session, struct buffer_reg_channel *regp)
{
int ret;
struct lttng_ht_iter iter;
/*
* Destroy a buffer registry channel with the given domain.
*/
-void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
- enum lttng_domain_type domain)
+void buffer_reg_channel_destroy(struct buffer_reg_channel *regp, enum lttng_domain_type domain)
{
if (!regp) {
return;
int ret;
struct buffer_reg_stream *sreg, *stmp;
/* Wipe stream */
- cds_list_for_each_entry_safe(sreg, stmp, ®p->streams, lnode) {
+ cds_list_for_each_entry_safe (sreg, stmp, ®p->streams, lnode) {
cds_list_del(&sreg->lnode);
regp->stream_count--;
buffer_reg_stream_destroy(sreg, domain);
ret = ust_app_release_object(NULL, regp->obj.ust);
if (ret < 0 && ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Buffer reg channel release obj handle %d failed with ret %d",
- regp->obj.ust->handle, ret);
+ regp->obj.ust->handle,
+ ret);
}
free(regp->obj.ust);
}
* Destroy a buffer registry session with the given domain.
*/
static void buffer_reg_session_destroy(struct buffer_reg_session *regp,
- enum lttng_domain_type domain)
+ enum lttng_domain_type domain)
{
int ret;
struct lttng_ht_iter iter;
/* Destroy all channels. */
rcu_read_lock();
- cds_lfht_for_each_entry(regp->channels->ht, &iter.iter, reg_chan,
- node.node) {
+ cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) {
ret = lttng_ht_del(regp->channels, &iter);
LTTNG_ASSERT(!ret);
buffer_reg_channel_destroy(reg_chan, domain);
static void rcu_free_buffer_reg_uid(struct rcu_head *head)
{
- struct lttng_ht_node_u64 *node =
- lttng::utils::container_of(head, <tng_ht_node_u64::head);
- struct buffer_reg_uid *reg =
- lttng::utils::container_of(node, &buffer_reg_uid::node);
+ struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head);
+ struct buffer_reg_uid *reg = lttng::utils::container_of(node, &buffer_reg_uid::node);
buffer_reg_session_destroy(reg->registry, reg->domain);
free(reg);
static void rcu_free_buffer_reg_pid(struct rcu_head *head)
{
- struct lttng_ht_node_u64 *node =
- lttng::utils::container_of(head, <tng_ht_node_u64::head);
- struct buffer_reg_pid *reg =
- lttng::utils::container_of(node, &buffer_reg_pid::node);
+ struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head);
+ struct buffer_reg_pid *reg = lttng::utils::container_of(node, &buffer_reg_pid::node);
buffer_reg_session_destroy(reg->registry, LTTNG_DOMAIN_UST);
free(reg);
* list or hash table. Use buffer_reg_pid_remove() before calling this function
* for the case that the object is in the global hash table.
*/
-void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
- struct consumer_output *consumer)
+void buffer_reg_uid_destroy(struct buffer_reg_uid *regp, struct consumer_output *consumer)
{
struct consumer_socket *socket;
}
DBG3("Buffer registry per UID destroy with id: %" PRIu64 ", ABI: %u, uid: %d",
- regp->session_id, regp->bits_per_long, regp->uid);
+ regp->session_id,
+ regp->bits_per_long,
+ regp->uid);
if (!consumer) {
goto destroy;
rcu_read_lock();
/* Get the right socket from the consumer object. */
- socket = consumer_find_socket_by_bitness(regp->bits_per_long,
- consumer);
+ socket = consumer_find_socket_by_bitness(regp->bits_per_long, consumer);
if (!socket) {
goto unlock;
}
if (regp->registry->reg.ust->_metadata_key) {
/* Return value does not matter. This call will print errors. */
(void) consumer_close_metadata(socket,
- regp->registry->reg.ust->_metadata_key);
+ regp->registry->reg.ust->_metadata_key);
}
break;
default:
return;
}
- DBG3("Buffer registry per PID destroy with id: %" PRIu64,
- regp->session_id);
+ DBG3("Buffer registry per PID destroy with id: %" PRIu64, regp->session_id);
/* This registry is only used by UST. */
call_rcu(®p->node.head, rcu_free_buffer_reg_pid);
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <common/common.hpp>
-#include <common/defaults.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-
+#include "agent.hpp"
#include "channel.hpp"
-#include "lttng-sessiond.hpp"
#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
#include "lttng-ust-ctl.hpp"
#include "lttng-ust-error.hpp"
-#include "utils.hpp"
#include "ust-app.hpp"
-#include "agent.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
/*
* Return allocated channel attributes.
*/
-struct lttng_channel *channel_new_default_attr(int dom,
- enum lttng_buffer_type type)
+struct lttng_channel *channel_new_default_attr(int dom, enum lttng_buffer_type type)
{
struct lttng_channel *chan;
const char *channel_name = DEFAULT_CHANNEL_NAME;
switch (dom) {
case LTTNG_DOMAIN_KERNEL:
LTTNG_ASSERT(type == LTTNG_BUFFER_GLOBAL);
- chan->attr.subbuf_size =
- default_get_kernel_channel_subbuf_size();
+ chan->attr.subbuf_size = default_get_kernel_channel_subbuf_size();
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;
- extended_attr->monitor_timer_interval =
- DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
+ extended_attr->monitor_timer_interval = DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
break;
case LTTNG_DOMAIN_JUL:
channel_name = DEFAULT_JUL_CHANNEL_NAME;
channel_name = DEFAULT_PYTHON_CHANNEL_NAME;
goto common_ust;
case LTTNG_DOMAIN_UST:
-common_ust:
+ common_ust:
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;
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;
}
break;
default:
- goto error; /* Not implemented */
+ goto error; /* Not implemented */
}
- if (snprintf(chan->name, sizeof(chan->name), "%s",
- channel_name) < 0) {
+ if (snprintf(chan->name, sizeof(chan->name), "%s", channel_name) < 0) {
PERROR("snprintf default channel name");
goto error;
}
/*
* Disable kernel channel of the kernel session.
*/
-int channel_kernel_disable(struct ltt_kernel_session *ksession,
- char *channel_name)
+int channel_kernel_disable(struct ltt_kernel_session *ksession, char *channel_name)
{
int ret;
struct ltt_kernel_channel *kchan;
* Enable kernel channel of the kernel session.
*/
enum lttng_error_code channel_kernel_enable(struct ltt_kernel_session *ksession,
- struct ltt_kernel_channel *kchan)
+ struct ltt_kernel_channel *kchan)
{
enum lttng_error_code ret_code;
static int channel_validate_kernel(struct lttng_channel *attr)
{
/* Kernel channels do not support blocking timeout. */
- if (((struct lttng_channel_extended *)attr->attr.extended.ptr)->blocking_timeout) {
+ if (((struct lttng_channel_extended *) attr->attr.extended.ptr)->blocking_timeout) {
return -1;
}
return 0;
* Create kernel channel of the kernel session and notify kernel thread.
*/
enum lttng_error_code channel_kernel_create(struct ltt_kernel_session *ksession,
- struct lttng_channel *attr, int kernel_pipe)
+ struct lttng_channel *attr,
+ int kernel_pipe)
{
enum lttng_error_code ret_code;
struct lttng_channel *defattr = NULL;
/* Creating channel attributes if needed */
if (attr == NULL) {
- defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL,
- LTTNG_BUFFER_GLOBAL);
+ defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
if (defattr == NULL) {
ret_code = LTTNG_ERR_FATAL;
goto error;
* Enable UST channel for session and domain.
*/
enum lttng_error_code channel_ust_enable(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+ struct ltt_ust_channel *uchan)
{
enum lttng_error_code ret_code = LTTNG_OK;
*/
(void) ust_app_enable_channel_glb(usess, uchan);
-
end:
return ret_code;
}
* Create UST channel for session and domain.
*/
enum lttng_error_code channel_ust_create(struct ltt_ust_session *usess,
- struct lttng_channel *attr, enum lttng_buffer_type type)
+ struct lttng_channel *attr,
+ enum lttng_buffer_type type)
{
enum lttng_error_code ret_code = LTTNG_OK;
struct ltt_ust_channel *uchan = NULL;
* 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))) {
+ if (!attr->attr.subbuf_size || (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
ret_code = LTTNG_ERR_INVALID;
goto error;
}
goto error;
}
- if (!attr->attr.num_subbuf ||
- (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
+ if (!attr->attr.num_subbuf || (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
ret_code = LTTNG_ERR_INVALID;
goto error;
}
* we won't be able to write the packets on disk
*/
if ((attr->attr.tracefile_size > 0) &&
- (attr->attr.tracefile_size < attr->attr.subbuf_size)) {
+ (attr->attr.tracefile_size < attr->attr.subbuf_size)) {
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,
- uchan->name, type, uchan->id);
+ uchan->name,
+ type,
+ uchan->id);
/* Flag session buffer type. */
if (!usess->buffer_type_changed) {
/* Adding the channel to the channel hash table. */
rcu_read_lock();
- if (strncmp(uchan->name, DEFAULT_METADATA_NAME,
- sizeof(uchan->name))) {
+ if (strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) {
lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
chan_published = true;
} else {
* 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));
}
rcu_read_unlock();
/*
* Disable UST channel for session and domain.
*/
-int channel_ust_disable(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+int channel_ust_disable(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
{
int ret = LTTNG_OK;
return ret;
}
-struct lttng_channel *trace_ust_channel_to_lttng_channel(
- const struct ltt_ust_channel *uchan)
+struct lttng_channel *trace_ust_channel_to_lttng_channel(const struct ltt_ust_channel *uchan)
{
struct lttng_channel *channel = NULL, *ret = NULL;
break;
}
- 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);
ret = channel;
channel = NULL;
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <string.h>
-#include <unistd.h>
+#include "clear.hpp"
+#include "cmd.hpp"
+#include "kernel.hpp"
+#include "session.hpp"
+#include "ust-app.hpp"
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/utils.hpp>
-#include "clear.hpp"
-#include "session.hpp"
-#include "ust-app.hpp"
-#include "kernel.hpp"
-#include "cmd.hpp"
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
namespace {
struct cmd_clear_session_reply_context {
};
} /* namespace */
-static
-void cmd_clear_session_reply(const struct ltt_session *session,
- void *_reply_context)
+static void cmd_clear_session_reply(const struct ltt_session *session, void *_reply_context)
{
int ret;
ssize_t comm_ret;
const struct cmd_clear_session_reply_context *reply_context =
- (cmd_clear_session_reply_context *) _reply_context;
+ (cmd_clear_session_reply_context *) _reply_context;
struct lttcomm_lttng_msg llm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_CLEAR_SESSION,
.ret_code = LTTNG_OK,
};
DBG("End of clear command: replying to client");
- comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd,
- &llm, sizeof(llm));
+ comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd, &llm, sizeof(llm));
if (comm_ret != (ssize_t) sizeof(llm)) {
- ERR("Failed to send result of session \"%s\" clear to client",
- session->name);
+ ERR("Failed to send result of session \"%s\" clear to client", session->name);
}
ret = close(reply_context->reply_sock_fd);
if (ret) {
}
if (!session->has_been_started) {
- /*
- * Nothing to be cleared, this is not an error: there is
- * indeed nothing to do, and there is no reason why we
- * should return an error to the user.
- */
- goto end;
+ /*
+ * Nothing to be cleared, this is not an error: there is
+ * indeed nothing to do, and there is no reason why we
+ * should return an error to the user.
+ */
+ goto end;
}
/* Unsupported feature in lttng-relayd before 2.11. */
if (session->consumer->type == CONSUMER_DST_NET &&
- (session->consumer->relay_major_version == 2 &&
- session->consumer->relay_minor_version < 12)) {
+ (session->consumer->relay_major_version == 2 &&
+ session->consumer->relay_minor_version < 12)) {
ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY;
goto end;
}
- if (session->consumer->type == CONSUMER_DST_NET &&
- !session->consumer->relay_allows_clear) {
+ if (session->consumer->type == CONSUMER_DST_NET && !session->consumer->relay_allows_clear) {
ret = LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY;
goto end;
}
* Use rotation to delete local and remote stream files.
*/
if (reply_context) {
- ret = session_add_clear_notifier(session,
- cmd_clear_session_reply,
- (void *) reply_context);
+ ret = session_add_clear_notifier(
+ session, cmd_clear_session_reply, (void *) reply_context);
if (ret) {
ret = LTTNG_ERR_FATAL;
goto end;
reply_context = NULL;
*sock_fd = -1;
}
- ret = cmd_rotate_session(session, NULL, true,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
+ ret = cmd_rotate_session(
+ session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE);
if (ret != LTTNG_OK) {
goto end;
}
if (session_was_active) {
/* Kernel tracing */
if (ksession != NULL) {
- DBG("Start kernel tracing session \"%s\"",
- session->name);
+ DBG("Start kernel tracing session \"%s\"", session->name);
ret = start_kernel_session(ksession);
if (ret != LTTNG_OK) {
goto end;
*
*/
+#include "agent-thread.hpp"
+#include "clear.hpp"
+#include "client.hpp"
+#include "cmd.hpp"
#include "common/buffer-view.hpp"
#include "common/compat/socket.hpp"
#include "common/dynamic-array.hpp"
#include "common/payload-view.hpp"
#include "common/payload.hpp"
#include "common/sessiond-comm/sessiond-comm.hpp"
+#include "health-sessiond.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
#include "lttng/lttng-error.h"
#include "lttng/tracker.h"
+#include "manage-consumer.hpp"
+#include "save.hpp"
+#include "testpoint.hpp"
+#include "utils.hpp"
+
#include <common/compat/getenv.hpp>
#include <common/tracker.hpp>
#include <common/unix.hpp>
#include <common/utils.hpp>
+
#include <lttng/error-query-internal.hpp>
#include <lttng/event-internal.hpp>
#include <lttng/session-descriptor-internal.hpp>
#include <lttng/session-internal.hpp>
#include <lttng/userspace-probe-internal.hpp>
+
#include <pthread.h>
#include <signal.h>
#include <stddef.h>
#include <sys/stat.h>
#include <unistd.h>
-#include "agent-thread.hpp"
-#include "clear.hpp"
-#include "client.hpp"
-#include "cmd.hpp"
-#include "health-sessiond.hpp"
-#include "kernel.hpp"
-#include "lttng-sessiond.hpp"
-#include "manage-consumer.hpp"
-#include "save.hpp"
-#include "testpoint.hpp"
-#include "utils.hpp"
-
namespace {
bool is_root;
* Return 0 on success, negative value on error.
*/
static int setup_lttng_msg(struct command_ctx *cmd_ctx,
- const void *payload_buf, size_t payload_len,
- const void *cmd_header_buf, size_t cmd_header_len)
+ const void *payload_buf,
+ size_t payload_len,
+ const void *cmd_header_buf,
+ size_t cmd_header_len)
{
int ret = 0;
const size_t header_len = sizeof(struct lttcomm_lttng_msg);
const size_t total_msg_size = header_len + cmd_header_len + payload_len;
- lttcomm_lttng_msg llm {};
+ lttcomm_lttng_msg llm{};
llm.cmd_type = cmd_ctx->lsm.cmd_type;
llm.pid = (uint32_t) cmd_ctx->lsm.domain.attr.pid;
cmd_ctx->lttng_msg_size = total_msg_size;
/* Append reply header. */
- ret = lttng_dynamic_buffer_append(
- &cmd_ctx->reply_payload.buffer, &llm, sizeof(llm));
+ ret = lttng_dynamic_buffer_append(&cmd_ctx->reply_payload.buffer, &llm, sizeof(llm));
if (ret) {
goto end;
}
/* Append command header. */
if (cmd_header_len) {
ret = lttng_dynamic_buffer_append(
- &cmd_ctx->reply_payload.buffer, cmd_header_buf,
- cmd_header_len);
+ &cmd_ctx->reply_payload.buffer, cmd_header_buf, cmd_header_len);
if (ret) {
goto end;
}
/* Append payload. */
if (payload_len) {
ret = lttng_dynamic_buffer_append(
- &cmd_ctx->reply_payload.buffer, payload_buf,
- payload_len);
+ &cmd_ctx->reply_payload.buffer, payload_buf, payload_len);
if (ret) {
goto end;
}
}
/* Append place-holder reply header. */
- ret = lttng_dynamic_buffer_append(
- &cmd_ctx->reply_payload.buffer, &llm, sizeof(llm));
+ ret = lttng_dynamic_buffer_append(&cmd_ctx->reply_payload.buffer, &llm, sizeof(llm));
if (ret) {
goto end;
}
return ret;
}
-static void update_lttng_msg(struct command_ctx *cmd_ctx, size_t cmd_header_len,
- size_t payload_len)
+static void update_lttng_msg(struct command_ctx *cmd_ctx, size_t cmd_header_len, size_t payload_len)
{
const size_t header_len = sizeof(struct lttcomm_lttng_msg);
const size_t total_msg_size = header_len + cmd_header_len + payload_len;
struct lttcomm_lttng_msg *p_llm;
- lttcomm_lttng_msg llm {};
+ lttcomm_lttng_msg llm{};
llm.cmd_type = cmd_ctx->lsm.cmd_type;
llm.pid = (uint32_t) cmd_ctx->lsm.domain.attr.pid;
* fallback on the 32-bit one,
*/
DBG3("Looking for a kernel consumer at these locations:");
- DBG3(" 1) %s", the_config.consumerd64_bin_path.value ? : "NULL");
+ DBG3(" 1) %s", the_config.consumerd64_bin_path.value ?: "NULL");
DBG3(" 2) %s/%s", INSTALL_BIN_PATH, DEFAULT_CONSUMERD_FILE);
- DBG3(" 3) %s", the_config.consumerd32_bin_path.value ? : "NULL");
+ DBG3(" 3) %s", the_config.consumerd32_bin_path.value ?: "NULL");
if (stat(the_config.consumerd64_bin_path.value, &st) == 0) {
DBG3("Found location #1");
consumer_to_use = the_config.consumerd64_bin_path.value;
DBG3("Found location #2");
consumer_to_use = INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE;
} else if (the_config.consumerd32_bin_path.value &&
- stat(the_config.consumerd32_bin_path.value, &st) == 0) {
+ stat(the_config.consumerd32_bin_path.value, &st) == 0) {
DBG3("Found location #3");
consumer_to_use = the_config.consumerd32_bin_path.value;
} else {
ret = -EINVAL;
goto error;
}
- DBG("Using kernel consumer at: %s", consumer_to_use);
- (void) execl(consumer_to_use, "lttng-consumerd",
- verbosity, "-k", "--consumerd-cmd-sock",
- consumer_data->cmd_unix_sock_path,
- "--consumerd-err-sock",
- consumer_data->err_unix_sock_path,
- "--group",
- the_config.tracing_group_name.value,
- NULL);
+ DBG("Using kernel consumer at: %s", consumer_to_use);
+ (void) execl(consumer_to_use,
+ "lttng-consumerd",
+ verbosity,
+ "-k",
+ "--consumerd-cmd-sock",
+ consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock",
+ consumer_data->err_unix_sock_path,
+ "--group",
+ the_config.tracing_group_name.value,
+ NULL);
break;
case LTTNG_CONSUMER64_UST:
{
if (!tmp) {
tmp = "";
}
- tmplen = strlen(the_config.consumerd64_lib_dir.value) + 1 /* : */ + strlen(tmp);
+ tmplen = strlen(the_config.consumerd64_lib_dir.value) + 1 /* : */ +
+ strlen(tmp);
tmpnew = zmalloc<char>(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
}
}
DBG("Using 64-bit UST consumer at: %s",
- the_config.consumerd64_bin_path.value);
+ the_config.consumerd64_bin_path.value);
(void) execl(the_config.consumerd64_bin_path.value,
- "lttng-consumerd", verbosity, "-u",
- "--consumerd-cmd-sock",
- consumer_data->cmd_unix_sock_path,
- "--consumerd-err-sock",
- consumer_data->err_unix_sock_path,
- "--group",
- the_config.tracing_group_name.value,
- NULL);
+ "lttng-consumerd",
+ verbosity,
+ "-u",
+ "--consumerd-cmd-sock",
+ consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock",
+ consumer_data->err_unix_sock_path,
+ "--group",
+ the_config.tracing_group_name.value,
+ NULL);
break;
}
case LTTNG_CONSUMER32_UST:
if (!tmp) {
tmp = "";
}
- tmplen = strlen(the_config.consumerd32_lib_dir.value) + 1 /* : */ + strlen(tmp);
+ tmplen = strlen(the_config.consumerd32_lib_dir.value) + 1 /* : */ +
+ strlen(tmp);
tmpnew = zmalloc<char>(tmplen + 1 /* \0 */);
if (!tmpnew) {
ret = -ENOMEM;
}
}
DBG("Using 32-bit UST consumer at: %s",
- the_config.consumerd32_bin_path.value);
+ the_config.consumerd32_bin_path.value);
(void) execl(the_config.consumerd32_bin_path.value,
- "lttng-consumerd", verbosity, "-u",
- "--consumerd-cmd-sock",
- consumer_data->cmd_unix_sock_path,
- "--consumerd-err-sock",
- consumer_data->err_unix_sock_path,
- "--group",
- the_config.tracing_group_name.value,
- NULL);
+ "lttng-consumerd",
+ verbosity,
+ "-u",
+ "--consumerd-cmd-sock",
+ consumer_data->cmd_unix_sock_path,
+ "--consumerd-err-sock",
+ consumer_data->err_unix_sock_path,
+ "--group",
+ the_config.tracing_group_name.value,
+ NULL);
break;
}
default:
if (session->kernel_session->consumer) {
consumer_output_put(session->kernel_session->consumer);
}
- session->kernel_session->consumer =
- consumer_copy_output(session->consumer);
+ session->kernel_session->consumer = consumer_copy_output(session->consumer);
/* Ease our life a bit for the next part */
consumer = session->kernel_session->consumer;
dir_name = DEFAULT_KERNEL_TRACE_DIR;
if (session->ust_session->consumer) {
consumer_output_put(session->ust_session->consumer);
}
- session->ust_session->consumer =
- consumer_copy_output(session->consumer);
+ session->ust_session->consumer = consumer_copy_output(session->consumer);
/* Ease our life a bit for the next part */
consumer = session->ust_session->consumer;
dir_name = DEFAULT_UST_TRACE_DIR;
}
/* Append correct directory to subdir */
- ret = lttng_strncpy(consumer->domain_subdir, dir_name,
- sizeof(consumer->domain_subdir));
+ ret = lttng_strncpy(consumer->domain_subdir, dir_name, sizeof(consumer->domain_subdir));
if (ret) {
ret = LTTNG_ERR_UNK;
goto error;
/*
* Create an UST session and add it to the session ust list.
*/
-static int create_ust_session(struct ltt_session *session,
- const struct lttng_domain *domain)
+static int create_ust_session(struct ltt_session *session, const struct lttng_domain *domain)
{
int ret;
struct ltt_ust_session *lus = NULL;
lus->live_timer_interval = session->live_timer;
session->ust_session = lus;
if (session->shm_path[0]) {
- strncpy(lus->root_shm_path, session->shm_path,
- sizeof(lus->root_shm_path));
+ strncpy(lus->root_shm_path, session->shm_path, sizeof(lus->root_shm_path));
lus->root_shm_path[sizeof(lus->root_shm_path) - 1] = '\0';
- strncpy(lus->shm_path, session->shm_path,
- sizeof(lus->shm_path));
+ strncpy(lus->shm_path, session->shm_path, sizeof(lus->shm_path));
lus->shm_path[sizeof(lus->shm_path) - 1] = '\0';
- strncat(lus->shm_path, "/ust",
- sizeof(lus->shm_path) - strlen(lus->shm_path) - 1);
+ strncat(lus->shm_path, "/ust", sizeof(lus->shm_path) - strlen(lus->shm_path) - 1);
}
/* Copy session output to the newly created UST session */
ret = copy_session_consumer(domain->type, session);
/*
* Count number of session permitted by uid/gid.
*/
-static unsigned int lttng_sessions_count(uid_t uid,
- gid_t gid __attribute__((unused)))
+static unsigned int lttng_sessions_count(uid_t uid, gid_t gid __attribute__((unused)))
{
unsigned int i = 0;
struct ltt_session *session;
const struct ltt_session_list *session_list = session_get_list();
DBG("Counting number of available session for UID %d", uid);
- cds_list_for_each_entry(session, &session_list->head, list) {
+ cds_list_for_each_entry (session, &session_list->head, list) {
if (!session_get(session)) {
continue;
}
session_lock(session);
/* Only count the sessions the user can control. */
- if (session_access_ok(session, uid) &&
- !session->destroyed) {
+ if (session_access_ok(session, uid) && !session->destroyed) {
i++;
}
session_unlock(session);
}
static enum lttng_error_code receive_lttng_trigger(struct command_ctx *cmd_ctx,
- int sock,
- int *sock_error,
- struct lttng_trigger **_trigger)
+ int sock,
+ int *sock_error,
+ struct lttng_trigger **_trigger)
{
int ret;
size_t trigger_len;
lttng_payload_init(&trigger_payload);
trigger_len = (size_t) cmd_ctx->lsm.u.trigger.length;
- ret = lttng_dynamic_buffer_set_size(
- &trigger_payload.buffer, trigger_len);
+ ret = lttng_dynamic_buffer_set_size(&trigger_payload.buffer, trigger_len);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
- sock_recv_len = lttcomm_recv_unix_sock(
- sock, trigger_payload.buffer.data, trigger_len);
+ sock_recv_len = lttcomm_recv_unix_sock(sock, trigger_payload.buffer.data, trigger_len);
if (sock_recv_len < 0 || sock_recv_len != trigger_len) {
ERR("Failed to receive trigger in command payload");
*sock_error = 1;
/* Receive fds, if any. */
if (cmd_ctx->lsm.fd_count > 0) {
sock_recv_len = lttcomm_recv_payload_fds_unix_sock(
- sock, cmd_ctx->lsm.fd_count, &trigger_payload);
- if (sock_recv_len > 0 &&
- sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
+ sock, cmd_ctx->lsm.fd_count, &trigger_payload);
+ if (sock_recv_len > 0 && sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
ERR("Failed to receive all file descriptors for trigger in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
*sock_error = 1;
goto end;
} else if (sock_recv_len <= 0) {
ERR("Failed to receive file descriptors for trigger in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_FATAL;
*sock_error = 1;
goto end;
/* Deserialize trigger. */
{
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &trigger_payload, 0, -1);
+ lttng_payload_view_from_payload(&trigger_payload, 0, -1);
- if (lttng_trigger_create_from_payload(&view, &trigger) !=
- trigger_len) {
+ if (lttng_trigger_create_from_payload(&view, &trigger) != trigger_len) {
ERR("Invalid trigger received as part of command payload");
ret_code = LTTNG_ERR_INVALID_TRIGGER;
lttng_trigger_put(trigger);
}
static enum lttng_error_code receive_lttng_error_query(struct command_ctx *cmd_ctx,
- int sock,
- int *sock_error,
- struct lttng_error_query **_query)
+ int sock,
+ int *sock_error,
+ struct lttng_error_query **_query)
{
int ret;
size_t query_len;
goto end;
}
- sock_recv_len = lttcomm_recv_unix_sock(
- sock, query_payload.buffer.data, query_len);
+ sock_recv_len = lttcomm_recv_unix_sock(sock, query_payload.buffer.data, query_len);
if (sock_recv_len < 0 || sock_recv_len != query_len) {
ERR("Failed to receive error query in command payload");
*sock_error = 1;
/* Receive fds, if any. */
if (cmd_ctx->lsm.fd_count > 0) {
sock_recv_len = lttcomm_recv_payload_fds_unix_sock(
- sock, cmd_ctx->lsm.fd_count, &query_payload);
- if (sock_recv_len > 0 &&
- sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
+ sock, cmd_ctx->lsm.fd_count, &query_payload);
+ if (sock_recv_len > 0 && sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
ERR("Failed to receive all file descriptors for error query in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
*sock_error = 1;
goto end;
} else if (sock_recv_len <= 0) {
ERR("Failed to receive file descriptors for error query in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_FATAL;
*sock_error = 1;
goto end;
/* Deserialize error query. */
{
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &query_payload, 0, -1);
+ lttng_payload_view_from_payload(&query_payload, 0, -1);
- if (lttng_error_query_create_from_payload(&view, &query) !=
- query_len) {
+ if (lttng_error_query_create_from_payload(&view, &query) != query_len) {
ERR("Invalid error query received as part of command payload");
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto end;
}
static enum lttng_error_code receive_lttng_event(struct command_ctx *cmd_ctx,
- int sock,
- int *sock_error,
- struct lttng_event **out_event,
- char **out_filter_expression,
- struct lttng_bytecode **out_bytecode,
- struct lttng_event_exclusion **out_exclusion)
+ int sock,
+ int *sock_error,
+ struct lttng_event **out_event,
+ char **out_filter_expression,
+ struct lttng_bytecode **out_bytecode,
+ struct lttng_event_exclusion **out_exclusion)
{
int ret;
size_t event_len;
goto end;
}
- sock_recv_len = lttcomm_recv_unix_sock(
- sock, event_payload.buffer.data, event_len);
+ sock_recv_len = lttcomm_recv_unix_sock(sock, event_payload.buffer.data, event_len);
if (sock_recv_len < 0 || sock_recv_len != event_len) {
ERR("Failed to receive event in command payload");
*sock_error = 1;
/* Receive fds, if any. */
if (cmd_ctx->lsm.fd_count > 0) {
sock_recv_len = lttcomm_recv_payload_fds_unix_sock(
- sock, cmd_ctx->lsm.fd_count, &event_payload);
- if (sock_recv_len > 0 &&
- sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
+ sock, cmd_ctx->lsm.fd_count, &event_payload);
+ if (sock_recv_len > 0 && sock_recv_len != cmd_ctx->lsm.fd_count * sizeof(int)) {
ERR("Failed to receive all file descriptors for event in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
*sock_error = 1;
goto end;
} else if (sock_recv_len <= 0) {
ERR("Failed to receive file descriptors for event in command payload: expected fd count = %u, ret = %d",
- cmd_ctx->lsm.fd_count, (int) ret);
+ cmd_ctx->lsm.fd_count,
+ (int) ret);
ret_code = LTTNG_ERR_FATAL;
*sock_error = 1;
goto end;
{
ssize_t len;
struct lttng_payload_view event_view =
- lttng_payload_view_from_payload(
- &event_payload, 0, -1);
+ lttng_payload_view_from_payload(&event_payload, 0, -1);
- len = lttng_event_create_from_payload(&event_view, &local_event,
- &local_exclusion, &local_filter_expression,
- &local_bytecode);
+ len = lttng_event_create_from_payload(&event_view,
+ &local_event,
+ &local_exclusion,
+ &local_filter_expression,
+ &local_bytecode);
if (len < 0) {
ERR("Failed to create an event from the received buffer");
}
if (len != event_len) {
- ERR("Userspace probe location from the received buffer is not the advertised length: header length = %zu" PRIu32 ", payload length = %zd", event_len, len);
+ ERR("Userspace probe location from the received buffer is not the advertised length: header length = %zu" PRIu32
+ ", payload length = %zd",
+ event_len,
+ len);
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto end;
}
return ret_code;
}
-static enum lttng_error_code receive_lttng_event_context(
- const struct command_ctx *cmd_ctx,
- int sock,
- int *sock_error,
- struct lttng_event_context **out_event_context)
+static enum lttng_error_code
+receive_lttng_event_context(const struct command_ctx *cmd_ctx,
+ int sock,
+ int *sock_error,
+ struct lttng_event_context **out_event_context)
{
int ret;
- const size_t event_context_len =
- (size_t) cmd_ctx->lsm.u.context.length;
+ const size_t event_context_len = (size_t) cmd_ctx->lsm.u.context.length;
ssize_t sock_recv_len;
enum lttng_error_code ret_code;
struct lttng_payload event_context_payload;
lttng_payload_init(&event_context_payload);
- ret = lttng_dynamic_buffer_set_size(&event_context_payload.buffer,
- event_context_len);
+ ret = lttng_dynamic_buffer_set_size(&event_context_payload.buffer, event_context_len);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
- sock_recv_len = lttcomm_recv_unix_sock(
- sock, event_context_payload.buffer.data,
- event_context_len);
+ sock_recv_len =
+ lttcomm_recv_unix_sock(sock, event_context_payload.buffer.data, event_context_len);
if (sock_recv_len < 0 || sock_recv_len != event_context_len) {
ERR("Failed to receive event context in command payload");
*sock_error = 1;
{
ssize_t len;
struct lttng_payload_view event_context_view =
- lttng_payload_view_from_payload(
- &event_context_payload, 0, -1);
+ lttng_payload_view_from_payload(&event_context_payload, 0, -1);
- len = lttng_event_context_create_from_payload(
- &event_context_view, &context);
+ len = lttng_event_context_create_from_payload(&event_context_view, &context);
if (len < 0) {
ERR("Failed to create a event context from the received buffer");
}
if (len != event_context_len) {
- ERR("Event context from the received buffer is not the advertised length: expected length = %zu, payload length = %zd", event_context_len, len);
+ ERR("Event context from the received buffer is not the advertised length: expected length = %zu, payload length = %zd",
+ event_context_len,
+ len);
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto end;
}
/*
* Version of setup_lttng_msg() without command header.
*/
-static int setup_lttng_msg_no_cmd_header(struct command_ctx *cmd_ctx,
- void *payload_buf, size_t payload_len)
+static int
+setup_lttng_msg_no_cmd_header(struct command_ctx *cmd_ctx, void *payload_buf, size_t payload_len)
{
return setup_lttng_msg(cmd_ctx, payload_buf, payload_len, NULL, 0);
}
{
int ret = 1;
- if (the_kernel_tracer_version.major != 2 ||
- the_kernel_tracer_version.minor < 11) {
+ if (the_kernel_tracer_version.major != 2 || the_kernel_tracer_version.minor < 11) {
DBG("Kernel tracer version is not compatible with the rotation feature");
ret = 0;
}
goto end;
}
- ret = lttcomm_send_unix_sock(
- sock, view->buffer.data, view->buffer.size);
+ ret = lttcomm_send_unix_sock(sock, view->buffer.data, view->buffer.size);
if (ret < 0) {
goto end;
}
* A command may assume the ownership of the socket, in which case its value
* should be set to -1.
*/
-static int process_client_msg(struct command_ctx *cmd_ctx, int *sock,
- int *sock_error)
+static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, int *sock_error)
{
int ret = LTTNG_OK;
bool need_tracing_session = true;
if (!lttcomm_sessiond_command_is_valid((lttcomm_sessiond_command) cmd_ctx->lsm.cmd_type)) {
ERR("Unknown client command received: command id = %" PRIu32,
- cmd_ctx->lsm.cmd_type);
+ cmd_ctx->lsm.cmd_type);
ret = LTTNG_ERR_UND;
goto error;
}
DBG("Processing client command '%s\' (%d)",
- lttcomm_sessiond_command_str((lttcomm_sessiond_command) cmd_ctx->lsm.cmd_type),
- cmd_ctx->lsm.cmd_type);
+ lttcomm_sessiond_command_str((lttcomm_sessiond_command) cmd_ctx->lsm.cmd_type),
+ cmd_ctx->lsm.cmd_type);
*sock_error = 0;
}
if (the_config.no_kernel && need_domain &&
- cmd_ctx->lsm.domain.type == LTTNG_DOMAIN_KERNEL) {
+ cmd_ctx->lsm.domain.type == LTTNG_DOMAIN_KERNEL) {
if (!is_root) {
ret = LTTNG_ERR_NEED_ROOT_SESSIOND;
} else {
* this here so we don't have to make the call for no payload at each
* command.
*/
- switch(cmd_ctx->lsm.cmd_type) {
+ switch (cmd_ctx->lsm.cmd_type) {
case LTTCOMM_SESSIOND_COMMAND_LIST_SESSIONS:
case LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINTS:
case LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINT_FIELDS:
}
/* Consumer is in an ERROR state. Report back to client */
- if (need_consumerd && uatomic_read(&the_kernel_consumerd_state) ==
- CONSUMER_ERROR) {
+ if (need_consumerd && uatomic_read(&the_kernel_consumerd_state) == CONSUMER_ERROR) {
ret = LTTNG_ERR_NO_KERNCONSUMERD;
goto error;
}
/* Start the kernel consumer daemon */
pthread_mutex_lock(&the_kconsumer_data.pid_mutex);
if (the_kconsumer_data.pid == 0 &&
- cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
+ cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
pthread_mutex_unlock(&the_kconsumer_data.pid_mutex);
ret = start_consumerd(&the_kconsumer_data);
if (ret < 0) {
* the consumer output of the session if exist.
*/
ret = consumer_create_socket(&the_kconsumer_data,
- cmd_ctx->session->kernel_session->consumer);
+ cmd_ctx->session->kernel_session->consumer);
if (ret < 0) {
goto error;
}
}
/* Consumer is in an ERROR state. Report back to client */
- if (need_consumerd &&
- uatomic_read(&the_ust_consumerd_state) ==
- CONSUMER_ERROR) {
+ if (need_consumerd && uatomic_read(&the_ust_consumerd_state) == CONSUMER_ERROR) {
ret = LTTNG_ERR_NO_USTCONSUMERD;
goto error;
}
/* 64-bit */
pthread_mutex_lock(&the_ustconsumer64_data.pid_mutex);
if (the_config.consumerd64_bin_path.value &&
- the_ustconsumer64_data.pid == 0 &&
- cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
+ the_ustconsumer64_data.pid == 0 &&
+ cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
pthread_mutex_unlock(&the_ustconsumer64_data.pid_mutex);
ret = start_consumerd(&the_ustconsumer64_data);
if (ret < 0) {
goto error;
}
- uatomic_set(&the_ust_consumerd64_fd, the_ustconsumer64_data.cmd_sock);
+ uatomic_set(&the_ust_consumerd64_fd,
+ the_ustconsumer64_data.cmd_sock);
uatomic_set(&the_ust_consumerd_state, CONSUMER_STARTED);
} else {
pthread_mutex_unlock(&the_ustconsumer64_data.pid_mutex);
* since it was set above and can ONLY be set in this thread.
*/
ret = consumer_create_socket(&the_ustconsumer64_data,
- cmd_ctx->session->ust_session->consumer);
+ cmd_ctx->session->ust_session->consumer);
if (ret < 0) {
goto error;
}
/* 32-bit */
pthread_mutex_lock(&the_ustconsumer32_data.pid_mutex);
if (the_config.consumerd32_bin_path.value &&
- the_ustconsumer32_data.pid == 0 &&
- cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
+ the_ustconsumer32_data.pid == 0 &&
+ cmd_ctx->lsm.cmd_type != LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER) {
pthread_mutex_unlock(&the_ustconsumer32_data.pid_mutex);
ret = start_consumerd(&the_ustconsumer32_data);
if (ret < 0) {
goto error;
}
- uatomic_set(&the_ust_consumerd32_fd, the_ustconsumer32_data.cmd_sock);
+ uatomic_set(&the_ust_consumerd32_fd,
+ the_ustconsumer32_data.cmd_sock);
uatomic_set(&the_ust_consumerd_state, CONSUMER_STARTED);
} else {
pthread_mutex_unlock(&the_ustconsumer32_data.pid_mutex);
* since it was set above and can ONLY be set in this thread.
*/
ret = consumer_create_socket(&the_ustconsumer32_data,
- cmd_ctx->session->ust_session->consumer);
+ cmd_ctx->session->ust_session->consumer);
if (ret < 0) {
goto error;
}
/* Validate consumer daemon state when start/stop trace command */
if (cmd_ctx->lsm.cmd_type == LTTCOMM_SESSIOND_COMMAND_START_TRACE ||
- cmd_ctx->lsm.cmd_type == LTTCOMM_SESSIOND_COMMAND_STOP_TRACE) {
+ cmd_ctx->lsm.cmd_type == LTTCOMM_SESSIOND_COMMAND_STOP_TRACE) {
switch (cmd_ctx->lsm.domain.type) {
case LTTNG_DOMAIN_NONE:
break;
*/
if (need_tracing_session) {
if (!session_access_ok(cmd_ctx->session,
- LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds)) ||
- cmd_ctx->session->destroyed) {
+ LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds)) ||
+ cmd_ctx->session->destroyed) {
ret = LTTNG_ERR_EPERM;
goto error;
}
{
struct lttng_event_context *event_context = NULL;
const enum lttng_error_code ret_code =
- receive_lttng_event_context(
- cmd_ctx, *sock, sock_error, &event_context);
+ receive_lttng_event_context(cmd_ctx, *sock, sock_error, &event_context);
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
}
case LTTCOMM_SESSIOND_COMMAND_DISABLE_CHANNEL:
{
- ret = cmd_disable_channel(cmd_ctx->session, cmd_ctx->lsm.domain.type,
- cmd_ctx->lsm.u.disable.channel_name);
+ ret = cmd_disable_channel(cmd_ctx->session,
+ cmd_ctx->lsm.domain.type,
+ cmd_ctx->lsm.u.disable.channel_name);
break;
}
case LTTCOMM_SESSIOND_COMMAND_ENABLE_CHANNEL:
{
- ret = cmd_enable_channel(
- cmd_ctx, *sock, the_kernel_poll_pipe[1]);
+ ret = cmd_enable_channel(cmd_ctx, *sock, the_kernel_poll_pipe[1]);
break;
}
case LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE:
{
struct lttng_dynamic_buffer payload;
struct lttng_buffer_view payload_view;
- const bool add_value =
- cmd_ctx->lsm.cmd_type ==
- LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE;
+ const bool add_value = cmd_ctx->lsm.cmd_type ==
+ LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE;
const size_t name_len =
- cmd_ctx->lsm.u.process_attr_tracker_add_remove_include_value
- .name_len;
+ cmd_ctx->lsm.u.process_attr_tracker_add_remove_include_value.name_len;
const enum lttng_domain_type domain_type =
- (enum lttng_domain_type)
- cmd_ctx->lsm.domain.type;
+ (enum lttng_domain_type) cmd_ctx->lsm.domain.type;
const enum lttng_process_attr process_attr =
- (enum lttng_process_attr) cmd_ctx->lsm.u
- .process_attr_tracker_add_remove_include_value
- .process_attr;
+ (enum lttng_process_attr) cmd_ctx->lsm.u
+ .process_attr_tracker_add_remove_include_value.process_attr;
const enum lttng_process_attr_value_type value_type =
- (enum lttng_process_attr_value_type) cmd_ctx
- ->lsm.u
- .process_attr_tracker_add_remove_include_value
- .value_type;
+ (enum lttng_process_attr_value_type) cmd_ctx->lsm.u
+ .process_attr_tracker_add_remove_include_value.value_type;
struct process_attr_value *value;
enum lttng_error_code ret_code;
long login_name_max;
* LOGIN_NAME_MAX is defined to 256.
*/
ERR("Rejecting process attribute tracker value %s as the provided exceeds the maximal allowed length: argument length = %zu, maximal length = %ld",
- add_value ? "addition" : "removal",
- name_len, login_name_max);
+ add_value ? "addition" : "removal",
+ name_len,
+ login_name_max);
ret = LTTNG_ERR_INVALID;
goto error;
}
ret = lttng_dynamic_buffer_set_size(&payload, name_len);
if (ret) {
ERR("Failed to allocate buffer to receive payload of %s process attribute tracker value argument",
- add_value ? "add" : "remove");
+ add_value ? "add" : "remove");
ret = LTTNG_ERR_NOMEM;
goto error_add_remove_tracker_value;
}
- ret = lttcomm_recv_unix_sock(
- *sock, payload.data, name_len);
+ ret = lttcomm_recv_unix_sock(*sock, payload.data, name_len);
if (ret <= 0) {
ERR("Failed to receive payload of %s process attribute tracker value argument",
- add_value ? "add" : "remove");
+ add_value ? "add" : "remove");
*sock_error = 1;
ret = LTTNG_ERR_INVALID_PROTOCOL;
goto error_add_remove_tracker_value;
}
}
- payload_view = lttng_buffer_view_from_dynamic_buffer(
- &payload, 0, name_len);
+ payload_view = lttng_buffer_view_from_dynamic_buffer(&payload, 0, name_len);
if (name_len > 0 && !lttng_buffer_view_is_valid(&payload_view)) {
ret = LTTNG_ERR_INVALID_PROTOCOL;
goto error_add_remove_tracker_value;
* attribute tracker that is specified and convert the value to
* add/remove to the internal sessiond representation.
*/
- ret_code = process_attr_value_from_comm(domain_type,
- process_attr, value_type,
- &cmd_ctx->lsm.u.process_attr_tracker_add_remove_include_value
- .integral_value,
- &payload_view, &value);
+ ret_code = process_attr_value_from_comm(
+ domain_type,
+ process_attr,
+ value_type,
+ &cmd_ctx->lsm.u.process_attr_tracker_add_remove_include_value.integral_value,
+ &payload_view,
+ &value);
if (ret_code != LTTNG_OK) {
ret = ret_code;
goto error_add_remove_tracker_value;
if (add_value) {
ret = cmd_process_attr_tracker_inclusion_set_add_value(
- cmd_ctx->session, domain_type,
- process_attr, value);
+ cmd_ctx->session, domain_type, process_attr, value);
} else {
ret = cmd_process_attr_tracker_inclusion_set_remove_value(
- cmd_ctx->session, domain_type,
- process_attr, value);
+ cmd_ctx->session, domain_type, process_attr, value);
}
process_attr_value_destroy(value);
error_add_remove_tracker_value:
{
enum lttng_tracking_policy tracking_policy;
const enum lttng_domain_type domain_type =
- (enum lttng_domain_type)
- cmd_ctx->lsm.domain.type;
+ (enum lttng_domain_type) cmd_ctx->lsm.domain.type;
const enum lttng_process_attr process_attr =
- (enum lttng_process_attr) cmd_ctx->lsm.u
- .process_attr_tracker_get_tracking_policy
- .process_attr;
+ (enum lttng_process_attr) cmd_ctx->lsm.u
+ .process_attr_tracker_get_tracking_policy.process_attr;
ret = cmd_process_attr_tracker_get_tracking_policy(
- cmd_ctx->session, domain_type, process_attr,
- &tracking_policy);
+ cmd_ctx->session, domain_type, process_attr, &tracking_policy);
if (ret != LTTNG_OK) {
goto error;
}
uint32_t tracking_policy_u32 = tracking_policy;
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx,
- &tracking_policy_u32, sizeof(uint32_t));
+ ret = setup_lttng_msg_no_cmd_header(
+ cmd_ctx, &tracking_policy_u32, sizeof(uint32_t));
if (ret < 0) {
ret = LTTNG_ERR_NOMEM;
goto error;
case LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_SET_POLICY:
{
const enum lttng_tracking_policy tracking_policy =
- (enum lttng_tracking_policy) cmd_ctx->lsm.u
- .process_attr_tracker_set_tracking_policy
- .tracking_policy;
+ (enum lttng_tracking_policy) cmd_ctx->lsm.u
+ .process_attr_tracker_set_tracking_policy.tracking_policy;
const enum lttng_domain_type domain_type =
- (enum lttng_domain_type)
- cmd_ctx->lsm.domain.type;
+ (enum lttng_domain_type) cmd_ctx->lsm.domain.type;
const enum lttng_process_attr process_attr =
- (enum lttng_process_attr) cmd_ctx->lsm.u
- .process_attr_tracker_set_tracking_policy
- .process_attr;
+ (enum lttng_process_attr) cmd_ctx->lsm.u
+ .process_attr_tracker_set_tracking_policy.process_attr;
ret = cmd_process_attr_tracker_set_tracking_policy(
- cmd_ctx->session, domain_type, process_attr,
- tracking_policy);
+ cmd_ctx->session, domain_type, process_attr, tracking_policy);
if (ret != LTTNG_OK) {
goto error;
}
struct lttng_process_attr_values *values;
struct lttng_dynamic_buffer reply;
const enum lttng_domain_type domain_type =
- (enum lttng_domain_type)
- cmd_ctx->lsm.domain.type;
+ (enum lttng_domain_type) cmd_ctx->lsm.domain.type;
const enum lttng_process_attr process_attr =
- (enum lttng_process_attr) cmd_ctx->lsm.u
- .process_attr_tracker_get_inclusion_set
- .process_attr;
+ (enum lttng_process_attr)
+ cmd_ctx->lsm.u.process_attr_tracker_get_inclusion_set.process_attr;
ret = cmd_process_attr_tracker_get_inclusion_set(
- cmd_ctx->session, domain_type, process_attr,
- &values);
+ cmd_ctx->session, domain_type, process_attr, &values);
if (ret != LTTNG_OK) {
goto error;
}
goto error_tracker_get_inclusion_set;
}
- ret = setup_lttng_msg_no_cmd_header(
- cmd_ctx, reply.data, reply.size);
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, reply.data, reply.size);
if (ret < 0) {
ret = LTTNG_ERR_NOMEM;
goto error_tracker_get_inclusion_set;
char *filter_expression;
struct lttng_event_exclusion *exclusions;
struct lttng_bytecode *bytecode;
- const enum lttng_error_code ret_code = receive_lttng_event(
- cmd_ctx, *sock, sock_error, &event,
- &filter_expression, &bytecode, &exclusions);
+ const enum lttng_error_code ret_code = receive_lttng_event(cmd_ctx,
+ *sock,
+ sock_error,
+ &event,
+ &filter_expression,
+ &bytecode,
+ &exclusions);
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
* always transferred.
*/
ret = cmd_ctx->lsm.cmd_type == LTTCOMM_SESSIOND_COMMAND_ENABLE_EVENT ?
- cmd_enable_event(cmd_ctx, event,
- filter_expression, exclusions,
- bytecode,
- the_kernel_poll_pipe[1]) :
- cmd_disable_event(cmd_ctx, event,
- filter_expression, bytecode,
- exclusions);
+ cmd_enable_event(cmd_ctx,
+ event,
+ filter_expression,
+ exclusions,
+ bytecode,
+ the_kernel_poll_pipe[1]) :
+ cmd_disable_event(cmd_ctx, event, filter_expression, bytecode, exclusions);
lttng_event_destroy(event);
break;
}
original_payload_size = cmd_ctx->reply_payload.buffer.size;
session_lock_list();
- ret_code = cmd_list_tracepoints(cmd_ctx->lsm.domain.type,
- &cmd_ctx->reply_payload);
+ ret_code = cmd_list_tracepoints(cmd_ctx->lsm.domain.type, &cmd_ctx->reply_payload);
session_unlock_list();
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- command_header_size - original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - command_header_size -
+ original_payload_size;
update_lttng_msg(cmd_ctx, command_header_size, payload_size);
ret = LTTNG_OK;
original_payload_size = cmd_ctx->reply_payload.buffer.size;
session_lock_list();
- ret_code = cmd_list_tracepoint_fields(
- cmd_ctx->lsm.domain.type, &cmd_ctx->reply_payload);
+ ret_code = cmd_list_tracepoint_fields(cmd_ctx->lsm.domain.type,
+ &cmd_ctx->reply_payload);
session_unlock_list();
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- command_header_size - original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - command_header_size -
+ original_payload_size;
update_lttng_msg(cmd_ctx, command_header_size, payload_size);
ret = LTTNG_OK;
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- command_header_size - original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - command_header_size -
+ original_payload_size;
update_lttng_msg(cmd_ctx, command_header_size, payload_size);
ret = LTTNG_OK;
goto error;
}
-
break;
}
case LTTCOMM_SESSIOND_COMMAND_START_TRACE:
* enabled time or size-based rotations, we have to make sure
* the kernel tracer supports it.
*/
- if (!cmd_ctx->session->has_been_started && \
- cmd_ctx->session->kernel_session && \
- (cmd_ctx->session->rotate_timer_period || \
- cmd_ctx->session->rotate_size) && \
- !check_rotate_compatible()) {
+ if (!cmd_ctx->session->has_been_started && cmd_ctx->session->kernel_session &&
+ (cmd_ctx->session->rotate_timer_period || cmd_ctx->session->rotate_size) &&
+ !check_rotate_compatible()) {
DBG("Kernel tracer version is not compatible with the rotation feature");
ret = LTTNG_ERR_ROTATION_WRONG_VERSION;
goto error;
}
case LTTCOMM_SESSIOND_COMMAND_DESTROY_SESSION:
{
- ret = cmd_destroy_session(cmd_ctx->session,
- the_notification_thread_handle, sock);
+ ret = cmd_destroy_session(cmd_ctx->session, the_notification_thread_handle, sock);
break;
}
case LTTCOMM_SESSIOND_COMMAND_LIST_DOMAINS:
goto error;
}
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, domains,
- nb_dom * sizeof(struct lttng_domain));
+ ret = setup_lttng_msg_no_cmd_header(
+ cmd_ctx, domains, nb_dom * sizeof(struct lttng_domain));
free(domains);
if (ret < 0) {
original_payload_size = cmd_ctx->reply_payload.buffer.size;
- ret_code = cmd_list_channels(cmd_ctx->lsm.domain.type,
- cmd_ctx->session, &cmd_ctx->reply_payload);
+ ret_code = cmd_list_channels(
+ cmd_ctx->lsm.domain.type, cmd_ctx->session, &cmd_ctx->reply_payload);
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- command_header_size - original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - command_header_size -
+ original_payload_size;
update_lttng_msg(cmd_ctx, command_header_size, payload_size);
ret = LTTNG_OK;
original_payload_size = cmd_ctx->reply_payload.buffer.size;
ret_code = cmd_list_events(cmd_ctx->lsm.domain.type,
- cmd_ctx->session,
- cmd_ctx->lsm.u.list.channel_name, &cmd_ctx->reply_payload);
+ cmd_ctx->session,
+ cmd_ctx->lsm.u.list.channel_name,
+ &cmd_ctx->reply_payload);
if (ret_code != LTTNG_OK) {
ret = (int) ret_code;
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- command_header_size - original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - command_header_size -
+ original_payload_size;
update_lttng_msg(cmd_ctx, command_header_size, payload_size);
ret = LTTNG_OK;
size_t payload_len = 0;
session_lock_list();
- nr_sessions = lttng_sessions_count(
- LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
- LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
+ nr_sessions = lttng_sessions_count(LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
+ LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
if (nr_sessions > 0) {
- payload_len = (sizeof(struct lttng_session) *
- nr_sessions) +
- (sizeof(struct lttng_session_extended) *
- nr_sessions);
+ payload_len = (sizeof(struct lttng_session) * nr_sessions) +
+ (sizeof(struct lttng_session_extended) * nr_sessions);
sessions_payload = zmalloc<lttng_session>(payload_len);
if (!sessions_payload) {
session_unlock_list();
goto setup_error;
}
- cmd_list_lttng_sessions(sessions_payload, nr_sessions,
- LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
- LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
+ cmd_list_lttng_sessions(sessions_payload,
+ nr_sessions,
+ LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
+ LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
}
session_unlock_list();
- ret = setup_lttng_msg_no_cmd_header(
- cmd_ctx, sessions_payload, payload_len);
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, sessions_payload, payload_len);
free(sessions_payload);
if (ret < 0) {
goto error;
}
- ret = cmd_register_consumer(cmd_ctx->session, cmd_ctx->lsm.domain.type,
- cmd_ctx->lsm.u.reg.path, cdata);
+ ret = cmd_register_consumer(
+ cmd_ctx->session, cmd_ctx->lsm.domain.type, cmd_ctx->lsm.u.reg.path, cdata);
break;
}
case LTTCOMM_SESSIOND_COMMAND_DATA_PENDING:
pending_ret_byte = (uint8_t) pending_ret;
/* 1 byte to return whether or not data is pending */
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx,
- &pending_ret_byte, 1);
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &pending_ret_byte, 1);
if (ret < 0) {
goto setup_error;
struct lttcomm_lttng_output_id reply;
lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_output.output;
- ret = cmd_snapshot_add_output(cmd_ctx->session,
- &output,
- &snapshot_id);
+ ret = cmd_snapshot_add_output(cmd_ctx->session, &output, &snapshot_id);
if (ret != LTTNG_OK) {
goto error;
}
reply.id = snapshot_id;
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &reply,
- sizeof(reply));
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &reply, sizeof(reply));
if (ret < 0) {
goto setup_error;
}
}
LTTNG_ASSERT((nb_output > 0 && outputs) || nb_output == 0);
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, outputs,
- nb_output * sizeof(struct lttng_snapshot_output));
+ ret = setup_lttng_msg_no_cmd_header(
+ cmd_ctx, outputs, nb_output * sizeof(struct lttng_snapshot_output));
free(outputs);
if (ret < 0) {
case LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_RECORD:
{
lttng_snapshot_output output = cmd_ctx->lsm.u.snapshot_record.output;
- ret = cmd_snapshot_record(cmd_ctx->session,
- &output, 0); // RFC: set to zero since it's ignored by cmd_snapshot_record
+ ret = cmd_snapshot_record(cmd_ctx->session, &output, 0); // RFC: set to zero since
+ // it's ignored by
+ // cmd_snapshot_record
break;
}
case LTTCOMM_SESSIOND_COMMAND_CREATE_SESSION_EXT:
goto error;
}
- ret = lttng_session_descriptor_serialize(return_descriptor,
- &payload);
+ ret = lttng_session_descriptor_serialize(return_descriptor, &payload);
if (ret) {
ERR("Failed to serialize session descriptor in reply to \"create session\" command");
lttng_session_descriptor_destroy(return_descriptor);
ret = LTTNG_ERR_NOMEM;
goto error;
}
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, payload.data,
- payload.size);
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, payload.data, payload.size);
if (ret) {
lttng_session_descriptor_destroy(return_descriptor);
ret = LTTNG_ERR_NOMEM;
}
case LTTCOMM_SESSIOND_COMMAND_SAVE_SESSION:
{
- ret = cmd_save_sessions(&cmd_ctx->lsm.u.save_session.attr,
- &cmd_ctx->creds);
+ ret = cmd_save_sessions(&cmd_ctx->lsm.u.save_session.attr, &cmd_ctx->creds);
break;
}
case LTTCOMM_SESSIOND_COMMAND_SET_SESSION_SHM_PATH:
{
ret = cmd_set_session_shm_path(cmd_ctx->session,
- cmd_ctx->lsm.u.set_shm_path.shm_path);
+ cmd_ctx->lsm.u.set_shm_path.shm_path);
break;
}
case LTTCOMM_SESSIOND_COMMAND_REGENERATE_METADATA:
goto setup_error;
}
- ret = receive_lttng_trigger(
- cmd_ctx, *sock, sock_error, &payload_trigger);
+ ret = receive_lttng_trigger(cmd_ctx, *sock, sock_error, &payload_trigger);
if (ret != LTTNG_OK) {
goto error;
}
original_reply_payload_size = cmd_ctx->reply_payload.buffer.size;
- ret = cmd_register_trigger(&cmd_creds, payload_trigger,
- cmd_ctx->lsm.u.trigger.is_trigger_anonymous,
- the_notification_thread_handle,
- &return_trigger);
+ ret = cmd_register_trigger(&cmd_creds,
+ payload_trigger,
+ cmd_ctx->lsm.u.trigger.is_trigger_anonymous,
+ the_notification_thread_handle,
+ &return_trigger);
if (ret != LTTNG_OK) {
lttng_trigger_put(payload_trigger);
goto error;
goto error;
}
- reply_payload_size = cmd_ctx->reply_payload.buffer.size -
- original_reply_payload_size;
+ reply_payload_size =
+ cmd_ctx->reply_payload.buffer.size - original_reply_payload_size;
update_lttng_msg(cmd_ctx, 0, reply_payload_size);
.gid = LTTNG_OPTIONAL_INIT_VALUE(cmd_ctx->creds.gid),
};
- ret = receive_lttng_trigger(
- cmd_ctx, *sock, sock_error, &payload_trigger);
+ ret = receive_lttng_trigger(cmd_ctx, *sock, sock_error, &payload_trigger);
if (ret != LTTNG_OK) {
goto error;
}
- ret = cmd_unregister_trigger(&cmd_creds, payload_trigger,
- the_notification_thread_handle);
+ ret = cmd_unregister_trigger(
+ &cmd_creds, payload_trigger, the_notification_thread_handle);
lttng_trigger_put(payload_trigger);
break;
}
goto error;
}
- ret = cmd_rotate_session(cmd_ctx->session, &rotate_return,
- false,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ ret = cmd_rotate_session(cmd_ctx->session,
+ &rotate_return,
+ false,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret < 0) {
ret = -ret;
goto error;
}
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &rotate_return,
- sizeof(rotate_return));
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &rotate_return, sizeof(rotate_return));
if (ret < 0) {
ret = -ret;
goto error;
struct lttng_rotation_get_info_return get_info_return;
memset(&get_info_return, 0, sizeof(get_info_return));
- ret = cmd_rotate_get_info(cmd_ctx->session, &get_info_return,
- cmd_ctx->lsm.u.get_rotation_info.rotation_id);
+ ret = cmd_rotate_get_info(cmd_ctx->session,
+ &get_info_return,
+ cmd_ctx->lsm.u.get_rotation_info.rotation_id);
if (ret < 0) {
ret = -ret;
goto error;
}
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &get_info_return,
- sizeof(get_info_return));
+ ret = setup_lttng_msg_no_cmd_header(
+ cmd_ctx, &get_info_return, sizeof(get_info_return));
if (ret < 0) {
ret = -ret;
goto error;
}
set_schedule = cmd_ctx->lsm.u.rotation_set_schedule.set == 1;
- schedule_type = (enum lttng_rotation_schedule_type) cmd_ctx->lsm.u.rotation_set_schedule.type;
+ schedule_type = (enum lttng_rotation_schedule_type)
+ cmd_ctx->lsm.u.rotation_set_schedule.type;
value = cmd_ctx->lsm.u.rotation_set_schedule.value;
- ret = cmd_rotation_set_schedule(cmd_ctx->session, set_schedule,
- schedule_type, value,
- the_notification_thread_handle);
+ ret = cmd_rotation_set_schedule(cmd_ctx->session,
+ set_schedule,
+ schedule_type,
+ value,
+ the_notification_thread_handle);
if (ret != LTTNG_OK) {
goto error;
}
schedules.size.set = !!cmd_ctx->session->rotate_size;
schedules.size.value = cmd_ctx->session->rotate_size;
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &schedules,
- sizeof(schedules));
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &schedules, sizeof(schedules));
if (ret < 0) {
ret = -ret;
goto error;
original_payload_size = cmd_ctx->reply_payload.buffer.size;
- ret = cmd_list_triggers(cmd_ctx, the_notification_thread_handle,
- &return_triggers);
+ ret = cmd_list_triggers(cmd_ctx, the_notification_thread_handle, &return_triggers);
if (ret != LTTNG_OK) {
goto error;
}
LTTNG_ASSERT(return_triggers);
- ret = lttng_triggers_serialize(
- return_triggers, &cmd_ctx->reply_payload);
+ ret = lttng_triggers_serialize(return_triggers, &cmd_ctx->reply_payload);
lttng_triggers_destroy(return_triggers);
if (ret) {
ERR("Failed to serialize triggers in reply to `list triggers` command");
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - original_payload_size;
update_lttng_msg(cmd_ctx, 0, payload_size);
original_payload_size = cmd_ctx->reply_payload.buffer.size;
- ret = receive_lttng_error_query(
- cmd_ctx, *sock, sock_error, &query);
+ ret = receive_lttng_error_query(cmd_ctx, *sock, sock_error, &query);
if (ret != LTTNG_OK) {
goto error;
}
- ret = cmd_execute_error_query(&cmd_creds, query, &results,
- the_notification_thread_handle);
+ ret = cmd_execute_error_query(
+ &cmd_creds, query, &results, the_notification_thread_handle);
lttng_error_query_destroy(query);
if (ret != LTTNG_OK) {
goto error;
}
LTTNG_ASSERT(results);
- ret = lttng_error_query_results_serialize(
- results, &cmd_ctx->reply_payload);
+ ret = lttng_error_query_results_serialize(results, &cmd_ctx->reply_payload);
lttng_error_query_results_destroy(results);
if (ret) {
ERR("Failed to serialize error query result set in reply to `execute error query` command");
goto error;
}
- payload_size = cmd_ctx->reply_payload.buffer.size -
- original_payload_size;
+ payload_size = cmd_ctx->reply_payload.buffer.size - original_payload_size;
update_lttng_msg(cmd_ctx, 0, payload_size);
int ret, client_sock;
/* Create client tool unix socket */
- client_sock = lttcomm_create_unix_sock(
- the_config.client_unix_sock_path.value);
+ client_sock = lttcomm_create_unix_sock(the_config.client_unix_sock_path.value);
if (client_sock < 0) {
- ERR("Create unix sock failed: %s",
- the_config.client_unix_sock_path.value);
+ ERR("Create unix sock failed: %s", the_config.client_unix_sock_path.value);
ret = -1;
goto end;
}
ret = utils_set_fd_cloexec(client_sock);
if (ret < 0) {
ERR("Unable to set CLOEXEC flag to the client Unix socket (fd: %d). "
- "Continuing but note that the consumer daemon will have a "
- "reference to this socket on exec()", client_sock);
+ "Continuing but note that the consumer daemon will have a "
+ "reference to this socket on exec()",
+ client_sock);
}
/* File permission MUST be 660 */
- ret = chmod(the_config.client_unix_sock_path.value,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ ret = chmod(the_config.client_unix_sock_path.value, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
- ERR("Set file permissions failed: %s",
- the_config.client_unix_sock_path.value);
+ ERR("Set file permissions failed: %s", the_config.client_unix_sock_path.value);
PERROR("chmod");
(void) lttcomm_close_unix_sock(client_sock);
ret = -1;
* the client.
*/
DBG("Receiving data from client ...");
- ret = lttcomm_recv_creds_unix_sock(sock, &cmd_ctx.lsm,
- sizeof(struct lttcomm_session_msg), &cmd_ctx.creds);
+ ret = lttcomm_recv_creds_unix_sock(
+ sock, &cmd_ctx.lsm, sizeof(struct lttcomm_session_msg), &cmd_ctx.creds);
if (ret != sizeof(struct lttcomm_session_msg)) {
DBG("Incomplete recv() from client... continuing");
ret = close(sock);
if (ret < LTTNG_OK || ret >= LTTNG_ERR_NR) {
WARN("Command returned an invalid status code, returning unknown error: "
- "command type = %s (%d), ret = %d",
- lttcomm_sessiond_command_str((lttcomm_sessiond_command) cmd_ctx.lsm.cmd_type),
- cmd_ctx.lsm.cmd_type, ret);
+ "command type = %s (%d), ret = %d",
+ lttcomm_sessiond_command_str(
+ (lttcomm_sessiond_command) cmd_ctx.lsm.cmd_type),
+ cmd_ctx.lsm.cmd_type,
+ ret);
ret = LTTNG_ERR_UNK;
}
if (cmd_completion_handler) {
enum lttng_error_code completion_code;
- completion_code = cmd_completion_handler->run(
- cmd_completion_handler->data);
+ completion_code = cmd_completion_handler->run(cmd_completion_handler->data);
if (completion_code != LTTNG_OK) {
continue;
}
if (sock >= 0) {
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &cmd_ctx.reply_payload,
- 0, -1);
- struct lttcomm_lttng_msg *llm = (typeof(
- llm)) cmd_ctx.reply_payload.buffer.data;
+ lttng_payload_view_from_payload(&cmd_ctx.reply_payload, 0, -1);
+ struct lttcomm_lttng_msg *llm =
+ (typeof(llm)) cmd_ctx.reply_payload.buffer.data;
LTTNG_ASSERT(cmd_ctx.reply_payload.buffer.size >= sizeof(*llm));
LTTNG_ASSERT(cmd_ctx.lttng_msg_size == cmd_ctx.reply_payload.buffer.size);
llm->fd_count = lttng_payload_view_get_fd_handle_count(&view);
DBG("Sending response (size: %d, retcode: %s (%d))",
- cmd_ctx.lttng_msg_size,
- lttng_strerror(-llm->ret_code),
- llm->ret_code);
+ cmd_ctx.lttng_msg_size,
+ lttng_strerror(-llm->ret_code),
+ llm->ret_code);
ret = send_unix_sock(sock, &view);
if (ret < 0) {
ERR("Failed to send data back to client");
return NULL;
}
-static
-bool shutdown_client_thread(void *thread_data)
+static bool shutdown_client_thread(void *thread_data)
{
struct lttng_pipe *client_quit_pipe = (lttng_pipe *) thread_data;
const int write_fd = lttng_pipe_get_writefd(client_quit_pipe);
thread_state.client_sock = client_sock_fd;
thread = lttng_thread_create("Client management",
- thread_manage_clients,
- shutdown_client_thread,
- cleanup_client_thread,
- client_quit_pipe);
+ thread_manage_clients,
+ shutdown_client_thread,
+ cleanup_client_thread,
+ client_quit_pipe);
if (!thread) {
goto error;
}
#include "trace-class.hpp"
lttng::sessiond::trace::clock_class::clock_class(std::string in_name,
- std::string in_description,
- nonstd::optional<lttng_uuid> in_uuid,
- scycles_t in_offset,
- cycles_t in_frequency) :
- name{std::move(in_name)},
- description{std::move(in_description)},
- uuid{std::move(in_uuid)},
- offset{in_offset},
- frequency{in_frequency}
+ std::string in_description,
+ nonstd::optional<lttng_uuid> in_uuid,
+ scycles_t in_offset,
+ cycles_t in_frequency) :
+ name{ std::move(in_name) },
+ description{ std::move(in_description) },
+ uuid{ std::move(in_uuid) },
+ offset{ in_offset },
+ frequency{ in_frequency }
{
}
*
*/
-
#define _LGPL_SOURCE
-#include <algorithm>
-#include <inttypes.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <urcu/list.h>
-#include <urcu/uatomic.h>
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "event.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "tracker.hpp"
+#include "utils.hpp"
#include <common/buffer-view.hpp>
#include <common/common.hpp>
#include <common/string-utils/string-utils.hpp>
#include <common/trace-chunk.hpp>
#include <common/utils.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/action.h>
#include <lttng/channel-internal.hpp>
#include <lttng/trigger/trigger-internal.hpp>
#include <lttng/userspace-probe-internal.hpp>
-#include "agent-thread.hpp"
-#include "agent.hpp"
-#include "buffer-registry.hpp"
-#include "channel.hpp"
-#include "cmd.hpp"
-#include "consumer.hpp"
-#include "event-notifier-error-accounting.hpp"
-#include "event.hpp"
-#include "health-sessiond.hpp"
-#include "kernel-consumer.hpp"
-#include "kernel.hpp"
-#include "lttng-sessiond.hpp"
-#include "lttng-syscall.hpp"
-#include "notification-thread-commands.hpp"
-#include "notification-thread.hpp"
-#include "rotate.hpp"
-#include "rotation-thread.hpp"
-#include "session.hpp"
-#include "timer.hpp"
-#include "tracker.hpp"
-#include "utils.hpp"
+#include <algorithm>
+#include <inttypes.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <urcu/list.h>
+#include <urcu/uatomic.h>
/* Sleep for 100ms between each check for the shm path's deletion. */
#define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000
struct cmd_completion_handler handler;
char shm_path[member_sizeof(struct ltt_session, shm_path)];
} destroy_completion_handler = {
- .handler = {
- .run = wait_on_path,
- .data = destroy_completion_handler.shm_path
- },
+ .handler = { .run = wait_on_path, .data = destroy_completion_handler.shm_path },
.shm_path = { 0 },
};
static struct cmd_completion_handler *current_completion_handler;
static int validate_ust_event_name(const char *);
static int cmd_enable_event_internal(struct ltt_session *session,
- const struct lttng_domain *domain,
- char *channel_name, struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- int wpipe);
-static enum lttng_error_code cmd_enable_channel_internal(
- struct ltt_session *session,
- const struct lttng_domain *domain,
- const struct lttng_channel *_attr,
- int wpipe);
+ const struct lttng_domain *domain,
+ char *channel_name,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ int wpipe);
+static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *session,
+ const struct lttng_domain *domain,
+ const struct lttng_channel *_attr,
+ int wpipe);
/*
* Create a session path used by list_lttng_sessions for the case that the
* session consumer is on the network.
*/
-static int build_network_session_path(char *dst, size_t size,
- struct ltt_session *session)
+static int build_network_session_path(char *dst, size_t size, struct ltt_session *session)
{
int ret, kdata_port, udata_port;
struct lttng_uri *kuri = NULL, *uuri = NULL, *uri = NULL;
* to print.
*/
if (*tmp_uurl != '\0') {
- ret = snprintf(dst, size, "[K]: %s [data: %d] -- [U]: %s [data: %d]",
- tmp_urls, kdata_port, tmp_uurl, udata_port);
+ ret = snprintf(dst,
+ size,
+ "[K]: %s [data: %d] -- [U]: %s [data: %d]",
+ tmp_urls,
+ kdata_port,
+ tmp_uurl,
+ udata_port);
} else {
int dport;
if (kuri || (!kuri && !uuri)) {
* lost packets).
*/
static int get_kernel_runtime_stats(struct ltt_session *session,
- struct ltt_kernel_channel *kchan, uint64_t *discarded_events,
- uint64_t *lost_packets)
+ struct ltt_kernel_channel *kchan,
+ uint64_t *discarded_events,
+ uint64_t *lost_packets)
{
int ret;
goto end;
}
- ret = consumer_get_discarded_events(session->id, kchan->key,
- session->kernel_session->consumer,
- discarded_events);
+ ret = consumer_get_discarded_events(
+ session->id, kchan->key, session->kernel_session->consumer, discarded_events);
if (ret < 0) {
goto end;
}
- ret = consumer_get_lost_packets(session->id, kchan->key,
- session->kernel_session->consumer,
- lost_packets);
+ ret = consumer_get_lost_packets(
+ session->id, kchan->key, session->kernel_session->consumer, lost_packets);
if (ret < 0) {
goto end;
}
* lost packets).
*/
static int get_ust_runtime_stats(struct ltt_session *session,
- struct ltt_ust_channel *uchan, uint64_t *discarded_events,
- uint64_t *lost_packets)
+ struct ltt_ust_channel *uchan,
+ uint64_t *discarded_events,
+ uint64_t *lost_packets)
{
int ret;
struct ltt_ust_session *usess;
if (usess->buffer_type == LTTNG_BUFFER_PER_UID) {
ret = ust_app_uid_get_channel_runtime_stats(usess->id,
- &usess->buffer_reg_uid_list,
- usess->consumer, uchan->id,
- uchan->attr.overwrite,
- discarded_events,
- lost_packets);
+ &usess->buffer_reg_uid_list,
+ usess->consumer,
+ uchan->id,
+ uchan->attr.overwrite,
+ discarded_events,
+ lost_packets);
} else if (usess->buffer_type == LTTNG_BUFFER_PER_PID) {
ret = ust_app_pid_get_channel_runtime_stats(usess,
- uchan, usess->consumer,
- uchan->attr.overwrite,
- discarded_events,
- lost_packets);
+ uchan,
+ usess->consumer,
+ uchan->attr.overwrite,
+ discarded_events,
+ lost_packets);
if (ret < 0) {
goto end;
}
*
* Return number of events in list on success or else a negative value.
*/
-static enum lttng_error_code list_lttng_agent_events(
- struct agent *agt, struct lttng_payload *reply_payload,
- unsigned int *nb_events)
+static enum lttng_error_code list_lttng_agent_events(struct agent *agt,
+ struct lttng_payload *reply_payload,
+ unsigned int *nb_events)
{
enum lttng_error_code ret_code;
int ret = 0;
local_nb_events = (unsigned int) agent_event_count;
- cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
+ cds_lfht_for_each_entry (agt->events->ht, &iter.iter, event, node.node) {
struct lttng_event *tmp_event = lttng_event_create();
if (!tmp_event) {
ret_code = LTTNG_ERR_FATAL;
goto error;
}
-
+
tmp_event->name[sizeof(tmp_event->name) - 1] = '\0';
tmp_event->enabled = !!event->enabled_count;
tmp_event->loglevel = event->loglevel_value;
tmp_event->loglevel_type = event->loglevel_type;
- ret = lttng_event_serialize(tmp_event, 0, NULL,
- event->filter_expression, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ tmp_event, 0, NULL, event->filter_expression, 0, NULL, reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
* Create a list of ust global domain events.
*/
static enum lttng_error_code list_lttng_ust_global_events(char *channel_name,
- struct ltt_ust_domain_global *ust_global,
- struct lttng_payload *reply_payload,
- unsigned int *nb_events)
+ struct ltt_ust_domain_global *ust_global,
+ struct lttng_payload *reply_payload,
+ unsigned int *nb_events)
{
enum lttng_error_code ret_code;
int ret;
DBG3("Listing UST global %d events", *nb_events);
- cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent, node.node) {
+ cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) {
struct lttng_event *tmp_event = NULL;
if (uevent->internal) {
goto error;
}
- if (lttng_strncpy(tmp_event->name, uevent->attr.name,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (lttng_strncpy(tmp_event->name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN)) {
ret_code = LTTNG_ERR_FATAL;
lttng_event_destroy(tmp_event);
goto error;
* We do not care about the filter bytecode and the fd from the
* userspace_probe_location.
*/
- ret = lttng_event_serialize(tmp_event, uevent->exclusion ? uevent->exclusion->count : 0,
- uevent->exclusion ? (char **) uevent->exclusion ->names : NULL,
- uevent->filter_expression, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(tmp_event,
+ uevent->exclusion ? uevent->exclusion->count : 0,
+ uevent->exclusion ? (char **) uevent->exclusion->names :
+ NULL,
+ uevent->filter_expression,
+ 0,
+ NULL,
+ reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
* Fill lttng_event array of all kernel events in the channel.
*/
static enum lttng_error_code list_lttng_kernel_events(char *channel_name,
- struct ltt_kernel_session *kernel_session,
- struct lttng_payload *reply_payload,
- unsigned int *nb_events)
+ struct ltt_kernel_session *kernel_session,
+ struct lttng_payload *reply_payload,
+ unsigned int *nb_events)
{
enum lttng_error_code ret_code;
int ret;
}
/* Kernel channels */
- cds_list_for_each_entry(event, &kchan->events_list.head , list) {
+ cds_list_for_each_entry (event, &kchan->events_list.head, list) {
struct lttng_event *tmp_event = lttng_event_create();
if (!tmp_event) {
lttng_event_destroy(tmp_event);
ret_code = LTTNG_ERR_FATAL;
goto end;
-
}
tmp_event->name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
tmp_event->type = LTTNG_EVENT_FUNCTION;
- memcpy(&tmp_event->attr.probe, &event->event->u.kprobe,
- sizeof(struct lttng_kernel_abi_kprobe));
+ memcpy(&tmp_event->attr.probe,
+ &event->event->u.kprobe,
+ sizeof(struct lttng_kernel_abi_kprobe));
break;
case LTTNG_KERNEL_ABI_KPROBE:
tmp_event->type = LTTNG_EVENT_PROBE;
- memcpy(&tmp_event->attr.probe, &event->event->u.kprobe,
- sizeof(struct lttng_kernel_abi_kprobe));
+ memcpy(&tmp_event->attr.probe,
+ &event->event->u.kprobe,
+ sizeof(struct lttng_kernel_abi_kprobe));
break;
case LTTNG_KERNEL_ABI_UPROBE:
tmp_event->type = LTTNG_EVENT_USERSPACE_PROBE;
break;
case LTTNG_KERNEL_ABI_FUNCTION:
tmp_event->type = LTTNG_EVENT_FUNCTION;
- memcpy(&(tmp_event->attr.ftrace), &event->event->u.ftrace,
- sizeof(struct lttng_kernel_abi_function));
+ memcpy(&(tmp_event->attr.ftrace),
+ &event->event->u.ftrace,
+ sizeof(struct lttng_kernel_abi_function));
break;
case LTTNG_KERNEL_ABI_NOOP:
tmp_event->type = LTTNG_EVENT_NOOP;
if (event->userspace_probe_location) {
struct lttng_userspace_probe_location *location_copy =
- lttng_userspace_probe_location_copy(
- event->userspace_probe_location);
+ lttng_userspace_probe_location_copy(
+ event->userspace_probe_location);
if (!location_copy) {
lttng_event_destroy(tmp_event);
goto end;
}
- ret = lttng_event_set_userspace_probe_location(
- tmp_event, location_copy);
+ ret = lttng_event_set_userspace_probe_location(tmp_event, location_copy);
if (ret) {
lttng_event_destroy(tmp_event);
- lttng_userspace_probe_location_destroy(
- location_copy);
+ lttng_userspace_probe_location_destroy(location_copy);
ret_code = LTTNG_ERR_INVALID;
goto end;
}
}
- ret = lttng_event_serialize(tmp_event, 0, NULL,
- event->filter_expression, 0, NULL, reply_payload);
+ ret = lttng_event_serialize(
+ tmp_event, 0, NULL, event->filter_expression, 0, NULL, reply_payload);
lttng_event_destroy(tmp_event);
if (ret) {
ret_code = LTTNG_ERR_FATAL;
* Add URI so the consumer output object. Set the correct path depending on the
* domain adding the default trace directory.
*/
-static enum lttng_error_code add_uri_to_consumer(
- const struct ltt_session *session,
- struct consumer_output *consumer,
- struct lttng_uri *uri, enum lttng_domain_type domain)
+static enum lttng_error_code add_uri_to_consumer(const struct ltt_session *session,
+ struct consumer_output *consumer,
+ struct lttng_uri *uri,
+ enum lttng_domain_type domain)
{
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
ret = lttng_strncpy(consumer->domain_subdir,
- DEFAULT_KERNEL_TRACE_DIR,
- sizeof(consumer->domain_subdir));
+ DEFAULT_KERNEL_TRACE_DIR,
+ sizeof(consumer->domain_subdir));
break;
case LTTNG_DOMAIN_UST:
ret = lttng_strncpy(consumer->domain_subdir,
- DEFAULT_UST_TRACE_DIR,
- sizeof(consumer->domain_subdir));
+ DEFAULT_UST_TRACE_DIR,
+ sizeof(consumer->domain_subdir));
break;
default:
/*
* tracing session consumer object which in this case there is
* no subdir.
*/
- memset(consumer->domain_subdir, 0,
- sizeof(consumer->domain_subdir));
+ memset(consumer->domain_subdir, 0, sizeof(consumer->domain_subdir));
ret = 0;
}
if (ret) {
if (consumer->type == CONSUMER_DST_NET) {
if ((uri->stype == LTTNG_STREAM_CONTROL &&
- consumer->dst.net.control_isset) ||
- (uri->stype == LTTNG_STREAM_DATA &&
- consumer->dst.net.data_isset)) {
+ consumer->dst.net.control_isset) ||
+ (uri->stype == LTTNG_STREAM_DATA && consumer->dst.net.data_isset)) {
ret_code = LTTNG_ERR_URL_EXIST;
goto error;
}
ret_code = LTTNG_ERR_INVALID;
goto error;
}
- DBG2("Setting trace directory path from URI to %s",
- uri->dst.path);
+ DBG2("Setting trace directory path from URI to %s", uri->dst.path);
memset(&consumer->dst, 0, sizeof(consumer->dst));
ret = lttng_strncpy(consumer->dst.session_root_path,
- uri->dst.path,
- sizeof(consumer->dst.session_root_path));
+ uri->dst.path,
+ sizeof(consumer->dst.session_root_path));
if (ret) {
ret_code = LTTNG_ERR_FATAL;
goto error;
rcu_read_lock();
if (session->consumer_fds_sent == 0 && session->consumer != NULL) {
- cds_lfht_for_each_entry(session->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = kernel_consumer_send_session(socket, session);
pthread_mutex_unlock(socket->lock);
* Else, it remains untouched and an LTTng error code is returned.
*/
static enum lttng_error_code create_connect_relayd(struct lttng_uri *uri,
- struct lttcomm_relayd_sock **relayd_sock,
- struct consumer_output *consumer)
+ struct lttcomm_relayd_sock **relayd_sock,
+ struct consumer_output *consumer)
{
int ret;
enum lttng_error_code status = LTTNG_OK;
struct lttcomm_relayd_sock *rsock;
- rsock = lttcomm_alloc_relayd_sock(uri, RELAYD_VERSION_COMM_MAJOR,
- RELAYD_VERSION_COMM_MINOR);
+ rsock = lttcomm_alloc_relayd_sock(
+ uri, RELAYD_VERSION_COMM_MAJOR, RELAYD_VERSION_COMM_MINOR);
if (!rsock) {
status = LTTNG_ERR_FATAL;
goto error;
}
consumer->relay_major_version = rsock->major;
consumer->relay_minor_version = rsock->minor;
- ret = relayd_get_configuration(rsock, 0,
- &result_flags);
+ ret = relayd_get_configuration(rsock, 0, &result_flags);
if (ret < 0) {
ERR("Unable to get relayd configuration");
status = LTTNG_ERR_RELAYD_CONNECT_FAIL;
*
* Returns LTTNG_OK on success or an LTTng error code on failure.
*/
-static enum lttng_error_code send_consumer_relayd_socket(
- unsigned int session_id,
- struct lttng_uri *relayd_uri,
- struct consumer_output *consumer,
- struct consumer_socket *consumer_sock,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- const uint64_t *current_chunk_id,
- time_t session_creation_time,
- bool session_name_contains_creation_time)
+static enum lttng_error_code send_consumer_relayd_socket(unsigned int session_id,
+ struct lttng_uri *relayd_uri,
+ struct consumer_output *consumer,
+ struct consumer_socket *consumer_sock,
+ const char *session_name,
+ const char *hostname,
+ const char *base_path,
+ int session_live_timer,
+ const uint64_t *current_chunk_id,
+ time_t session_creation_time,
+ bool session_name_contains_creation_time)
{
int ret;
struct lttcomm_relayd_sock *rsock = NULL;
}
/* Send relayd socket to consumer. */
- ret = consumer_send_relayd_socket(consumer_sock, rsock, consumer,
- relayd_uri->stype, session_id,
- session_name, hostname, base_path,
- session_live_timer, current_chunk_id,
- session_creation_time, session_name_contains_creation_time);
+ ret = consumer_send_relayd_socket(consumer_sock,
+ rsock,
+ consumer,
+ relayd_uri->stype,
+ session_id,
+ session_name,
+ hostname,
+ base_path,
+ session_live_timer,
+ current_chunk_id,
+ session_creation_time,
+ session_name_contains_creation_time);
if (ret < 0) {
status = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
goto close_sock;
*
* Returns LTTNG_OK, or an LTTng error code on failure.
*/
-static enum lttng_error_code send_consumer_relayd_sockets(
- unsigned int session_id, struct consumer_output *consumer,
- struct consumer_socket *sock, const char *session_name,
- const char *hostname, const char *base_path, int session_live_timer,
- const uint64_t *current_chunk_id, time_t session_creation_time,
- bool session_name_contains_creation_time)
+static enum lttng_error_code send_consumer_relayd_sockets(unsigned int session_id,
+ struct consumer_output *consumer,
+ struct consumer_socket *sock,
+ const char *session_name,
+ const char *hostname,
+ const char *base_path,
+ int session_live_timer,
+ const uint64_t *current_chunk_id,
+ time_t session_creation_time,
+ bool session_name_contains_creation_time)
{
enum lttng_error_code status = LTTNG_OK;
/* Sending control relayd socket. */
if (!sock->control_sock_sent) {
status = send_consumer_relayd_socket(session_id,
- &consumer->dst.net.control, consumer, sock,
- session_name, hostname, base_path, session_live_timer,
- current_chunk_id, session_creation_time,
- session_name_contains_creation_time);
+ &consumer->dst.net.control,
+ consumer,
+ sock,
+ session_name,
+ hostname,
+ base_path,
+ session_live_timer,
+ current_chunk_id,
+ session_creation_time,
+ session_name_contains_creation_time);
if (status != LTTNG_OK) {
goto error;
}
/* Sending data relayd socket. */
if (!sock->data_sock_sent) {
status = send_consumer_relayd_socket(session_id,
- &consumer->dst.net.data, consumer, sock,
- session_name, hostname, base_path, session_live_timer,
- current_chunk_id, session_creation_time,
- session_name_contains_creation_time);
+ &consumer->dst.net.data,
+ consumer,
+ sock,
+ session_name,
+ hostname,
+ base_path,
+ session_live_timer,
+ current_chunk_id,
+ session_creation_time,
+ session_name_contains_creation_time);
if (status != LTTNG_OK) {
goto error;
}
rcu_read_lock();
if (session->current_trace_chunk) {
enum lttng_trace_chunk_status status = lttng_trace_chunk_get_id(
- session->current_trace_chunk, ¤t_chunk_id.value);
+ session->current_trace_chunk, ¤t_chunk_id.value);
if (status == LTTNG_TRACE_CHUNK_STATUS_OK) {
current_chunk_id.is_set = true;
}
}
- if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET
- && usess->consumer->enabled) {
+ if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET &&
+ usess->consumer->enabled) {
/* For each consumer socket, send relayd sockets */
- cds_lfht_for_each_entry(usess->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (
+ usess->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
- ret = send_consumer_relayd_sockets(session->id,
- usess->consumer, socket,
- session->name, session->hostname,
- session->base_path,
- session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
- session->creation_time,
- session->name_contains_creation_time);
+ ret = send_consumer_relayd_sockets(
+ session->id,
+ usess->consumer,
+ socket,
+ session->name,
+ session->hostname,
+ session->base_path,
+ session->live_timer,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time,
+ session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
/* Session is now ready for network streaming. */
session->net_handle = 1;
}
- session->consumer->relay_major_version =
- usess->consumer->relay_major_version;
- session->consumer->relay_minor_version =
- usess->consumer->relay_minor_version;
- session->consumer->relay_allows_clear =
- usess->consumer->relay_allows_clear;
+ session->consumer->relay_major_version = usess->consumer->relay_major_version;
+ session->consumer->relay_minor_version = usess->consumer->relay_minor_version;
+ session->consumer->relay_allows_clear = usess->consumer->relay_allows_clear;
}
- if (ksess && ksess->consumer && ksess->consumer->type == CONSUMER_DST_NET
- && ksess->consumer->enabled) {
- cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ if (ksess && ksess->consumer && ksess->consumer->type == CONSUMER_DST_NET &&
+ ksess->consumer->enabled) {
+ cds_lfht_for_each_entry (
+ ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
- ret = send_consumer_relayd_sockets(session->id,
- ksess->consumer, socket,
- session->name, session->hostname,
- session->base_path,
- session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
- session->creation_time,
- session->name_contains_creation_time);
+ ret = send_consumer_relayd_sockets(
+ session->id,
+ ksess->consumer,
+ socket,
+ session->name,
+ session->hostname,
+ session->base_path,
+ session->live_timer,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time,
+ session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
goto error;
/* Session is now ready for network streaming. */
session->net_handle = 1;
}
- session->consumer->relay_major_version =
- ksess->consumer->relay_major_version;
- session->consumer->relay_minor_version =
- ksess->consumer->relay_minor_version;
- session->consumer->relay_allows_clear =
- ksess->consumer->relay_allows_clear;
+ session->consumer->relay_major_version = ksess->consumer->relay_major_version;
+ session->consumer->relay_minor_version = ksess->consumer->relay_minor_version;
+ session->consumer->relay_allows_clear = ksess->consumer->relay_allows_clear;
}
error:
}
/* For each channel */
- cds_list_for_each_entry(kchan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (kchan, &ksess->channel_list.head, list) {
if (kchan->stream_count == 0) {
ret = kernel_open_channel_stream(kchan);
if (ret < 0) {
}
/* Flush all buffers after stopping */
- cds_list_for_each_entry(kchan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (kchan, &ksess->channel_list.head, list) {
ret = kernel_flush_buffer(kchan);
if (ret < 0) {
ERR("Kernel flush buffer error");
* Command LTTNG_DISABLE_CHANNEL processed by the client thread.
*/
int cmd_disable_channel(struct ltt_session *session,
- enum lttng_domain_type domain, char *channel_name)
+ enum lttng_domain_type domain,
+ char *channel_name)
{
int ret;
struct ltt_ust_session *usess;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
{
- ret = channel_kernel_disable(session->kernel_session,
- channel_name);
+ ret = channel_kernel_disable(session->kernel_session, channel_name);
if (ret != LTTNG_OK) {
goto error;
}
goto end;
}
- sock_recv_len = lttcomm_recv_unix_sock(sock, channel_buffer.data,
- channel_len);
+ sock_recv_len = lttcomm_recv_unix_sock(sock, channel_buffer.data, channel_len);
if (sock_recv_len < 0 || sock_recv_len != channel_len) {
ERR("Failed to receive \"enable channel\" command payload");
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = cmd_enable_channel_internal(
- cmd_ctx->session, &command_domain, channel, wpipe);
+ ret = cmd_enable_channel_internal(cmd_ctx->session, &command_domain, channel, wpipe);
end:
lttng_dynamic_buffer_reset(&channel_buffer);
return ret;
}
-static enum lttng_error_code cmd_enable_channel_internal(
- struct ltt_session *session,
- const struct lttng_domain *domain,
- const struct lttng_channel *_attr,
- int wpipe)
+static enum lttng_error_code cmd_enable_channel_internal(struct ltt_session *session,
+ const struct lttng_domain *domain,
+ const struct lttng_channel *_attr,
+ int wpipe)
{
enum lttng_error_code ret_code;
struct ltt_ust_session *usess = session->ust_session;
len = lttng_strnlen(attr->name, sizeof(attr->name));
/* Validate channel name */
- if (attr->name[0] == '.' ||
- memchr(attr->name, '/', len) != NULL) {
+ if (attr->name[0] == '.' || memchr(attr->name, '/', len) != NULL) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto end;
}
if (kernel_supports_ring_buffer_snapshot_sample_positions() != 1) {
/* Sampling position of buffer is not supported */
WARN("Kernel tracer does not support buffer monitoring. "
- "Setting the monitor interval timer to 0 "
- "(disabled) for channel '%s' of session '%s'",
- attr->name, session->name);
+ "Setting the monitor interval timer to 0 "
+ "(disabled) for channel '%s' of session '%s'",
+ attr->name,
+ session->name);
lttng_channel_set_monitor_timer_interval(attr, 0);
}
break;
{
struct ltt_kernel_channel *kchan;
- kchan = trace_kernel_get_channel_by_name(
- attr->name, session->kernel_session);
+ kchan = trace_kernel_get_channel_by_name(attr->name, session->kernel_session);
if (kchan == NULL) {
/*
* Don't try to create a channel if the session has been started at
goto error;
}
- if (session->snapshot.nb_output > 0 ||
- session->snapshot_mode) {
+ if (session->snapshot.nb_output > 0 || session->snapshot_mode) {
/* Enforce mmap output for snapshot sessions. */
attr->attr.output = LTTNG_EVENT_MMAP;
}
- ret_code = channel_kernel_create(
- session->kernel_session, attr, wpipe);
+ ret_code = channel_kernel_create(session->kernel_session, attr, wpipe);
if (attr->name[0] != '\0') {
session->kernel_session->has_non_default_channel = 1;
}
* adhered to.
*/
if (domain->type == LTTNG_DOMAIN_JUL) {
- if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
} else if (domain->type == LTTNG_DOMAIN_LOG4J) {
- if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME, LTTNG_SYMBOL_NAME_LEN)) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
} else if (domain->type == LTTNG_DOMAIN_PYTHON) {
- if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (strncmp(attr->name,
+ DEFAULT_PYTHON_CHANNEL_NAME,
+ LTTNG_SYMBOL_NAME_LEN)) {
ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
goto error;
}
return ret_code;
}
-enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy *policy)
+enum lttng_error_code
+cmd_process_attr_tracker_get_tracking_policy(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy *policy)
{
enum lttng_error_code ret_code = LTTNG_OK;
const struct process_attr_tracker *tracker;
ret_code = LTTNG_ERR_INVALID;
goto end;
}
- tracker = kernel_get_process_attr_tracker(
- session->kernel_session, process_attr);
+ tracker = kernel_get_process_attr_tracker(session->kernel_session, process_attr);
break;
case LTTNG_DOMAIN_UST:
if (!session->ust_session) {
ret_code = LTTNG_ERR_INVALID;
goto end;
}
- tracker = trace_ust_get_process_attr_tracker(
- session->ust_session, process_attr);
+ tracker = trace_ust_get_process_attr_tracker(session->ust_session, process_attr);
break;
default:
ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
return ret_code;
}
-enum lttng_error_code cmd_process_attr_tracker_set_tracking_policy(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy)
+enum lttng_error_code
+cmd_process_attr_tracker_set_tracking_policy(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy)
{
enum lttng_error_code ret_code = LTTNG_OK;
goto end;
}
ret_code = kernel_process_attr_tracker_set_tracking_policy(
- session->kernel_session, process_attr, policy);
+ session->kernel_session, process_attr, policy);
break;
case LTTNG_DOMAIN_UST:
if (!session->ust_session) {
goto end;
}
ret_code = trace_ust_process_attr_tracker_set_tracking_policy(
- session->ust_session, process_attr, policy);
+ session->ust_session, process_attr, policy);
break;
default:
ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
return ret_code;
}
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_add_value(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+cmd_process_attr_tracker_inclusion_set_add_value(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
enum lttng_error_code ret_code = LTTNG_OK;
goto end;
}
ret_code = kernel_process_attr_tracker_inclusion_set_add_value(
- session->kernel_session, process_attr, value);
+ session->kernel_session, process_attr, value);
break;
case LTTNG_DOMAIN_UST:
if (!session->ust_session) {
goto end;
}
ret_code = trace_ust_process_attr_tracker_inclusion_set_add_value(
- session->ust_session, process_attr, value);
+ session->ust_session, process_attr, value);
break;
default:
ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
return ret_code;
}
-enum lttng_error_code cmd_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+cmd_process_attr_tracker_inclusion_set_remove_value(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
enum lttng_error_code ret_code = LTTNG_OK;
goto end;
}
ret_code = kernel_process_attr_tracker_inclusion_set_remove_value(
- session->kernel_session, process_attr, value);
+ session->kernel_session, process_attr, value);
break;
case LTTNG_DOMAIN_UST:
if (!session->ust_session) {
goto end;
}
ret_code = trace_ust_process_attr_tracker_inclusion_set_remove_value(
- session->ust_session, process_attr, value);
+ session->ust_session, process_attr, value);
break;
default:
ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
return ret_code;
}
-enum lttng_error_code cmd_process_attr_tracker_get_inclusion_set(
- struct ltt_session *session,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- struct lttng_process_attr_values **values)
+enum lttng_error_code
+cmd_process_attr_tracker_get_inclusion_set(struct ltt_session *session,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ struct lttng_process_attr_values **values)
{
enum lttng_error_code ret_code = LTTNG_OK;
const struct process_attr_tracker *tracker;
ret_code = LTTNG_ERR_INVALID;
goto end;
}
- tracker = kernel_get_process_attr_tracker(
- session->kernel_session, process_attr);
+ tracker = kernel_get_process_attr_tracker(session->kernel_session, process_attr);
break;
case LTTNG_DOMAIN_UST:
if (!session->ust_session) {
ret_code = LTTNG_ERR_INVALID;
goto end;
}
- tracker = trace_ust_get_process_attr_tracker(
- session->ust_session, process_attr);
+ tracker = trace_ust_get_process_attr_tracker(session->ust_session, process_attr);
break;
default:
ret_code = LTTNG_ERR_UNSUPPORTED_DOMAIN;
* Command LTTNG_DISABLE_EVENT processed by the client thread.
*/
int cmd_disable_event(struct command_ctx *cmd_ctx,
- struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *bytecode,
- struct lttng_event_exclusion *exclusion)
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *bytecode,
+ struct lttng_event_exclusion *exclusion)
{
int ret;
const char *event_name;
event_name = event->name;
/* Error out on unhandled search criteria */
- if (event->loglevel_type || event->loglevel != -1 || event->enabled
- || event->pid || event->filter || event->exclusion) {
+ if (event->loglevel_type || event->loglevel != -1 || event->enabled || event->pid ||
+ event->filter || event->exclusion) {
ret = LTTNG_ERR_UNK;
goto error;
}
case LTTNG_EVENT_SYSCALL:
case LTTNG_EVENT_PROBE:
case LTTNG_EVENT_FUNCTION:
- case LTTNG_EVENT_FUNCTION_ENTRY:/* fall-through */
+ case LTTNG_EVENT_FUNCTION_ENTRY: /* fall-through */
if (event_name[0] == '\0') {
- ret = event_kernel_disable_event(kchan,
- NULL, event->type);
+ ret = event_kernel_disable_event(kchan, NULL, event->type);
} else {
- ret = event_kernel_disable_event(kchan,
- event_name, event->type);
+ ret = event_kernel_disable_event(kchan, event_name, event->type);
}
if (ret != LTTNG_OK) {
goto error_unlock;
goto error_unlock;
}
- uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
- channel_name);
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
if (uchan == NULL) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error_unlock;
if (event->name[0] == '\0') {
ret = event_ust_disable_all_tracepoints(usess, uchan);
} else {
- ret = event_ust_disable_tracepoint(usess, uchan,
- event_name);
+ ret = event_ust_disable_tracepoint(usess, uchan, event_name);
}
if (ret != LTTNG_OK) {
goto error_unlock;
goto error_unlock;
}
- DBG3("Disable UST event %s in channel %s completed", event_name,
- channel_name);
+ DBG3("Disable UST event %s in channel %s completed", event_name, channel_name);
break;
}
case LTTNG_DOMAIN_LOG4J:
* Command LTTNG_ADD_CONTEXT processed by the client thread.
*/
int cmd_add_context(struct command_ctx *cmd_ctx,
- const struct lttng_event_context *event_context, int kwpipe)
+ const struct lttng_event_context *event_context,
+ int kwpipe)
{
int ret, chan_kern_created = 0, chan_ust_created = 0;
const enum lttng_domain_type domain = cmd_ctx->lsm.domain.type;
chan_kern_created = 1;
}
/* Add kernel context to kernel tracer */
- ret = context_kernel_add(session->kernel_session,
- event_context, channel_name);
+ ret = context_kernel_add(session->kernel_session, event_context, channel_name);
if (ret != LTTNG_OK) {
goto error;
}
* name, return an error.
*/
if (domain == LTTNG_DOMAIN_JUL && *channel_name &&
- strcmp(channel_name,
- DEFAULT_JUL_CHANNEL_NAME)) {
+ strcmp(channel_name, DEFAULT_JUL_CHANNEL_NAME)) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
} else if (domain == LTTNG_DOMAIN_LOG4J && *channel_name &&
- strcmp(channel_name,
- DEFAULT_LOG4J_CHANNEL_NAME)) {
+ strcmp(channel_name, DEFAULT_LOG4J_CHANNEL_NAME)) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
}
chan_ust_created = 1;
}
- ret = context_ust_add(usess, domain, event_context,
- channel_name);
+ ret = context_ust_add(usess, domain, event_context, channel_name);
if (ret != LTTNG_OK) {
goto error;
}
error:
if (chan_kern_created) {
- struct ltt_kernel_channel *kchan =
- trace_kernel_get_channel_by_name(DEFAULT_CHANNEL_NAME,
- session->kernel_session);
+ struct ltt_kernel_channel *kchan = trace_kernel_get_channel_by_name(
+ DEFAULT_CHANNEL_NAME, session->kernel_session);
/* Created previously, this should NOT fail. */
LTTNG_ASSERT(kchan);
kernel_destroy_channel(kchan);
}
if (chan_ust_created) {
- struct ltt_ust_channel *uchan =
- trace_ust_find_channel_by_name(
- session->ust_session->domain_global.channels,
- DEFAULT_CHANNEL_NAME);
+ struct ltt_ust_channel *uchan = trace_ust_find_channel_by_name(
+ session->ust_session->domain_global.channels, DEFAULT_CHANNEL_NAME);
/* Created previously, this should NOT fail. */
LTTNG_ASSERT(uchan);
/* Remove from the channel list of the session. */
- trace_ust_delete_channel(session->ust_session->domain_global.channels,
- uchan);
+ trace_ust_delete_channel(session->ust_session->domain_global.channels, uchan);
trace_ust_destroy_channel(uchan);
}
end:
* by the agents.
*/
if (name_starts_with(name, DEFAULT_JUL_EVENT_COMPONENT) ||
- name_starts_with(name, DEFAULT_LOG4J_EVENT_COMPONENT) ||
- name_starts_with(name, DEFAULT_PYTHON_EVENT_COMPONENT)) {
+ name_starts_with(name, DEFAULT_LOG4J_EVENT_COMPONENT) ||
+ name_starts_with(name, DEFAULT_PYTHON_EVENT_COMPONENT)) {
ret = -1;
}
* enable the events through which all "agent" events are funeled.
*/
static int _cmd_enable_event(struct ltt_session *session,
- const struct lttng_domain *domain,
- char *channel_name, struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- int wpipe, bool internal_event)
+ const struct lttng_domain *domain,
+ char *channel_name,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ int wpipe,
+ bool internal_event)
{
int ret = 0, channel_created = 0;
struct lttng_channel *attr = NULL;
* session, explicitely require that -c chan_name needs
* to be provided.
*/
- if (session->kernel_session->has_non_default_channel
- && channel_name[0] == '\0') {
+ 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);
+ kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
if (kchan == NULL) {
- attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL,
- LTTNG_BUFFER_GLOBAL);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL, LTTNG_BUFFER_GLOBAL);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- if (lttng_strncpy(attr->name, channel_name,
- sizeof(attr->name))) {
+ if (lttng_strncpy(attr->name, channel_name, sizeof(attr->name))) {
ret = LTTNG_ERR_INVALID;
goto error;
}
- ret = cmd_enable_channel_internal(
- session, domain, attr, wpipe);
+ ret = cmd_enable_channel_internal(session, domain, attr, wpipe);
if (ret != LTTNG_OK) {
goto error;
}
}
/* Get the newly created kernel channel pointer */
- kchan = trace_kernel_get_channel_by_name(channel_name,
- session->kernel_session);
+ kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session);
if (kchan == NULL) {
/* This sould not happen... */
ret = LTTNG_ERR_FATAL;
}
memcpy(filter_a, filter, sizeof(*filter_a) + filter->len);
}
- event->type = LTTNG_EVENT_TRACEPOINT; /* Hack */
- ret = event_kernel_enable_event(kchan, event,
- filter_expression, filter);
+ event->type = LTTNG_EVENT_TRACEPOINT; /* Hack */
+ ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
filter_expression = NULL;
filter = NULL;
free(filter_a);
goto error;
}
- event->type = LTTNG_EVENT_SYSCALL; /* Hack */
- ret = event_kernel_enable_event(kchan, event,
- filter_expression_a, filter_a);
+ event->type = LTTNG_EVENT_SYSCALL; /* Hack */
+ ret = event_kernel_enable_event(
+ kchan, event, filter_expression_a, filter_a);
/* We have passed ownership */
filter_expression_a = NULL;
filter_a = NULL;
case LTTNG_EVENT_FUNCTION:
case LTTNG_EVENT_FUNCTION_ENTRY:
case LTTNG_EVENT_TRACEPOINT:
- ret = event_kernel_enable_event(kchan, event,
- filter_expression, filter);
+ ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
filter_expression = NULL;
filter = NULL;
}
break;
case LTTNG_EVENT_SYSCALL:
- ret = event_kernel_enable_event(kchan, event,
- filter_expression, filter);
+ ret = event_kernel_enable_event(kchan, event, filter_expression, filter);
/* We have passed ownership */
filter_expression = NULL;
filter = NULL;
}
/* Get channel from global UST domain */
- uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
- channel_name);
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name);
if (uchan == NULL) {
/* Create default channel */
- attr = channel_new_default_attr(LTTNG_DOMAIN_UST,
- usess->buffer_type);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_UST, usess->buffer_type);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- if (lttng_strncpy(attr->name, channel_name,
- sizeof(attr->name))) {
+ if (lttng_strncpy(attr->name, channel_name, sizeof(attr->name))) {
ret = LTTNG_ERR_INVALID;
goto error;
}
- ret = cmd_enable_channel_internal(
- session, domain, attr, wpipe);
+ ret = cmd_enable_channel_internal(session, domain, attr, wpipe);
if (ret != LTTNG_OK) {
goto error;
}
/* Get the newly created channel reference back */
- uchan = trace_ust_find_channel_by_name(
- usess->domain_global.channels, channel_name);
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
+ channel_name);
LTTNG_ASSERT(uchan);
}
*/
ret = validate_ust_event_name(event->name);
if (ret) {
- WARN("Userspace event name %s failed validation.",
- event->name);
+ WARN("Userspace event name %s failed validation.", event->name);
ret = LTTNG_ERR_INVALID_EVENT_NAME;
goto error;
}
}
/* At this point, the session and channel exist on the tracer */
- ret = event_ust_enable_tracepoint(usess, uchan, event,
- filter_expression, filter, exclusion,
- internal_event);
+ ret = event_ust_enable_tracepoint(
+ usess, uchan, event, filter_expression, filter, exclusion, internal_event);
/* We have passed ownership */
filter_expression = NULL;
filter = NULL;
memset(&uevent, 0, sizeof(uevent));
uevent.type = LTTNG_EVENT_TRACEPOINT;
uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- default_event_name = event_get_default_agent_ust_name(
- domain->type);
+ default_event_name = event_get_default_agent_ust_name(domain->type);
if (!default_event_name) {
ret = LTTNG_ERR_FATAL;
goto error;
struct lttng_bytecode *filter_copy = NULL;
if (filter) {
- const size_t filter_size = sizeof(
- struct lttng_bytecode)
- + filter->len;
+ const size_t filter_size =
+ sizeof(struct lttng_bytecode) + filter->len;
filter_copy = zmalloc<lttng_bytecode>(filter_size);
if (!filter_copy) {
}
memcpy(filter_copy, filter, filter_size);
- filter_expression_copy =
- strdup(filter_expression);
+ filter_expression_copy = strdup(filter_expression);
if (!filter_expression) {
ret = LTTNG_ERR_NOMEM;
}
}
}
- ret = cmd_enable_event_internal(session, &tmp_dom,
- (char *) default_chan_name,
- &uevent, filter_expression_copy,
- filter_copy, NULL, wpipe);
+ ret = cmd_enable_event_internal(session,
+ &tmp_dom,
+ (char *) default_chan_name,
+ &uevent,
+ filter_expression_copy,
+ filter_copy,
+ NULL,
+ wpipe);
}
if (ret == LTTNG_ERR_UST_EVENT_ENABLED) {
/* The wild card * means that everything should be enabled. */
if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
- ret = event_agent_enable_all(usess, agt, event, filter,
- filter_expression);
+ ret = event_agent_enable_all(usess, agt, event, filter, filter_expression);
} else {
- ret = event_agent_enable(usess, agt, event, filter,
- filter_expression);
+ ret = event_agent_enable(usess, agt, event, filter, filter_expression);
}
filter = NULL;
filter_expression = NULL;
* We own filter, exclusion, and filter_expression.
*/
int cmd_enable_event(struct command_ctx *cmd_ctx,
- struct lttng_event *event,
- char *filter_expression,
- struct lttng_event_exclusion *exclusion,
- struct lttng_bytecode *bytecode,
- int wpipe)
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_event_exclusion *exclusion,
+ struct lttng_bytecode *bytecode,
+ int wpipe)
{
int ret;
/*
* - exclusion
*/
ret = _cmd_enable_event(cmd_ctx->session,
- &command_domain,
- cmd_ctx->lsm.u.enable.channel_name, event,
- filter_expression, bytecode, exclusion, wpipe, false);
+ &command_domain,
+ cmd_ctx->lsm.u.enable.channel_name,
+ event,
+ filter_expression,
+ bytecode,
+ exclusion,
+ wpipe,
+ false);
filter_expression = NULL;
bytecode = NULL;
exclusion = NULL;
* reserved names.
*/
static int cmd_enable_event_internal(struct ltt_session *session,
- const struct lttng_domain *domain,
- char *channel_name, struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- int wpipe)
+ const struct lttng_domain *domain,
+ char *channel_name,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ int wpipe)
{
- return _cmd_enable_event(session, domain, channel_name, event,
- filter_expression, filter, exclusion, wpipe, true);
+ return _cmd_enable_event(session,
+ domain,
+ channel_name,
+ event,
+ filter_expression,
+ filter,
+ exclusion,
+ wpipe,
+ true);
}
/*
* Command LTTNG_LIST_TRACEPOINTS processed by the client thread.
*/
enum lttng_error_code cmd_list_tracepoints(enum lttng_domain_type domain,
- struct lttng_payload *reply_payload)
+ struct lttng_payload *reply_payload)
{
enum lttng_error_code ret_code;
int ret;
/* Reserve space for command reply header. */
reply_command_header_offset = reply_payload->buffer.size;
ret = lttng_dynamic_buffer_set_size(&reply_payload->buffer,
- reply_command_header_offset +
- sizeof(struct lttcomm_list_command_header));
+ reply_command_header_offset +
+ sizeof(struct lttcomm_list_command_header));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL,
- reply_payload);
+ ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
/* Update command reply header. */
reply_command_header.count = (uint32_t) nb_events;
- memcpy(reply_payload->buffer.data + reply_command_header_offset, &reply_command_header,
- sizeof(reply_command_header));
+ memcpy(reply_payload->buffer.data + reply_command_header_offset,
+ &reply_command_header,
+ sizeof(reply_command_header));
ret_code = LTTNG_OK;
error:
* Command LTTNG_LIST_TRACEPOINT_FIELDS processed by the client thread.
*/
enum lttng_error_code cmd_list_tracepoint_fields(enum lttng_domain_type domain,
- struct lttng_payload *reply)
+ struct lttng_payload *reply)
{
enum lttng_error_code ret_code;
int ret;
/* Reserve space for command reply header. */
reply_command_header_offset = reply->buffer.size;
ret = lttng_dynamic_buffer_set_size(&reply->buffer,
- reply_command_header_offset +
- sizeof(struct lttcomm_list_command_header));
+ reply_command_header_offset +
+ sizeof(struct lttcomm_list_command_header));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto error;
break;
case LTTNG_DOMAIN_KERNEL:
- default: /* fall-through */
+ default: /* fall-through */
ret_code = LTTNG_ERR_UND;
goto error;
}
/* Update command reply header. */
reply_command_header.count = (uint32_t) nb_fields;
- memcpy(reply->buffer.data + reply_command_header_offset, &reply_command_header,
- sizeof(reply_command_header));
+ memcpy(reply->buffer.data + reply_command_header_offset,
+ &reply_command_header,
+ sizeof(reply_command_header));
ret_code = LTTNG_OK;
return ret_code;
}
-enum lttng_error_code cmd_list_syscalls(
- struct lttng_payload *reply_payload)
+enum lttng_error_code cmd_list_syscalls(struct lttng_payload *reply_payload)
{
enum lttng_error_code ret_code;
ssize_t nb_events, i;
/* Reserve space for command reply header. */
reply_command_header_offset = reply_payload->buffer.size;
ret = lttng_dynamic_buffer_set_size(&reply_payload->buffer,
- reply_command_header_offset +
- sizeof(struct lttcomm_list_command_header));
+ reply_command_header_offset +
+ sizeof(struct lttcomm_list_command_header));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
nb_events = syscall_table_list(&events);
if (nb_events < 0) {
- ret_code = (enum lttng_error_code) -nb_events;
+ ret_code = (enum lttng_error_code) - nb_events;
goto end;
}
for (i = 0; i < nb_events; i++) {
- ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL,
- reply_payload);
+ ret = lttng_event_serialize(&events[i], 0, NULL, NULL, 0, NULL, reply_payload);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Update command reply header. */
reply_command_header.count = (uint32_t) nb_events;
- memcpy(reply_payload->buffer.data + reply_command_header_offset, &reply_command_header,
- sizeof(reply_command_header));
+ memcpy(reply_payload->buffer.data + reply_command_header_offset,
+ &reply_command_header,
+ sizeof(reply_command_header));
ret_code = LTTNG_OK;
end:
unsigned long nb_chan = 0;
struct ltt_kernel_session *ksession;
struct ltt_ust_session *usess;
- const bool session_rotated_after_last_stop =
- session->rotated_after_last_stop;
- const bool session_cleared_after_last_stop =
- session->cleared_after_last_stop;
+ const bool session_rotated_after_last_stop = session->rotated_after_last_stop;
+ const bool session_cleared_after_last_stop = session->cleared_after_last_stop;
LTTNG_ASSERT(session);
}
if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING &&
- !session->current_trace_chunk) {
+ !session->current_trace_chunk) {
/*
* A rotation was launched while the session was stopped and
* it has not been completed yet. It is not possible to start
* supported.
*/
WARN("Refusing to start session \"%s\" as a rotation launched after the last \"stop\" is still ongoing",
- session->name);
+ session->name);
ret = LTTNG_ERR_ROTATION_PENDING;
goto error;
}
if (!session->has_been_started) {
struct lttng_trace_chunk *trace_chunk;
- DBG("Creating initial trace chunk of session \"%s\"",
- session->name);
- trace_chunk = session_create_new_trace_chunk(
- session, NULL, NULL, NULL);
+ DBG("Creating initial trace chunk of session \"%s\"", session->name);
+ trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
if (!trace_chunk) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
LTTNG_ASSERT(!session->current_trace_chunk);
- ret = (lttng_error_code) session_set_trace_chunk(session, trace_chunk,
- NULL);
+ ret = (lttng_error_code) session_set_trace_chunk(
+ session, trace_chunk, NULL);
lttng_trace_chunk_put(trace_chunk);
if (ret) {
ret = LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER;
}
} else {
DBG("Rotating session \"%s\" from its current \"NULL\" trace chunk to a new chunk",
- session->name);
+ session->name);
/*
* Rotate existing streams into the new chunk.
* This is a "quiet" rotation has no client has
* was produced as the session was stopped, so the
* rotation should happen on reception of the command.
*/
- ret = (lttng_error_code) cmd_rotate_session(session, NULL, true,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ ret = (lttng_error_code) cmd_rotate_session(
+ session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
if (ret != LTTNG_OK) {
goto error;
}
if (session->rotate_timer_period && !session->rotation_schedule_timer_enabled) {
int int_ret = timer_session_rotation_schedule_timer_start(
- session, session->rotate_timer_period);
+ session, session->rotate_timer_period);
if (int_ret < 0) {
ERR("Failed to enable rotate timer");
} else {
session->active = 0;
/* 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;
+ session->rotated_after_last_stop = session_rotated_after_last_stop;
+ session->cleared_after_last_stop = session_cleared_after_last_stop;
}
end:
return ret;
}
}
- DBG("Completed stop session \"%s\" (id %" PRIu64 ")", session->name,
- session->id);
+ DBG("Completed stop session \"%s\" (id %" PRIu64 ")", session->name, session->id);
/* Flag inactive after a successful stop. */
session->active = 0;
ret = LTTNG_OK;
* Set the base_path of the session only if subdir of a control uris is set.
* Return LTTNG_OK on success, otherwise LTTNG_ERR_*.
*/
-static int set_session_base_path_from_uris(struct ltt_session *session,
- size_t nb_uri,
- struct lttng_uri *uris)
+static int
+set_session_base_path_from_uris(struct ltt_session *session, size_t nb_uri, struct lttng_uri *uris)
{
int ret;
size_t i;
for (i = 0; i < nb_uri; i++) {
- if (uris[i].stype != LTTNG_STREAM_CONTROL ||
- uris[i].subdir[0] == '\0') {
+ if (uris[i].stype != LTTNG_STREAM_CONTROL || uris[i].subdir[0] == '\0') {
/* Not interested in these URIs */
continue;
}
session->base_path = strdup(uris[i].subdir);
if (!session->base_path) {
PERROR("Failed to copy base path \"%s\" to session \"%s\"",
- uris[i].subdir, session->name);
+ uris[i].subdir,
+ session->name);
ret = LTTNG_ERR_NOMEM;
goto error;
}
DBG2("Setting base path \"%s\" for session \"%s\"",
- session->base_path, session->name);
+ session->base_path,
+ session->name);
}
ret = LTTNG_OK;
error:
/*
* Command LTTNG_SET_CONSUMER_URI processed by the client thread.
*/
-int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri,
- struct lttng_uri *uris)
+int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, struct lttng_uri *uris)
{
int ret, i;
struct ltt_kernel_session *ksess = session->kernel_session;
/* Set the "global" consumer URIs */
for (i = 0; i < nb_uri; i++) {
- ret = add_uri_to_consumer(session, session->consumer, &uris[i],
- LTTNG_DOMAIN_NONE);
+ ret = add_uri_to_consumer(session, session->consumer, &uris[i], LTTNG_DOMAIN_NONE);
if (ret != LTTNG_OK) {
goto error;
}
if (session->ust_session) {
for (i = 0; i < nb_uri; i++) {
ret = add_uri_to_consumer(session,
- session->ust_session->consumer,
- &uris[i], LTTNG_DOMAIN_UST);
+ session->ust_session->consumer,
+ &uris[i],
+ LTTNG_DOMAIN_UST);
if (ret != LTTNG_OK) {
goto error;
}
if (session->kernel_session) {
for (i = 0; i < nb_uri; i++) {
ret = add_uri_to_consumer(session,
- session->kernel_session->consumer,
- &uris[i], LTTNG_DOMAIN_KERNEL);
+ session->kernel_session->consumer,
+ &uris[i],
+ LTTNG_DOMAIN_KERNEL);
if (ret != LTTNG_OK) {
goto error;
}
return ret;
}
-static
-enum lttng_error_code set_session_output_from_descriptor(
- struct ltt_session *session,
- const struct lttng_session_descriptor *descriptor)
+static enum lttng_error_code
+set_session_output_from_descriptor(struct ltt_session *session,
+ const struct lttng_session_descriptor *descriptor)
{
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
enum lttng_session_descriptor_type session_type =
- lttng_session_descriptor_get_type(descriptor);
+ lttng_session_descriptor_get_type(descriptor);
enum lttng_session_descriptor_output_type output_type =
- lttng_session_descriptor_get_output_type(descriptor);
+ lttng_session_descriptor_get_output_type(descriptor);
struct lttng_uri uris[2] = {};
size_t uri_count = 0;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
goto end;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL:
- lttng_session_descriptor_get_local_output_uri(descriptor,
- &uris[0]);
+ lttng_session_descriptor_get_local_output_uri(descriptor, &uris[0]);
uri_count = 1;
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
- lttng_session_descriptor_get_network_output_uris(descriptor,
- &uris[0], &uris[1]);
+ lttng_session_descriptor_get_network_output_uris(descriptor, &uris[0], &uris[1]);
uri_count = 2;
break;
default:
}
ret = snapshot_output_init_with_uri(session,
- DEFAULT_SNAPSHOT_MAX_SIZE,
- NULL, uris, uri_count, session->consumer,
- new_output, &session->snapshot);
+ DEFAULT_SNAPSHOT_MAX_SIZE,
+ NULL,
+ uris,
+ uri_count,
+ session->consumer,
+ new_output,
+ &session->snapshot);
if (ret < 0) {
- ret_code = (ret == -ENOMEM) ?
- LTTNG_ERR_NOMEM : LTTNG_ERR_INVALID;
+ ret_code = (ret == -ENOMEM) ? LTTNG_ERR_NOMEM : LTTNG_ERR_INVALID;
snapshot_output_destroy(new_output);
goto end;
}
return ret_code;
}
-static
-enum lttng_error_code cmd_create_session_from_descriptor(
- struct lttng_session_descriptor *descriptor,
- const lttng_sock_cred *creds,
- const char *home_path)
+static enum lttng_error_code
+cmd_create_session_from_descriptor(struct lttng_session_descriptor *descriptor,
+ const lttng_sock_cred *creds,
+ const char *home_path)
{
int ret;
enum lttng_error_code ret_code;
}
}
- descriptor_status = lttng_session_descriptor_get_session_name(
- descriptor, &session_name);
+ descriptor_status = lttng_session_descriptor_get_session_name(descriptor, &session_name);
switch (descriptor_status) {
case LTTNG_SESSION_DESCRIPTOR_STATUS_OK:
break;
goto end;
}
- ret_code = session_create(session_name, creds->uid, creds->gid,
- &new_session);
+ ret_code = session_create(session_name, creds->uid, creds->gid, &new_session);
if (ret_code != LTTNG_OK) {
goto end;
}
ret_code = notification_thread_command_add_session(the_notification_thread_handle,
- new_session->id, new_session->name, new_session->uid, new_session->gid);
+ new_session->id,
+ new_session->name,
+ new_session->uid,
+ new_session->gid);
if (ret_code != LTTNG_OK) {
goto end;
}
/* Announce the session's destruction to the notification thread when it is destroyed. */
ret = session_add_destroy_notifier(
- new_session,
- [](const struct ltt_session *session,
- void *user_data __attribute__((unused))) {
- (void) notification_thread_command_remove_session(
- the_notification_thread_handle, session->id);
- },
- NULL);
+ new_session,
+ [](const struct ltt_session *session, void *user_data __attribute__((unused))) {
+ (void) notification_thread_command_remove_session(
+ the_notification_thread_handle, session->id);
+ },
+ NULL);
if (ret) {
PERROR("Failed to add notification thread command to session's destroy notifiers: session name = %s",
- new_session->name);
+ new_session->name);
ret = LTTNG_ERR_NOMEM;
goto end;
}
if (!session_name) {
- ret = lttng_session_descriptor_set_session_name(descriptor,
- new_session->name);
+ ret = lttng_session_descriptor_set_session_name(descriptor, new_session->name);
if (ret) {
ret_code = LTTNG_ERR_SESSION_FAIL;
goto end;
}
}
- if (!lttng_session_descriptor_is_output_destination_initialized(
- descriptor)) {
+ if (!lttng_session_descriptor_is_output_destination_initialized(descriptor)) {
/*
* Only include the session's creation time in the output
* destination if the name of the session itself was
* not auto-generated.
*/
ret_code = lttng_session_descriptor_set_default_output(
- descriptor,
- session_name ? &new_session->creation_time : NULL,
- home_path);
+ descriptor, session_name ? &new_session->creation_time : NULL, home_path);
if (ret_code != LTTNG_OK) {
goto end;
}
} else {
new_session->has_user_specified_directory =
- lttng_session_descriptor_has_output_directory(
- descriptor);
+ lttng_session_descriptor_has_output_directory(descriptor);
}
switch (lttng_session_descriptor_get_type(descriptor)) {
break;
case LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE:
new_session->live_timer =
- lttng_session_descriptor_live_get_timer_interval(
- descriptor);
+ lttng_session_descriptor_live_get_timer_interval(descriptor);
break;
default:
break;
return ret_code;
}
-enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx, int sock,
- struct lttng_session_descriptor **return_descriptor)
+enum lttng_error_code cmd_create_session(struct command_ctx *cmd_ctx,
+ int sock,
+ struct lttng_session_descriptor **return_descriptor)
{
int ret;
size_t payload_size;
enum lttng_error_code ret_code;
lttng_dynamic_buffer_init(&payload);
- if (cmd_ctx->lsm.u.create_session.home_dir_size >=
- LTTNG_PATH_MAX) {
+ if (cmd_ctx->lsm.u.create_session.home_dir_size >= LTTNG_PATH_MAX) {
ret_code = LTTNG_ERR_INVALID;
goto error;
}
if (cmd_ctx->lsm.u.create_session.session_descriptor_size >
- LTTNG_SESSION_DESCRIPTOR_MAX_LEN) {
+ LTTNG_SESSION_DESCRIPTOR_MAX_LEN) {
ret_code = LTTNG_ERR_INVALID;
goto error;
}
payload_size = cmd_ctx->lsm.u.create_session.home_dir_size +
- cmd_ctx->lsm.u.create_session.session_descriptor_size;
+ cmd_ctx->lsm.u.create_session.session_descriptor_size;
ret = lttng_dynamic_buffer_set_size(&payload, payload_size);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
}
home_dir_view = lttng_buffer_view_from_dynamic_buffer(
- &payload,
- 0,
- cmd_ctx->lsm.u.create_session.home_dir_size);
+ &payload, 0, cmd_ctx->lsm.u.create_session.home_dir_size);
if (cmd_ctx->lsm.u.create_session.home_dir_size > 0 &&
- !lttng_buffer_view_is_valid(&home_dir_view)) {
+ !lttng_buffer_view_is_valid(&home_dir_view)) {
ERR("Invalid payload in \"create session\" command: buffer too short to contain home directory");
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto error;
}
session_descriptor_view = lttng_buffer_view_from_dynamic_buffer(
- &payload,
- cmd_ctx->lsm.u.create_session.home_dir_size,
- cmd_ctx->lsm.u.create_session.session_descriptor_size);
+ &payload,
+ cmd_ctx->lsm.u.create_session.home_dir_size,
+ cmd_ctx->lsm.u.create_session.session_descriptor_size);
if (!lttng_buffer_view_is_valid(&session_descriptor_view)) {
ERR("Invalid payload in \"create session\" command: buffer too short to contain session descriptor");
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto error;
}
- ret = lttng_session_descriptor_create_from_buffer(
- &session_descriptor_view, &session_descriptor);
+ ret = lttng_session_descriptor_create_from_buffer(&session_descriptor_view,
+ &session_descriptor);
if (ret < 0) {
ERR("Failed to create session descriptor from payload of \"create session\" command");
ret_code = LTTNG_ERR_INVALID;
* Sets the descriptor's auto-generated properties (name, output) if
* needed.
*/
- ret_code = cmd_create_session_from_descriptor(session_descriptor,
- &cmd_ctx->creds,
- home_dir_view.size ? home_dir_view.data : NULL);
+ ret_code =
+ cmd_create_session_from_descriptor(session_descriptor,
+ &cmd_ctx->creds,
+ home_dir_view.size ? home_dir_view.data : NULL);
if (ret_code != LTTNG_OK) {
goto error;
}
return ret_code;
}
-static
-void cmd_destroy_session_reply(const struct ltt_session *session,
- void *_reply_context)
+static void cmd_destroy_session_reply(const struct ltt_session *session, void *_reply_context)
{
int ret;
ssize_t comm_ret;
const struct cmd_destroy_session_reply_context *reply_context =
- (cmd_destroy_session_reply_context *) _reply_context;
+ (cmd_destroy_session_reply_context *) _reply_context;
struct lttng_dynamic_buffer payload;
struct lttcomm_session_destroy_command_header cmd_header;
struct lttng_trace_archive_location *location = NULL;
.cmd_type = LTTCOMM_SESSIOND_COMMAND_DESTROY_SESSION,
.ret_code = reply_context->destruction_status,
.pid = UINT32_MAX,
- .cmd_header_size =
- sizeof(struct lttcomm_session_destroy_command_header),
+ .cmd_header_size = sizeof(struct lttcomm_session_destroy_command_header),
.data_size = 0,
.fd_count = 0,
};
goto error;
}
- cmd_header.rotation_state =
- (int32_t) (reply_context->implicit_rotation_on_destroy ?
- session->rotation_state :
- LTTNG_ROTATION_STATE_NO_ROTATION);
- ret = lttng_dynamic_buffer_append(&payload, &cmd_header,
- sizeof(cmd_header));
+ cmd_header.rotation_state = (int32_t) (reply_context->implicit_rotation_on_destroy ?
+ session->rotation_state :
+ LTTNG_ROTATION_STATE_NO_ROTATION);
+ ret = lttng_dynamic_buffer_append(&payload, &cmd_header, sizeof(cmd_header));
if (ret) {
ERR("Failed to append session destruction command header");
goto error;
if (!reply_context->implicit_rotation_on_destroy) {
DBG("No implicit rotation performed during the destruction of session \"%s\", sending reply",
- session->name);
+ session->name);
goto send_reply;
}
if (session->rotation_state != LTTNG_ROTATION_STATE_COMPLETED) {
DBG("Rotation state of session \"%s\" is not \"completed\", sending session destruction reply",
- session->name);
+ session->name);
goto send_reply;
}
location = session_get_trace_archive_location(session);
if (!location) {
ERR("Failed to get the location of the trace archive produced during the destruction of session \"%s\"",
- session->name);
+ session->name);
goto error;
}
payload_size_before_location = payload.size;
- comm_ret = lttng_trace_archive_location_serialize(location,
- &payload);
+ comm_ret = lttng_trace_archive_location_serialize(location, &payload);
lttng_trace_archive_location_put(location);
if (comm_ret < 0) {
ERR("Failed to serialize the location of the trace archive produced during the destruction of session \"%s\"",
- session->name);
+ session->name);
goto error;
}
/* Update the message to indicate the location's length. */
((struct lttcomm_lttng_msg *) payload.data)->data_size =
- payload.size - payload_size_before_location;
+ payload.size - payload_size_before_location;
send_reply:
- comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd,
- payload.data, payload.size);
+ comm_ret = lttcomm_send_unix_sock(reply_context->reply_sock_fd, payload.data, payload.size);
if (comm_ret != (ssize_t) payload.size) {
ERR("Failed to send result of the destruction of session \"%s\" to client",
- session->name);
+ session->name);
}
error:
ret = close(reply_context->reply_sock_fd);
* Called with session lock held.
*/
int cmd_destroy_session(struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle,
- int *sock_fd)
+ struct notification_thread_handle *notification_thread_handle,
+ int *sock_fd)
{
int ret;
enum lttng_error_code destruction_last_error = LTTNG_OK;
/* Safety net */
LTTNG_ASSERT(session);
- DBG("Begin destroy session %s (id %" PRIu64 ")", session->name,
- session->id);
+ DBG("Begin destroy session %s (id %" PRIu64 ")", session->name, session->id);
if (session->active) {
DBG("Session \"%s\" is active, attempting to stop it before destroying it",
- session->name);
+ session->name);
ret = cmd_stop_trace(session);
if (ret != LTTNG_OK && ret != LTTNG_ERR_TRACE_ALREADY_STOPPED) {
/* Carry on with the destruction of the session. */
ERR("Failed to stop session \"%s\" as part of its destruction: %s",
- session->name, lttng_strerror(-ret));
+ session->name,
+ lttng_strerror(-ret));
destruction_last_error = (lttng_error_code) ret;
}
}
if (session->rotation_schedule_timer_enabled) {
- if (timer_session_rotation_schedule_timer_stop(
- session)) {
+ if (timer_session_rotation_schedule_timer_stop(session)) {
ERR("Failed to stop the \"rotation schedule\" timer of session %s",
- session->name);
+ session->name);
destruction_last_error = LTTNG_ERR_TIMER_STOP_ERROR;
}
}
* Perform a last rotation on destruction if rotations have
* occurred during the session's lifetime.
*/
- ret = cmd_rotate_session(session, NULL, false,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ ret = cmd_rotate_session(
+ session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret != LTTNG_OK) {
ERR("Failed to perform an implicit rotation as part of the destruction of session \"%s\": %s",
- session->name, lttng_strerror(-ret));
+ session->name,
+ lttng_strerror(-ret));
destruction_last_error = (lttng_error_code) -ret;
}
if (reply_context) {
* emitted and no renaming of the current trace chunk takes
* place.
*/
- ret = cmd_rotate_session(session, NULL, true,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
+ ret = cmd_rotate_session(
+ session, NULL, true, LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
/*
* Rotation operations may not be supported by the kernel
* tracer. Hence, do not consider this implicit rotation as
* the session and waited for pending data; there is nothing
* left to do but complete the destruction of the session.
*/
- if (ret != LTTNG_OK &&
- ret != -LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL) {
+ if (ret != LTTNG_OK && ret != -LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL) {
ERR("Failed to perform a quiet rotation as part of the destruction of session \"%s\": %s",
- session->name, lttng_strerror(ret));
+ session->name,
+ lttng_strerror(ret));
destruction_last_error = (lttng_error_code) -ret;
}
}
*/
current_completion_handler = &destroy_completion_handler.handler;
ret = lttng_strncpy(destroy_completion_handler.shm_path,
- session->shm_path,
- sizeof(destroy_completion_handler.shm_path));
+ session->shm_path,
+ sizeof(destroy_completion_handler.shm_path));
LTTNG_ASSERT(!ret);
}
session_destroy(session);
if (reply_context) {
reply_context->destruction_status = destruction_last_error;
- ret = session_add_destroy_notifier(session,
- cmd_destroy_session_reply,
- (void *) reply_context);
+ ret = session_add_destroy_notifier(
+ session, cmd_destroy_session_reply, (void *) reply_context);
if (ret) {
ret = LTTNG_ERR_FATAL;
goto end;
* Command LTTNG_REGISTER_CONSUMER processed by the client thread.
*/
int cmd_register_consumer(struct ltt_session *session,
- enum lttng_domain_type domain, const char *sock_path,
- struct consumer_data *cdata)
+ enum lttng_domain_type domain,
+ const char *sock_path,
+ struct consumer_data *cdata)
{
int ret, sock;
struct consumer_socket *socket = NULL;
/*
* Command LTTNG_LIST_DOMAINS processed by the client thread.
*/
-ssize_t cmd_list_domains(struct ltt_session *session,
- struct lttng_domain **domains)
+ssize_t cmd_list_domains(struct ltt_session *session, struct lttng_domain **domains)
{
int ret, index = 0;
ssize_t nb_dom = 0;
nb_dom++;
rcu_read_lock();
- cds_lfht_for_each_entry(session->ust_session->agents->ht, &iter.iter,
- agt, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->agents->ht, &iter.iter, agt, node.node) {
if (agt->being_used) {
nb_dom++;
}
index++;
rcu_read_lock();
- cds_lfht_for_each_entry(session->ust_session->agents->ht, &iter.iter,
- agt, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->agents->ht, &iter.iter, agt, node.node) {
if (agt->being_used) {
(*domains)[index].type = agt->domain;
(*domains)[index].buf_type = session->ust_session->buffer_type;
return -ret;
}
-
/*
* Command LTTNG_LIST_CHANNELS processed by the client thread.
*/
enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
- struct ltt_session *session,
- struct lttng_payload *payload)
+ struct ltt_session *session,
+ struct lttng_payload *payload)
{
int ret = 0;
unsigned int i = 0;
/* Reserve space for command reply header. */
ret = lttng_dynamic_buffer_set_size(&payload->buffer,
- cmd_header_offset + sizeof(cmd_header));
+ cmd_header_offset + sizeof(cmd_header));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Kernel channels */
struct ltt_kernel_channel *kchan;
if (session->kernel_session != NULL) {
- cds_list_for_each_entry(kchan,
- &session->kernel_session->channel_list.head, list) {
+ cds_list_for_each_entry (
+ kchan, &session->kernel_session->channel_list.head, list) {
uint64_t discarded_events, lost_packets;
struct lttng_channel_extended *extended;
extended = (struct lttng_channel_extended *)
- kchan->channel->attr.extended.ptr;
+ kchan->channel->attr.extended.ptr;
- ret = get_kernel_runtime_stats(session, kchan,
- &discarded_events, &lost_packets);
+ ret = get_kernel_runtime_stats(
+ session, kchan, &discarded_events, &lost_packets);
if (ret < 0) {
ret_code = LTTNG_ERR_UNK;
goto end;
extended->discarded_events = discarded_events;
extended->lost_packets = lost_packets;
- ret = lttng_channel_serialize(
- kchan->channel, &payload->buffer);
+ ret = lttng_channel_serialize(kchan->channel, &payload->buffer);
if (ret) {
ERR("Failed to serialize lttng_channel: channel name = '%s'",
- kchan->channel->name);
+ kchan->channel->name);
ret_code = LTTNG_ERR_UNK;
goto end;
}
struct ltt_ust_channel *uchan;
rcu_read_lock();
- cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
- &iter.iter, uchan, node.node) {
+ cds_lfht_for_each_entry (session->ust_session->domain_global.channels->ht,
+ &iter.iter,
+ uchan,
+ node.node) {
uint64_t discarded_events = 0, lost_packets = 0;
struct lttng_channel *channel = NULL;
struct lttng_channel_extended *extended;
goto end;
}
- extended = (struct lttng_channel_extended *)
- channel->attr.extended.ptr;
+ extended = (struct lttng_channel_extended *) channel->attr.extended.ptr;
- ret = get_ust_runtime_stats(session, uchan,
- &discarded_events, &lost_packets);
+ ret = get_ust_runtime_stats(
+ session, uchan, &discarded_events, &lost_packets);
if (ret < 0) {
lttng_channel_destroy(channel);
ret_code = LTTNG_ERR_UNK;
extended->discarded_events = discarded_events;
extended->lost_packets = lost_packets;
- ret = lttng_channel_serialize(
- channel, &payload->buffer);
+ ret = lttng_channel_serialize(channel, &payload->buffer);
if (ret) {
ERR("Failed to serialize lttng_channel: channel name = '%s'",
- channel->name);
+ channel->name);
lttng_channel_destroy(channel);
ret_code = LTTNG_ERR_UNK;
goto end;
/* Update command reply header. */
cmd_header.count = (uint32_t) i;
- memcpy(payload->buffer.data + cmd_header_offset, &cmd_header,
- sizeof(cmd_header));
+ memcpy(payload->buffer.data + cmd_header_offset, &cmd_header, sizeof(cmd_header));
ret_code = LTTNG_OK;
end:
* Command LTTNG_LIST_EVENTS processed by the client thread.
*/
enum lttng_error_code cmd_list_events(enum lttng_domain_type domain,
- struct ltt_session *session,
- char *channel_name,
- struct lttng_payload *reply_payload)
+ struct ltt_session *session,
+ char *channel_name,
+ struct lttng_payload *reply_payload)
{
int buffer_resize_ret;
enum lttng_error_code ret_code = LTTNG_OK;
/* Reserve space for command reply header. */
reply_command_header_offset = reply_payload->buffer.size;
- buffer_resize_ret = lttng_dynamic_buffer_set_size(&reply_payload->buffer,
- reply_command_header_offset +
- sizeof(struct lttcomm_list_command_header));
+ buffer_resize_ret = lttng_dynamic_buffer_set_size(
+ &reply_payload->buffer,
+ reply_command_header_offset + sizeof(struct lttcomm_list_command_header));
if (buffer_resize_ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
if (session->kernel_session != NULL) {
- ret_code = list_lttng_kernel_events(channel_name,
- session->kernel_session, reply_payload, &nb_events);
+ ret_code = list_lttng_kernel_events(
+ channel_name, session->kernel_session, reply_payload, &nb_events);
}
break;
case LTTNG_DOMAIN_UST:
{
if (session->ust_session != NULL) {
- ret_code = list_lttng_ust_global_events(channel_name,
- &session->ust_session->domain_global,
- reply_payload, &nb_events);
+ ret_code =
+ list_lttng_ust_global_events(channel_name,
+ &session->ust_session->domain_global,
+ reply_payload,
+ &nb_events);
}
break;
struct agent *agt;
rcu_read_lock();
- cds_lfht_for_each_entry(session->ust_session->agents->ht,
- &iter.iter, agt, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->agents->ht, &iter.iter, agt, node.node) {
if (agt->domain == domain) {
ret_code = list_lttng_agent_events(
- agt, reply_payload, &nb_events);
+ agt, reply_payload, &nb_events);
break;
}
}
/* Update command reply header. */
reply_command_header.count = (uint32_t) nb_events;
- memcpy(reply_payload->buffer.data + reply_command_header_offset, &reply_command_header,
- sizeof(reply_command_header));
+ memcpy(reply_payload->buffer.data + reply_command_header_offset,
+ &reply_command_header,
+ sizeof(reply_command_header));
end:
return ret_code;
* session_lock_list() and session_unlock_list().
*/
void cmd_list_lttng_sessions(struct lttng_session *sessions,
- size_t session_count, uid_t uid, gid_t gid)
+ size_t session_count,
+ uid_t uid,
+ gid_t gid)
{
int ret;
unsigned int i = 0;
struct ltt_session *session;
struct ltt_session_list *list = session_get_list();
- struct lttng_session_extended *extended =
- (typeof(extended)) (&sessions[session_count]);
+ struct lttng_session_extended *extended = (typeof(extended)) (&sessions[session_count]);
- DBG("Getting all available session for UID %d GID %d",
- uid, gid);
+ DBG("Getting all available session for UID %d GID %d", uid, gid);
/*
* Iterate over session list and append data after the control struct in
* the buffer.
*/
- cds_list_for_each_entry(session, &list->head, list) {
+ cds_list_for_each_entry (session, &list->head, list) {
if (!session_get(session)) {
continue;
}
/*
* Only list the sessions the user can control.
*/
- if (!session_access_ok(session, uid) ||
- session->destroyed) {
+ if (!session_access_ok(session, uid) || session->destroyed) {
session_put(session);
continue;
}
struct ltt_ust_session *usess = session->ust_session;
if (session->consumer->type == CONSUMER_DST_NET ||
- (ksess && ksess->consumer->type == CONSUMER_DST_NET) ||
- (usess && usess->consumer->type == CONSUMER_DST_NET)) {
- ret = build_network_session_path(sessions[i].path,
- sizeof(sessions[i].path), session);
+ (ksess && ksess->consumer->type == CONSUMER_DST_NET) ||
+ (usess && usess->consumer->type == CONSUMER_DST_NET)) {
+ ret = build_network_session_path(
+ sessions[i].path, sizeof(sessions[i].path), session);
} else {
- ret = snprintf(sessions[i].path, sizeof(sessions[i].path), "%s",
- session->consumer->dst.session_root_path);
+ ret = snprintf(sessions[i].path,
+ sizeof(sessions[i].path),
+ "%s",
+ session->consumer->dst.session_root_path);
}
if (ret < 0) {
PERROR("snprintf session path");
* Return LTTNG_OK on success or else a LTTNG_ERR code.
*/
int cmd_snapshot_add_output(struct ltt_session *session,
- const struct lttng_snapshot_output *output, uint32_t *id)
+ const struct lttng_snapshot_output *output,
+ uint32_t *id)
{
int ret;
struct snapshot_output *new_output;
goto error;
}
- ret = snapshot_output_init(session, output->max_size, output->name,
- output->ctrl_url, output->data_url, session->consumer, new_output,
- &session->snapshot);
+ ret = snapshot_output_init(session,
+ output->max_size,
+ output->name,
+ output->ctrl_url,
+ output->data_url,
+ session->consumer,
+ new_output,
+ &session->snapshot);
if (ret < 0) {
if (ret == -ENOMEM) {
ret = LTTNG_ERR_NOMEM;
*
* Return LTTNG_OK on success or else a LTTNG_ERR code.
*/
-int cmd_snapshot_del_output(struct ltt_session *session,
- const struct lttng_snapshot_output *output)
+int cmd_snapshot_del_output(struct ltt_session *session, const struct lttng_snapshot_output *output)
{
int ret;
struct snapshot_output *sout = NULL;
}
if (output->id) {
- DBG("Cmd snapshot del output id %" PRIu32 " for session %s", output->id,
- session->name);
+ DBG("Cmd snapshot del output id %" PRIu32 " for session %s",
+ output->id,
+ session->name);
sout = snapshot_find_output_by_id(output->id, &session->snapshot);
} else if (*output->name != '\0') {
- DBG("Cmd snapshot del output name %s for session %s", output->name,
- session->name);
+ DBG("Cmd snapshot del output name %s for session %s", output->name, session->name);
sout = snapshot_find_output_by_name(output->name, &session->snapshot);
}
if (!sout) {
* Return the size of the newly allocated outputs or a negative LTTNG_ERR code.
*/
ssize_t cmd_snapshot_list_outputs(struct ltt_session *session,
- struct lttng_snapshot_output **outputs)
+ struct lttng_snapshot_output **outputs)
{
int ret, idx = 0;
struct lttng_snapshot_output *list = NULL;
/* Copy list from session to the new list object. */
rcu_read_lock();
- cds_lfht_for_each_entry(session->snapshot.output_ht->ht, &iter.iter,
- output, node.node) {
+ cds_lfht_for_each_entry (session->snapshot.output_ht->ht, &iter.iter, output, node.node) {
LTTNG_ASSERT(output->consumer);
list[idx].id = output->id;
list[idx].max_size = output->max_size;
- if (lttng_strncpy(list[idx].name, output->name,
- sizeof(list[idx].name))) {
+ if (lttng_strncpy(list[idx].name, output->name, sizeof(list[idx].name))) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
if (output->consumer->type == CONSUMER_DST_LOCAL) {
if (lttng_strncpy(list[idx].ctrl_url,
- output->consumer->dst.session_root_path,
- sizeof(list[idx].ctrl_url))) {
+ output->consumer->dst.session_root_path,
+ sizeof(list[idx].ctrl_url))) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
} else {
/* Control URI. */
ret = uri_to_str_url(&output->consumer->dst.net.control,
- list[idx].ctrl_url, sizeof(list[idx].ctrl_url));
+ list[idx].ctrl_url,
+ sizeof(list[idx].ctrl_url));
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
goto error;
/* Data URI. */
ret = uri_to_str_url(&output->consumer->dst.net.data,
- list[idx].data_url, sizeof(list[idx].data_url));
+ list[idx].data_url,
+ sizeof(list[idx].data_url));
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
goto error;
*
* Return 0 if the metadata can be generated, a LTTNG_ERR code otherwise.
*/
-static
-int check_regenerate_metadata_support(struct ltt_session *session)
+static int check_regenerate_metadata_support(struct ltt_session *session)
{
int ret;
}
}
if (session->consumer->type == CONSUMER_DST_NET &&
- session->consumer->relay_minor_version < 8) {
+ session->consumer->relay_minor_version < 8) {
ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
goto end;
}
}
if (session->kernel_session) {
- ret = kernctl_session_regenerate_metadata(
- session->kernel_session->fd);
+ ret = kernctl_session_regenerate_metadata(session->kernel_session->fd);
if (ret < 0) {
ERR("Failed to regenerate the kernel metadata");
goto end;
}
if (session->kernel_session) {
- ret = kernctl_session_regenerate_statedump(
- session->kernel_session->fd);
+ ret = kernctl_session_regenerate_statedump(session->kernel_session->fd);
/*
* Currently, the statedump in kernel can only fail if out
* of memory.
return ret;
}
-static
-enum lttng_error_code synchronize_tracer_notifier_register(
- struct notification_thread_handle *notification_thread,
- struct lttng_trigger *trigger, const struct lttng_credentials *cmd_creds)
+static enum lttng_error_code
+synchronize_tracer_notifier_register(struct notification_thread_handle *notification_thread,
+ struct lttng_trigger *trigger,
+ const struct lttng_credentials *cmd_creds)
{
enum lttng_error_code ret_code;
- const struct lttng_condition *condition =
- lttng_trigger_get_const_condition(trigger);
+ const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
const char *trigger_name;
uid_t trigger_owner;
enum lttng_trigger_status trigger_status;
const enum lttng_domain_type trigger_domain =
- lttng_trigger_get_underlying_domain_type_restriction(
- trigger);
+ lttng_trigger_get_underlying_domain_type_restriction(trigger);
trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
LTTNG_ASSERT(condition);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
+ trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
session_lock_list();
switch (trigger_domain) {
enum lttng_error_code notif_thread_unregister_ret;
notif_thread_unregister_ret =
- notification_thread_command_unregister_trigger(
- notification_thread, trigger);
+ notification_thread_command_unregister_trigger(notification_thread,
+ trigger);
if (notif_thread_unregister_ret != LTTNG_OK) {
/* Return the original error code. */
ERR("Failed to unregister trigger from notification thread during error recovery: trigger name = '%s', trigger owner uid = %d, error code = %d",
- trigger_name,
- (int) trigger_owner,
- ret_code);
+ trigger_name,
+ (int) trigger_owner,
+ ret_code);
}
}
break;
case LTTNG_DOMAIN_PYTHON:
{
/* Agent domains. */
- struct agent *agt = agent_find_by_event_notifier_domain(
- trigger_domain);
+ struct agent *agt = agent_find_by_event_notifier_domain(trigger_domain);
if (!agt) {
agt = agent_create(trigger_domain);
}
enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_creds,
- struct lttng_trigger *trigger,
- bool is_trigger_anonymous,
- struct notification_thread_handle *notification_thread,
- struct lttng_trigger **return_trigger)
+ struct lttng_trigger *trigger,
+ bool is_trigger_anonymous,
+ struct notification_thread_handle *notification_thread,
+ struct lttng_trigger **return_trigger)
{
enum lttng_error_code ret_code;
const char *trigger_name;
enum lttng_trigger_status trigger_status;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
+ trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_owner);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
DBG("Running register trigger command: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
/*
* Validate the trigger credentials against the command credentials.
* Only the root user can register a trigger with non-matching
* credentials.
*/
- if (!lttng_credentials_is_equal_uid(
- lttng_trigger_get_credentials(trigger),
- cmd_creds)) {
+ if (!lttng_credentials_is_equal_uid(lttng_trigger_get_credentials(trigger), cmd_creds)) {
if (lttng_credentials_get_uid(cmd_creds) != 0) {
ERR("Trigger credentials do not match the command credentials: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
ret_code = LTTNG_ERR_INVALID_TRIGGER;
goto end;
}
ret_code = lttng_trigger_generate_bytecode(trigger, cmd_creds);
if (ret_code != LTTNG_OK) {
ERR("Failed to generate bytecode of trigger: trigger name = '%s', trigger owner uid = %d, error code = %d",
- trigger_name, (int) trigger_owner, ret_code);
+ trigger_name,
+ (int) trigger_owner,
+ ret_code);
goto end;
}
* immutable.
*/
ret_code = notification_thread_command_register_trigger(
- notification_thread, trigger, is_trigger_anonymous);
+ notification_thread, trigger, is_trigger_anonymous);
if (ret_code != LTTNG_OK) {
DBG("Failed to register trigger to notification thread: trigger name = '%s', trigger owner uid = %d, error code = %d",
- trigger_name, (int) trigger_owner, ret_code);
+ trigger_name,
+ (int) trigger_owner,
+ ret_code);
goto end;
}
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
+ trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
/*
* Synchronize tracers if the trigger adds an event notifier.
*/
if (lttng_trigger_needs_tracer_notifier(trigger)) {
- ret_code = synchronize_tracer_notifier_register(notification_thread,
- trigger, cmd_creds);
+ ret_code = synchronize_tracer_notifier_register(
+ notification_thread, trigger, cmd_creds);
if (ret_code != LTTNG_OK) {
- ERR("Error registering tracer notifier: %s",
- lttng_strerror(-ret_code));
+ ERR("Error registering tracer notifier: %s", lttng_strerror(-ret_code));
goto end;
}
}
return ret_code;
}
-static
-enum lttng_error_code synchronize_tracer_notifier_unregister(
- const struct lttng_trigger *trigger)
+static enum lttng_error_code
+synchronize_tracer_notifier_unregister(const struct lttng_trigger *trigger)
{
enum lttng_error_code ret_code;
- const struct lttng_condition *condition =
- lttng_trigger_get_const_condition(trigger);
+ const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
const enum lttng_domain_type trigger_domain =
- lttng_trigger_get_underlying_domain_type_restriction(
- trigger);
+ lttng_trigger_get_underlying_domain_type_restriction(trigger);
LTTNG_ASSERT(condition);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
session_lock_list();
switch (trigger_domain) {
case LTTNG_DOMAIN_PYTHON:
{
/* Agent domains. */
- struct agent *agt = agent_find_by_event_notifier_domain(
- trigger_domain);
+ struct agent *agt = agent_find_by_event_notifier_domain(trigger_domain);
/*
* This trigger was never registered in the first place. Calling
}
enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd_creds,
- const struct lttng_trigger *trigger,
- struct notification_thread_handle *notification_thread)
+ const struct lttng_trigger *trigger,
+ struct notification_thread_handle *notification_thread)
{
enum lttng_error_code ret_code;
const char *trigger_name;
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
DBG("Running unregister trigger command: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
/*
* Validate the trigger credentials against the command credentials.
* Only the root user can unregister a trigger with non-matching
* credentials.
*/
- if (!lttng_credentials_is_equal_uid(
- lttng_trigger_get_credentials(trigger),
- cmd_creds)) {
+ if (!lttng_credentials_is_equal_uid(lttng_trigger_get_credentials(trigger), cmd_creds)) {
if (lttng_credentials_get_uid(cmd_creds) != 0) {
ERR("Trigger credentials do not match the command credentials: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
ret_code = LTTNG_ERR_INVALID_TRIGGER;
goto end;
}
/* Fetch the sessiond side trigger object. */
ret_code = notification_thread_command_get_trigger(
- notification_thread, trigger, &sessiond_trigger);
+ notification_thread, trigger, &sessiond_trigger);
if (ret_code != LTTNG_OK) {
DBG("Failed to get trigger from notification thread during unregister: trigger name = '%s', trigger owner uid = %d, error code = %d",
- trigger_name, (int) trigger_owner, ret_code);
+ trigger_name,
+ (int) trigger_owner,
+ ret_code);
goto end;
}
*/
lttng_trigger_set_as_unregistered(sessiond_trigger);
- ret_code = notification_thread_command_unregister_trigger(notification_thread,
- trigger);
+ ret_code = notification_thread_command_unregister_trigger(notification_thread, trigger);
if (ret_code != LTTNG_OK) {
DBG("Failed to unregister trigger from notification thread: trigger name = '%s', trigger owner uid = %d, error code = %d",
- trigger_name, (int) trigger_owner, ret_code);
+ trigger_name,
+ (int) trigger_owner,
+ ret_code);
goto end;
}
ERR("Error unregistering trigger to tracer.");
goto end;
}
-
}
end:
}
enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
- struct notification_thread_handle *notification_thread,
- struct lttng_triggers **return_triggers)
+ struct notification_thread_handle *notification_thread,
+ struct lttng_triggers **return_triggers)
{
int ret;
enum lttng_error_code ret_code;
/* Get the set of triggers from the notification thread. */
ret_code = notification_thread_command_list_triggers(
- notification_thread, cmd_ctx->creds.uid, &triggers);
+ notification_thread, cmd_ctx->creds.uid, &triggers);
if (ret_code != LTTNG_OK) {
goto end;
}
return ret_code;
}
-enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
- const struct lttng_error_query *query,
- struct lttng_error_query_results **_results,
- struct notification_thread_handle *notification_thread)
+enum lttng_error_code
+cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
+ const struct lttng_error_query *query,
+ struct lttng_error_query_results **_results,
+ struct notification_thread_handle *notification_thread)
{
enum lttng_error_code ret_code;
const struct lttng_trigger *query_target_trigger;
query_target_trigger = lttng_error_query_trigger_borrow_target(query);
break;
case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
- query_target_trigger =
- lttng_error_query_condition_borrow_target(query);
+ query_target_trigger = lttng_error_query_condition_borrow_target(query);
break;
case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
- query_target_trigger = lttng_error_query_action_borrow_trigger_target(
- query);
+ query_target_trigger = lttng_error_query_action_borrow_trigger_target(query);
break;
default:
abort();
LTTNG_ASSERT(query_target_trigger);
- ret_code = notification_thread_command_get_trigger(notification_thread,
- query_target_trigger, &matching_trigger);
+ ret_code = notification_thread_command_get_trigger(
+ notification_thread, query_target_trigger, &matching_trigger);
if (ret_code != LTTNG_OK) {
goto end;
}
/* No longer needed. */
query_target_trigger = NULL;
- if (lttng_error_query_get_target_type(query) ==
- LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION) {
+ if (lttng_error_query_get_target_type(query) == LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION) {
/* Get the sessiond-side version of the target action. */
query_target_action =
- lttng_error_query_action_borrow_action_target(
- query, matching_trigger);
+ lttng_error_query_action_borrow_action_target(query, matching_trigger);
}
trigger_status = lttng_trigger_get_name(matching_trigger, &trigger_name);
- trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
- trigger_status = lttng_trigger_get_owner_uid(matching_trigger,
- &trigger_owner);
+ trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
+ trigger_status = lttng_trigger_get_owner_uid(matching_trigger, &trigger_owner);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
results = lttng_error_query_results_create();
}
DBG("Running \"execute error query\" command: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
/*
* Validate the trigger credentials against the command credentials.
* Only the root user can target a trigger with non-matching
* credentials.
*/
- if (!lttng_credentials_is_equal_uid(
- lttng_trigger_get_credentials(matching_trigger),
- cmd_creds)) {
+ if (!lttng_credentials_is_equal_uid(lttng_trigger_get_credentials(matching_trigger),
+ cmd_creds)) {
if (lttng_credentials_get_uid(cmd_creds) != 0) {
ERR("Trigger credentials do not match the command credentials: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
- trigger_name, (int) trigger_owner,
- (int) lttng_credentials_get_uid(cmd_creds));
+ trigger_name,
+ (int) trigger_owner,
+ (int) lttng_credentials_get_uid(cmd_creds));
ret_code = LTTNG_ERR_INVALID_TRIGGER;
goto end;
}
switch (lttng_error_query_get_target_type(query)) {
case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
- trigger_status = lttng_trigger_add_error_results(
- matching_trigger, results);
+ trigger_status = lttng_trigger_add_error_results(matching_trigger, results);
switch (trigger_status) {
case LTTNG_TRIGGER_STATUS_OK:
break;
case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
{
- trigger_status = lttng_trigger_condition_add_error_results(
- matching_trigger, results);
+ trigger_status =
+ lttng_trigger_condition_add_error_results(matching_trigger, results);
switch (trigger_status) {
case LTTNG_TRIGGER_STATUS_OK:
case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
{
const enum lttng_action_status action_status =
- lttng_action_add_error_query_results(
- query_target_action, results);
+ lttng_action_add_error_query_results(query_target_action, results);
switch (action_status) {
case LTTNG_ACTION_STATUS_OK:
*
* Return LTTNG_OK on success or a LTTNG_ERR code.
*/
-static enum lttng_error_code set_relayd_for_snapshot(
- struct consumer_output *output,
- const struct ltt_session *session)
+static enum lttng_error_code set_relayd_for_snapshot(struct consumer_output *output,
+ const struct ltt_session *session)
{
enum lttng_error_code status = LTTNG_OK;
struct lttng_ht_iter iter;
DBG2("Set relayd object from snapshot output");
if (session->current_trace_chunk) {
- enum lttng_trace_chunk_status chunk_status =
- lttng_trace_chunk_get_id(
- session->current_trace_chunk,
- ¤t_chunk_id.value);
+ enum lttng_trace_chunk_status chunk_status = lttng_trace_chunk_get_id(
+ session->current_trace_chunk, ¤t_chunk_id.value);
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK) {
current_chunk_id.is_set = true;
* snapshot output.
*/
rcu_read_lock();
- cds_lfht_for_each_entry(output->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
- status = send_consumer_relayd_sockets(session->id,
- output, socket,
- session->name, session->hostname,
- base_path,
- session->live_timer,
- current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
- session->creation_time,
- session->name_contains_creation_time);
+ status = send_consumer_relayd_sockets(
+ session->id,
+ output,
+ socket,
+ session->name,
+ session->hostname,
+ base_path,
+ session->live_timer,
+ current_chunk_id.is_set ? ¤t_chunk_id.value : NULL,
+ session->creation_time,
+ session->name_contains_creation_time);
pthread_mutex_unlock(socket->lock);
if (status != LTTNG_OK) {
rcu_read_unlock();
*
* Return LTTNG_OK on success or a LTTNG_ERR code.
*/
-static enum lttng_error_code record_kernel_snapshot(
- struct ltt_kernel_session *ksess,
- const struct consumer_output *output,
- const struct ltt_session *session,
- uint64_t nb_packets_per_stream)
+static enum lttng_error_code record_kernel_snapshot(struct ltt_kernel_session *ksess,
+ const struct consumer_output *output,
+ const struct ltt_session *session,
+ uint64_t nb_packets_per_stream)
{
enum lttng_error_code status;
LTTNG_ASSERT(output);
LTTNG_ASSERT(session);
- status = kernel_snapshot_record(
- ksess, output, nb_packets_per_stream);
+ status = kernel_snapshot_record(ksess, output, nb_packets_per_stream);
return status;
}
* Returns LTTNG_OK on success or a LTTNG_ERR error code.
*/
static enum lttng_error_code record_ust_snapshot(struct ltt_ust_session *usess,
- const struct consumer_output *output,
- const struct ltt_session *session,
- uint64_t nb_packets_per_stream)
+ const struct consumer_output *output,
+ const struct ltt_session *session,
+ uint64_t nb_packets_per_stream)
{
enum lttng_error_code status;
LTTNG_ASSERT(output);
LTTNG_ASSERT(session);
- status = ust_app_snapshot_record(
- usess, output, nb_packets_per_stream);
+ status = ust_app_snapshot_record(usess, output, nb_packets_per_stream);
return status;
}
-static
-uint64_t get_session_size_one_more_packet_per_stream(
- const struct ltt_session *session, uint64_t cur_nr_packets)
+static uint64_t get_session_size_one_more_packet_per_stream(const struct ltt_session *session,
+ uint64_t cur_nr_packets)
{
uint64_t tot_size = 0;
if (session->kernel_session) {
struct ltt_kernel_channel *chan;
- const struct ltt_kernel_session *ksess =
- session->kernel_session;
+ const struct ltt_kernel_session *ksess = session->kernel_session;
- cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
if (cur_nr_packets >= chan->channel->attr.num_subbuf) {
/*
* Don't take channel into account if we
*/
continue;
}
- tot_size += chan->channel->attr.subbuf_size
- * chan->stream_count;
+ tot_size += chan->channel->attr.subbuf_size * chan->stream_count;
}
}
if (session->ust_session) {
const struct ltt_ust_session *usess = session->ust_session;
- tot_size += ust_app_get_size_one_more_packet_per_stream(usess,
- cur_nr_packets);
+ tot_size += ust_app_get_size_one_more_packet_per_stream(usess, cur_nr_packets);
}
return tot_size;
* an approximation: for instance, applications could appear/disappear
* in between this call and actually grabbing data.
*/
-static
-int64_t get_session_nb_packets_per_stream(const struct ltt_session *session,
- uint64_t max_size)
+static int64_t get_session_nb_packets_per_stream(const struct ltt_session *session,
+ uint64_t max_size)
{
int64_t size_left;
uint64_t cur_nb_packets = 0;
if (!max_size) {
- return 0; /* Infinite */
+ return 0; /* Infinite */
}
size_left = max_size;
for (;;) {
uint64_t one_more_packet_tot_size;
- one_more_packet_tot_size = get_session_size_one_more_packet_per_stream(
- session, cur_nb_packets);
+ one_more_packet_tot_size =
+ get_session_size_one_more_packet_per_stream(session, cur_nb_packets);
if (!one_more_packet_tot_size) {
/* We are already grabbing all packets. */
break;
return cur_nb_packets;
}
-static
-enum lttng_error_code snapshot_record(struct ltt_session *session,
- const struct snapshot_output *snapshot_output)
+static enum lttng_error_code snapshot_record(struct ltt_session *session,
+ const struct snapshot_output *snapshot_output)
{
int64_t nb_packets_per_stream;
char snapshot_chunk_name[LTTNG_NAME_MAX];
struct consumer_output *snapshot_ust_consumer_output = NULL;
struct consumer_output *snapshot_kernel_consumer_output = NULL;
- ret = snprintf(snapshot_chunk_name, sizeof(snapshot_chunk_name),
- "%s-%s-%" PRIu64,
- snapshot_output->name,
- snapshot_output->datetime,
- snapshot_output->nb_snapshot);
+ ret = snprintf(snapshot_chunk_name,
+ sizeof(snapshot_chunk_name),
+ "%s-%s-%" PRIu64,
+ snapshot_output->name,
+ snapshot_output->datetime,
+ snapshot_output->nb_snapshot);
if (ret < 0 || ret >= sizeof(snapshot_chunk_name)) {
ERR("Failed to format snapshot name");
ret_code = LTTNG_ERR_INVALID;
goto error;
}
DBG("Recording snapshot \"%s\" for session \"%s\" with chunk name \"%s\"",
- snapshot_output->name, session->name,
- snapshot_chunk_name);
+ snapshot_output->name,
+ session->name,
+ snapshot_chunk_name);
if (!session->kernel_session && !session->ust_session) {
ERR("Failed to record snapshot as no channels exist");
ret_code = LTTNG_ERR_NO_CHANNEL;
}
if (session->kernel_session) {
- original_kernel_consumer_output =
- session->kernel_session->consumer;
- snapshot_kernel_consumer_output =
- consumer_copy_output(snapshot_output->consumer);
- strcpy(snapshot_kernel_consumer_output->chunk_path,
- snapshot_chunk_name);
+ original_kernel_consumer_output = session->kernel_session->consumer;
+ snapshot_kernel_consumer_output = consumer_copy_output(snapshot_output->consumer);
+ strcpy(snapshot_kernel_consumer_output->chunk_path, snapshot_chunk_name);
/* Copy the original domain subdir. */
strcpy(snapshot_kernel_consumer_output->domain_subdir,
- original_kernel_consumer_output->domain_subdir);
+ original_kernel_consumer_output->domain_subdir);
ret = consumer_copy_sockets(snapshot_kernel_consumer_output,
- original_kernel_consumer_output);
+ original_kernel_consumer_output);
if (ret < 0) {
ERR("Failed to copy consumer sockets from snapshot output configuration");
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
- ret_code = set_relayd_for_snapshot(
- snapshot_kernel_consumer_output, session);
+ ret_code = set_relayd_for_snapshot(snapshot_kernel_consumer_output, session);
if (ret_code != LTTNG_OK) {
ERR("Failed to setup relay daemon for kernel tracer snapshot");
goto error;
}
- session->kernel_session->consumer =
- snapshot_kernel_consumer_output;
+ session->kernel_session->consumer = snapshot_kernel_consumer_output;
}
if (session->ust_session) {
original_ust_consumer_output = session->ust_session->consumer;
- snapshot_ust_consumer_output =
- consumer_copy_output(snapshot_output->consumer);
- strcpy(snapshot_ust_consumer_output->chunk_path,
- snapshot_chunk_name);
+ snapshot_ust_consumer_output = consumer_copy_output(snapshot_output->consumer);
+ strcpy(snapshot_ust_consumer_output->chunk_path, snapshot_chunk_name);
/* Copy the original domain subdir. */
strcpy(snapshot_ust_consumer_output->domain_subdir,
- original_ust_consumer_output->domain_subdir);
+ original_ust_consumer_output->domain_subdir);
ret = consumer_copy_sockets(snapshot_ust_consumer_output,
- original_ust_consumer_output);
+ original_ust_consumer_output);
if (ret < 0) {
ERR("Failed to copy consumer sockets from snapshot output configuration");
ret_code = LTTNG_ERR_NOMEM;
goto error;
}
- ret_code = set_relayd_for_snapshot(
- snapshot_ust_consumer_output, session);
+ ret_code = set_relayd_for_snapshot(snapshot_ust_consumer_output, session);
if (ret_code != LTTNG_OK) {
ERR("Failed to setup relay daemon for userspace tracer snapshot");
goto error;
}
- session->ust_session->consumer =
- snapshot_ust_consumer_output;
+ session->ust_session->consumer = snapshot_ust_consumer_output;
}
- snapshot_trace_chunk = session_create_new_trace_chunk(session,
- snapshot_kernel_consumer_output ?:
- snapshot_ust_consumer_output,
- consumer_output_get_base_path(
- snapshot_output->consumer),
- snapshot_chunk_name);
+ snapshot_trace_chunk = session_create_new_trace_chunk(
+ session,
+ snapshot_kernel_consumer_output ?: snapshot_ust_consumer_output,
+ consumer_output_get_base_path(snapshot_output->consumer),
+ snapshot_chunk_name);
if (!snapshot_trace_chunk) {
ERR("Failed to create temporary trace chunk to record a snapshot of session \"%s\"",
- session->name);
+ session->name);
ret_code = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
snapshot_trace_chunk = NULL;
if (ret) {
ERR("Failed to set temporary trace chunk to record a snapshot of session \"%s\"",
- session->name);
+ session->name);
ret_code = LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER;
goto error;
}
- nb_packets_per_stream = get_session_nb_packets_per_stream(session,
- snapshot_output->max_size);
+ nb_packets_per_stream =
+ get_session_nb_packets_per_stream(session, snapshot_output->max_size);
if (nb_packets_per_stream < 0) {
ret_code = LTTNG_ERR_MAX_SIZE_INVALID;
goto error_close_trace_chunk;
if (session->kernel_session) {
ret_code = record_kernel_snapshot(session->kernel_session,
- snapshot_kernel_consumer_output, session,
- nb_packets_per_stream);
+ snapshot_kernel_consumer_output,
+ session,
+ nb_packets_per_stream);
if (ret_code != LTTNG_OK) {
goto error_close_trace_chunk;
}
if (session->ust_session) {
ret_code = record_ust_snapshot(session->ust_session,
- snapshot_ust_consumer_output, session,
- nb_packets_per_stream);
+ snapshot_ust_consumer_output,
+ session,
+ nb_packets_per_stream);
if (ret_code != LTTNG_OK) {
goto error_close_trace_chunk;
}
error_close_trace_chunk:
if (session_set_trace_chunk(session, NULL, &snapshot_trace_chunk)) {
- ERR("Failed to release the current trace chunk of session \"%s\"",
- session->name);
+ ERR("Failed to release the current trace chunk of session \"%s\"", session->name);
ret_code = LTTNG_ERR_UNK;
}
- if (session_close_trace_chunk(session, snapshot_trace_chunk,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION, NULL)) {
+ if (session_close_trace_chunk(session,
+ snapshot_trace_chunk,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION,
+ NULL)) {
/*
* Don't goto end; make sure the chunk is closed for the session
* to allow future snapshots.
*/
- ERR("Failed to close snapshot trace chunk of session \"%s\"",
- session->name);
+ ERR("Failed to close snapshot trace chunk of session \"%s\"", session->name);
ret_code = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
}
session->ust_session->consumer = original_ust_consumer_output;
}
if (original_kernel_consumer_output) {
- session->kernel_session->consumer =
- original_kernel_consumer_output;
+ session->kernel_session->consumer = original_kernel_consumer_output;
}
consumer_output_put(snapshot_ust_consumer_output);
consumer_output_put(snapshot_kernel_consumer_output);
* Return LTTNG_OK on success or else a LTTNG_ERR code.
*/
int cmd_snapshot_record(struct ltt_session *session,
- const struct lttng_snapshot_output *output,
- int wait __attribute__((unused)))
+ const struct lttng_snapshot_output *output,
+ int wait __attribute__((unused)))
{
enum lttng_error_code cmd_ret = LTTNG_OK;
int ret;
DBG("Cmd snapshot record for session %s", session->name);
/* Get the datetime for the snapshot output directory. */
- ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime,
- sizeof(datetime));
+ ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime, sizeof(datetime));
if (!ret) {
cmd_ret = LTTNG_ERR_INVALID;
goto error;
goto error;
}
- ret = snapshot_output_init(session, output->max_size,
- output->name,
- output->ctrl_url, output->data_url,
- session->consumer,
- tmp_output, NULL);
+ ret = snapshot_output_init(session,
+ output->max_size,
+ output->name,
+ output->ctrl_url,
+ output->data_url,
+ session->consumer,
+ tmp_output,
+ NULL);
if (ret < 0) {
if (ret == -ENOMEM) {
cmd_ret = LTTNG_ERR_NOMEM;
struct lttng_ht_iter iter;
rcu_read_lock();
- cds_lfht_for_each_entry(session->snapshot.output_ht->ht,
- &iter.iter, sout, node.node) {
+ cds_lfht_for_each_entry (
+ session->snapshot.output_ht->ht, &iter.iter, sout, node.node) {
struct snapshot_output output_copy;
/*
}
output_copy.nb_snapshot = session->snapshot.nb_snapshot;
- memcpy(output_copy.datetime, datetime,
- sizeof(datetime));
+ memcpy(output_copy.datetime, datetime, sizeof(datetime));
/* Use temporary name. */
if (*output->name != '\0') {
if (lttng_strncpy(output_copy.name,
- output->name,
- sizeof(output_copy.name))) {
+ output->name,
+ sizeof(output_copy.name))) {
cmd_ret = LTTNG_ERR_INVALID;
rcu_read_unlock();
goto error;
/*
* Command LTTNG_SET_SESSION_SHM_PATH processed by the client thread.
*/
-int cmd_set_session_shm_path(struct ltt_session *session,
- const char *shm_path)
+int cmd_set_session_shm_path(struct ltt_session *session, const char *shm_path)
{
/* Safety net */
LTTNG_ASSERT(session);
return LTTNG_ERR_SESSION_STARTED;
}
- strncpy(session->shm_path, shm_path,
- sizeof(session->shm_path));
+ strncpy(session->shm_path, shm_path, sizeof(session->shm_path));
session->shm_path[sizeof(session->shm_path) - 1] = '\0';
return LTTNG_OK;
* Returns LTTNG_OK on success or else a negative LTTng error code.
*/
int cmd_rotate_session(struct ltt_session *session,
- struct lttng_rotate_session_return *rotate_return,
- bool quiet_rotation,
- enum lttng_trace_chunk_command_type command)
+ struct lttng_rotate_session_return *rotate_return,
+ bool quiet_rotation,
+ enum lttng_trace_chunk_command_type command)
{
int ret;
uint64_t ongoing_rotation_chunk_id;
* destroy.
* Rotation is not supported for snapshot traces (no output).
*/
- if ((!quiet_rotation && session->live_timer) ||
- !session->output_traces) {
+ if ((!quiet_rotation && session->live_timer) || !session->output_traces) {
cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE;
goto end;
}
/* Unsupported feature in lttng-relayd before 2.11. */
if (!quiet_rotation && session->consumer->type == CONSUMER_DST_NET &&
- (session->consumer->relay_major_version == 2 &&
- session->consumer->relay_minor_version < 11)) {
+ (session->consumer->relay_major_version == 2 &&
+ session->consumer->relay_minor_version < 11)) {
cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY;
goto end;
}
if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) {
DBG("Refusing to launch a rotation; a rotation is already in progress for session %s",
- session->name);
+ session->name);
cmd_ret = LTTNG_ERR_ROTATION_PENDING;
goto end;
}
*/
if (session->rotated_after_last_stop) {
DBG("Session \"%s\" was already rotated after stop, refusing rotation",
- session->name);
+ session->name);
cmd_ret = LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP;
goto end;
}
*/
if (session->cleared_after_last_stop) {
DBG("Session \"%s\" was already cleared after stop, refusing rotation",
- session->name);
+ session->name);
cmd_ret = LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR;
goto end;
}
if (session->active) {
- new_trace_chunk = session_create_new_trace_chunk(session, NULL,
- NULL, NULL);
+ new_trace_chunk = session_create_new_trace_chunk(session, NULL, NULL, NULL);
if (!new_trace_chunk) {
cmd_ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
* be closed on the consumer(s), otherwise it will never be
* cleaned-up, which will result in a leak.
*/
- ret = session_set_trace_chunk(session, new_trace_chunk,
- &chunk_being_archived);
+ ret = session_set_trace_chunk(session, new_trace_chunk, &chunk_being_archived);
if (ret) {
cmd_ret = LTTNG_ERR_CREATE_TRACE_CHUNK_FAIL_CONSUMER;
goto error;
if (!chunk_being_archived) {
DBG("Rotating session \"%s\" from a \"NULL\" trace chunk to a new trace chunk, skipping completion check",
- session->name);
+ session->name);
if (failed_to_rotate) {
cmd_ret = rotation_fail_code;
goto error;
}
session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
- chunk_status = lttng_trace_chunk_get_id(chunk_being_archived,
- &ongoing_rotation_chunk_id);
+ chunk_status = lttng_trace_chunk_get_id(chunk_being_archived, &ongoing_rotation_chunk_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
- ret = session_close_trace_chunk(session, chunk_being_archived,
- command, session->last_chunk_path);
+ ret = session_close_trace_chunk(
+ session, chunk_being_archived, command, session->last_chunk_path);
if (ret) {
cmd_ret = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
goto error;
}
session->quiet_rotation = quiet_rotation;
- ret = timer_session_rotation_pending_check_start(session,
- DEFAULT_ROTATE_PENDING_TIMER);
+ ret = timer_session_rotation_pending_check_start(session, DEFAULT_ROTATE_PENDING_TIMER);
if (ret) {
cmd_ret = LTTNG_ERR_UNK;
goto error;
chunk_being_archived = NULL;
if (!quiet_rotation) {
ret = notification_thread_command_session_rotation_ongoing(
- the_notification_thread_handle, session->id,
- ongoing_rotation_chunk_id);
+ the_notification_thread_handle, session->id, ongoing_rotation_chunk_id);
if (ret != LTTNG_OK) {
ERR("Failed to notify notification thread that a session rotation is ongoing for session %s",
- session->name);
+ session->name);
cmd_ret = (lttng_error_code) ret;
}
}
DBG("Cmd rotate session %s, archive_id %" PRIu64 " sent",
- session->name, ongoing_rotation_chunk_id);
+ session->name,
+ ongoing_rotation_chunk_id);
end:
lttng_trace_chunk_put(new_trace_chunk);
lttng_trace_chunk_put(chunk_being_archived);
ret = (cmd_ret == LTTNG_OK) ? cmd_ret : -((int) cmd_ret);
return ret;
error:
- if (session_reset_rotation_state(session,
- LTTNG_ROTATION_STATE_ERROR)) {
- ERR("Failed to reset rotation state of session \"%s\"",
- session->name);
+ if (session_reset_rotation_state(session, LTTNG_ROTATION_STATE_ERROR)) {
+ ERR("Failed to reset rotation state of session \"%s\"", session->name);
}
goto end;
}
* Return LTTNG_OK on success or else an LTTNG_ERR code.
*/
int cmd_rotate_get_info(struct ltt_session *session,
- struct lttng_rotation_get_info_return *info_return,
- uint64_t rotation_id)
+ struct lttng_rotation_get_info_return *info_return,
+ uint64_t rotation_id)
{
enum lttng_error_code cmd_ret = LTTNG_OK;
enum lttng_rotation_state rotation_state;
- DBG("Cmd rotate_get_info session %s, rotation id %" PRIu64, session->name,
- session->most_recent_chunk_id.value);
+ DBG("Cmd rotate_get_info session %s, rotation id %" PRIu64,
+ session->name,
+ session->most_recent_chunk_id.value);
if (session->chunk_being_archived) {
enum lttng_trace_chunk_status chunk_status;
uint64_t chunk_id;
- chunk_status = lttng_trace_chunk_get_id(
- session->chunk_being_archived,
- &chunk_id);
+ chunk_status = lttng_trace_chunk_get_id(session->chunk_being_archived, &chunk_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
- rotation_state = rotation_id == chunk_id ?
- LTTNG_ROTATION_STATE_ONGOING :
- LTTNG_ROTATION_STATE_EXPIRED;
+ rotation_state = rotation_id == chunk_id ? LTTNG_ROTATION_STATE_ONGOING :
+ LTTNG_ROTATION_STATE_EXPIRED;
} else {
if (session->last_archived_chunk_id.is_set &&
- rotation_id != session->last_archived_chunk_id.value) {
+ rotation_id != session->last_archived_chunk_id.value) {
rotation_state = LTTNG_ROTATION_STATE_EXPIRED;
} else {
rotation_state = session->rotation_state;
switch (rotation_state) {
case LTTNG_ROTATION_STATE_NO_ROTATION:
DBG("Reporting that no rotation has occurred within the lifetime of session \"%s\"",
- session->name);
+ session->name);
goto end;
case LTTNG_ROTATION_STATE_EXPIRED:
- DBG("Reporting that the rotation state of rotation id %" PRIu64 " of session \"%s\" has expired",
- rotation_id, session->name);
+ DBG("Reporting that the rotation state of rotation id %" PRIu64
+ " of session \"%s\" has expired",
+ rotation_id,
+ session->name);
break;
case LTTNG_ROTATION_STATE_ONGOING:
DBG("Reporting that rotation id %" PRIu64 " of session \"%s\" is still pending",
- rotation_id, session->name);
+ rotation_id,
+ session->name);
break;
case LTTNG_ROTATION_STATE_COMPLETED:
{
size_t current_tracing_path_reply_len;
DBG("Reporting that rotation id %" PRIu64 " of session \"%s\" is completed",
- rotation_id, session->name);
+ rotation_id,
+ session->name);
switch (session_get_consumer_destination_type(session)) {
case CONSUMER_DST_LOCAL:
- current_tracing_path_reply =
- info_return->location.local.absolute_path;
+ current_tracing_path_reply = info_return->location.local.absolute_path;
current_tracing_path_reply_len =
- sizeof(info_return->location.local.absolute_path);
+ sizeof(info_return->location.local.absolute_path);
info_return->location_type =
- (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL;
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL;
fmt_ret = asprintf(&chunk_path,
- "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
- session_get_base_path(session),
- session->last_archived_chunk_name);
+ "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
+ session_get_base_path(session),
+ session->last_archived_chunk_name);
if (fmt_ret == -1) {
PERROR("Failed to format the path of the last archived trace chunk");
info_return->status = LTTNG_ROTATION_STATUS_ERROR;
{
uint16_t ctrl_port, data_port;
- current_tracing_path_reply =
- info_return->location.relay.relative_path;
+ current_tracing_path_reply = info_return->location.relay.relative_path;
current_tracing_path_reply_len =
- sizeof(info_return->location.relay.relative_path);
+ sizeof(info_return->location.relay.relative_path);
/* Currently the only supported relay protocol. */
info_return->location.relay.protocol =
- (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP;
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP;
fmt_ret = lttng_strncpy(info_return->location.relay.host,
- session_get_net_consumer_hostname(session),
- sizeof(info_return->location.relay.host));
+ session_get_net_consumer_hostname(session),
+ sizeof(info_return->location.relay.host));
if (fmt_ret) {
ERR("Failed to copy host name to rotate_get_info reply");
info_return->status = LTTNG_ROTATION_STATUS_ERROR;
info_return->location.relay.ports.control = ctrl_port;
info_return->location.relay.ports.data = data_port;
info_return->location_type =
- (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY;
+ (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY;
chunk_path = strdup(session->last_chunk_path);
if (!chunk_path) {
ERR("Failed to allocate the path of the last archived trace chunk");
abort();
}
- fmt_ret = lttng_strncpy(current_tracing_path_reply,
- chunk_path, current_tracing_path_reply_len);
+ fmt_ret = lttng_strncpy(
+ current_tracing_path_reply, chunk_path, current_tracing_path_reply_len);
free(chunk_path);
if (fmt_ret) {
ERR("Failed to copy path of the last archived trace chunk to rotate_get_info reply");
break;
}
case LTTNG_ROTATION_STATE_ERROR:
- DBG("Reporting that an error occurred during rotation %" PRIu64 " of session \"%s\"",
- rotation_id, session->name);
+ DBG("Reporting that an error occurred during rotation %" PRIu64
+ " of session \"%s\"",
+ rotation_id,
+ session->name);
break;
default:
abort();
* Return LTTNG_OK on success or else a positive LTTNG_ERR code.
*/
int cmd_rotation_set_schedule(struct ltt_session *session,
- bool activate, enum lttng_rotation_schedule_type schedule_type,
- uint64_t new_value,
- struct notification_thread_handle *notification_thread_handle)
+ bool activate,
+ enum lttng_rotation_schedule_type schedule_type,
+ uint64_t new_value,
+ struct notification_thread_handle *notification_thread_handle)
{
int ret;
uint64_t *parameter_value;
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
parameter_value = &session->rotate_timer_period;
if (new_value >= UINT_MAX) {
- DBG("Failing ROTATION_SET_SCHEDULE command as the value requested for a periodic rotation schedule is invalid: %" PRIu64 " > %u (UINT_MAX)",
- new_value, UINT_MAX);
+ DBG("Failing ROTATION_SET_SCHEDULE command as the value requested for a periodic rotation schedule is invalid: %" PRIu64
+ " > %u (UINT_MAX)",
+ new_value,
+ UINT_MAX);
ret = LTTNG_ERR_INVALID;
goto end;
}
* Only start the timer if the session is active,
* otherwise it will be started when the session starts.
*/
- ret = timer_session_rotation_schedule_timer_start(
- session, new_value);
+ ret = timer_session_rotation_schedule_timer_start(session, new_value);
if (ret) {
ERR("Failed to enable session rotation timer in ROTATION_SET_SCHEDULE command");
ret = LTTNG_ERR_UNK;
goto end;
}
} else {
- ret = timer_session_rotation_schedule_timer_stop(
- session);
+ ret = timer_session_rotation_schedule_timer_stop(session);
if (ret) {
ERR("Failed to disable session rotation timer in ROTATION_SET_SCHEDULE command");
ret = LTTNG_ERR_UNK;
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
if (activate) {
- ret = subscribe_session_consumed_size_rotation(session,
- new_value, notification_thread_handle);
+ ret = subscribe_session_consumed_size_rotation(
+ session, new_value, notification_thread_handle);
if (ret) {
ERR("Failed to enable consumed-size notification in ROTATION_SET_SCHEDULE command");
ret = LTTNG_ERR_UNK;
goto end;
}
} else {
- ret = unsubscribe_session_consumed_size_rotation(session,
- notification_thread_handle);
+ ret = unsubscribe_session_consumed_size_rotation(
+ session, notification_thread_handle);
if (ret) {
ERR("Failed to disable consumed-size notification in ROTATION_SET_SCHEDULE command");
ret = LTTNG_ERR_UNK;
goto end;
}
-
}
break;
default:
const char *shm_path = (const char *) path_data;
DBG("Waiting for the shm path at %s to be removed before completing session destruction",
- shm_path);
+ shm_path);
while (true) {
int ret;
struct stat st;
} else {
if (!S_ISDIR(st.st_mode)) {
ERR("The type of shm path %s returned by stat() is not a directory; aborting the wait for shm path removal",
- shm_path);
+ shm_path);
break;
}
}
*
*/
-#include <common/hashtable/utils.hpp>
+#include "condition-internal.hpp"
+
#include <common/hashtable/hashtable.hpp>
+#include <common/hashtable/utils.hpp>
-#include <lttng/condition/condition.h>
-#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/buffer-usage-internal.hpp>
-#include <lttng/condition/session-consumed-size-internal.hpp>
-#include <lttng/condition/session-rotation-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/condition.h>
#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
+#include <lttng/condition/session-consumed-size-internal.hpp>
+#include <lttng/condition/session-rotation-internal.hpp>
#include <lttng/event-rule/event-rule-internal.hpp>
-#include <lttng/condition/event-rule-matches-internal.hpp>
-#include "condition-internal.hpp"
-static
-unsigned long lttng_condition_buffer_usage_hash(
- const struct lttng_condition *_condition)
+static unsigned long lttng_condition_buffer_usage_hash(const struct lttng_condition *_condition)
{
unsigned long hash;
unsigned long condition_type;
struct lttng_condition_buffer_usage *condition;
- condition = lttng::utils::container_of(_condition,
- <tng_condition_buffer_usage::parent);
+ condition = lttng::utils::container_of(_condition, <tng_condition_buffer_usage::parent);
condition_type = (unsigned long) condition->parent.type;
hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
hash ^= hash_key_str(condition->channel_name, lttng_ht_seed);
}
if (condition->domain.set) {
- hash ^= hash_key_ulong(
- (void *) condition->domain.type,
- lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) condition->domain.type, lttng_ht_seed);
}
if (condition->threshold_ratio.set) {
hash ^= hash_key_u64(&condition->threshold_ratio.value, lttng_ht_seed);
return hash;
}
-static
-unsigned long lttng_condition_session_consumed_size_hash(
- const struct lttng_condition *_condition)
+static unsigned long
+lttng_condition_session_consumed_size_hash(const struct lttng_condition *_condition)
{
unsigned long hash;
- unsigned long condition_type =
- (unsigned long) LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE;
+ unsigned long condition_type = (unsigned long) LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE;
struct lttng_condition_session_consumed_size *condition;
uint64_t val;
condition = lttng::utils::container_of(_condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
if (condition->session_name) {
return hash;
}
-static
-unsigned long lttng_condition_session_rotation_hash(
- const struct lttng_condition *_condition)
+static unsigned long lttng_condition_session_rotation_hash(const struct lttng_condition *_condition)
{
unsigned long hash, condition_type;
struct lttng_condition_session_rotation *condition;
- condition = lttng::utils::container_of(_condition,
- <tng_condition_session_rotation::parent);
+ condition =
+ lttng::utils::container_of(_condition, <tng_condition_session_rotation::parent);
condition_type = (unsigned long) condition->parent.type;
hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
LTTNG_ASSERT(condition->session_name);
return hash;
}
-static unsigned long lttng_condition_event_rule_matches_hash(
- const struct lttng_condition *condition)
+static unsigned long
+lttng_condition_event_rule_matches_hash(const struct lttng_condition *condition)
{
unsigned long hash, condition_type;
enum lttng_condition_status condition_status;
const struct lttng_event_rule *event_rule;
condition_type = (unsigned long) condition->type;
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
hash = hash_key_ulong((void *) condition_type, lttng_ht_seed);
{
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- ©_buffer, 0, -1);
+ lttng_payload_view_from_payload(©_buffer, 0, -1);
- ret = lttng_condition_create_from_payload(
- &view, ©);
+ ret = lttng_condition_create_from_payload(&view, ©);
if (ret < 0) {
copy = NULL;
goto end;
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <inttypes.h>
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/defaults.hpp>
-#include <common/uri.hpp>
#include <common/relayd/relayd.hpp>
#include <common/string-utils/format.hpp>
+#include <common/uri.hpp>
-#include "consumer.hpp"
-#include "health-sessiond.hpp"
-#include "ust-app.hpp"
-#include "utils.hpp"
-#include "lttng-sessiond.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
/*
* Return allocated full pathname of the session using the consumer trace path
* returned.
*/
char *setup_channel_trace_path(struct consumer_output *consumer,
- const char *session_path, size_t *consumer_path_offset)
+ const char *session_path,
+ size_t *consumer_path_offset)
{
int ret;
char *pathname;
}
/* Get correct path name destination */
- if (consumer->type == CONSUMER_DST_NET &&
- consumer->relay_major_version == 2 &&
- consumer->relay_minor_version < 11) {
- ret = snprintf(pathname, LTTNG_PATH_MAX, "%s%s/%s/%s",
- consumer->dst.net.base_dir,
- consumer->chunk_path, consumer->domain_subdir,
- session_path);
+ if (consumer->type == CONSUMER_DST_NET && consumer->relay_major_version == 2 &&
+ consumer->relay_minor_version < 11) {
+ ret = snprintf(pathname,
+ LTTNG_PATH_MAX,
+ "%s%s/%s/%s",
+ consumer->dst.net.base_dir,
+ consumer->chunk_path,
+ consumer->domain_subdir,
+ session_path);
*consumer_path_offset = 0;
} else {
- ret = snprintf(pathname, LTTNG_PATH_MAX, "%s/%s",
- consumer->domain_subdir, session_path);
+ ret = snprintf(
+ pathname, LTTNG_PATH_MAX, "%s/%s", consumer->domain_subdir, session_path);
*consumer_path_offset = strlen(consumer->domain_subdir) + 1;
}
- DBG3("Consumer trace path relative to current trace chunk: \"%s\"",
- pathname);
+ DBG3("Consumer trace path relative to current trace chunk: \"%s\"", pathname);
if (ret < 0) {
PERROR("Failed to format channel path");
goto error;
*
* Return 0 on success else a negative value on error.
*/
-int consumer_socket_send(
- struct consumer_socket *socket, const void *msg, size_t len)
+int consumer_socket_send(struct consumer_socket *socket, const void *msg, size_t len)
{
int fd;
ssize_t size;
* negative value is sent back and both parameters are untouched.
*/
int consumer_recv_status_channel(struct consumer_socket *sock,
- uint64_t *key, unsigned int *stream_count)
+ uint64_t *key,
+ unsigned int *stream_count)
{
int ret;
struct lttcomm_consumer_status_channel reply;
*
* On success return positive value. On error, negative value.
*/
-int consumer_send_destroy_relayd(struct consumer_socket *sock,
- struct consumer_output *consumer)
+int consumer_send_destroy_relayd(struct consumer_socket *sock, struct consumer_output *consumer)
{
int ret;
struct lttcomm_consumer_msg msg;
/* Destroy any relayd connection */
if (consumer->type == CONSUMER_DST_NET) {
rcu_read_lock();
- cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
- node.node) {
+ cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) {
int ret;
/* Send destroy relayd command */
*
* Return 0 on success, else negative value on error
*/
-int consumer_create_socket(struct consumer_data *data,
- struct consumer_output *output)
+int consumer_create_socket(struct consumer_data *data, struct consumer_output *output)
{
int ret = 0;
struct consumer_socket *socket;
socket->type = data->type;
- DBG3("Consumer socket created (fd: %d) and added to output",
- data->cmd_sock);
+ DBG3("Consumer socket created (fd: %d) and added to output", data->cmd_sock);
error:
return ret;
* object reference is not needed anymore.
*/
struct consumer_socket *consumer_find_socket_by_bitness(int bits,
- const struct consumer_output *consumer)
+ const struct consumer_output *consumer)
{
int consumer_fd;
struct consumer_socket *socket = NULL;
socket = consumer_find_socket(consumer_fd, consumer);
if (!socket) {
- ERR("Consumer socket fd %d not found in consumer obj %p",
- consumer_fd, consumer);
+ ERR("Consumer socket fd %d not found in consumer obj %p", consumer_fd, consumer);
}
end:
* be acquired before calling this function and across use of the
* returned consumer_socket.
*/
-struct consumer_socket *consumer_find_socket(int key,
- const struct consumer_output *consumer)
+struct consumer_socket *consumer_find_socket(int key, const struct consumer_output *consumer)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *node;
return NULL;
}
- lttng_ht_lookup(consumer->socks, (void *)((unsigned long) key),
- &iter);
+ lttng_ht_lookup(consumer->socks, (void *) ((unsigned long) key), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node != NULL) {
socket = lttng::utils::container_of(node, &consumer_socket::node);
* Add consumer socket to consumer output object. Read side lock must be
* acquired before calling this function.
*/
-void consumer_add_socket(struct consumer_socket *sock,
- struct consumer_output *consumer)
+void consumer_add_socket(struct consumer_socket *sock, struct consumer_output *consumer)
{
LTTNG_ASSERT(sock);
LTTNG_ASSERT(consumer);
* Delete consumer socket to consumer output object. Read side lock must be
* acquired before calling this function.
*/
-void consumer_del_socket(struct consumer_socket *sock,
- struct consumer_output *consumer)
+void consumer_del_socket(struct consumer_socket *sock, struct consumer_output *consumer)
{
int ret;
struct lttng_ht_iter iter;
{
struct lttng_ht_node_ulong *node =
lttng::utils::container_of(head, <tng_ht_node_ulong::head);
- struct consumer_socket *socket =
- lttng::utils::container_of(node, &consumer_socket::node);
+ struct consumer_socket *socket = lttng::utils::container_of(node, &consumer_socket::node);
free(socket);
}
}
rcu_read_lock();
- cds_lfht_for_each_entry(obj->socks->ht, &iter.iter, socket, node.node) {
+ cds_lfht_for_each_entry (obj->socks->ht, &iter.iter, socket, node.node) {
consumer_del_socket(socket, obj);
consumer_destroy_socket(socket);
}
*/
static void consumer_release_output(struct urcu_ref *ref)
{
- struct consumer_output *obj =
- lttng::utils::container_of(ref, &consumer_output::ref);
+ struct consumer_output *obj = lttng::utils::container_of(ref, &consumer_output::ref);
consumer_destroy_output_sockets(obj);
}
output->enabled = src->enabled;
output->net_seq_index = src->net_seq_index;
- memcpy(output->domain_subdir, src->domain_subdir,
- sizeof(output->domain_subdir));
+ memcpy(output->domain_subdir, src->domain_subdir, sizeof(output->domain_subdir));
output->snapshot = src->snapshot;
output->relay_major_version = src->relay_major_version;
output->relay_minor_version = src->relay_minor_version;
*
* Return 0 on success or else a negative value.
*/
-int consumer_copy_sockets(struct consumer_output *dst,
- struct consumer_output *src)
+int consumer_copy_sockets(struct consumer_output *dst, struct consumer_output *src)
{
int ret = 0;
struct lttng_ht_iter iter;
LTTNG_ASSERT(src);
rcu_read_lock();
- cds_lfht_for_each_entry(src->socks->ht, &iter.iter, socket, node.node) {
+ cds_lfht_for_each_entry (src->socks->ht, &iter.iter, socket, node.node) {
/* Ignore socket that are already there. */
copy_sock = consumer_find_socket(*socket->fd_ptr, dst);
if (copy_sock) {
* error.
*/
int consumer_set_network_uri(const struct ltt_session *session,
- struct consumer_output *output,
- struct lttng_uri *uri)
+ struct consumer_output *output,
+ struct lttng_uri *uri)
{
int ret;
struct lttng_uri *dst_uri = NULL;
/* Assign default port. */
uri->port = DEFAULT_NETWORK_CONTROL_PORT;
} else {
- if (output->dst.net.data_isset && uri->port ==
- output->dst.net.data.port) {
+ if (output->dst.net.data_isset && uri->port == output->dst.net.data.port) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
/* Assign default port. */
uri->port = DEFAULT_NETWORK_DATA_PORT;
} else {
- if (output->dst.net.control_isset && uri->port ==
- output->dst.net.control.port) {
+ if (output->dst.net.control_isset &&
+ uri->port == output->dst.net.control.port) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
goto error;
}
ret = snprintf(output->dst.net.base_dir,
- sizeof(output->dst.net.base_dir),
- "/%s/%s/", session->hostname, uri->subdir);
+ sizeof(output->dst.net.base_dir),
+ "/%s/%s/",
+ session->hostname,
+ uri->subdir);
} else {
if (session->has_auto_generated_name) {
ret = snprintf(output->dst.net.base_dir,
- sizeof(output->dst.net.base_dir),
- "/%s/%s/", session->hostname,
- session->name);
+ sizeof(output->dst.net.base_dir),
+ "/%s/%s/",
+ session->hostname,
+ session->name);
} else {
char session_creation_datetime[16];
size_t strftime_ret;
goto error;
}
strftime_ret = strftime(session_creation_datetime,
- sizeof(session_creation_datetime),
- "%Y%m%d-%H%M%S", timeinfo);
+ sizeof(session_creation_datetime),
+ "%Y%m%d-%H%M%S",
+ timeinfo);
if (strftime_ret == 0) {
ERR("Failed to format session creation timestamp while setting network URI");
ret = -LTTNG_ERR_FATAL;
goto error;
}
ret = snprintf(output->dst.net.base_dir,
- sizeof(output->dst.net.base_dir),
- "/%s/%s-%s/", session->hostname,
- session->name,
- session_creation_datetime);
+ sizeof(output->dst.net.base_dir),
+ "/%s/%s-%s/",
+ session->hostname,
+ session->name,
+ session_creation_datetime);
}
}
if (ret >= sizeof(output->dst.net.base_dir)) {
goto error;
}
- DBG3("Consumer set network uri base_dir path %s",
- output->dst.net.base_dir);
+ DBG3("Consumer set network uri base_dir path %s", output->dst.net.base_dir);
end:
return 0;
*
* The consumer socket lock must be held by the caller.
*/
-int consumer_send_fds(struct consumer_socket *sock, const int *fds,
- size_t nb_fd)
+int consumer_send_fds(struct consumer_socket *sock, const int *fds, size_t nb_fd)
{
int ret;
*
* The consumer socket lock must be held by the caller.
*/
-int consumer_send_msg(struct consumer_socket *sock,
- const struct lttcomm_consumer_msg *msg)
+int consumer_send_msg(struct consumer_socket *sock, const struct lttcomm_consumer_msg *msg)
{
int ret;
*
* The consumer socket lock must be held by the caller.
*/
-int consumer_send_channel(struct consumer_socket *sock,
- struct lttcomm_consumer_msg *msg)
+int consumer_send_channel(struct consumer_socket *sock, struct lttcomm_consumer_msg *msg)
{
int ret;
* information.
*/
void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t subbuf_size,
- uint64_t num_subbuf,
- int overwrite,
- unsigned int switch_timer_interval,
- unsigned int read_timer_interval,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- unsigned int monitor_timer_interval,
- int output,
- int type,
- uint64_t session_id,
- const char *pathname,
- const char *name,
- uint64_t relayd_id,
- uint64_t key,
- const lttng_uuid& uuid,
- uint32_t chan_id,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- uint64_t session_id_per_pid,
- unsigned int monitor,
- uint32_t ust_app_uid,
- int64_t blocking_timeout,
- const char *root_shm_path,
- const char *shm_path,
- struct lttng_trace_chunk *trace_chunk,
- const struct lttng_credentials *buffer_credentials)
+ uint64_t subbuf_size,
+ uint64_t num_subbuf,
+ int overwrite,
+ unsigned int switch_timer_interval,
+ unsigned int read_timer_interval,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ unsigned int monitor_timer_interval,
+ int output,
+ int type,
+ uint64_t session_id,
+ const char *pathname,
+ const char *name,
+ uint64_t relayd_id,
+ uint64_t key,
+ const lttng_uuid& uuid,
+ uint32_t chan_id,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ uint64_t session_id_per_pid,
+ unsigned int monitor,
+ uint32_t ust_app_uid,
+ int64_t blocking_timeout,
+ const char *root_shm_path,
+ const char *shm_path,
+ struct lttng_trace_chunk *trace_chunk,
+ const struct lttng_credentials *buffer_credentials)
{
LTTNG_ASSERT(msg);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
LTTNG_OPTIONAL_SET(&msg->u.ask_channel.chunk_id, chunk_id);
}
- msg->u.ask_channel.buffer_credentials.uid =
- lttng_credentials_get_uid(buffer_credentials);
- msg->u.ask_channel.buffer_credentials.gid =
- lttng_credentials_get_gid(buffer_credentials);
+ msg->u.ask_channel.buffer_credentials.uid = lttng_credentials_get_uid(buffer_credentials);
+ msg->u.ask_channel.buffer_credentials.gid = lttng_credentials_get_gid(buffer_credentials);
msg->cmd_type = LTTNG_CONSUMER_ASK_CHANNEL_CREATION;
msg->u.ask_channel.subbuf_size = subbuf_size;
- msg->u.ask_channel.num_subbuf = num_subbuf ;
+ msg->u.ask_channel.num_subbuf = num_subbuf;
msg->u.ask_channel.overwrite = overwrite;
msg->u.ask_channel.switch_timer_interval = switch_timer_interval;
msg->u.ask_channel.read_timer_interval = read_timer_interval;
std::copy(uuid.begin(), uuid.end(), msg->u.ask_channel.uuid);
if (pathname) {
- strncpy(msg->u.ask_channel.pathname, pathname,
- sizeof(msg->u.ask_channel.pathname));
- msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname)-1] = '\0';
+ strncpy(msg->u.ask_channel.pathname, pathname, sizeof(msg->u.ask_channel.pathname));
+ msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname) - 1] = '\0';
}
strncpy(msg->u.ask_channel.name, name, sizeof(msg->u.ask_channel.name));
msg->u.ask_channel.name[sizeof(msg->u.ask_channel.name) - 1] = '\0';
if (root_shm_path) {
- strncpy(msg->u.ask_channel.root_shm_path, root_shm_path,
+ strncpy(msg->u.ask_channel.root_shm_path,
+ root_shm_path,
sizeof(msg->u.ask_channel.root_shm_path));
- msg->u.ask_channel.root_shm_path[sizeof(msg->u.ask_channel.root_shm_path) - 1] = '\0';
+ msg->u.ask_channel.root_shm_path[sizeof(msg->u.ask_channel.root_shm_path) - 1] =
+ '\0';
}
if (shm_path) {
- strncpy(msg->u.ask_channel.shm_path, shm_path,
- sizeof(msg->u.ask_channel.shm_path));
+ strncpy(msg->u.ask_channel.shm_path, shm_path, sizeof(msg->u.ask_channel.shm_path));
msg->u.ask_channel.shm_path[sizeof(msg->u.ask_channel.shm_path) - 1] = '\0';
}
}
* Init channel communication message structure.
*/
void consumer_init_add_channel_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t channel_key,
- uint64_t session_id,
- const char *pathname,
- uint64_t relayd_id,
- const char *name,
- unsigned int nb_init_streams,
- enum lttng_event_output output,
- int type,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- unsigned int monitor,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- unsigned int monitor_timer_interval,
- struct lttng_trace_chunk *trace_chunk)
+ uint64_t channel_key,
+ uint64_t session_id,
+ const char *pathname,
+ uint64_t relayd_id,
+ const char *name,
+ unsigned int nb_init_streams,
+ enum lttng_event_output output,
+ int type,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ unsigned int monitor,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ unsigned int monitor_timer_interval,
+ struct lttng_trace_chunk *trace_chunk)
{
LTTNG_ASSERT(msg);
msg->u.channel.is_live = is_in_live_session;
msg->u.channel.monitor_timer_interval = monitor_timer_interval;
- strncpy(msg->u.channel.pathname, pathname,
- sizeof(msg->u.channel.pathname));
+ strncpy(msg->u.channel.pathname, pathname, sizeof(msg->u.channel.pathname));
msg->u.channel.pathname[sizeof(msg->u.channel.pathname) - 1] = '\0';
strncpy(msg->u.channel.name, name, sizeof(msg->u.channel.name));
* Init stream communication message structure.
*/
void consumer_init_add_stream_comm_msg(struct lttcomm_consumer_msg *msg,
- uint64_t channel_key,
- uint64_t stream_key,
- int32_t cpu)
+ uint64_t channel_key,
+ uint64_t stream_key,
+ int32_t cpu)
{
LTTNG_ASSERT(msg);
}
void consumer_init_streams_sent_comm_msg(struct lttcomm_consumer_msg *msg,
- enum lttng_consumer_command cmd,
- uint64_t channel_key, uint64_t net_seq_idx)
+ enum lttng_consumer_command cmd,
+ uint64_t channel_key,
+ uint64_t net_seq_idx)
{
LTTNG_ASSERT(msg);
* Send stream communication structure to the consumer.
*/
int consumer_send_stream(struct consumer_socket *sock,
- struct consumer_output *dst, struct lttcomm_consumer_msg *msg,
- const int *fds, size_t nb_fd)
+ struct consumer_output *dst,
+ struct lttcomm_consumer_msg *msg,
+ const int *fds,
+ size_t nb_fd)
{
int ret;
* On success return positive value. On error, negative value.
*/
int consumer_send_relayd_socket(struct consumer_socket *consumer_sock,
- struct lttcomm_relayd_sock *rsock, struct consumer_output *consumer,
- enum lttng_stream_type type, uint64_t session_id,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- const uint64_t *current_chunk_id, time_t session_creation_time,
- bool session_name_contains_creation_time)
+ struct lttcomm_relayd_sock *rsock,
+ struct consumer_output *consumer,
+ enum lttng_stream_type type,
+ uint64_t session_id,
+ const char *session_name,
+ const char *hostname,
+ const char *base_path,
+ int session_live_timer,
+ const uint64_t *current_chunk_id,
+ time_t session_creation_time,
+ bool session_name_contains_creation_time)
{
int ret;
int fd;
char output_path[LTTNG_PATH_MAX] = {};
uint64_t relayd_session_id;
- ret = relayd_create_session(rsock, &relayd_session_id,
- session_name, hostname, base_path,
- session_live_timer, consumer->snapshot,
- session_id, the_sessiond_uuid, current_chunk_id,
- session_creation_time,
- session_name_contains_creation_time,
- output_path);
+ ret = relayd_create_session(rsock,
+ &relayd_session_id,
+ session_name,
+ hostname,
+ base_path,
+ session_live_timer,
+ consumer->snapshot,
+ session_id,
+ the_sessiond_uuid,
+ current_chunk_id,
+ session_creation_time,
+ session_name_contains_creation_time,
+ output_path);
if (ret < 0) {
/* Close the control socket. */
(void) relayd_close(rsock);
goto error;
}
msg.u.relayd_sock.relayd_session_id = relayd_session_id;
- DBG("Created session on relay, output path reply: %s",
- output_path);
+ DBG("Created session on relay, output path reply: %s", output_path);
}
msg.cmd_type = LTTNG_CONSUMER_ADD_RELAYD_SOCKET;
return ret;
}
-static
-int consumer_send_pipe(struct consumer_socket *consumer_sock,
- enum lttng_consumer_command cmd, int pipe)
+static int
+consumer_send_pipe(struct consumer_socket *consumer_sock, enum lttng_consumer_command cmd, int pipe)
{
int ret;
struct lttcomm_consumer_msg msg;
command_name = "SET_CHANNEL_MONITOR_PIPE";
break;
default:
- ERR("Unexpected command received in %s (cmd = %d)", __func__,
- (int) cmd);
+ ERR("Unexpected command received in %s (cmd = %d)", __func__, (int) cmd);
abort();
}
goto error;
}
- DBG3("Sending %s pipe %d to consumer on socket %d",
- pipe_name,
- pipe, *consumer_sock->fd_ptr);
+ DBG3("Sending %s pipe %d to consumer on socket %d", pipe_name, pipe, *consumer_sock->fd_ptr);
ret = consumer_send_fds(consumer_sock, &pipe, 1);
if (ret < 0) {
goto error;
return ret;
}
-int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock,
- int pipe)
+int consumer_send_channel_monitor_pipe(struct consumer_socket *consumer_sock, int pipe)
{
- return consumer_send_pipe(consumer_sock,
- LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE, pipe);
+ return consumer_send_pipe(consumer_sock, LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE, pipe);
}
/*
* Ask the consumer if the data is pending for the specific session id.
* Returns 1 if data is pending, 0 otherwise, or < 0 on error.
*/
-int consumer_is_data_pending(uint64_t session_id,
- struct consumer_output *consumer)
+int consumer_is_data_pending(uint64_t session_id, struct consumer_output *consumer)
{
int ret;
- int32_t ret_code = 0; /* Default is that the data is NOT pending */
+ int32_t ret_code = 0; /* Default is that the data is NOT pending */
struct consumer_socket *socket;
struct lttng_ht_iter iter;
struct lttcomm_consumer_msg msg;
/* Send command for each consumer */
rcu_read_lock();
- cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
- node.node) {
+ cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = consumer_socket_send(socket, &msg, sizeof(msg));
if (ret < 0) {
rcu_read_unlock();
DBG("Consumer data is %s pending for session id %" PRIu64,
- ret_code == 1 ? "" : "NOT", session_id);
+ ret_code == 1 ? "" : "NOT",
+ session_id);
return ret_code;
error_unlock:
*
* Return 0 on success else a negative value.
*/
-int consumer_close_metadata(struct consumer_socket *socket,
- uint64_t metadata_key)
+int consumer_close_metadata(struct consumer_socket *socket, uint64_t metadata_key)
{
int ret;
struct lttcomm_consumer_msg msg;
*
* Return 0 on success else a negative value.
*/
-int consumer_setup_metadata(struct consumer_socket *socket,
- uint64_t metadata_key)
+int consumer_setup_metadata(struct consumer_socket *socket, uint64_t metadata_key)
{
int ret;
struct lttcomm_consumer_msg msg;
* Return 0 on success else a negative value.
*/
int consumer_push_metadata(struct consumer_socket *socket,
- uint64_t metadata_key, char *metadata_str, size_t len,
- size_t target_offset, uint64_t version)
+ uint64_t metadata_key,
+ char *metadata_str,
+ size_t len,
+ size_t target_offset,
+ uint64_t version)
{
int ret;
struct lttcomm_consumer_msg msg;
goto end;
}
- DBG3("Consumer pushing metadata on sock %d of len %zu", *socket->fd_ptr,
- len);
+ DBG3("Consumer pushing metadata on sock %d of len %zu", *socket->fd_ptr, len);
ret = consumer_socket_send(socket, metadata_str, len);
if (ret < 0) {
* Returns LTTNG_OK on success or else an LTTng error code.
*/
enum lttng_error_code consumer_snapshot_channel(struct consumer_socket *socket,
- uint64_t key, const struct consumer_output *output, int metadata,
- const char *channel_path,
- uint64_t nb_packets_per_stream)
+ uint64_t key,
+ const struct consumer_output *output,
+ int metadata,
+ const char *channel_path,
+ uint64_t nb_packets_per_stream)
{
int ret;
enum lttng_error_code status = LTTNG_OK;
msg.u.snapshot_channel.metadata = metadata;
if (output->type == CONSUMER_DST_NET) {
- msg.u.snapshot_channel.relayd_id =
- output->net_seq_index;
+ msg.u.snapshot_channel.relayd_id = output->net_seq_index;
msg.u.snapshot_channel.use_relayd = 1;
} else {
msg.u.snapshot_channel.relayd_id = (uint64_t) -1ULL;
}
ret = lttng_strncpy(msg.u.snapshot_channel.pathname,
- channel_path,
- sizeof(msg.u.snapshot_channel.pathname));
+ channel_path,
+ sizeof(msg.u.snapshot_channel.pathname));
if (ret < 0) {
ERR("Snapshot path exceeds the maximal allowed length of %zu bytes (%zu bytes required) with path \"%s\"",
- sizeof(msg.u.snapshot_channel.pathname),
- strlen(channel_path),
- channel_path);
+ sizeof(msg.u.snapshot_channel.pathname),
+ strlen(channel_path),
+ channel_path);
status = LTTNG_ERR_SNAPSHOT_FAIL;
goto error;
}
/*
* Ask the consumer the number of discarded events for a channel.
*/
-int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
- struct consumer_output *consumer, uint64_t *discarded)
+int consumer_get_discarded_events(uint64_t session_id,
+ uint64_t channel_key,
+ struct consumer_output *consumer,
+ uint64_t *discarded)
{
int ret;
struct consumer_socket *socket;
/* Send command for each consumer */
rcu_read_lock();
- cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
- node.node) {
+ cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) {
uint64_t consumer_discarded = 0;
pthread_mutex_lock(socket->lock);
ret = consumer_socket_send(socket, &msg, sizeof(msg));
* No need for a recv reply status because the answer to the
* command is the reply status message.
*/
- ret = consumer_socket_recv(socket, &consumer_discarded,
- sizeof(consumer_discarded));
+ ret = consumer_socket_recv(socket, &consumer_discarded, sizeof(consumer_discarded));
if (ret < 0) {
ERR("get discarded events");
pthread_mutex_unlock(socket->lock);
*discarded += consumer_discarded;
}
ret = 0;
- DBG("Consumer discarded %" PRIu64 " events in session id %" PRIu64,
- *discarded, session_id);
+ DBG("Consumer discarded %" PRIu64 " events in session id %" PRIu64, *discarded, session_id);
end:
rcu_read_unlock();
/*
* Ask the consumer the number of lost packets for a channel.
*/
-int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
- struct consumer_output *consumer, uint64_t *lost)
+int consumer_get_lost_packets(uint64_t session_id,
+ uint64_t channel_key,
+ struct consumer_output *consumer,
+ uint64_t *lost)
{
int ret;
struct consumer_socket *socket;
/* Send command for each consumer */
rcu_read_lock();
- cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
- node.node) {
+ cds_lfht_for_each_entry (consumer->socks->ht, &iter.iter, socket, node.node) {
uint64_t consumer_lost = 0;
pthread_mutex_lock(socket->lock);
ret = consumer_socket_send(socket, &msg, sizeof(msg));
* No need for a recv reply status because the answer to the
* command is the reply status message.
*/
- ret = consumer_socket_recv(socket, &consumer_lost,
- sizeof(consumer_lost));
+ ret = consumer_socket_recv(socket, &consumer_lost, sizeof(consumer_lost));
if (ret < 0) {
ERR("get lost packets");
pthread_mutex_unlock(socket->lock);
*lost += consumer_lost;
}
ret = 0;
- DBG("Consumer lost %" PRIu64 " packets in session id %" PRIu64,
- *lost, session_id);
+ DBG("Consumer lost %" PRIu64 " packets in session id %" PRIu64, *lost, session_id);
end:
rcu_read_unlock();
* when the rotation started. On the relay, this allows to keep track in which
* chunk each stream is currently writing to (for the rotate_pending operation).
*/
-int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
- struct consumer_output *output,
- bool is_metadata_channel)
+int consumer_rotate_channel(struct consumer_socket *socket,
+ uint64_t key,
+ struct consumer_output *output,
+ bool is_metadata_channel)
{
int ret;
struct lttcomm_consumer_msg msg;
return ret;
}
-int consumer_init(struct consumer_socket *socket,
- const lttng_uuid& sessiond_uuid)
+int consumer_init(struct consumer_socket *socket, const lttng_uuid& sessiond_uuid)
{
int ret;
struct lttcomm_consumer_msg msg = {
* Called with the consumer socket lock held.
*/
int consumer_create_trace_chunk(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- const char *domain_subdir)
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ const char *domain_subdir)
{
int ret;
enum lttng_trace_chunk_status chunk_status;
LTTNG_ASSERT(chunk);
if (relayd_id != -1ULL) {
- LTTNG_OPTIONAL_SET(&msg.u.create_trace_chunk.relayd_id,
- relayd_id);
+ LTTNG_OPTIONAL_SET(&msg.u.create_trace_chunk.relayd_id, relayd_id);
}
- chunk_status = lttng_trace_chunk_get_name(chunk, &chunk_name,
- &chunk_name_overridden);
+ chunk_status = lttng_trace_chunk_get_name(chunk, &chunk_name, &chunk_name_overridden);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK &&
- chunk_status != LTTNG_TRACE_CHUNK_STATUS_NONE) {
+ chunk_status != LTTNG_TRACE_CHUNK_STATUS_NONE) {
ERR("Failed to get name of trace chunk");
ret = -LTTNG_ERR_FATAL;
goto error;
}
if (chunk_name_overridden) {
ret = lttng_strncpy(msg.u.create_trace_chunk.override_name,
- chunk_name,
- sizeof(msg.u.create_trace_chunk.override_name));
+ chunk_name,
+ sizeof(msg.u.create_trace_chunk.override_name));
if (ret) {
ERR("Trace chunk name \"%s\" exceeds the maximal length allowed by the consumer protocol",
- chunk_name);
+ chunk_name);
ret = -LTTNG_ERR_FATAL;
goto error;
}
}
- chunk_status = lttng_trace_chunk_get_creation_timestamp(chunk,
- &creation_timestamp);
+ chunk_status = lttng_trace_chunk_get_creation_timestamp(chunk, &creation_timestamp);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -LTTNG_ERR_FATAL;
goto error;
}
- msg.u.create_trace_chunk.creation_timestamp =
- (uint64_t) creation_timestamp;
+ msg.u.create_trace_chunk.creation_timestamp = (uint64_t) creation_timestamp;
/* Only used for logging purposes. */
- ret = time_to_iso8601_str(creation_timestamp,
- creation_timestamp_buffer,
- sizeof(creation_timestamp_buffer));
- creation_timestamp_str = !ret ? creation_timestamp_buffer :
- "(formatting error)";
+ ret = time_to_iso8601_str(
+ creation_timestamp, creation_timestamp_buffer, sizeof(creation_timestamp_buffer));
+ creation_timestamp_str = !ret ? creation_timestamp_buffer : "(formatting error)";
chunk_status = lttng_trace_chunk_get_id(chunk, &chunk_id);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
if (chunk_has_local_output) {
chunk_status = lttng_trace_chunk_borrow_chunk_directory_handle(
- chunk, &chunk_directory_handle);
+ chunk, &chunk_directory_handle);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -LTTNG_ERR_FATAL;
goto error;
}
- chunk_status = lttng_trace_chunk_get_credentials(
- chunk, &chunk_credentials);
+ chunk_status = lttng_trace_chunk_get_credentials(chunk, &chunk_credentials);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
/*
* Not associating credentials to a sessiond chunk is a
ret = -LTTNG_ERR_FATAL;
goto error;
}
- tc_status = lttng_trace_chunk_create_subdirectory(
- chunk, domain_subdir);
+ tc_status = lttng_trace_chunk_create_subdirectory(chunk, domain_subdir);
if (tc_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
PERROR("Failed to create chunk domain output directory \"%s\"",
- domain_subdir);
+ domain_subdir);
ret = -LTTNG_ERR_FATAL;
goto error;
}
- domain_handle = lttng_directory_handle_create_from_handle(
- domain_subdir,
- chunk_directory_handle);
+ domain_handle = lttng_directory_handle_create_from_handle(domain_subdir,
+ chunk_directory_handle);
if (!domain_handle) {
ret = -LTTNG_ERR_FATAL;
goto error;
* The ownership of the chunk directory handle's is maintained
* by the trace chunk.
*/
- domain_dirfd = lttng_directory_handle_get_dirfd(
- domain_handle);
+ domain_dirfd = lttng_directory_handle_get_dirfd(domain_handle);
LTTNG_ASSERT(domain_dirfd >= 0);
msg.u.create_trace_chunk.credentials.value.uid =
- lttng_credentials_get_uid(&chunk_credentials);
+ lttng_credentials_get_uid(&chunk_credentials);
msg.u.create_trace_chunk.credentials.value.gid =
- lttng_credentials_get_gid(&chunk_credentials);
+ lttng_credentials_get_gid(&chunk_credentials);
msg.u.create_trace_chunk.credentials.is_set = 1;
}
DBG("Sending consumer create trace chunk command: relayd_id = %" PRId64
- ", session_id = %" PRIu64 ", chunk_id = %" PRIu64
- ", creation_timestamp = %s",
- relayd_id, session_id, chunk_id,
- creation_timestamp_str);
+ ", session_id = %" PRIu64 ", chunk_id = %" PRIu64 ", creation_timestamp = %s",
+ relayd_id,
+ session_id,
+ chunk_id,
+ creation_timestamp_str);
health_code_update();
ret = consumer_send_msg(socket, &msg);
health_code_update();
* Called with the consumer socket lock held.
*/
int consumer_close_trace_chunk(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- char *closed_trace_chunk_path)
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ char *closed_trace_chunk_path)
{
int ret;
enum lttng_trace_chunk_status chunk_status;
lttng_dynamic_buffer_init(&path_reception_buffer);
if (relayd_id != -1ULL) {
- LTTNG_OPTIONAL_SET(
- &msg.u.close_trace_chunk.relayd_id, relayd_id);
+ LTTNG_OPTIONAL_SET(&msg.u.close_trace_chunk.relayd_id, relayd_id);
}
- chunk_status = lttng_trace_chunk_get_close_command(
- chunk, &close_command);
+ chunk_status = lttng_trace_chunk_get_close_command(chunk, &close_command);
switch (chunk_status) {
case LTTNG_TRACE_CHUNK_STATUS_OK:
LTTNG_OPTIONAL_SET(&msg.u.close_trace_chunk.close_command,
- (uint32_t) close_command);
+ (uint32_t) close_command);
break;
case LTTNG_TRACE_CHUNK_STATUS_NONE:
break;
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
msg.u.close_trace_chunk.chunk_id = chunk_id;
- chunk_status = lttng_trace_chunk_get_close_timestamp(chunk,
- &close_timestamp);
+ chunk_status = lttng_trace_chunk_get_close_timestamp(chunk, &close_timestamp);
/*
* A trace chunk should be closed locally before being closed remotely.
* Otherwise, the close timestamp would never be transmitted to the
msg.u.close_trace_chunk.close_timestamp = (uint64_t) close_timestamp;
if (msg.u.close_trace_chunk.close_command.is_set) {
- close_command_name = lttng_trace_chunk_command_type_get_name(
- close_command);
+ close_command_name = lttng_trace_chunk_command_type_get_name(close_command);
}
DBG("Sending consumer close trace chunk command: relayd_id = %" PRId64
- ", session_id = %" PRIu64 ", chunk_id = %" PRIu64
- ", close command = \"%s\"",
- relayd_id, session_id, chunk_id, close_command_name);
+ ", session_id = %" PRIu64 ", chunk_id = %" PRIu64 ", close command = \"%s\"",
+ relayd_id,
+ session_id,
+ chunk_id,
+ close_command_name);
health_code_update();
ret = consumer_socket_send(socket, &msg, sizeof(struct lttcomm_consumer_msg));
goto error;
}
if (reply.path_length >= LTTNG_PATH_MAX) {
- ERR("Invalid path returned by relay daemon: %" PRIu32 "bytes exceeds maximal allowed length of %d bytes",
- reply.path_length, LTTNG_PATH_MAX);
+ ERR("Invalid path returned by relay daemon: %" PRIu32
+ "bytes exceeds maximal allowed length of %d bytes",
+ reply.path_length,
+ LTTNG_PATH_MAX);
ret = -LTTNG_ERR_INVALID_PROTOCOL;
goto error;
}
- ret = lttng_dynamic_buffer_set_size(&path_reception_buffer,
- reply.path_length);
+ ret = lttng_dynamic_buffer_set_size(&path_reception_buffer, reply.path_length);
if (ret) {
ERR("Failed to allocate reception buffer of path returned by the \"close trace chunk\" command");
ret = -LTTNG_ERR_NOMEM;
goto error;
}
- ret = consumer_socket_recv(socket, path_reception_buffer.data,
- path_reception_buffer.size);
+ ret = consumer_socket_recv(socket, path_reception_buffer.data, path_reception_buffer.size);
if (ret < 0) {
ERR("Communication error while receiving path of closed trace chunk");
ret = -LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
* closed_trace_chunk_path is assumed to have a length >=
* LTTNG_PATH_MAX
*/
- memcpy(closed_trace_chunk_path, path_reception_buffer.data,
- path_reception_buffer.size);
+ memcpy(closed_trace_chunk_path,
+ path_reception_buffer.data,
+ path_reception_buffer.size);
}
error:
lttng_dynamic_buffer_reset(&path_reception_buffer);
* Returns 0 on success, or a negative value on error.
*/
int consumer_trace_chunk_exists(struct consumer_socket *socket,
- uint64_t relayd_id, uint64_t session_id,
- struct lttng_trace_chunk *chunk,
- enum consumer_trace_chunk_exists_status *result)
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ enum consumer_trace_chunk_exists_status *result)
{
int ret;
enum lttng_trace_chunk_status chunk_status;
LTTNG_ASSERT(socket);
if (relayd_id != -1ULL) {
- LTTNG_OPTIONAL_SET(&msg.u.trace_chunk_exists.relayd_id,
- relayd_id);
+ LTTNG_OPTIONAL_SET(&msg.u.trace_chunk_exists.relayd_id, relayd_id);
}
chunk_status = lttng_trace_chunk_get_id(chunk, &chunk_id);
msg.u.trace_chunk_exists.chunk_id = chunk_id;
DBG("Sending consumer trace chunk exists command: relayd_id = %" PRId64
- ", session_id = %" PRIu64
- ", chunk_id = %" PRIu64, relayd_id, session_id, chunk_id);
+ ", session_id = %" PRIu64 ", chunk_id = %" PRIu64,
+ relayd_id,
+ session_id,
+ chunk_id);
health_code_update();
ret = consumer_send_msg(socket, &msg);
ret = -1;
goto error;
}
- DBG("Consumer reply to TRACE_CHUNK_EXISTS command: %s",
- consumer_reply_str);
+ DBG("Consumer reply to TRACE_CHUNK_EXISTS command: %s", consumer_reply_str);
ret = 0;
error:
health_code_update();
*/
#define _LGPL_SOURCE
+#include "agent.hpp"
+#include "context.hpp"
+#include "kernel.hpp"
+#include "trace-ust.hpp"
+#include "ust-app.hpp"
+
+#include <common/error.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <urcu/list.h>
-#include <common/error.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-
-#include "context.hpp"
-#include "kernel.hpp"
-#include "ust-app.hpp"
-#include "trace-ust.hpp"
-#include "agent.hpp"
-
/*
* Add kernel context to all channel.
*
* Assumes the ownership of kctx.
*/
static int add_kctx_all_channels(struct ltt_kernel_session *ksession,
- struct ltt_kernel_context *kctx)
+ struct ltt_kernel_context *kctx)
{
int ret;
struct ltt_kernel_channel *kchan;
DBG("Adding kernel context to all channels");
/* Go over all channels */
- cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) {
+ cds_list_for_each_entry (kchan, &ksession->channel_list.head, list) {
struct ltt_kernel_context *kctx_copy;
kctx_copy = trace_kernel_copy_context(kctx);
*
* Assumes the ownership of kctx.
*/
-static int add_kctx_to_channel(struct ltt_kernel_context *kctx,
- struct ltt_kernel_channel *kchan)
+static int add_kctx_to_channel(struct ltt_kernel_context *kctx, struct ltt_kernel_channel *kchan)
{
int ret;
* Add UST context to channel.
*/
static int add_uctx_to_channel(struct ltt_ust_session *usess,
- enum lttng_domain_type domain,
- struct ltt_ust_channel *uchan,
- const struct lttng_event_context *ctx)
+ enum lttng_domain_type domain,
+ struct ltt_ust_channel *uchan,
+ const struct lttng_event_context *ctx)
{
int ret;
struct ltt_ust_context *uctx = NULL;
LTTNG_ASSERT(ctx);
/* Check if context is duplicate */
- cds_list_for_each_entry(uctx, &uchan->ctx_list, list) {
+ cds_list_for_each_entry (uctx, &uchan->ctx_list, list) {
if (trace_ust_match_context(uctx, ctx)) {
ret = LTTNG_ERR_UST_CONTEXT_EXIST;
goto duplicate;
* Add kernel context to tracer.
*/
int context_kernel_add(struct ltt_kernel_session *ksession,
- const struct lttng_event_context *ctx,
- const char *channel_name)
+ const struct lttng_event_context *ctx,
+ const char *channel_name)
{
int ret;
struct ltt_kernel_channel *kchan;
kctx->ctx.u.perf_counter.type = ctx->u.perf_counter.type;
kctx->ctx.u.perf_counter.config = ctx->u.perf_counter.config;
- strncpy(kctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name,
- LTTNG_SYMBOL_NAME_LEN);
+ strncpy(kctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name, LTTNG_SYMBOL_NAME_LEN);
kctx->ctx.u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
if (*channel_name == '\0') {
* Add UST context to tracer.
*/
int context_ust_add(struct ltt_ust_session *usess,
- enum lttng_domain_type domain,
- const struct lttng_event_context *ctx,
- const char *channel_name)
+ enum lttng_domain_type domain,
+ const struct lttng_event_context *ctx,
+ const char *channel_name)
{
int ret = LTTNG_OK;
struct lttng_ht_iter iter;
} else {
rcu_read_lock();
/* Add ctx all events, all channels */
- cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) {
+ cds_lfht_for_each_entry (chan_ht->ht, &iter.iter, uchan, node.node) {
ret = add_uctx_to_channel(usess, domain, uchan, ctx);
if (ret) {
- ERR("Failed to add context to channel %s",
- uchan->name);
+ ERR("Failed to add context to channel %s", uchan->name);
continue;
}
}
*
*/
-#include "ctf2-trace-class-visitor.hpp"
#include "clock-class.hpp"
+#include "ctf2-trace-class-visitor.hpp"
#include <common/exception.hpp>
#include <common/format.hpp>
json::json make_json_fragment(const char *type)
{
- return {{"type", type}};
+ return { { "type", type } };
}
-json::json to_json(const lst::field_location &location)
+json::json to_json(const lst::field_location& location)
{
json::json location_array;
break;
}
- std::copy(location.elements_.begin(), location.elements_.end(),
- std::back_inserter(location_array));
+ std::copy(location.elements_.begin(),
+ location.elements_.end(),
+ std::back_inserter(location_array));
return location_array;
}
virtual void visit(const lst::integer_type& type) override final
{
_fragment["type"] = type.signedness_ == lst::integer_type::signedness::SIGNED ?
- "fixed-length-signed-integer" :
- "fixed-length-unsigned-integer";
+ "fixed-length-signed-integer" :
+ "fixed-length-unsigned-integer";
_fragment["length"] = type.size;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
_fragment["type"] = "fixed-length-floating-point-number";
_fragment["length"] = type.exponent_digits + type.mantissa_digits;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
}
template <class EnumerationType>
void visit_enumeration(const EnumerationType& type)
{
- _fragment["type"] = std::is_signed<typename EnumerationType::mapping::range_t::range_integer_t>::value ?
- "fixed-length-signed-enumeration" :
- "fixed-length-unsigned-enumeration";
+ _fragment["type"] =
+ std::is_signed<
+ typename EnumerationType::mapping::range_t::range_integer_t>::value ?
+ "fixed-length-signed-enumeration" :
+ "fixed-length-unsigned-enumeration";
_fragment["length"] = type.size;
_fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ?
- "big-endian" :
- "little-endian";
+ "big-endian" :
+ "little-endian";
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
if (type.roles_.size() > 0) {
if (std::is_signed<typename EnumerationType::mapping::range_t::
- range_integer_t>::value) {
- LTTNG_THROW_ERROR(fmt::format(
- "Failed to serialize {}: unexpected role",
- _fragment["type"]));
+ range_integer_t>::value) {
+ LTTNG_THROW_ERROR(
+ fmt::format("Failed to serialize {}: unexpected role",
+ _fragment["type"]));
}
auto role_array = json::json::array();
if (type.mappings_->size() < 1) {
LTTNG_THROW_ERROR(fmt::format(
- "Failed to serialize {}: enumeration must have at least one mapping",
- _fragment["type"]));
+ "Failed to serialize {}: enumeration must have at least one mapping",
+ _fragment["type"]));
}
json::json mappings_value;
- for (const auto &mapping : *type.mappings_) {
- mappings_value[mapping.name] = {{mapping.range.begin, mapping.range.end}};
+ for (const auto& mapping : *type.mappings_) {
+ mappings_value[mapping.name] = { { mapping.range.begin,
+ mapping.range.end } };
}
_fragment["mappings"] = std::move(mappings_value);
}
virtual void visit(const lst::null_terminated_string_type& type
- __attribute__((unused))) override final
+ __attribute__((unused))) override final
{
_fragment["type"] = "null-terminated-string";
}
}
auto member_classes_value = json::json::array();
- for (const auto &field : type.fields_) {
+ for (const auto& field : type.fields_) {
::ctf2::field_visitor member_visitor;
json::json member_class;
json::json member_class;
/* TODO missing selector-field-range. */
- member_class["selector-field-ranges"] = {{option.first.range.begin, option.first.range.end}};
+ member_class["selector-field-ranges"] = { { option.first.range.begin,
+ option.first.range.end } };
option.second->accept(option_visitor);
member_class["field-class"] = option_visitor.move_fragment();
options_value.emplace_back(std::move(member_class));
}; /* namespace */
lsc::trace_class_visitor::trace_class_visitor(
- lsc::append_metadata_fragment_function append_metadata_fragment) :
+ lsc::append_metadata_fragment_function append_metadata_fragment) :
_append_metadata_fragment(append_metadata_fragment)
{
}
void lsc::trace_class_visitor::visit(const lst::clock_class& clock_class)
{
- auto clock_class_fragment = make_json_fragment("clock-class");
+ auto clock_class_fragment = make_json_fragment("clock-class");
json::json offset;
- offset.update({{"seconds", clock_class.offset / clock_class.frequency},
- {"cycles", clock_class.offset % clock_class.frequency}});
+ offset.update({ { "seconds", clock_class.offset / clock_class.frequency },
+ { "cycles", clock_class.offset % clock_class.frequency } });
- clock_class_fragment.update({
- {"name", clock_class.name},
- {"description", clock_class.description},
- {"frequency", clock_class.frequency},
- {"offset", std::move(offset)}});
+ clock_class_fragment.update({ { "name", clock_class.name },
+ { "description", clock_class.description },
+ { "frequency", clock_class.frequency },
+ { "offset", std::move(offset) } });
if (clock_class.uuid) {
clock_class_fragment["uuid"] = *clock_class.uuid;
stream_class_fragment["id"] = stream_class.id;
if (stream_class.default_clock_class_name) {
stream_class_fragment["default-clock-class-name"] =
- *stream_class.default_clock_class_name;
+ *stream_class.default_clock_class_name;
}
const auto packet_context = stream_class.packet_context();
::ctf2::field_visitor visitor;
event_header->accept(visitor);
- stream_class_fragment["event-record-header-field-class"] =
- visitor.move_fragment();
+ stream_class_fragment["event-record-header-field-class"] = visitor.move_fragment();
}
const auto event_context = stream_class.event_context();
event_context->accept(visitor);
stream_class_fragment["event-record-common-context-field-class"] =
- visitor.move_fragment();
+ visitor.move_fragment();
}
append_metadata_fragment(stream_class_fragment);
*
*/
-#include <stddef.h>
-#include <stdlib.h>
-#include <urcu.h>
-#include <common/futex.hpp>
-#include <common/macros.hpp>
-
#include "dispatch.hpp"
-#include "ust-app.hpp"
-#include "testpoint.hpp"
#include "fd-limit.hpp"
#include "health-sessiond.hpp"
#include "lttng-sessiond.hpp"
+#include "testpoint.hpp"
#include "thread.hpp"
+#include "ust-app.hpp"
+
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <urcu.h>
namespace {
struct thread_notifiers {
* this is possible hence simply stopping the
* update.
*/
- DBG3("UST app update failed to find app sock %d",
- app_sock);
+ DBG3("UST app update failed to find app sock %d", app_sock);
goto unlock_rcu;
}
ust_app_global_update_event_notifier_rules(app);
/* For all tracing session(s) */
- cds_list_for_each_entry_safe(sess, stmp, &session_list->head, list) {
+ cds_list_for_each_entry_safe (sess, stmp, &session_list->head, list) {
if (!session_get(sess)) {
continue;
}
session_lock(sess);
- if (!sess->active || !sess->ust_session ||
- !sess->ust_session->active) {
+ if (!sess->active || !sess->ust_session || !sess->ust_session->active) {
goto unlock_session;
}
goto error_create;
}
- cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
- &wait_queue->head, head) {
+ cds_list_for_each_entry_safe (wait_node, tmp_wait_node, &wait_queue->head, head) {
LTTNG_ASSERT(wait_node->app);
ret = lttng_poll_add(&events, wait_node->app->sock, LPOLLIN);
if (ret < 0) {
uint32_t revents = LTTNG_POLL_GETEV(&events, i);
int pollfd = LTTNG_POLL_GETFD(&events, i);
- cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
- &wait_queue->head, head) {
- if (pollfd == wait_node->app->sock &&
- (revents & (LPOLLHUP | LPOLLERR))) {
+ cds_list_for_each_entry_safe (wait_node, tmp_wait_node, &wait_queue->head, head) {
+ if (pollfd == wait_node->app->sock && (revents & (LPOLLHUP | LPOLLERR))) {
cds_list_del(&wait_node->head);
wait_queue->count--;
ust_app_destroy(wait_node->app);
rcu_register_thread();
- health_register(the_health_sessiond,
- HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH);
+ health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH);
if (testpoint(sessiond_thread_app_reg_dispatch)) {
goto error_testpoint;
health_code_update();
/* Dequeue command for registration */
- node = cds_wfcq_dequeue_blocking(
- ¬ifiers->ust_cmd_queue->head,
- ¬ifiers->ust_cmd_queue->tail);
+ node = cds_wfcq_dequeue_blocking(¬ifiers->ust_cmd_queue->head,
+ ¬ifiers->ust_cmd_queue->tail);
if (node == NULL) {
DBG("Woken up but nothing in the UST command queue");
/* Continue thread execution */
ust_cmd = lttng::utils::container_of(node, &ust_command::node);
DBG("Dispatching UST registration pid:%d ppid:%d uid:%d"
- " gid:%d sock:%d name:%s (version %d.%d)",
- ust_cmd->reg_msg.pid, ust_cmd->reg_msg.ppid,
- ust_cmd->reg_msg.uid, ust_cmd->reg_msg.gid,
- ust_cmd->sock, ust_cmd->reg_msg.name,
- ust_cmd->reg_msg.major, ust_cmd->reg_msg.minor);
+ " gid:%d sock:%d name:%s (version %d.%d)",
+ ust_cmd->reg_msg.pid,
+ ust_cmd->reg_msg.ppid,
+ ust_cmd->reg_msg.uid,
+ ust_cmd->reg_msg.gid,
+ ust_cmd->sock,
+ ust_cmd->reg_msg.name,
+ ust_cmd->reg_msg.major,
+ ust_cmd->reg_msg.minor);
if (ust_cmd->reg_msg.type == LTTNG_UST_CTL_SOCKET_CMD) {
wait_node = zmalloc<ust_reg_wait_node>();
CDS_INIT_LIST_HEAD(&wait_node->head);
/* Create application object if socket is CMD. */
- wait_node->app = ust_app_create(&ust_cmd->reg_msg,
- ust_cmd->sock);
+ wait_node->app = ust_app_create(&ust_cmd->reg_msg, ust_cmd->sock);
if (!wait_node->app) {
ret = close(ust_cmd->sock);
if (ret < 0) {
* Look for the application in the local wait queue and set the
* notify socket if found.
*/
- cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
- &wait_queue.head, head) {
+ cds_list_for_each_entry_safe (
+ wait_node, tmp_wait_node, &wait_queue.head, head) {
health_code_update();
if (wait_node->app->pid == ust_cmd->reg_msg.pid) {
wait_node->app->notify_sock = ust_cmd->sock;
app = wait_node->app;
free(wait_node);
wait_node = NULL;
- DBG3("UST app notify socket %d is set", ust_cmd->sock);
+ DBG3("UST app notify socket %d is set",
+ ust_cmd->sock);
break;
}
}
/* Send notify socket through the notify pipe. */
ret = send_socket_to_thread(
- notifiers->apps_cmd_notify_pipe_write_fd,
- app->notify_sock);
+ notifiers->apps_cmd_notify_pipe_write_fd, app->notify_sock);
if (ret < 0) {
rcu_read_unlock();
session_unlock_list();
* to the thread and unregistration will take place at that
* place.
*/
- ret = send_socket_to_thread(
- notifiers->apps_cmd_pipe_write_fd,
- app->sock);
+ ret = send_socket_to_thread(notifiers->apps_cmd_pipe_write_fd,
+ app->sock);
if (ret < 0) {
rcu_read_unlock();
session_unlock_list();
error:
/* Clean up wait queue. */
- cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
- &wait_queue.head, head) {
+ cds_list_for_each_entry_safe (wait_node, tmp_wait_node, &wait_queue.head, head) {
cds_list_del(&wait_node->head);
wait_queue.count--;
free(wait_node);
/* Empty command queue. */
for (;;) {
/* Dequeue command for registration */
- node = cds_wfcq_dequeue_blocking(
- ¬ifiers->ust_cmd_queue->head,
- ¬ifiers->ust_cmd_queue->tail);
+ node = cds_wfcq_dequeue_blocking(¬ifiers->ust_cmd_queue->head,
+ ¬ifiers->ust_cmd_queue->tail);
if (node == NULL) {
break;
}
}
bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
- int apps_cmd_pipe_write_fd,
- int apps_cmd_notify_pipe_write_fd)
+ int apps_cmd_pipe_write_fd,
+ int apps_cmd_notify_pipe_write_fd)
{
struct lttng_thread *thread;
struct thread_notifiers *notifiers;
notifiers->apps_cmd_notify_pipe_write_fd = apps_cmd_notify_pipe_write_fd;
thread = lttng_thread_create("UST registration dispatch",
- thread_dispatch_ust_registration,
- shutdown_ust_dispatch_thread,
- cleanup_ust_dispatch_thread,
- notifiers);
+ thread_dispatch_ust_registration,
+ shutdown_ust_dispatch_thread,
+ cleanup_ust_dispatch_thread,
+ notifiers);
if (!thread) {
goto error;
}
namespace lst = lttng::sessiond::trace;
lst::event_class::event_class(unsigned int in_id,
- unsigned int in_stream_class_id,
- int in_log_level,
- std::string in_name,
- nonstd::optional<std::string> in_model_emf_uri,
- lttng::sessiond::trace::type::cuptr in_payload) :
- id{in_id},
- stream_class_id{in_stream_class_id},
- log_level{in_log_level},
- name{std::move(in_name)},
- model_emf_uri{std::move(in_model_emf_uri)},
- payload{std::move(in_payload)}
+ unsigned int in_stream_class_id,
+ int in_log_level,
+ std::string in_name,
+ nonstd::optional<std::string> in_model_emf_uri,
+ lttng::sessiond::trace::type::cuptr in_payload) :
+ id{ in_id },
+ stream_class_id{ in_stream_class_id },
+ log_level{ in_log_level },
+ name{ std::move(in_name) },
+ model_emf_uri{ std::move(in_model_emf_uri) },
+ payload{ std::move(in_payload) }
{
}
*
*/
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <urcu/compiler.h>
-#include <pthread.h>
+#include "event-notifier-error-accounting.hpp"
+#include "lttng-ust-error.hpp"
+#include "ust-app.hpp"
#include <common/error.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/index-allocator.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/shm.hpp>
+
#include <lttng/trigger/trigger-internal.hpp>
-#include "event-notifier-error-accounting.hpp"
-#include "lttng-ust-error.hpp"
-#include "ust-app.hpp"
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <urcu/compiler.h>
#define ERROR_COUNTER_INDEX_HT_INITIAL_SIZE 16
} /* namespace */
static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
- const char **trigger_name,
- uid_t *trigger_owner_uid)
+ const char **trigger_name,
+ uid_t *trigger_owner_uid)
{
enum lttng_trigger_status trigger_status;
abort();
}
- trigger_status = lttng_trigger_get_owner_uid(trigger,
- trigger_owner_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, trigger_owner_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
}
-static inline
-const char *error_accounting_status_str(
- enum event_notifier_error_accounting_status status)
+static inline const char *
+error_accounting_status_str(enum event_notifier_error_accounting_status status)
{
switch (status) {
case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK:
{
int i;
struct ust_error_accounting_entry *entry =
- lttng::utils::container_of(head, &ust_error_accounting_entry::rcu_head);
+ lttng::utils::container_of(head, &ust_error_accounting_entry::rcu_head);
for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
lttng_ust_ctl_release_object(-1, entry->cpu_counters[i]);
free(entry);
}
-static
-bool ust_error_accounting_entry_get(struct ust_error_accounting_entry *entry)
+static bool ust_error_accounting_entry_get(struct ust_error_accounting_entry *entry)
{
return urcu_ref_get_unless_zero(&entry->ref);
}
-static
-void ust_error_accounting_entry_release(struct urcu_ref *entry_ref)
+static void ust_error_accounting_entry_release(struct urcu_ref *entry_ref)
{
struct ust_error_accounting_entry *entry =
- lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref);
+ lttng::utils::container_of(entry_ref, &ust_error_accounting_entry::ref);
rcu_read_lock();
cds_lfht_del(error_counter_uid_ht->ht, &entry->node.node);
rcu_read_unlock();
}
-
-static
-void ust_error_accounting_entry_put(struct ust_error_accounting_entry *entry)
+static void ust_error_accounting_entry_put(struct ust_error_accounting_entry *entry)
{
if (!entry) {
return;
/*
* Put one reference to every UID entries.
*/
-static
-void put_ref_all_ust_error_accounting_entry(void)
+static void put_ref_all_ust_error_accounting_entry(void)
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
rcu_read_lock();
- cds_lfht_for_each_entry(error_counter_uid_ht->ht, &iter.iter,
- uid_entry, node.node) {
- ust_error_accounting_entry_put(uid_entry);
+ cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
+ ust_error_accounting_entry_put(uid_entry);
}
rcu_read_unlock();
/*
* Get one reference to every UID entries.
*/
-static
-void get_ref_all_ust_error_accounting_entry(void)
+static void get_ref_all_ust_error_accounting_entry(void)
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
ASSERT_LOCKED(the_event_notifier_counter.lock);
rcu_read_lock();
- cds_lfht_for_each_entry(error_counter_uid_ht->ht, &iter.iter,
- uid_entry, node.node) {
- ust_error_accounting_entry_get(uid_entry);
+ cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
+ ust_error_accounting_entry_get(uid_entry);
}
rcu_read_unlock();
#endif /* HAVE_LIBLTTNG_UST_CTL */
-static
-enum event_notifier_error_accounting_status
-init_error_accounting_state(struct error_accounting_state *state,
- uint64_t index_count)
+static enum event_notifier_error_accounting_status
+init_error_accounting_state(struct error_accounting_state *state, uint64_t index_count)
{
enum event_notifier_error_accounting_status status;
goto end;
}
- state->indices_ht = lttng_ht_new(ERROR_COUNTER_INDEX_HT_INITIAL_SIZE,
- LTTNG_HT_TYPE_U64);
+ state->indices_ht = lttng_ht_new(ERROR_COUNTER_INDEX_HT_INITIAL_SIZE, LTTNG_HT_TYPE_U64);
if (!state->indices_ht) {
ERR("Failed to allocate error counter indices hash table");
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
return status;
}
-static
-void fini_error_accounting_state(struct error_accounting_state *state)
+static void fini_error_accounting_state(struct error_accounting_state *state)
{
LTTNG_ASSERT(state);
}
enum event_notifier_error_accounting_status
-event_notifier_error_accounting_init(uint64_t buffer_size_kernel,
- uint64_t buffer_size_ust)
+event_notifier_error_accounting_init(uint64_t buffer_size_kernel, uint64_t buffer_size_ust)
{
enum event_notifier_error_accounting_status status;
status = init_error_accounting_state(&kernel_state, buffer_size_kernel);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Failed to initialize kernel event notifier accounting state: status = %s",
- error_accounting_status_str(status));
+ error_accounting_status_str(status));
goto end;
}
status = init_error_accounting_state(&ust_state, buffer_size_ust);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Failed to initialize UST event notifier accounting state: status = %s",
- error_accounting_status_str(status));
+ error_accounting_status_str(status));
goto error_ust_state;
}
- error_counter_uid_ht = lttng_ht_new(
- ERROR_COUNTER_INDEX_HT_INITIAL_SIZE, LTTNG_HT_TYPE_U64);
+ error_counter_uid_ht = lttng_ht_new(ERROR_COUNTER_INDEX_HT_INITIAL_SIZE, LTTNG_HT_TYPE_U64);
if (!error_counter_uid_ht) {
ERR("Failed to allocate UID to error counter accountant hash table");
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
* Return the error counteur index associated to this event notifier tracer
* token. Returns _STATUS_OK if found and _STATUS_NOT_FOUND otherwise.
*/
-static
-enum event_notifier_error_accounting_status get_error_counter_index_for_token(
- struct error_accounting_state *state, uint64_t tracer_token,
- uint64_t *error_counter_index)
+static enum event_notifier_error_accounting_status get_error_counter_index_for_token(
+ struct error_accounting_state *state, uint64_t tracer_token, uint64_t *error_counter_index)
{
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
* Find the entry for this app's UID, the caller acquires a reference if the
* entry is found.
*/
-static
-struct ust_error_accounting_entry *ust_error_accounting_entry_find(
- struct lttng_ht *uid_ht, const struct ust_app *app)
+static struct ust_error_accounting_entry *ust_error_accounting_entry_find(struct lttng_ht *uid_ht,
+ const struct ust_app *app)
{
struct ust_error_accounting_entry *entry;
struct lttng_ht_node_u64 *node;
lttng_ht_lookup(uid_ht, &key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
- if(node == NULL) {
+ if (node == NULL) {
entry = NULL;
} else {
bool got_ref;
- entry = caa_container_of(node,
- struct ust_error_accounting_entry, node);
+ entry = caa_container_of(node, struct ust_error_accounting_entry, node);
got_ref = ust_error_accounting_entry_get(entry);
if (!got_ref) {
* Create the entry for this app's UID, the caller acquires a reference to the
* entry,
*/
-static
-struct ust_error_accounting_entry *ust_error_accounting_entry_create(
- const struct ust_app *app)
+static struct ust_error_accounting_entry *
+ust_error_accounting_entry_create(const struct ust_app *app)
{
int i, ret, *cpu_counter_fds = NULL;
struct lttng_ust_ctl_daemon_counter *daemon_counter;
if (!ust_app_supports_counters(app)) {
DBG("Refusing to create accounting entry for application (unsupported feature): app name = '%s', app ppid = %d",
- app->name, (int) app->ppid);
+ app->name,
+ (int) app->ppid);
goto error;
}
cpu_counter_fds = calloc<int>(entry->nr_counter_cpu_fds);
if (!cpu_counter_fds) {
PERROR("Failed to allocate event notifier error counter file descriptors array: application uid = %d, application name = '%s', pid = %d, allocation size = %zu",
- (int) app->uid, app->name, (int) app->pid,
- entry->nr_counter_cpu_fds * sizeof(*cpu_counter_fds));
+ (int) app->uid,
+ app->name,
+ (int) app->pid,
+ entry->nr_counter_cpu_fds * sizeof(*cpu_counter_fds));
goto error_counter_cpu_fds_alloc;
}
cpu_counters = calloc<lttng_ust_abi_object_data *>(entry->nr_counter_cpu_fds);
if (!cpu_counters) {
PERROR("Failed to allocate event notifier error counter lttng_ust_abi_object_data array: application uid = %d, application name = '%s', pid = %d, allocation size = %zu",
- (int) app->uid, app->name, (int) app->pid,
- entry->nr_counter_cpu_fds * sizeof(struct lttng_ust_abi_object_data *));
+ (int) app->uid,
+ app->name,
+ (int) app->pid,
+ entry->nr_counter_cpu_fds * sizeof(struct lttng_ust_abi_object_data *));
goto error_counter_cpus_alloc;
}
cpu_counter_fds[i] = shm_create_anonymous("event-notifier-error-accounting");
if (cpu_counter_fds[i] == -1) {
ERR("Failed to create event notifier error accounting shared memory for application user: application uid = %d, pid = %d, application name = '%s'",
- (int) app->uid, (int) app->pid, app->name);
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
goto error_shm_alloc;
}
}
/*
* Ownership of the file descriptors transferred to the ustctl object.
*/
- daemon_counter = lttng_ust_ctl_create_counter(1, &dimension, 0, -1,
- entry->nr_counter_cpu_fds, cpu_counter_fds,
- LTTNG_UST_CTL_COUNTER_BITNESS_32,
- LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR,
- LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU,
- false);
+ daemon_counter = lttng_ust_ctl_create_counter(1,
+ &dimension,
+ 0,
+ -1,
+ entry->nr_counter_cpu_fds,
+ cpu_counter_fds,
+ LTTNG_UST_CTL_COUNTER_BITNESS_32,
+ LTTNG_UST_CTL_COUNTER_ARITHMETIC_MODULAR,
+ LTTNG_UST_CTL_COUNTER_ALLOC_PER_CPU,
+ false);
if (!daemon_counter) {
goto error_create_daemon_counter;
}
ret = lttng_ust_ctl_create_counter_data(daemon_counter, &counter);
if (ret) {
ERR("Failed to create userspace tracer counter data for application user: uid = %d, pid = %d, application name = '%s'",
- (int) app->uid, (int) app->pid, app->name);
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
goto error_create_counter_data;
}
for (i = 0; i < entry->nr_counter_cpu_fds; i++) {
- ret = lttng_ust_ctl_create_counter_cpu_data(daemon_counter, i,
- &cpu_counters[i]);
+ ret = lttng_ust_ctl_create_counter_cpu_data(daemon_counter, i, &cpu_counters[i]);
if (ret) {
ERR("Failed to create userspace tracer counter cpu data for application user: uid = %d, pid = %d, application name = '%s'",
- (int) app->uid, (int) app->pid,
- app->name);
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
goto error_create_counter_cpu_data;
}
}
ret = close(cpu_counter_fds[i]);
if (ret) {
PERROR("Failed to close error counter per-CPU shm file descriptor: fd = %d",
- cpu_counter_fds[i]);
+ cpu_counter_fds[i]);
}
}
}
return entry;
}
-static
-enum event_notifier_error_accounting_status send_counter_data_to_ust(
- struct ust_app *app,
- struct lttng_ust_abi_object_data *new_counter)
+static enum event_notifier_error_accounting_status
+send_counter_data_to_ust(struct ust_app *app, struct lttng_ust_abi_object_data *new_counter)
{
int ret;
enum event_notifier_error_accounting_status status;
/* Attach counter to trigger group. */
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_send_counter_data_to_ust(app->sock,
- app->event_notifier_group.object->handle, new_counter);
+ ret = lttng_ust_ctl_send_counter_data_to_ust(
+ app->sock, app->event_notifier_group.object->handle, new_counter);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Failed to send counter data to application: application name = '%s', pid = %d, ret = %d",
- app->name, app->pid, ret);
+ app->name,
+ app->pid,
+ ret);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
} else {
DBG3("Failed to send counter data to application (application is dead): application name = '%s', pid = %d, ret = %d",
- app->name, app->pid, ret);
+ app->name,
+ app->pid,
+ ret);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD;
}
return status;
}
-static
-enum event_notifier_error_accounting_status send_counter_cpu_data_to_ust(
- struct ust_app *app,
- struct lttng_ust_abi_object_data *counter,
- struct lttng_ust_abi_object_data *counter_cpu)
+static enum event_notifier_error_accounting_status
+send_counter_cpu_data_to_ust(struct ust_app *app,
+ struct lttng_ust_abi_object_data *counter,
+ struct lttng_ust_abi_object_data *counter_cpu)
{
int ret;
enum event_notifier_error_accounting_status status;
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_send_counter_cpu_data_to_ust(app->sock,
- counter, counter_cpu);
+ ret = lttng_ust_ctl_send_counter_cpu_data_to_ust(app->sock, counter, counter_cpu);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) {
ERR("Failed to send counter CPU data to application: application name = '%s', pid = %d, ret = %d",
- app->name, app->pid, ret);
+ app->name,
+ app->pid,
+ ret);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
} else {
DBG3("Failed to send counter CPU data to application: application name = '%s', pid = %d, ret = %d",
- app->name, app->pid, ret);
+ app->name,
+ app->pid,
+ ret);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD;
}
}
/* Duplicate counter object data. */
- ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter,
- entry->counter);
+ ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter, entry->counter);
if (ret) {
ERR("Failed to duplicate event notifier error accounting counter for application user: application uid = %d, pid = %d, application name = '%s'",
- (int) app->uid, (int) app->pid, app->name);
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto error_duplicate_counter;
}
}
ERR("Failed to send counter data to application tracer: status = %s, application uid = %d, pid = %d, application name = '%s'",
- error_accounting_status_str(status),
- (int) app->uid, (int) app->pid, app->name);
+ error_accounting_status_str(status),
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto error_send_counter_data;
}
cpu_counters = calloc<lttng_ust_abi_object_data *>(entry->nr_counter_cpu_fds);
if (!cpu_counters) {
PERROR("Failed to allocate event notifier error counter lttng_ust_abi_object_data array: application uid = %d, application name = '%s', pid = %d, allocation size = %zu",
- (int) app->uid, app->name, (int) app->pid,
- entry->nr_counter_cpu_fds * sizeof(**cpu_counters));
+ (int) app->uid,
+ app->name,
+ (int) app->pid,
+ entry->nr_counter_cpu_fds * sizeof(**cpu_counters));
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
goto error_allocate_cpu_counters;
}
struct lttng_ust_abi_object_data *new_counter_cpu = NULL;
ret = lttng_ust_ctl_duplicate_ust_object_data(&new_counter_cpu,
- entry->cpu_counters[i]);
+ entry->cpu_counters[i]);
if (ret) {
ERR("Failed to duplicate userspace tracer counter cpu data for application user: uid = %d, pid = %d, application name = '%s'",
- (int) app->uid, (int) app->pid,
- app->name);
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOMEM;
goto error_duplicate_cpu_counter;
}
cpu_counters[i] = new_counter_cpu;
- status = send_counter_cpu_data_to_ust(app, new_counter,
- new_counter_cpu);
+ status = send_counter_cpu_data_to_ust(app, new_counter, new_counter_cpu);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
if (status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD) {
goto error_send_cpu_counter_data;
}
ERR("Failed to send counter cpu data to application tracer: status = %s, application uid = %d, pid = %d, application name = '%s'",
- error_accounting_status_str(status),
- (int) app->uid, (int) app->pid,
- app->name);
+ error_accounting_status_str(status),
+ (int) app->uid,
+ (int) app->pid,
+ app->name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto error_send_cpu_counter_data;
}
entry = ust_error_accounting_entry_find(error_counter_uid_ht, app);
if (entry == NULL) {
ERR("Failed to find event notitifier error accounting entry on application teardown: pid = %d, application name = '%s'",
- app->pid, app->name);
+ app->pid,
+ app->name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto end;
} else {
}
for (i = 0; i < app->event_notifier_group.nr_counter_cpu; i++) {
- lttng_ust_ctl_release_object(app->sock,
- app->event_notifier_group.counter_cpu[i]);
+ lttng_ust_ctl_release_object(app->sock, app->event_notifier_group.counter_cpu[i]);
free(app->event_notifier_group.counter_cpu[i]);
}
return status;
}
-static
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_ust_get_count(
- const struct lttng_trigger *trigger, uint64_t *count)
+static enum event_notifier_error_accounting_status
+event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigger, uint64_t *count)
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
uid_t trigger_owner_uid;
const char *trigger_name;
-
rcu_read_lock();
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
- status = get_error_counter_index_for_token(&ust_state, tracer_token,
- &error_counter_index);
+ status = get_error_counter_index_for_token(&ust_state, tracer_token, &error_counter_index);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
-
- ERR("Failed to retrieve index for tracer token: token = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d, status = %s",
- tracer_token, trigger_name,
- (int) trigger_owner_uid,
- error_accounting_status_str(status));
+ ERR("Failed to retrieve index for tracer token: token = %" PRIu64
+ ", trigger name = '%s', trigger owner uid = %d, status = %s",
+ tracer_token,
+ trigger_name,
+ (int) trigger_owner_uid,
+ error_accounting_status_str(status));
goto end;
}
* a trigger to a given sessiond is also allowed to create an event
* notifier on all apps that this sessiond is aware of.
*/
- cds_lfht_for_each_entry(error_counter_uid_ht->ht, &iter.iter,
- uid_entry, node.node) {
+ cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
int ret;
int64_t local_value = 0;
bool overflow = false, underflow = false;
ret = lttng_ust_ctl_counter_aggregate(uid_entry->daemon_counter,
- dimension_indexes, &local_value, &overflow,
- &underflow);
+ dimension_indexes,
+ &local_value,
+ &overflow,
+ &underflow);
if (ret || local_value < 0) {
if (ret) {
ERR("Failed to aggregate event notifier error counter values of trigger: trigger name = '%s', trigger owner uid = %d",
- trigger_name,
- (int) trigger_owner_uid);
+ trigger_name,
+ (int) trigger_owner_uid);
} else if (local_value < 0) {
ERR("Negative event notifier error counter value encountered during aggregation: trigger name = '%s', trigger owner uid = %d, value = %" PRId64,
- trigger_name,
- (int) trigger_owner_uid,
- local_value);
+ trigger_name,
+ (int) trigger_owner_uid,
+ local_value);
} else {
abort();
}
return status;
}
-static
-enum event_notifier_error_accounting_status event_notifier_error_accounting_ust_clear(
- const struct lttng_trigger *trigger)
+static enum event_notifier_error_accounting_status
+event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger)
{
struct lttng_ht_iter iter;
struct ust_error_accounting_entry *uid_entry;
const uint64_t tracer_token = lttng_trigger_get_tracer_token(trigger);
rcu_read_lock();
- status = get_error_counter_index_for_token(&ust_state, tracer_token,
- &error_counter_index);
+ status = get_error_counter_index_for_token(&ust_state, tracer_token, &error_counter_index);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(trigger, &trigger_name,
- &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
- ERR("Failed to retrieve index for tracer token: token = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d, status = %s",
- tracer_token, trigger_name,
- (int) trigger_owner_uid,
- error_accounting_status_str(status));
+ ERR("Failed to retrieve index for tracer token: token = %" PRIu64
+ ", trigger name = '%s', trigger owner uid = %d, status = %s",
+ tracer_token,
+ trigger_name,
+ (int) trigger_owner_uid,
+ error_accounting_status_str(status));
goto end;
}
* errors) can be generated from any applications that this session
* daemon is managing.
*/
- cds_lfht_for_each_entry(error_counter_uid_ht->ht, &iter.iter,
- uid_entry, node.node) {
- const int ret = lttng_ust_ctl_counter_clear(uid_entry->daemon_counter,
- &dimension_index);
+ cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) {
+ const int ret =
+ lttng_ust_ctl_counter_clear(uid_entry->daemon_counter, &dimension_index);
if (ret) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(trigger, &trigger_name,
- &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
ERR("Failed to clear event notifier counter value for trigger: counter uid = %d, trigger name = '%s', trigger owner uid = %d",
- (int) uid_entry->node.key, trigger_name,
- (int) trigger_owner_uid);
+ (int) uid_entry->node.key,
+ trigger_name,
+ (int) trigger_owner_uid);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto end;
}
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
-static
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_kernel_clear(
- const struct lttng_trigger *trigger)
+static enum event_notifier_error_accounting_status
+event_notifier_error_accounting_kernel_clear(const struct lttng_trigger *trigger)
{
int ret;
uint64_t error_counter_index;
enum event_notifier_error_accounting_status status;
struct lttng_kernel_abi_counter_clear counter_clear = {};
- status = get_error_counter_index_for_token(&kernel_state,
- lttng_trigger_get_tracer_token(trigger),
- &error_counter_index);
+ status = get_error_counter_index_for_token(
+ &kernel_state, lttng_trigger_get_tracer_token(trigger), &error_counter_index);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(
- trigger, &trigger_name, &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
ERR("Failed to get event notifier error counter index: trigger owner uid = %d, trigger name = '%s', status = '%s'",
- trigger_owner_uid, trigger_name,
- error_accounting_status_str(status));
+ trigger_owner_uid,
+ trigger_name,
+ error_accounting_status_str(status));
goto end;
}
counter_clear.index.number_dimensions = 1;
counter_clear.index.dimension_indexes[0] = error_counter_index;
- ret = kernctl_counter_clear(
- kernel_error_accounting_entry.error_counter_fd,
- &counter_clear);
+ ret = kernctl_counter_clear(kernel_error_accounting_entry.error_counter_fd, &counter_clear);
if (ret) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(
- trigger, &trigger_name, &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
ERR("Failed to clear kernel event notifier error counter: trigger owner uid = %d, trigger name = '%s'",
- trigger_owner_uid, trigger_name);
+ trigger_owner_uid,
+ trigger_name);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto end;
}
}
enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_kernel(
- int kernel_event_notifier_group_fd)
+event_notifier_error_accounting_register_kernel(int kernel_event_notifier_group_fd)
{
int error_counter_fd = -1, ret;
enum event_notifier_error_accounting_status status;
lttng_kernel_abi_counter_conf error_counter_conf = {
.arithmetic = LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR,
.bitness = sizeof(void *) == sizeof(uint32_t) ?
- LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 :
- LTTNG_KERNEL_ABI_COUNTER_BITNESS_64,
+ LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 :
+ LTTNG_KERNEL_ABI_COUNTER_BITNESS_64,
.number_dimensions = 1,
.global_sum_step = 0,
.dimensions = {},
error_counter_conf.dimensions[0].has_underflow = false;
error_counter_conf.dimensions[0].has_overflow = false;
- ret = kernctl_create_event_notifier_group_error_counter(
- kernel_event_notifier_group_fd, &error_counter_conf);
+ ret = kernctl_create_event_notifier_group_error_counter(kernel_event_notifier_group_fd,
+ &error_counter_conf);
if (ret < 0) {
PERROR("Failed to create event notifier group error counter through kernel ioctl: kernel_event_notifier_group_fd = %d",
- kernel_event_notifier_group_fd);
+ kernel_event_notifier_group_fd);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto error;
}
ret = fcntl(error_counter_fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
PERROR("Failed to set FD_CLOEXEC flag on event notifier error counter file descriptor: error_counter_fd = %d",
- error_counter_fd);
+ error_counter_fd);
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
goto error;
}
- DBG("Created kernel event notifier group error counter: fd = %d",
- error_counter_fd);
+ DBG("Created kernel event notifier group error counter: fd = %d", error_counter_fd);
- kernel_error_accounting_entry.error_counter_fd =
- error_counter_fd;
+ kernel_error_accounting_entry.error_counter_fd = error_counter_fd;
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
error:
return status;
}
-static
-enum event_notifier_error_accounting_status create_error_counter_index_for_token(
- struct error_accounting_state *state, uint64_t tracer_token,
- uint64_t *error_counter_index)
+static enum event_notifier_error_accounting_status create_error_counter_index_for_token(
+ struct error_accounting_state *state, uint64_t tracer_token, uint64_t *error_counter_index)
{
struct index_ht_entry *index_entry;
enum lttng_index_allocator_status index_alloc_status;
LTTNG_ASSERT(state);
/* Allocate a new index for that counter. */
- index_alloc_status = lttng_index_allocator_alloc(state->index_allocator,
- &local_error_counter_index);
+ index_alloc_status =
+ lttng_index_allocator_alloc(state->index_allocator, &local_error_counter_index);
switch (index_alloc_status) {
case LTTNG_INDEX_ALLOCATOR_STATUS_EMPTY:
DBG("No indices left in the configured event notifier error counter: "
- "number-of-indices = %" PRIu64,
- lttng_index_allocator_get_index_count(
- state->index_allocator));
+ "number-of-indices = %" PRIu64,
+ lttng_index_allocator_get_index_count(state->index_allocator));
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE;
goto end;
case LTTNG_INDEX_ALLOCATOR_STATUS_OK:
lttng_ht_node_init_u64(&index_entry->node, tracer_token);
lttng_ht_add_unique_u64(state->indices_ht, &index_entry->node);
- DBG("Allocated error counter index for tracer token: tracer token = %" PRIu64 ", index = %" PRIu64,
- tracer_token, local_error_counter_index);
+ DBG("Allocated error counter index for tracer token: tracer token = %" PRIu64
+ ", index = %" PRIu64,
+ tracer_token,
+ local_error_counter_index);
*error_counter_index = local_error_counter_index;
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
end:
}
enum event_notifier_error_accounting_status
-event_notifier_error_accounting_register_event_notifier(
- const struct lttng_trigger *trigger,
- uint64_t *error_counter_index)
+event_notifier_error_accounting_register_event_notifier(const struct lttng_trigger *trigger,
+ uint64_t *error_counter_index)
{
enum event_notifier_error_accounting_status status;
uint64_t local_error_counter_index;
* Check if this event notifier already has a error counter index
* assigned.
*/
- status = get_error_counter_index_for_token(state,
- lttng_trigger_get_tracer_token(trigger),
- &local_error_counter_index);
+ status = get_error_counter_index_for_token(
+ state, lttng_trigger_get_tracer_token(trigger), &local_error_counter_index);
switch (status) {
case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NOT_FOUND:
{
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(
- trigger, &trigger_name, &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
DBG("Event notifier error counter index not found for tracer token (allocating a new one): trigger name = '%s', trigger owner uid = %d, tracer token = %" PRIu64,
- trigger_name, trigger_owner_uid,
- lttng_trigger_get_tracer_token(trigger));
+ trigger_name,
+ trigger_owner_uid,
+ lttng_trigger_get_tracer_token(trigger));
- status = create_error_counter_index_for_token(state,
- lttng_trigger_get_tracer_token(trigger),
- &local_error_counter_index);
+ status = create_error_counter_index_for_token(
+ state, lttng_trigger_get_tracer_token(trigger), &local_error_counter_index);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Error creating index for token: status = %s, trigger name = '%s', trigger owner uid = %d",
- error_accounting_status_str(status),
- trigger_name, trigger_owner_uid);
+ error_accounting_status_str(status),
+ trigger_name,
+ trigger_owner_uid);
goto end;
}
}
}
#endif /* HAVE_LIBLTTNG_UST_CTL */
-
end:
return status;
}
-static
-enum event_notifier_error_accounting_status
-event_notifier_error_accounting_kernel_get_count(
- const struct lttng_trigger *trigger, uint64_t *count)
+static enum event_notifier_error_accounting_status
+event_notifier_error_accounting_kernel_get_count(const struct lttng_trigger *trigger,
+ uint64_t *count)
{
struct lttng_kernel_abi_counter_aggregate counter_aggregate = {};
enum event_notifier_error_accounting_status status;
uint64_t error_counter_index;
int ret;
- status = get_error_counter_index_for_token(&kernel_state,
- lttng_trigger_get_tracer_token(trigger),
- &error_counter_index);
+ status = get_error_counter_index_for_token(
+ &kernel_state, lttng_trigger_get_tracer_token(trigger), &error_counter_index);
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Error getting index for token: status=%s",
- error_accounting_status_str(status));
+ error_accounting_status_str(status));
goto end;
}
LTTNG_ASSERT(kernel_error_accounting_entry.error_counter_fd);
- ret = kernctl_counter_get_aggregate_value(
- kernel_error_accounting_entry.error_counter_fd,
- &counter_aggregate);
+ ret = kernctl_counter_get_aggregate_value(kernel_error_accounting_entry.error_counter_fd,
+ &counter_aggregate);
if (ret || counter_aggregate.value.value < 0) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(trigger, &trigger_name,
- &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
if (counter_aggregate.value.value < 0) {
ERR("Invalid negative event notifier error counter value: trigger owner = %d, trigger name = '%s', value = %" PRId64,
- trigger_owner_uid, trigger_name,
- counter_aggregate.value.value);
+ trigger_owner_uid,
+ trigger_name,
+ counter_aggregate.value.value);
} else {
ERR("Failed to getting event notifier error count: trigger owner = %d, trigger name = '%s', ret = %d",
- trigger_owner_uid, trigger_name, ret);
+ trigger_owner_uid,
+ trigger_name,
+ ret);
}
status = EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_ERR;
}
enum event_notifier_error_accounting_status
-event_notifier_error_accounting_get_count(
- const struct lttng_trigger *trigger, uint64_t *count)
+event_notifier_error_accounting_get_count(const struct lttng_trigger *trigger, uint64_t *count)
{
switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
case LTTNG_DOMAIN_KERNEL:
- return event_notifier_error_accounting_kernel_get_count(
- trigger, count);
+ return event_notifier_error_accounting_kernel_get_count(trigger, count);
case LTTNG_DOMAIN_UST:
case LTTNG_DOMAIN_PYTHON:
case LTTNG_DOMAIN_JUL:
case LTTNG_DOMAIN_LOG4J:
#ifdef HAVE_LIBLTTNG_UST_CTL
- return event_notifier_error_accounting_ust_get_count(trigger,
- count);
+ return event_notifier_error_accounting_ust_get_count(trigger, count);
#else
*count = 0;
return EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK;
}
}
-static
-enum event_notifier_error_accounting_status
+static enum event_notifier_error_accounting_status
event_notifier_error_accounting_clear(const struct lttng_trigger *trigger)
{
switch (lttng_trigger_get_underlying_domain_type_restriction(trigger)) {
static void free_index_ht_entry(struct rcu_head *head)
{
- struct index_ht_entry *entry = caa_container_of(head,
- struct index_ht_entry, rcu_head);
+ struct index_ht_entry *entry = caa_container_of(head, struct index_ht_entry, rcu_head);
free(entry);
}
-void event_notifier_error_accounting_unregister_event_notifier(
- const struct lttng_trigger *trigger)
+void event_notifier_error_accounting_unregister_event_notifier(const struct lttng_trigger *trigger)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
/* Trigger details already logged by callee on error. */
ERR("Failed to clear event notifier error counter during unregistration of event notifier: status = '%s'",
- error_accounting_status_str(status));
+ error_accounting_status_str(status));
goto end;
}
pthread_mutex_lock(&the_event_notifier_counter.lock);
the_event_notifier_counter.count--;
if (the_event_notifier_counter.count == 0) {
-
/*
* When unregistering the last event notifier, put one
* reference to every uid entries on the behalf of all
if (node) {
int del_ret;
struct index_ht_entry *index_entry =
- lttng::utils::container_of(node, &index_ht_entry::node);
+ lttng::utils::container_of(node, &index_ht_entry::node);
enum lttng_index_allocator_status index_alloc_status;
index_alloc_status = lttng_index_allocator_release(
- state->index_allocator,
- index_entry->error_counter_index);
+ state->index_allocator, index_entry->error_counter_index);
if (index_alloc_status != LTTNG_INDEX_ALLOCATOR_STATUS_OK) {
uid_t trigger_owner_uid;
const char *trigger_name;
- get_trigger_info_for_log(trigger, &trigger_name,
- &trigger_owner_uid);
+ get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
- ERR("Failed to release event notifier error counter index: index = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d",
- index_entry->error_counter_index,
- trigger_name, (int) trigger_owner_uid);
+ ERR("Failed to release event notifier error counter index: index = %" PRIu64
+ ", trigger name = '%s', trigger owner uid = %d",
+ index_entry->error_counter_index,
+ trigger_name,
+ (int) trigger_owner_uid);
/* Don't exit, perform the rest of the clean-up. */
}
*/
#define _LGPL_SOURCE
-#include <urcu/list.h>
-#include <string.h>
-
-#include <common/compat/errno.hpp>
-#include <lttng/lttng.h>
-#include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-matches.h>
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.hpp>
-#include <common/bytecode/bytecode.hpp>
-#include <common/error.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/filter.hpp>
-#include <common/context.hpp>
-
+#include "agent.hpp"
#include "channel.hpp"
#include "event.hpp"
#include "kernel.hpp"
#include "lttng-sessiond.hpp"
#include "lttng-ust-ctl.hpp"
#include "lttng-ust-error.hpp"
-#include "ust-app.hpp"
#include "trace-kernel.hpp"
#include "trace-ust.hpp"
-#include "agent.hpp"
+#include "ust-app.hpp"
#include "utils.hpp"
+#include <common/bytecode/bytecode.hpp>
+#include <common/compat/errno.hpp>
+#include <common/context.hpp>
+#include <common/error.hpp>
+#include <common/filter.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <lttng/condition/condition.h>
+#include <lttng/condition/event-rule-matches.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/event-rule.h>
+#include <lttng/lttng.h>
+
+#include <string.h>
+#include <urcu/list.h>
+
/*
* Add unique UST event based on the event name, filter bytecode and loglevel.
*/
-static void add_unique_ust_event(struct lttng_ht *ht,
- struct ltt_ust_event *event)
+static void add_unique_ust_event(struct lttng_ht *ht, struct ltt_ust_event *event)
{
struct cds_lfht_node *node_ptr;
struct ltt_ust_ht_key key;
key.exclusion = event->exclusion;
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct(event->node.key, lttng_ht_seed),
- trace_ust_ht_match_event, &key, &event->node.node);
+ ht->hash_fct(event->node.key, lttng_ht_seed),
+ trace_ust_ht_match_event,
+ &key,
+ &event->node.node);
LTTNG_ASSERT(node_ptr == &event->node.node);
}
* If event_name is NULL all events of the specified type are disabled.
*/
int event_kernel_disable_event(struct ltt_kernel_channel *kchan,
- const char *event_name, enum lttng_event_type type)
+ const char *event_name,
+ enum lttng_event_type type)
{
int ret, error = 0, found = 0;
struct ltt_kernel_event *kevent;
LTTNG_ASSERT(kchan);
/* For each event in the kernel session */
- cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
+ cds_list_for_each_entry (kevent, &kchan->events_list.head, list) {
if (type != LTTNG_EVENT_ALL && kevent->type != type)
continue;
if (event_name != NULL && strcmp(event_name, kevent->event->name)) {
}
}
DBG("Disable kernel event: found %d events with name: %s and type: %d",
- found, event_name ? event_name : "NULL", type);
+ found,
+ event_name ? event_name : "NULL",
+ type);
if (event_name != NULL && !found) {
ret = LTTNG_ERR_NO_EVENT;
* We own filter_expression and filter.
*/
int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
- struct lttng_event *event, char *filter_expression,
- struct lttng_bytecode *filter)
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter)
{
int ret;
struct ltt_kernel_event *kevent;
LTTNG_ASSERT(kchan);
LTTNG_ASSERT(event);
- kevent = trace_kernel_find_event(event->name, kchan,
- event->type, filter);
+ kevent = trace_kernel_find_event(event->name, kchan, event->type, filter);
if (kevent == NULL) {
ret = kernel_create_event(event, kchan, filter_expression, filter);
/* We have passed ownership */
* We own filter_expression, filter, and exclusion.
*/
int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct lttng_event *event,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- bool internal_event)
+ struct ltt_ust_channel *uchan,
+ struct lttng_event *event,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ bool internal_event)
{
int ret = LTTNG_OK, to_create = 0;
struct ltt_ust_event *uevent;
rcu_read_lock();
- uevent = trace_ust_find_event(uchan->events, event->name, filter,
- (enum lttng_ust_abi_loglevel_type) event->loglevel_type,
- event->loglevel, exclusion);
+ uevent = trace_ust_find_event(uchan->events,
+ event->name,
+ filter,
+ (enum lttng_ust_abi_loglevel_type) event->loglevel_type,
+ event->loglevel,
+ exclusion);
if (!uevent) {
- ret = trace_ust_create_event(event, filter_expression,
- filter, exclusion, internal_event, &uevent);
+ ret = trace_ust_create_event(
+ event, filter_expression, filter, exclusion, internal_event, &uevent);
/* We have passed ownership */
filter_expression = NULL;
filter = NULL;
goto end;
}
- DBG("Event UST %s %s in channel %s", uevent->attr.name,
- to_create ? "created" : "enabled", uchan->name);
+ DBG("Event UST %s %s in channel %s",
+ uevent->attr.name,
+ to_create ? "created" : "enabled",
+ uchan->name);
ret = LTTNG_OK;
* Disable UST tracepoint of a channel from a UST session.
*/
int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, const char *event_name)
+ struct ltt_ust_channel *uchan,
+ const char *event_name)
{
int ret;
struct ltt_ust_event *uevent;
* We use a custom lookup since we need the iterator for the next_duplicate
* call in the do while loop below.
*/
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) event_name, lttng_ht_seed),
- trace_ust_ht_match_event_by_name, event_name, &iter.iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) event_name, lttng_ht_seed),
+ trace_ust_ht_match_event_by_name,
+ event_name,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (node == NULL) {
DBG2("Trace UST event NOT found by name %s", event_name);
goto next;
}
uevent->enabled = 0;
- DBG2("Event UST %s disabled in channel %s", uevent->attr.name,
- uchan->name);
+ DBG2("Event UST %s disabled in channel %s", uevent->attr.name, uchan->name);
if (!usess->active) {
goto next;
ret = LTTNG_ERR_UST_DISABLE_FAIL;
goto error;
}
-next:
+ next:
/* Get next duplicate event by name. */
- cds_lfht_next_duplicate(ht->ht, trace_ust_ht_match_event_by_name,
- event_name, &iter.iter);
+ cds_lfht_next_duplicate(
+ ht->ht, trace_ust_ht_match_event_by_name, event_name, &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
} while (node);
/*
* Disable all UST tracepoints for a channel from a UST session.
*/
-int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
{
int ret, i, size, error = 0;
struct lttng_ht_iter iter;
rcu_read_lock();
/* Disabling existing events */
- cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent,
- node.node) {
+ cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) {
if (uevent->enabled == 1) {
- ret = event_ust_disable_tracepoint(usess, uchan,
- uevent->attr.name);
+ ret = event_ust_disable_tracepoint(usess, uchan, uevent->attr.name);
if (ret < 0) {
error = LTTNG_ERR_UST_DISABLE_FAIL;
continue;
}
for (i = 0; i < size; i++) {
- ret = event_ust_disable_tracepoint(usess, uchan,
- events[i].name);
+ ret = event_ust_disable_tracepoint(usess, uchan, events[i].name);
if (ret < 0) {
/* Continue to disable the rest... */
error = LTTNG_ERR_UST_DISABLE_FAIL;
/* Flag every event as enabled. */
rcu_read_lock();
- cds_lfht_for_each_entry (
- agt->events->ht, &iter.iter, aevent, node.node) {
+ cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) {
aevent->enabled_count++;
}
rcu_read_unlock();
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
int event_agent_enable_all(struct ltt_ust_session *usess,
- struct agent *agt, struct lttng_event *event,
- struct lttng_bytecode *filter ,char *filter_expression)
+ struct agent *agt,
+ struct lttng_event *event,
+ struct lttng_bytecode *filter,
+ char *filter_expression)
{
int ret;
* the lttng-ctl library.
*/
static int add_filter_app_ctx(struct lttng_bytecode *bytecode,
- const char *filter_expression, struct agent *agt)
+ const char *filter_expression,
+ struct agent *agt)
{
int ret = LTTNG_OK;
char *provider_name = NULL, *ctx_name = NULL;
- struct bytecode_symbol_iterator *it =
- bytecode_symbol_iterator_create(bytecode);
+ struct bytecode_symbol_iterator *it = bytecode_symbol_iterator_create(bytecode);
if (!it) {
ret = LTTNG_ERR_NOMEM;
do {
struct lttng_event_context ctx;
- const char *symbol_name =
- bytecode_symbol_iterator_get_name(it);
+ const char *symbol_name = bytecode_symbol_iterator_get_name(it);
- if (parse_application_context(symbol_name, &provider_name,
- &ctx_name)) {
+ if (parse_application_context(symbol_name, &provider_name, &ctx_name)) {
/* Not an application context. */
continue;
}
/* Recognized an application context. */
DBG("Enabling event with filter expression \"%s\" requires enabling the %s:%s application context.",
- filter_expression, provider_name, ctx_name);
+ filter_expression,
+ provider_name,
+ ctx_name);
ret = agent_add_context(&ctx, agt);
if (ret != LTTNG_OK) {
- ERR("Failed to add application context %s:%s.",
- provider_name, ctx_name);
+ ERR("Failed to add application context %s:%s.", provider_name, ctx_name);
goto end;
}
ret = agent_enable_context(&ctx, agt->domain);
if (ret != LTTNG_OK) {
- ERR("Failed to enable application context %s:%s.",
- provider_name, ctx_name);
+ ERR("Failed to enable application context %s:%s.", provider_name, ctx_name);
goto end;
}
}
static int agent_enable(struct agent *agt,
- struct lttng_event *event,
- struct lttng_bytecode *filter,
- char *filter_expression)
+ struct lttng_event *event,
+ struct lttng_bytecode *filter,
+ char *filter_expression)
{
int ret, created = 0;
struct agent_event *aevent;
LTTNG_ASSERT(agt);
rcu_read_lock();
- aevent = agent_find_event(event->name, event->loglevel_type,
- event->loglevel, filter_expression, agt);
+ aevent = agent_find_event(
+ event->name, event->loglevel_type, event->loglevel, filter_expression, agt);
if (!aevent) {
- aevent = agent_create_event(event->name, event->loglevel_type,
- event->loglevel, filter,
- filter_expression);
+ aevent = agent_create_event(event->name,
+ event->loglevel_type,
+ event->loglevel,
+ filter,
+ filter_expression);
if (!aevent) {
ret = LTTNG_ERR_NOMEM;
goto error;
}
if (created && aevent->filter) {
- ret = add_filter_app_ctx(
- aevent->filter, aevent->filter_expression, agt);
+ ret = add_filter_app_ctx(aevent->filter, aevent->filter_expression, agt);
if (ret != LTTNG_OK) {
goto error;
}
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
int event_agent_enable(struct ltt_ust_session *usess,
- struct agent *agt,
- struct lttng_event *event,
- struct lttng_bytecode *filter,
- char *filter_expression)
+ struct agent *agt,
+ struct lttng_event *event,
+ struct lttng_bytecode *filter,
+ char *filter_expression)
{
LTTNG_ASSERT(usess);
LTTNG_ASSERT(event);
LTTNG_ASSERT(agt);
- DBG("Enabling agent event: event pattern = '%s', session id = %" PRIu64 ", loglevel type = %d, loglevel = %d, filter expression = '%s'",
- event->name, usess->id, event->loglevel_type,
- event->loglevel,
- filter_expression ? filter_expression : "(none)");
+ DBG("Enabling agent event: event pattern = '%s', session id = %" PRIu64
+ ", loglevel type = %d, loglevel = %d, filter expression = '%s'",
+ event->name,
+ usess->id,
+ event->loglevel_type,
+ event->loglevel,
+ filter_expression ? filter_expression : "(none)");
return agent_enable(agt, event, filter, filter_expression);
}
condition = lttng_trigger_get_const_condition(trigger);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- c_status = lttng_condition_event_rule_matches_get_rule(
- condition, &rule);
+ c_status = lttng_condition_event_rule_matches_get_rule(condition, &rule);
LTTNG_ASSERT(c_status == LTTNG_CONDITION_STATUS_OK);
switch (lttng_event_rule_get_type(rule)) {
/* Get the filter bytecode */
filter_bytecode = lttng_event_rule_get_filter_bytecode(rule);
if (filter_bytecode) {
- filter_bytecode_copy =
- lttng_bytecode_copy(filter_bytecode);
+ filter_bytecode_copy = lttng_bytecode_copy(filter_bytecode);
if (!filter_bytecode_copy) {
ret = LTTNG_ERR_NOMEM;
goto end;
}
DBG("Enabling agent event from trigger: trigger name = '%s', trigger owner uid = %d, token = %" PRIu64,
- trigger_name, trigger_owner_uid,
- lttng_trigger_get_tracer_token(trigger));
+ trigger_name,
+ trigger_owner_uid,
+ lttng_trigger_get_tracer_token(trigger));
- ret = agent_enable(agt, event, filter_bytecode_copy,
- filter_expression_copy);
+ ret = agent_enable(agt, event, filter_bytecode_copy, filter_expression_copy);
/* Ownership was passed even in case of error. */
filter_expression_copy = NULL;
filter_bytecode_copy = NULL;
}
static int trigger_agent_disable_one(const struct lttng_trigger *trigger,
- struct agent *agt,
- struct agent_event *aevent)
+ struct agent *agt,
+ struct agent_event *aevent)
{
int ret;
*/
DBG("Event agent disabling %s (loglevel type %d, loglevel value %d) for trigger %" PRIu64,
- aevent->name, aevent->loglevel_type,
- aevent->loglevel_value, lttng_trigger_get_tracer_token(trigger));
+ aevent->name,
+ aevent->loglevel_type,
+ aevent->loglevel_value,
+ lttng_trigger_get_tracer_token(trigger));
/* Already disabled? */
if (!AGENT_EVENT_IS_ENABLED(aevent)) {
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
static int event_agent_disable_one(struct ltt_ust_session *usess,
- struct agent *agt, struct agent_event *aevent)
+ struct agent *agt,
+ struct agent_event *aevent)
{
int ret;
struct ltt_ust_event *uevent = NULL;
LTTNG_ASSERT(aevent);
DBG("Event agent disabling %s (loglevel type %d, loglevel value %d) for session %" PRIu64,
- aevent->name, aevent->loglevel_type, aevent->loglevel_value,
- usess->id);
+ aevent->name,
+ aevent->loglevel_type,
+ aevent->loglevel_value,
+ usess->id);
/* Already disabled? */
if (!AGENT_EVENT_IS_ENABLED(aevent)) {
* the event and finally disable it.
*/
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
- (char *) ust_channel_name);
+ (char *) ust_channel_name);
if (!uchan) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
goto error;
* happens thanks to an UST filter. The following -1 is actually
* ignored since the type is LTTNG_UST_LOGLEVEL_ALL.
*/
- uevent = trace_ust_find_event(uchan->events, (char *) ust_event_name,
- aevent->filter, LTTNG_UST_ABI_LOGLEVEL_ALL, -1, NULL);
+ uevent = trace_ust_find_event(uchan->events,
+ (char *) ust_event_name,
+ aevent->filter,
+ LTTNG_UST_ABI_LOGLEVEL_ALL,
+ -1,
+ NULL);
/* If the agent event exists, it must be available on the UST side. */
LTTNG_ASSERT(uevent);
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int trigger_agent_disable(
- const struct lttng_trigger *trigger, struct agent *agt)
+int trigger_agent_disable(const struct lttng_trigger *trigger, struct agent *agt)
{
int ret = LTTNG_OK;
struct agent_event *aevent;
LTTNG_ASSERT(trigger);
LTTNG_ASSERT(agt);
- DBG("Event agent disabling for trigger %" PRIu64,
- lttng_trigger_get_tracer_token(trigger));
+ DBG("Event agent disabling for trigger %" PRIu64, lttng_trigger_get_tracer_token(trigger));
rcu_read_lock();
aevent = agent_find_event_by_trigger(trigger, agt);
if (aevent == NULL) {
DBG2("Event agent NOT found by trigger %" PRIu64,
- lttng_trigger_get_tracer_token(trigger));
+ lttng_trigger_get_tracer_token(trigger));
ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
goto end;
}
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
- const char *event_name)
+int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt, const char *event_name)
{
int ret = LTTNG_OK;
struct agent_event *aevent;
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int event_agent_disable_all(struct ltt_ust_session *usess,
- struct agent *agt)
+int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt)
{
int ret;
struct agent_event *aevent;
/* Disable every event. */
rcu_read_lock();
- cds_lfht_for_each_entry(agt->events->ht, &iter.iter, aevent,
- node.node) {
+ cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) {
if (!AGENT_EVENT_IS_ENABLED(aevent)) {
continue;
}
*/
#define _LGPL_SOURCE
-#include <urcu/uatomic.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <stdio.h>
#include "fd-limit.hpp"
-#include <common/error.hpp>
+
#include <common/compat/errno.hpp>
+#include <common/error.hpp>
+
+#include <stdio.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <urcu/uatomic.h>
/* total count of fd. */
static long fd_count;
}
newval = uatomic_add_return(&fd_count, (long) nr);
- if ((long) (newval * 100)
- - (long) (max_nr_fd * fd_threshold[type]) > 0) {
+ if ((long) (newval * 100) - (long) (max_nr_fd * fd_threshold[type]) > 0) {
uatomic_sub(&fd_count, (long) nr);
return -EPERM;
}
return 0;
}
-void lttng_fd_put(enum lttng_fd_type type __attribute__((unused)),
- unsigned int nr)
+void lttng_fd_put(enum lttng_fd_type type __attribute__((unused)), unsigned int nr)
{
uatomic_sub(&fd_count, (long) nr);
}
return false;
}
- return std::equal(a.cbegin(), a.cend(), b.cbegin(),
- [](typename FieldTypeSet::const_reference field_a,
- typename FieldTypeSet::const_reference field_b) {
- return *field_a == *field_b;
- });
+ return std::equal(a.cbegin(),
+ a.cend(),
+ b.cbegin(),
+ [](typename FieldTypeSet::const_reference field_a,
+ typename FieldTypeSet::const_reference field_b) {
+ return *field_a == *field_b;
+ });
}
} /* namespace */
lst::field_location::field_location(lst::field_location::root in_lookup_root,
- lst::field_location::elements in_elements) :
- root_{in_lookup_root}, elements_{std::move(in_elements)}
+ lst::field_location::elements in_elements) :
+ root_{ in_lookup_root }, elements_{ std::move(in_elements) }
{
}
bool lst::field_location::operator==(const lst::field_location& other) const noexcept
{
- return root_ == other.root_ &&
- elements_ == other.elements_;
+ return root_ == other.root_ && elements_ == other.elements_;
}
-lst::type::type(unsigned int in_alignment) : alignment{in_alignment}
+lst::type::type(unsigned int in_alignment) : alignment{ in_alignment }
{
}
bool lst::type::operator==(const lst::type& other) const noexcept
{
- return typeid(*this) == typeid(other) &&
- alignment == other.alignment &&
+ return typeid(*this) == typeid(other) && alignment == other.alignment &&
/* defer to concrete type comparison */
this->_is_equal(other);
}
}
lst::field::field(std::string in_name, lst::type::cuptr in_type) :
- name{std::move(in_name)}, _type{std::move(in_type)}
+ name{ std::move(in_name) }, _type{ std::move(in_type) }
{
if (!_type) {
- LTTNG_THROW_ERROR(fmt::format("Invalid type used to create field: field name = `{}`", name));
+ LTTNG_THROW_ERROR(
+ fmt::format("Invalid type used to create field: field name = `{}`", name));
}
}
return std::move(_type);
}
-const lst::type &lst::field::get_type() const
+const lst::type& lst::field::get_type() const
{
if (_type) {
return *_type;
} else {
- LTTNG_THROW_ERROR(fmt::format("Invalid attempt to access field type after transfer: field name = `{}`", name));
+ LTTNG_THROW_ERROR(fmt::format(
+ "Invalid attempt to access field type after transfer: field name = `{}`",
+ name));
}
}
lst::integer_type::integer_type(unsigned int in_alignment,
- enum lst::byte_order in_byte_order,
- unsigned int in_size,
- enum lst::integer_type::signedness in_signedness,
- enum lst::integer_type::base in_base,
- roles in_roles) :
+ enum lst::byte_order in_byte_order,
+ unsigned int in_size,
+ enum lst::integer_type::signedness in_signedness,
+ enum lst::integer_type::base in_base,
+ roles in_roles) :
type(in_alignment),
- byte_order{in_byte_order},
- size{in_size},
- signedness_{in_signedness},
- base_{in_base},
- roles_{std::move(in_roles)}
+ byte_order{ in_byte_order },
+ size{ in_size },
+ signedness_{ in_signedness },
+ base_{ in_base },
+ roles_{ std::move(in_roles) }
{
}
lst::type::cuptr lst::integer_type::copy() const
{
return lttng::make_unique<integer_type>(
- alignment, byte_order, size, signedness_, base_, roles_);
+ alignment, byte_order, size, signedness_, base_, roles_);
}
-bool lst::integer_type::_is_equal(const type &base_other) const noexcept
+bool lst::integer_type::_is_equal(const type& base_other) const noexcept
{
const auto& other = static_cast<decltype(*this)&>(base_other);
- return this->byte_order == other.byte_order &&
- this->size == other.size &&
- this->signedness_ == other.signedness_ &&
- this->base_ == other.base_ &&
+ return this->byte_order == other.byte_order && this->size == other.size &&
+ this->signedness_ == other.signedness_ && this->base_ == other.base_ &&
this->roles_ == other.roles_;
}
}
lst::floating_point_type::floating_point_type(unsigned int in_alignment,
- lst::byte_order in_byte_order,
- unsigned int in_exponent_digits,
- unsigned int in_mantissa_digits) :
+ lst::byte_order in_byte_order,
+ unsigned int in_exponent_digits,
+ unsigned int in_mantissa_digits) :
type(in_alignment),
byte_order(in_byte_order),
- exponent_digits{in_exponent_digits},
+ exponent_digits{ in_exponent_digits },
mantissa_digits(in_mantissa_digits)
{
/* Allowed (exponent, mantissa) pairs. */
static const std::set<std::pair<unsigned int, unsigned int>> allowed_pairs{
- {5, 11}, /* binary16 */
- {8, 24}, /* binary32 */
- {11, 53}, /* binary64 */
- {15, 113}, /* binary128 */
+ { 5, 11 }, /* binary16 */
+ { 8, 24 }, /* binary32 */
+ { 11, 53 }, /* binary64 */
+ { 15, 113 }, /* binary128 */
};
- if (allowed_pairs.find({exponent_digits, mantissa_digits}) != allowed_pairs.end()) {
+ if (allowed_pairs.find({ exponent_digits, mantissa_digits }) != allowed_pairs.end()) {
/* mantissa and exponent digits is a valid pair. */
return;
}
- LTTNG_THROW_INVALID_ARGUMENT_ERROR(
- fmt::format("Invalid exponent/mantissa values provided while creating {}",
- typeid(*this)));
+ LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
+ "Invalid exponent/mantissa values provided while creating {}", typeid(*this)));
}
lst::type::cuptr lst::floating_point_type::copy() const
{
return lttng::make_unique<floating_point_type>(
- alignment, byte_order, exponent_digits, mantissa_digits);
+ alignment, byte_order, exponent_digits, mantissa_digits);
}
void lst::floating_point_type::accept(type_visitor& visitor) const
const auto& other = static_cast<decltype(*this)&>(base_other);
return this->byte_order == other.byte_order &&
- this->exponent_digits == other.exponent_digits &&
- this->mantissa_digits == other.mantissa_digits;
+ this->exponent_digits == other.exponent_digits &&
+ this->mantissa_digits == other.mantissa_digits;
}
lst::enumeration_type::enumeration_type(unsigned int in_alignment,
- enum lst::byte_order in_byte_order,
- unsigned int in_size,
- enum signedness in_signedness,
- enum base in_base,
- lst::integer_type::roles in_roles) :
- integer_type(in_alignment,
- in_byte_order,
- in_size,
- in_signedness,
- in_base,
- std::move(in_roles))
+ enum lst::byte_order in_byte_order,
+ unsigned int in_size,
+ enum signedness in_signedness,
+ enum base in_base,
+ lst::integer_type::roles in_roles) :
+ integer_type(
+ in_alignment, in_byte_order, in_size, in_signedness, in_base, std::move(in_roles))
{
}
template <>
void variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>::accept(
- lst::type_visitor& visitor) const
+ lst::type_visitor& visitor) const
{
visitor.visit(*this);
}
template <>
void variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::accept(
- lst::type_visitor& visitor) const
+ lst::type_visitor& visitor) const
{
visitor.visit(*this);
}
} /* namespace lttng */
lst::array_type::array_type(unsigned int in_alignment, type::cuptr in_element_type) :
- type(in_alignment), element_type{std::move(in_element_type)}
+ type(in_alignment), element_type{ std::move(in_element_type) }
{
}
}
lst::static_length_array_type::static_length_array_type(unsigned int in_alignment,
- type::cuptr in_element_type,
- uint64_t in_length) :
- array_type(in_alignment, std::move(in_element_type)),
- length{in_length}
+ type::cuptr in_element_type,
+ uint64_t in_length) :
+ array_type(in_alignment, std::move(in_element_type)), length{ in_length }
{
}
lst::type::cuptr lst::static_length_array_type::copy() const
{
return lttng::make_unique<static_length_array_type>(
- alignment, element_type->copy(), length);
+ alignment, element_type->copy(), length);
}
void lst::static_length_array_type::accept(type_visitor& visitor) const
visitor.visit(*this);
}
-lst::dynamic_length_array_type::dynamic_length_array_type(unsigned int in_alignment,
- type::cuptr in_element_type,
- lst::field_location in_length_field_location) :
+lst::dynamic_length_array_type::dynamic_length_array_type(
+ unsigned int in_alignment,
+ type::cuptr in_element_type,
+ lst::field_location in_length_field_location) :
array_type(in_alignment, std::move(in_element_type)),
- length_field_location{std::move(in_length_field_location)}
+ length_field_location{ std::move(in_length_field_location) }
{
}
const auto& other = static_cast<decltype(*this)&>(base_other);
return array_type::_is_equal(base_other) &&
- this->length_field_location == other.length_field_location;
+ this->length_field_location == other.length_field_location;
}
lst::type::cuptr lst::dynamic_length_array_type::copy() const
{
return lttng::make_unique<dynamic_length_array_type>(
- alignment, element_type->copy(), length_field_location);
+ alignment, element_type->copy(), length_field_location);
}
void lst::dynamic_length_array_type::accept(type_visitor& visitor) const
visitor.visit(*this);
}
-lst::static_length_blob_type::static_length_blob_type(
- unsigned int in_alignment, uint64_t in_length_bytes, roles in_roles) :
- type(in_alignment), length_bytes{in_length_bytes}, roles_{std::move(in_roles)}
+lst::static_length_blob_type::static_length_blob_type(unsigned int in_alignment,
+ uint64_t in_length_bytes,
+ roles in_roles) :
+ type(in_alignment), length_bytes{ in_length_bytes }, roles_{ std::move(in_roles) }
{
}
}
lst::dynamic_length_blob_type::dynamic_length_blob_type(
- unsigned int in_alignment, lst::field_location in_length_field_location) :
- type(in_alignment), length_field_location{std::move(in_length_field_location)}
+ unsigned int in_alignment, lst::field_location in_length_field_location) :
+ type(in_alignment), length_field_location{ std::move(in_length_field_location) }
{
}
}
lst::string_type::string_type(unsigned int in_alignment, enum encoding in_encoding) :
- type(in_alignment), encoding_{in_encoding}
+ type(in_alignment), encoding_{ in_encoding }
{
}
return this->encoding_ == other.encoding_;
}
-lst::static_length_string_type::static_length_string_type(
- unsigned int in_alignment, enum encoding in_encoding, uint64_t in_length) :
- string_type(in_alignment, in_encoding), length{in_length}
+lst::static_length_string_type::static_length_string_type(unsigned int in_alignment,
+ enum encoding in_encoding,
+ uint64_t in_length) :
+ string_type(in_alignment, in_encoding), length{ in_length }
{
}
visitor.visit(*this);
}
-lst::dynamic_length_string_type::dynamic_length_string_type(unsigned int in_alignment,
- enum encoding in_encoding,
- field_location in_length_field_location) :
+lst::dynamic_length_string_type::dynamic_length_string_type(
+ unsigned int in_alignment,
+ enum encoding in_encoding,
+ field_location in_length_field_location) :
string_type(in_alignment, in_encoding),
- length_field_location{std::move(in_length_field_location)}
+ length_field_location{ std::move(in_length_field_location) }
{
}
const auto& other = static_cast<decltype(*this)&>(base_other);
return string_type::_is_equal(base_other) &&
- this->length_field_location == other.length_field_location;
+ this->length_field_location == other.length_field_location;
}
lst::type::cuptr lst::dynamic_length_string_type::copy() const
{
return lttng::make_unique<dynamic_length_string_type>(
- alignment, encoding_, length_field_location);
+ alignment, encoding_, length_field_location);
}
void lst::dynamic_length_string_type::accept(type_visitor& visitor) const
}
lst::null_terminated_string_type::null_terminated_string_type(unsigned int in_alignment,
- enum encoding in_encoding) :
+ enum encoding in_encoding) :
string_type(in_alignment, in_encoding)
{
}
}
lst::structure_type::structure_type(unsigned int in_alignment, fields in_fields) :
- type(in_alignment), fields_{std::move(in_fields)}
+ type(in_alignment), fields_{ std::move(in_fields) }
{
}
bool lst::structure_type::_is_equal(const type& base_other) const noexcept
{
- const auto &other = static_cast<decltype(*this)&>(base_other);
+ const auto& other = static_cast<decltype(*this)&>(base_other);
return fields_are_equal(this->fields_, other.fields_);
}
copy_of_fields.reserve(fields_.size());
for (const auto& field : fields_) {
- copy_of_fields.emplace_back(lttng::make_unique<lst::field>(
- field->name, field->get_type().copy()));
+ copy_of_fields.emplace_back(
+ lttng::make_unique<lst::field>(field->name, field->get_type().copy()));
}
return lttng::make_unique<structure_type>(alignment, std::move(copy_of_fields));
*/
#include "lttng-sessiond.hpp"
+
#include <common/uuid.hpp>
lttng_uuid the_sessiond_uuid;
struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
-int the_kernel_poll_pipe[2] = {-1, -1};
+int the_kernel_poll_pipe[2] = { -1, -1 };
pid_t the_ppid;
pid_t the_child_ppid;
*
*/
-#include "lttng-sessiond.hpp"
#include "health-sessiond.hpp"
-#include <common/macros.hpp>
+#include "lttng-sessiond.hpp"
+#include "thread.hpp"
+#include "utils.hpp"
+
#include <common/error.hpp>
-#include <common/utils.hpp>
+#include <common/macros.hpp>
#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
#include <inttypes.h>
#include <sys/stat.h>
-#include "utils.hpp"
-#include "thread.hpp"
namespace {
struct thread_notifiers {
};
} /* namespace */
-static
-void mark_thread_as_ready(struct thread_notifiers *notifiers)
+static void mark_thread_as_ready(struct thread_notifiers *notifiers)
{
DBG("Marking health management thread as ready");
sem_post(¬ifiers->ready);
}
-static
-void wait_until_thread_is_ready(struct thread_notifiers *notifiers)
+static void wait_until_thread_is_ready(struct thread_notifiers *notifiers)
{
DBG("Waiting for health management thread to be ready");
sem_wait(¬ifiers->ready);
struct health_comm_reply reply;
/* Thread-specific quit pipe. */
struct thread_notifiers *notifiers = (thread_notifiers *) data;
- const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(
- notifiers->quit_pipe);
+ const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
DBG("[thread] Manage health check started");
}
ret = chmod(the_config.health_unix_sock_path.value,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
- ERR("Unable to set permissions on %s", the_config.health_unix_sock_path.value);
+ ERR("Unable to set permissions on %s",
+ the_config.health_unix_sock_path.value);
PERROR("chmod");
goto error;
}
DBG("Health check ready");
/* Infinite blocking call, waiting for transmission */
-restart:
+ restart:
ret = lttng_poll_wait(&events, -1);
if (ret < 0) {
/*
(void) utils_set_fd_cloexec(new_sock);
DBG("Receiving data from client for health...");
- ret = lttcomm_recv_unix_sock(new_sock, (void *)&msg, sizeof(msg));
+ ret = lttcomm_recv_unix_sock(new_sock, (void *) &msg, sizeof(msg));
if (ret <= 0) {
DBG("Nothing recv() from client... continuing");
ret = close(new_sock);
DBG2("Health check return value %" PRIx64, reply.ret_code);
- ret = lttcomm_send_unix_sock(new_sock, (void *) &reply,
- sizeof(reply));
+ ret = lttcomm_send_unix_sock(new_sock, (void *) &reply, sizeof(reply));
if (ret < 0) {
ERR("Failed to send health data back to client");
}
static bool shutdown_health_management_thread(void *data)
{
- struct thread_notifiers *notifiers = ( thread_notifiers *) data;
+ struct thread_notifiers *notifiers = (thread_notifiers *) data;
const int write_fd = lttng_pipe_get_writefd(notifiers->quit_pipe);
return notify_thread_pipe(write_fd) == 1;
goto error;
}
thread = lttng_thread_create("Health management",
- thread_manage_health,
- shutdown_health_management_thread,
- cleanup_health_management_thread,
- notifiers);
+ thread_manage_health,
+ shutdown_health_management_thread,
+ cleanup_health_management_thread,
+ notifiers);
if (!thread) {
goto error;
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <inttypes.h>
-
-#include <common/common.hpp>
-#include <common/defaults.hpp>
-#include <common/compat/string.hpp>
-
#include "consumer.hpp"
#include "health-sessiond.hpp"
#include "kernel-consumer.hpp"
+#include "lttng-sessiond.hpp"
#include "notification-thread-commands.hpp"
#include "session.hpp"
-#include "lttng-sessiond.hpp"
-static char *create_channel_path(struct consumer_output *consumer,
- size_t *consumer_path_offset)
+#include <common/common.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static char *create_channel_path(struct consumer_output *consumer, size_t *consumer_path_offset)
{
int ret;
char tmp_path[PATH_MAX];
/* Get the right path name destination */
if (consumer->type == CONSUMER_DST_LOCAL ||
- (consumer->type == CONSUMER_DST_NET &&
- consumer->relay_major_version == 2 &&
- consumer->relay_minor_version >= 11)) {
+ (consumer->type == CONSUMER_DST_NET && consumer->relay_major_version == 2 &&
+ consumer->relay_minor_version >= 11)) {
pathname = strdup(consumer->domain_subdir);
if (!pathname) {
PERROR("Failed to copy domain subdirectory string %s",
- consumer->domain_subdir);
+ consumer->domain_subdir);
goto error;
}
*consumer_path_offset = strlen(consumer->domain_subdir);
DBG3("Kernel local consumer trace path relative to current trace chunk: \"%s\"",
- pathname);
+ pathname);
} else {
/* Network output, relayd < 2.11. */
- ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
- consumer->dst.net.base_dir,
- consumer->domain_subdir);
+ ret = snprintf(tmp_path,
+ sizeof(tmp_path),
+ "%s%s",
+ consumer->dst.net.base_dir,
+ consumer->domain_subdir);
if (ret < 0) {
PERROR("snprintf kernel metadata path");
goto error;
} else if (ret >= sizeof(tmp_path)) {
ERR("Kernel channel path exceeds the maximal allowed length of of %zu bytes (%i bytes required) with path \"%s%s\"",
- sizeof(tmp_path), ret,
- consumer->dst.net.base_dir,
- consumer->domain_subdir);
+ sizeof(tmp_path),
+ ret,
+ consumer->dst.net.base_dir,
+ consumer->domain_subdir);
goto error;
}
pathname = lttng_strndup(tmp_path, sizeof(tmp_path));
/*
* Sending a single channel to the consumer with command ADD_CHANNEL.
*/
-static
-int kernel_consumer_add_channel(struct consumer_socket *sock,
- struct ltt_kernel_channel *channel,
- struct ltt_kernel_session *ksession,
- unsigned int monitor)
+static int kernel_consumer_add_channel(struct consumer_socket *sock,
+ struct ltt_kernel_channel *channel,
+ struct ltt_kernel_session *ksession,
+ unsigned int monitor)
{
int ret;
char *pathname = NULL;
LTTNG_ASSERT(ksession->consumer);
consumer = ksession->consumer;
- channel_attr_extended = (struct lttng_channel_extended *)
- channel->channel->attr.extended.ptr;
+ channel_attr_extended =
+ (struct lttng_channel_extended *) channel->channel->attr.extended.ptr;
- DBG("Kernel consumer adding channel %s to kernel consumer",
- channel->channel->name);
+ DBG("Kernel consumer adding channel %s to kernel consumer", channel->channel->name);
is_local_trace = consumer->net_seq_index == -1ULL;
pathname = create_channel_path(consumer, &consumer_path_offset);
enum lttng_trace_chunk_status chunk_status;
char *pathname_index;
- ret = asprintf(&pathname_index, "%s/" DEFAULT_INDEX_DIR,
- pathname);
+ ret = asprintf(&pathname_index, "%s/" DEFAULT_INDEX_DIR, pathname);
if (ret < 0) {
ERR("Failed to format channel index directory");
ret = -1;
* Create the index subdirectory which will take care
* of implicitly creating the channel's path.
*/
- chunk_status = lttng_trace_chunk_create_subdirectory(
- ksession->current_trace_chunk, pathname_index);
+ chunk_status = lttng_trace_chunk_create_subdirectory(ksession->current_trace_chunk,
+ pathname_index);
free(pathname_index);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
/* Prep channel message structure */
consumer_init_add_channel_comm_msg(&lkm,
- channel->key,
- ksession->id,
- &pathname[consumer_path_offset],
- consumer->net_seq_index,
- channel->channel->name,
- channel->stream_count,
- channel->channel->attr.output,
- CONSUMER_CHANNEL_TYPE_DATA,
- channel->channel->attr.tracefile_size,
- channel->channel->attr.tracefile_count,
- monitor,
- channel->channel->attr.live_timer_interval,
- ksession->is_live_session,
- channel_attr_extended->monitor_timer_interval,
- ksession->current_trace_chunk);
+ channel->key,
+ ksession->id,
+ &pathname[consumer_path_offset],
+ consumer->net_seq_index,
+ channel->channel->name,
+ channel->stream_count,
+ channel->channel->attr.output,
+ CONSUMER_CHANNEL_TYPE_DATA,
+ channel->channel->attr.tracefile_size,
+ channel->channel->attr.tracefile_count,
+ monitor,
+ channel->channel->attr.live_timer_interval,
+ ksession->is_live_session,
+ channel_attr_extended->monitor_timer_interval,
+ ksession->current_trace_chunk);
health_code_update();
ASSERT_SESSION_LIST_LOCKED();
status = notification_thread_command_add_channel(the_notification_thread_handle,
- session->id, channel->channel->name, channel->key, LTTNG_DOMAIN_KERNEL,
- channel->channel->attr.subbuf_size * channel->channel->attr.num_subbuf);
+ session->id,
+ channel->channel->name,
+ channel->key,
+ LTTNG_DOMAIN_KERNEL,
+ channel->channel->attr.subbuf_size *
+ channel->channel->attr.num_subbuf);
rcu_read_unlock();
if (status != LTTNG_OK) {
ret = -1;
* The consumer socket lock must be held by the caller.
*/
int kernel_consumer_add_metadata(struct consumer_socket *sock,
- struct ltt_kernel_session *ksession, unsigned int monitor)
+ struct ltt_kernel_session *ksession,
+ unsigned int monitor)
{
int ret;
struct lttcomm_consumer_msg lkm;
LTTNG_ASSERT(ksession->consumer);
LTTNG_ASSERT(sock);
- DBG("Sending metadata %d to kernel consumer",
- ksession->metadata_stream_fd);
+ DBG("Sending metadata %d to kernel consumer", ksession->metadata_stream_fd);
/* Get consumer output pointer */
consumer = ksession->consumer;
/* Prep channel message structure */
consumer_init_add_channel_comm_msg(&lkm,
- ksession->metadata->key,
- ksession->id,
- "",
- consumer->net_seq_index,
- ksession->metadata->conf->name,
- 1,
- ksession->metadata->conf->attr.output,
- CONSUMER_CHANNEL_TYPE_METADATA,
- ksession->metadata->conf->attr.tracefile_size,
- ksession->metadata->conf->attr.tracefile_count,
- monitor,
- ksession->metadata->conf->attr.live_timer_interval,
- ksession->is_live_session,
- 0,
- ksession->current_trace_chunk);
+ ksession->metadata->key,
+ ksession->id,
+ "",
+ consumer->net_seq_index,
+ ksession->metadata->conf->name,
+ 1,
+ ksession->metadata->conf->attr.output,
+ CONSUMER_CHANNEL_TYPE_METADATA,
+ ksession->metadata->conf->attr.tracefile_size,
+ ksession->metadata->conf->attr.tracefile_count,
+ monitor,
+ ksession->metadata->conf->attr.live_timer_interval,
+ ksession->is_live_session,
+ 0,
+ ksession->current_trace_chunk);
health_code_update();
/* Prep stream message structure */
consumer_init_add_stream_comm_msg(&lkm,
- ksession->metadata->key,
- ksession->metadata_stream_fd,
- 0 /* CPU: 0 for metadata. */);
+ ksession->metadata->key,
+ ksession->metadata_stream_fd,
+ 0 /* CPU: 0 for metadata. */);
health_code_update();
/* Send stream and file descriptor */
- ret = consumer_send_stream(sock, consumer, &lkm,
- &ksession->metadata_stream_fd, 1);
+ ret = consumer_send_stream(sock, consumer, &lkm, &ksession->metadata_stream_fd, 1);
if (ret < 0) {
goto error;
}
/*
* Sending a single stream to the consumer with command ADD_STREAM.
*/
-static
-int kernel_consumer_add_stream(struct consumer_socket *sock,
- struct ltt_kernel_channel *channel,
- struct ltt_kernel_stream *stream,
- struct ltt_kernel_session *session)
+static int kernel_consumer_add_stream(struct consumer_socket *sock,
+ struct ltt_kernel_channel *channel,
+ struct ltt_kernel_stream *stream,
+ struct ltt_kernel_session *session)
{
int ret;
struct lttcomm_consumer_msg lkm;
LTTNG_ASSERT(sock);
DBG("Sending stream %d of channel %s to kernel consumer",
- stream->fd, channel->channel->name);
+ stream->fd,
+ channel->channel->name);
/* Get consumer output pointer */
consumer = session->consumer;
/* Prep stream consumer message */
- consumer_init_add_stream_comm_msg(&lkm,
- channel->key,
- stream->fd,
- stream->cpu);
+ consumer_init_add_stream_comm_msg(&lkm, channel->key, stream->fd, stream->cpu);
health_code_update();
* Sending the notification that all streams were sent with STREAMS_SENT.
*/
int kernel_consumer_streams_sent(struct consumer_socket *sock,
- struct ltt_kernel_session *session, uint64_t channel_key)
+ struct ltt_kernel_session *session,
+ uint64_t channel_key)
{
int ret;
struct lttcomm_consumer_msg lkm;
consumer = session->consumer;
/* Prep stream consumer message */
- consumer_init_streams_sent_comm_msg(&lkm,
- LTTNG_CONSUMER_STREAMS_SENT,
- channel_key, consumer->net_seq_index);
+ consumer_init_streams_sent_comm_msg(
+ &lkm, LTTNG_CONSUMER_STREAMS_SENT, channel_key, consumer->net_seq_index);
health_code_update();
* The consumer socket lock must be held by the caller.
*/
int kernel_consumer_send_channel_streams(struct consumer_socket *sock,
- struct ltt_kernel_channel *channel, struct ltt_kernel_session *ksession,
- unsigned int monitor)
+ struct ltt_kernel_channel *channel,
+ struct ltt_kernel_session *ksession,
+ unsigned int monitor)
{
int ret = LTTNG_OK;
struct ltt_kernel_stream *stream;
goto error;
}
- DBG("Sending streams of channel %s to kernel consumer",
- channel->channel->name);
+ DBG("Sending streams of channel %s to kernel consumer", channel->channel->name);
if (!channel->sent_to_consumer) {
ret = kernel_consumer_add_channel(sock, channel, ksession, monitor);
}
/* Send streams */
- cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
+ cds_list_for_each_entry (stream, &channel->stream_list.head, list) {
if (!stream->fd || stream->sent_to_consumer) {
continue;
}
/* Add stream on the kernel consumer side. */
- ret = kernel_consumer_add_stream(sock, channel, stream,
- ksession);
+ ret = kernel_consumer_add_stream(sock, channel, stream, ksession);
if (ret < 0) {
goto error;
}
*
* The consumer socket lock must be held by the caller.
*/
-int kernel_consumer_send_session(struct consumer_socket *sock,
- struct ltt_kernel_session *session)
+int kernel_consumer_send_session(struct consumer_socket *sock, struct ltt_kernel_session *session)
{
int ret, monitor = 0;
struct ltt_kernel_channel *chan;
}
/* Send channel and streams of it */
- cds_list_for_each_entry(chan, &session->channel_list.head, list) {
- ret = kernel_consumer_send_channel_streams(sock, chan, session,
- monitor);
+ cds_list_for_each_entry (chan, &session->channel_list.head, list) {
+ ret = kernel_consumer_send_channel_streams(sock, chan, session, monitor);
if (ret < 0) {
goto error;
}
}
int kernel_consumer_destroy_channel(struct consumer_socket *socket,
- struct ltt_kernel_channel *channel)
+ struct ltt_kernel_channel *channel)
{
int ret;
struct lttcomm_consumer_msg msg;
}
int kernel_consumer_destroy_metadata(struct consumer_socket *socket,
- struct ltt_kernel_metadata *metadata)
+ struct ltt_kernel_metadata *metadata)
{
int ret;
struct lttcomm_consumer_msg msg;
*/
#define _LGPL_SOURCE
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/types.h>
+#include "condition-internal.hpp"
+#include "consumer.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "kern-modules.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "modprobe.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotate.hpp"
+#include "sessiond-config.hpp"
+#include "tracker.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/hashtable/utils.hpp>
-#include <common/trace-chunk.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/kernel-ctl/kernel-ioctl.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/trace-chunk.hpp>
#include <common/tracker.hpp>
#include <common/utils.hpp>
-#include <lttng/event.h>
-#include <lttng/lttng-error.h>
-#include <lttng/tracker.h>
-#include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.hpp>
-#include <lttng/condition/event-rule-matches.h>
#include <lttng/condition/event-rule-matches-internal.hpp>
-#include <lttng/event-rule/event-rule.h>
+#include <lttng/condition/event-rule-matches.h>
#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/kernel-uprobe-internal.hpp>
+#include <lttng/event.h>
+#include <lttng/lttng-error.h>
+#include <lttng/tracker.h>
+#include <lttng/userspace-probe-internal.hpp>
+#include <lttng/userspace-probe.h>
-#include "event-notifier-error-accounting.hpp"
-#include "lttng-sessiond.hpp"
-#include "lttng-syscall.hpp"
-#include "condition-internal.hpp"
-#include "consumer.hpp"
-#include "kernel.hpp"
-#include "kernel-consumer.hpp"
-#include "kern-modules.hpp"
-#include "sessiond-config.hpp"
-#include "utils.hpp"
-#include "rotate.hpp"
-#include "modprobe.hpp"
-#include "tracker.hpp"
-#include "notification-thread-commands.hpp"
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
/*
* Key used to reference a channel between the sessiond and the consumer. This
*
* Assumes the ownership of ctx.
*/
-int kernel_add_channel_context(struct ltt_kernel_channel *chan,
- struct ltt_kernel_context *ctx)
+int kernel_add_channel_context(struct ltt_kernel_channel *chan, struct ltt_kernel_context *ctx)
{
int ret;
}
if (ret) {
WARN("Could not set kernel session name for session %" PRIu64 " name: %s",
- session->id, session->name);
+ session->id,
+ session->name);
}
ret = kernctl_session_set_creation_time(lks->fd, session->creation_time);
if (ret) {
WARN("Could not set kernel session creation time for session %" PRIu64 " name: %s",
- session->id, session->name);
+ session->id,
+ session->name);
}
return 0;
* Create a kernel channel, register it to the kernel tracer and add it to the
* kernel session.
*/
-int kernel_create_channel(struct ltt_kernel_session *session,
- struct lttng_channel *chan)
+int kernel_create_channel(struct ltt_kernel_session *session, struct lttng_channel *chan)
{
int ret;
struct ltt_kernel_channel *lkc;
}
DBG3("Kernel create channel %s with attr: %d, %" PRIu64 ", %" PRIu64 ", %u, %u, %d, %d",
- chan->name, lkc->channel->attr.overwrite,
- lkc->channel->attr.subbuf_size, lkc->channel->attr.num_subbuf,
- lkc->channel->attr.switch_timer_interval, lkc->channel->attr.read_timer_interval,
- lkc->channel->attr.live_timer_interval, lkc->channel->attr.output);
+ chan->name,
+ lkc->channel->attr.overwrite,
+ lkc->channel->attr.subbuf_size,
+ lkc->channel->attr.num_subbuf,
+ lkc->channel->attr.switch_timer_interval,
+ lkc->channel->attr.read_timer_interval,
+ lkc->channel->attr.live_timer_interval,
+ lkc->channel->attr.output);
/* Kernel tracer channel creation */
ret = kernctl_create_channel(session->fd, &lkc->channel->attr);
lkc->key = ++next_kernel_channel_key;
DBG("Kernel channel %s created (fd: %d, key: %" PRIu64 ")",
- lkc->channel->name, lkc->fd, lkc->key);
+ lkc->channel->name,
+ lkc->fd,
+ lkc->key);
return 0;
ret = fcntl(local_fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
PERROR("Failed to set FD_CLOEXEC on kernel event notifier group file descriptor: fd = %d",
- local_fd);
+ local_fd);
goto error;
}
ret = close(local_fd);
if (ret) {
PERROR("Failed to close kernel event notifier group file descriptor: fd = %d",
- local_fd);
+ local_fd);
}
}
* elf symbol
* Returns -1 on error
*/
-static
-int extract_userspace_probe_offset_function_elf(
- const struct lttng_userspace_probe_location *probe_location,
- uid_t uid, gid_t gid, uint64_t *offset)
+static int extract_userspace_probe_offset_function_elf(
+ const struct lttng_userspace_probe_location *probe_location,
+ uid_t uid,
+ gid_t gid,
+ uint64_t *offset)
{
int fd;
int ret = 0;
enum lttng_userspace_probe_location_lookup_method_type lookup_method_type;
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(probe_location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- lookup = lttng_userspace_probe_location_get_lookup_method(
- probe_location);
+ lookup = lttng_userspace_probe_location_get_lookup_method(probe_location);
if (!lookup) {
ret = -1;
goto end;
}
- lookup_method_type =
- lttng_userspace_probe_location_lookup_method_get_type(lookup);
+ lookup_method_type = lttng_userspace_probe_location_lookup_method_get_type(lookup);
LTTNG_ASSERT(lookup_method_type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
- symbol = lttng_userspace_probe_location_function_get_function_name(
- probe_location);
+ symbol = lttng_userspace_probe_location_function_get_function_name(probe_location);
if (!symbol) {
ret = -1;
goto end;
ret = run_as_extract_elf_symbol_offset(fd, symbol, uid, gid, offset);
if (ret < 0) {
DBG("userspace probe offset calculation failed for "
- "function %s", symbol);
+ "function %s",
+ symbol);
goto end;
}
- DBG("userspace probe elf offset for %s is 0x%jd", symbol, (intmax_t)(*offset));
+ DBG("userspace probe elf offset for %s is 0x%jd", symbol, (intmax_t) (*offset));
end:
return ret;
}
* SDT tracepoint.
* Returns -1 on error.
*/
-static
-int extract_userspace_probe_offset_tracepoint_sdt(
- const struct lttng_userspace_probe_location *probe_location,
- uid_t uid, gid_t gid, uint64_t **offsets,
- uint32_t *offsets_count)
+static int extract_userspace_probe_offset_tracepoint_sdt(
+ const struct lttng_userspace_probe_location *probe_location,
+ uid_t uid,
+ gid_t gid,
+ uint64_t **offsets,
+ uint32_t *offsets_count)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_method_type;
const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
int fd, i;
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(probe_location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
lookup = lttng_userspace_probe_location_get_lookup_method(probe_location);
if (!lookup) {
goto end;
}
- lookup_method_type =
- lttng_userspace_probe_location_lookup_method_get_type(lookup);
+ lookup_method_type = lttng_userspace_probe_location_lookup_method_get_type(lookup);
LTTNG_ASSERT(lookup_method_type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
-
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
- probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
- probe_location);
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(probe_location);
if (!probe_name) {
ret = -1;
goto end;
}
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
- probe_location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(probe_location);
if (!provider_name) {
ret = -1;
goto end;
goto end;
}
- ret = run_as_extract_sdt_probe_offsets(fd, provider_name, probe_name,
- uid, gid, offsets, offsets_count);
+ ret = run_as_extract_sdt_probe_offsets(
+ fd, provider_name, probe_name, uid, gid, offsets, offsets_count);
if (ret < 0) {
DBG("userspace probe offset calculation failed for sdt "
- "probe %s:%s", provider_name, probe_name);
+ "probe %s:%s",
+ provider_name,
+ probe_name);
goto end;
}
}
DBG("%u userspace probe SDT offsets found for %s:%s at:",
- *offsets_count, provider_name, probe_name);
+ *offsets_count,
+ provider_name,
+ probe_name);
for (i = 0; i < *offsets_count; i++) {
- DBG("\t0x%jd", (intmax_t)((*offsets)[i]));
+ DBG("\t0x%jd", (intmax_t) ((*offsets)[i]));
}
end:
return ret;
}
-static
-int userspace_probe_add_callsite(
- const struct lttng_userspace_probe_location *location,
- uid_t uid, gid_t gid, int fd)
+static int userspace_probe_add_callsite(const struct lttng_userspace_probe_location *location,
+ uid_t uid,
+ gid_t gid,
+ int fd)
{
const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
enum lttng_userspace_probe_location_lookup_method_type type;
struct lttng_kernel_abi_event_callsite callsite;
uint64_t offset;
- ret = extract_userspace_probe_offset_function_elf(location,
- uid, gid, &offset);
+ ret = extract_userspace_probe_offset_function_elf(location, uid, gid, &offset);
if (ret) {
ret = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
* This call allocates the offsets buffer. This buffer must be freed
* by the caller
*/
- ret = extract_userspace_probe_offset_tracepoint_sdt(location,
- uid, gid, &offsets, &offsets_count);
+ ret = extract_userspace_probe_offset_tracepoint_sdt(
+ location, uid, gid, &offsets, &offsets_count);
if (ret) {
ret = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
* Extract the offsets of the instrumentation point for the different lookup
* methods.
*/
-static
-int userspace_probe_event_add_callsites(struct lttng_event *ev,
- struct ltt_kernel_session *session, int fd)
+static int userspace_probe_event_add_callsites(struct lttng_event *ev,
+ struct ltt_kernel_session *session,
+ int fd)
{
int ret;
const struct lttng_userspace_probe_location *location = NULL;
goto end;
}
- ret = userspace_probe_add_callsite(location, session->uid, session->gid,
- fd);
+ ret = userspace_probe_add_callsite(location, session->uid, session->gid, fd);
if (ret) {
- WARN("Failed to add callsite to userspace probe event '%s'",
- ev->name);
+ WARN("Failed to add callsite to userspace probe event '%s'", ev->name);
}
end:
* Extract the offsets of the instrumentation point for the different look-up
* methods.
*/
-static int userspace_probe_event_rule_add_callsites(
- const struct lttng_event_rule *rule,
- const struct lttng_credentials *creds,
- int fd)
+static int userspace_probe_event_rule_add_callsites(const struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds,
+ int fd)
{
int ret;
enum lttng_event_rule_status status;
goto end;
}
- ret = userspace_probe_add_callsite(location,
- lttng_credentials_get_uid(creds),
- lttng_credentials_get_gid(creds), fd);
+ ret = userspace_probe_add_callsite(
+ location, lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds), fd);
if (ret) {
- WARN("Failed to add callsite to user space probe object: fd = %d",
- fd);
+ WARN("Failed to add callsite to user space probe object: fd = %d", fd);
}
end:
* We own filter_expression and filter.
*/
int kernel_create_event(struct lttng_event *ev,
- struct ltt_kernel_channel *channel,
- char *filter_expression,
- struct lttng_bytecode *filter)
+ struct ltt_kernel_channel *channel,
+ char *filter_expression,
+ struct lttng_bytecode *filter)
{
int err, fd;
enum lttng_error_code ret;
LTTNG_ASSERT(channel);
/* We pass ownership of filter_expression and filter */
- ret = trace_kernel_create_event(ev, filter_expression,
- filter, &event);
+ ret = trace_kernel_create_event(ev, filter_expression, filter, &event);
if (ret != LTTNG_OK) {
goto error;
}
}
if (ev->type == LTTNG_EVENT_USERSPACE_PROBE) {
- ret = (lttng_error_code) userspace_probe_event_add_callsites(ev, channel->session,
- event->fd);
+ ret = (lttng_error_code) userspace_probe_event_add_callsites(
+ ev, channel->session, event->fd);
if (ret) {
goto add_callsite_error;
}
add_callsite_error:
enable_error:
filter_error:
- {
- int closeret;
+{
+ int closeret;
- closeret = close(event->fd);
- if (closeret) {
- PERROR("close event fd");
- }
+ closeret = close(event->fd);
+ if (closeret) {
+ PERROR("close event fd");
}
+}
free_event:
free(event);
error:
chan->enabled = 0;
DBG("Kernel channel %s disabled (fd: %d, key: %" PRIu64 ")",
- chan->channel->name, chan->fd, chan->key);
+ chan->channel->name,
+ chan->fd,
+ chan->key);
return 0;
chan->enabled = 1;
DBG("Kernel channel %s enabled (fd: %d, key: %" PRIu64 ")",
- chan->channel->name, chan->fd, chan->key);
+ chan->channel->name,
+ chan->fd,
+ chan->key);
return 0;
ret = kernctl_disable(event->fd);
if (ret < 0) {
PERROR("Failed to disable kernel event: name = '%s', fd = %d",
- event->event->name, event->fd);
+ event->event->name,
+ event->fd);
goto error;
}
/*
* Disable a kernel event notifier.
*/
-static
-int kernel_disable_event_notifier_rule(struct ltt_kernel_event_notifier_rule *event)
+static int kernel_disable_event_notifier_rule(struct ltt_kernel_event_notifier_rule *event)
{
int ret;
ret = kernctl_disable(event->fd);
if (ret < 0) {
PERROR("Failed to disable kernel event notifier: fd = %d, token = %" PRIu64,
- event->fd, event->token);
+ event->fd,
+ event->token);
goto error;
}
event->enabled = 0;
- DBG("Disabled kernel event notifier: fd = %d, token = %" PRIu64,
- event->fd, event->token);
+ DBG("Disabled kernel event notifier: fd = %d, token = %" PRIu64, event->fd, event->token);
error:
return ret;
}
-static
-struct process_attr_tracker *_kernel_get_process_attr_tracker(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr)
+static struct process_attr_tracker *
+_kernel_get_process_attr_tracker(struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr)
{
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
}
}
-const struct process_attr_tracker *kernel_get_process_attr_tracker(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr)
+const struct process_attr_tracker *
+kernel_get_process_attr_tracker(struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr)
{
- return (const struct process_attr_tracker *)
- _kernel_get_process_attr_tracker(session, process_attr);
+ return (const struct process_attr_tracker *) _kernel_get_process_attr_tracker(session,
+ process_attr);
}
-enum lttng_error_code kernel_process_attr_tracker_set_tracking_policy(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy)
+enum lttng_error_code
+kernel_process_attr_tracker_set_tracking_policy(struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy)
{
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
struct process_attr_tracker *tracker =
- _kernel_get_process_attr_tracker(session, process_attr);
+ _kernel_get_process_attr_tracker(session, process_attr);
enum lttng_tracking_policy previous_policy;
if (!tracker) {
return ret_code;
}
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_add_value(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+kernel_process_attr_tracker_inclusion_set_add_value(struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
int ret, integral_value;
enum lttng_error_code ret_code;
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME) {
uid_t uid;
- ret_code = utils_user_id_from_name(
- value->value.user_name, &uid);
+ ret_code = utils_user_id_from_name(value->value.user_name, &uid);
if (ret_code != LTTNG_OK) {
goto end;
}
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME) {
gid_t gid;
- ret_code = utils_group_id_from_name(
- value->value.group_name, &gid);
+ ret_code = utils_group_id_from_name(value->value.group_name, &gid);
if (ret_code != LTTNG_OK) {
goto end;
}
}
DBG("Kernel track %s %d for session id %" PRIu64,
- lttng_process_attr_to_string(process_attr),
- integral_value, session->id);
+ lttng_process_attr_to_string(process_attr),
+ integral_value,
+ session->id);
if (process_attr == LTTNG_PROCESS_ATTR_PROCESS_ID) {
/*
* Maintain a special case for the process ID process attribute
*/
ret = kernctl_track_pid(session->fd, integral_value);
} else {
- ret = kernctl_track_id(
- session->fd, process_attr, integral_value);
+ ret = kernctl_track_id(session->fd, process_attr, integral_value);
}
if (ret == 0) {
ret_code = LTTNG_OK;
}
/* Attempt to remove the value from the tracker. */
- status = process_attr_tracker_inclusion_set_remove_value(
- tracker, value);
+ status = process_attr_tracker_inclusion_set_remove_value(tracker, value);
if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
ERR("Failed to roll-back the tracking of kernel %s process attribute %d while handling a kern-ctl error",
- lttng_process_attr_to_string(process_attr),
- integral_value);
+ lttng_process_attr_to_string(process_attr),
+ integral_value);
}
end:
return ret_code;
}
-enum lttng_error_code kernel_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_kernel_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+kernel_process_attr_tracker_inclusion_set_remove_value(struct ltt_kernel_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
int ret, integral_value;
enum lttng_error_code ret_code;
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME) {
uid_t uid;
- ret_code = utils_user_id_from_name(
- value->value.user_name, &uid);
+ ret_code = utils_user_id_from_name(value->value.user_name, &uid);
if (ret_code != LTTNG_OK) {
goto end;
}
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME) {
gid_t gid;
- ret_code = utils_group_id_from_name(
- value->value.group_name, &gid);
+ ret_code = utils_group_id_from_name(value->value.group_name, &gid);
if (ret_code != LTTNG_OK) {
goto end;
}
goto end;
}
- status = process_attr_tracker_inclusion_set_remove_value(
- tracker, value);
+ status = process_attr_tracker_inclusion_set_remove_value(tracker, value);
if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
switch (status) {
case PROCESS_ATTR_TRACKER_STATUS_MISSING:
}
DBG("Kernel track %s %d for session id %" PRIu64,
- lttng_process_attr_to_string(process_attr),
- integral_value, session->id);
+ lttng_process_attr_to_string(process_attr),
+ integral_value,
+ session->id);
if (process_attr == LTTNG_PROCESS_ATTR_PROCESS_ID) {
/*
* Maintain a special case for the process ID process attribute
*/
ret = kernctl_untrack_pid(session->fd, integral_value);
} else {
- ret = kernctl_untrack_id(
- session->fd, process_attr, integral_value);
+ ret = kernctl_untrack_id(session->fd, process_attr, integral_value);
}
if (ret == 0) {
ret_code = LTTNG_OK;
}
/* Attempt to add the value to the tracker. */
- status = process_attr_tracker_inclusion_set_add_value(
- tracker, value);
+ status = process_attr_tracker_inclusion_set_add_value(tracker, value);
if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
ERR("Failed to roll-back the tracking of kernel %s process attribute %d while handling a kern-ctl error",
- lttng_process_attr_to_string(process_attr),
- integral_value);
+ lttng_process_attr_to_string(process_attr),
+ integral_value);
}
end:
return ret_code;
DBG("Flush buffer for channel %s", channel->channel->name);
- cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
+ cds_list_for_each_entry (stream, &channel->stream_list.head, list) {
DBG("Flushing channel stream %d", stream->fd);
ret = kernctl_buffer_flush(stream->fd);
if (ret < 0) {
PERROR("ioctl");
- ERR("Fail to flush buffer for stream %d (ret: %d)",
- stream->fd, ret);
+ ERR("Fail to flush buffer for stream %d (ret: %d)", stream->fd, ret);
}
}
LTTNG_ASSERT(channel);
while ((ret = kernctl_create_stream(channel->fd)) >= 0) {
- lks = trace_kernel_create_stream(channel->channel->name,
- channel->stream_count);
+ lks = trace_kernel_create_stream(channel->channel->name, channel->stream_count);
if (lks == NULL) {
ret = close(ret);
if (ret) {
cds_list_add(&lks->list, &channel->stream_list.head);
channel->stream_count++;
- DBG("Kernel stream %s created (fd: %d, state: %d)", lks->name, lks->fd,
- lks->state);
+ DBG("Kernel stream %s created (fd: %d, state: %d)", lks->name, lks->fd, lks->state);
}
return channel->stream_count;
size_t new_nbmem;
new_nbmem = nbmem << 1;
- DBG("Reallocating event list from %zu to %zu bytes",
- nbmem, new_nbmem);
- new_elist = (lttng_event *) realloc(elist, new_nbmem * sizeof(struct lttng_event));
+ DBG("Reallocating event list from %zu to %zu bytes", nbmem, new_nbmem);
+ new_elist = (lttng_event *) realloc(elist,
+ new_nbmem * sizeof(struct lttng_event));
if (new_elist == NULL) {
PERROR("realloc list events");
free(event);
goto end;
}
/* Zero the new memory */
- memset(new_elist + nbmem, 0,
- (new_nbmem - nbmem) * sizeof(struct lttng_event));
+ memset(new_elist + nbmem,
+ 0,
+ (new_nbmem - nbmem) * sizeof(struct lttng_event));
nbmem = new_nbmem;
elist = new_elist;
}
*events = elist;
DBG("Kernel list events done (%zu events)", count);
end:
- ret = fclose(fp); /* closes both fp and fd */
+ ret = fclose(fp); /* closes both fp and fd */
if (ret) {
PERROR("fclose");
}
* Get kernel version and validate it.
*/
int kernel_validate_version(struct lttng_kernel_abi_tracer_version *version,
- struct lttng_kernel_abi_tracer_abi_version *abi_version)
+ struct lttng_kernel_abi_tracer_abi_version *abi_version)
{
int ret;
/* Validate version */
if (version->major != VERSION_MAJOR) {
ERR("Kernel tracer major version (%d) is not compatible with lttng-tools major version (%d)",
- version->major, VERSION_MAJOR);
+ version->major,
+ VERSION_MAJOR);
goto error_version;
}
ret = kernctl_tracer_abi_version(kernel_tracer_fd, abi_version);
}
if (abi_version->major != LTTNG_KERNEL_ABI_MAJOR_VERSION) {
ERR("Kernel tracer ABI version (%d.%d) does not match the expected ABI major version (%d.*)",
- abi_version->major, abi_version->minor,
- LTTNG_KERNEL_ABI_MAJOR_VERSION);
+ abi_version->major,
+ abi_version->minor,
+ LTTNG_KERNEL_ABI_MAJOR_VERSION);
goto error;
}
DBG2("Kernel tracer version validated (%d.%d, ABI %d.%d)",
- version->major, version->minor,
- abi_version->major, abi_version->minor);
+ version->major,
+ version->minor,
+ abi_version->major,
+ abi_version->minor);
return 0;
error_version:
/* For each consumer socket. */
rcu_read_lock();
- cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (
+ ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
struct ltt_kernel_channel *chan;
/* For each channel, ask the consumer to destroy it. */
- cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
ret = kernel_consumer_destroy_channel(socket, chan);
if (ret < 0) {
/* Consumer is probably dead. Use next socket. */
*
* Return LTTNG_OK on success or else return a LTTNG_ERR code.
*/
-enum lttng_error_code kernel_snapshot_record(
- struct ltt_kernel_session *ksess,
- const struct consumer_output *output,
- uint64_t nb_packets_per_stream)
+enum lttng_error_code kernel_snapshot_record(struct ltt_kernel_session *ksess,
+ const struct consumer_output *output,
+ uint64_t nb_packets_per_stream)
{
int err, ret, saved_metadata_fd;
enum lttng_error_code status = LTTNG_OK;
goto error_open_stream;
}
- trace_path = setup_channel_trace_path(ksess->consumer,
- "", &consumer_path_offset);
+ trace_path = setup_channel_trace_path(ksess->consumer, "", &consumer_path_offset);
if (!trace_path) {
status = LTTNG_ERR_INVALID;
goto error;
}
/* Send metadata to consumer and snapshot everything. */
- cds_lfht_for_each_entry(output->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) {
struct ltt_kernel_channel *chan;
pthread_mutex_lock(socket->lock);
}
/* For each channel, ask the consumer to snapshot it. */
- cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
- status = consumer_snapshot_channel(socket, chan->key, output, 0,
- &trace_path[consumer_path_offset],
- nb_packets_per_stream);
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
+ status = consumer_snapshot_channel(socket,
+ chan->key,
+ output,
+ 0,
+ &trace_path[consumer_path_offset],
+ nb_packets_per_stream);
if (status != LTTNG_OK) {
- (void) kernel_consumer_destroy_metadata(socket,
- ksess->metadata);
+ (void) kernel_consumer_destroy_metadata(socket, ksess->metadata);
goto error_consumer;
}
}
/* Snapshot metadata, */
- status = consumer_snapshot_channel(socket, ksess->metadata->key, output,
- 1, &trace_path[consumer_path_offset], 0);
+ status = consumer_snapshot_channel(socket,
+ ksess->metadata->key,
+ output,
+ 1,
+ &trace_path[consumer_path_offset],
+ 0);
if (status != LTTNG_OK) {
goto error_consumer;
}
return kernctl_syscall_mask(chan_fd, syscall_mask, nr_bits);
}
-static
-int kernel_tracer_abi_greater_or_equal(unsigned int major, unsigned int minor)
+static int kernel_tracer_abi_greater_or_equal(unsigned int major, unsigned int minor)
{
int ret;
struct lttng_kernel_abi_tracer_abi_version abi;
LTTNG_ASSERT(ksess);
LTTNG_ASSERT(ksess->consumer);
- DBG("Rotate kernel session %s started (session %" PRIu64 ")",
- session->name, session->id);
+ DBG("Rotate kernel session %s started (session %" PRIu64 ")", session->name, session->id);
rcu_read_lock();
* Note that this loop will end after one iteration given that there is
* only one kernel consumer.
*/
- cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
struct ltt_kernel_channel *chan;
/* For each channel, ask the consumer to rotate it. */
- cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
DBG("Rotate kernel channel %" PRIu64 ", session %s",
- chan->key, session->name);
- ret = consumer_rotate_channel(socket, chan->key,
- ksess->consumer,
- /* is_metadata_channel */ false);
+ chan->key,
+ session->name);
+ ret = consumer_rotate_channel(socket,
+ chan->key,
+ ksess->consumer,
+ /* is_metadata_channel */ false);
if (ret < 0) {
status = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
/*
* Rotate the metadata channel.
*/
- ret = consumer_rotate_channel(socket, ksess->metadata->key,
- ksess->consumer,
- /* is_metadata_channel */ true);
+ ret = consumer_rotate_channel(socket,
+ ksess->metadata->key,
+ ksess->consumer,
+ /* is_metadata_channel */ true);
if (ret < 0) {
status = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
return status;
}
-enum lttng_error_code kernel_create_channel_subdirectories(
- const struct ltt_kernel_session *ksess)
+enum lttng_error_code kernel_create_channel_subdirectories(const struct ltt_kernel_session *ksess)
{
enum lttng_error_code ret = LTTNG_OK;
enum lttng_trace_chunk_status chunk_status;
* of implicitly creating the channel's path.
*/
chunk_status = lttng_trace_chunk_create_subdirectory(
- ksess->current_trace_chunk,
- DEFAULT_KERNEL_TRACE_DIR "/" DEFAULT_INDEX_DIR);
+ ksess->current_trace_chunk, DEFAULT_KERNEL_TRACE_DIR "/" DEFAULT_INDEX_DIR);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
/* Validate kernel version */
- ret = kernel_validate_version(&the_kernel_tracer_version,
- &the_kernel_tracer_abi_version);
+ ret = kernel_validate_version(&the_kernel_tracer_version, &the_kernel_tracer_abi_version);
if (ret < 0) {
goto error_version;
}
}
if (ret < 1) {
WARN("Kernel tracer does not support buffer monitoring. "
- "The monitoring timer of channels in the kernel domain "
- "will be set to 0 (disabled).");
+ "The monitoring timer of channels in the kernel domain "
+ "will be set to 0 (disabled).");
}
ret = kernel_supports_event_notifiers();
} else {
enum event_notifier_error_accounting_status error_accounting_status;
enum lttng_error_code error_code_ret =
- kernel_create_event_notifier_group_notification_fd(
- &kernel_tracer_event_notifier_group_notification_fd);
+ kernel_create_event_notifier_group_notification_fd(
+ &kernel_tracer_event_notifier_group_notification_fd);
if (error_code_ret != LTTNG_OK) {
goto error_modules;
}
error_accounting_status = event_notifier_error_accounting_register_kernel(
- kernel_tracer_event_notifier_group_fd);
+ kernel_tracer_event_notifier_group_fd);
if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Failed to initialize event notifier error accounting for kernel tracer");
error_code_ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING;
}
kernel_token_to_event_notifier_rule_ht = cds_lfht_new(
- DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING,
- NULL);
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!kernel_token_to_event_notifier_rule_ht) {
goto error_token_ht;
}
}
DBG("Kernel tracer initialized: kernel tracer fd = %d, event notifier group fd = %d, event notifier group notification fd = %d",
- kernel_tracer_fd, kernel_tracer_event_notifier_group_fd,
- kernel_tracer_event_notifier_group_notification_fd);
+ kernel_tracer_fd,
+ kernel_tracer_event_notifier_group_fd,
+ kernel_tracer_event_notifier_group_notification_fd);
ret = syscall_init_table(kernel_tracer_fd);
if (ret < 0) {
ERR("Unable to populate syscall table. Syscall tracing won't "
- "work for this session daemon.");
+ "work for this session daemon.");
}
return 0;
modprobe_remove_lttng_control();
ret = close(kernel_tracer_fd);
if (ret) {
- PERROR("Failed to close kernel tracer file descriptor: fd = %d",
- kernel_tracer_fd);
+ PERROR("Failed to close kernel tracer file descriptor: fd = %d", kernel_tracer_fd);
}
kernel_tracer_fd = -1;
return LTTNG_ERR_KERN_VERSION;
-
error_token_ht:
ret = close(kernel_tracer_event_notifier_group_notification_fd);
if (ret) {
PERROR("Failed to close kernel tracer event notifier group notification file descriptor: fd = %d",
- kernel_tracer_event_notifier_group_notification_fd);
+ kernel_tracer_event_notifier_group_notification_fd);
}
kernel_tracer_event_notifier_group_notification_fd = -1;
ret = close(kernel_tracer_event_notifier_group_fd);
if (ret) {
PERROR("Failed to close kernel tracer event notifier group file descriptor: fd = %d",
- kernel_tracer_event_notifier_group_fd);
+ kernel_tracer_event_notifier_group_fd);
}
kernel_tracer_event_notifier_group_fd = -1;
ret = close(kernel_tracer_fd);
if (ret) {
- PERROR("Failed to close kernel tracer file descriptor: fd = %d",
- kernel_tracer_fd);
+ PERROR("Failed to close kernel tracer file descriptor: fd = %d", kernel_tracer_fd);
}
kernel_tracer_fd = -1;
DBG2("Closing kernel event notifier group notification file descriptor");
if (kernel_tracer_event_notifier_group_notification_fd >= 0) {
int ret = notification_thread_command_remove_tracer_event_source(
- the_notification_thread_handle,
- kernel_tracer_event_notifier_group_notification_fd);
+ the_notification_thread_handle,
+ kernel_tracer_event_notifier_group_notification_fd);
if (ret != LTTNG_OK) {
ERR("Failed to remove kernel event notifier notification from notification thread");
}
ret = close(kernel_tracer_event_notifier_group_notification_fd);
if (ret) {
PERROR("Failed to close kernel event notifier group notification file descriptor: fd = %d",
- kernel_tracer_event_notifier_group_notification_fd);
+ kernel_tracer_event_notifier_group_notification_fd);
}
kernel_tracer_event_notifier_group_notification_fd = -1;
}
if (kernel_token_to_event_notifier_rule_ht) {
- const int ret = cds_lfht_destroy(
- kernel_token_to_event_notifier_rule_ht, NULL);
+ const int ret = cds_lfht_destroy(kernel_token_to_event_notifier_rule_ht, NULL);
LTTNG_ASSERT(ret == 0);
}
if (ret) {
PERROR("Failed to close kernel event notifier group file descriptor: fd = %d",
- kernel_tracer_event_notifier_group_fd);
+ kernel_tracer_event_notifier_group_fd);
}
kernel_tracer_event_notifier_group_fd = -1;
if (ret) {
PERROR("Failed to close kernel tracer file descriptor: fd = %d",
- kernel_tracer_fd);
+ kernel_tracer_fd);
}
kernel_tracer_fd = -1;
LTTNG_ASSERT(ksess);
LTTNG_ASSERT(ksess->consumer);
- DBG("Clear kernel session %s (session %" PRIu64 ")",
- session->name, session->id);
+ DBG("Clear kernel session %s (session %" PRIu64 ")", session->name, session->id);
rcu_read_lock();
* Note that this loop will end after one iteration given that there is
* only one kernel consumer.
*/
- cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
- socket, node.node) {
+ cds_lfht_for_each_entry (ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
struct ltt_kernel_channel *chan;
/* For each channel, ask the consumer to clear it. */
- cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &ksess->channel_list.head, list) {
DBG("Clear kernel channel %" PRIu64 ", session %s",
- chan->key, session->name);
+ chan->key,
+ session->name);
ret = consumer_clear_channel(socket, chan->key);
if (ret < 0) {
goto error;
error:
switch (-ret) {
case LTTCOMM_CONSUMERD_RELAYD_CLEAR_DISALLOWED:
- status = LTTNG_ERR_CLEAR_RELAY_DISALLOWED;
- break;
+ status = LTTNG_ERR_CLEAR_RELAY_DISALLOWED;
+ break;
default:
- status = LTTNG_ERR_CLEAR_FAIL_CONSUMER;
- break;
+ status = LTTNG_ERR_CLEAR_FAIL_CONSUMER;
+ break;
}
end:
rcu_read_unlock();
return status;
}
-enum lttng_error_code kernel_create_event_notifier_group_notification_fd(
- int *event_notifier_group_notification_fd)
+enum lttng_error_code
+kernel_create_event_notifier_group_notification_fd(int *event_notifier_group_notification_fd)
{
int local_fd = -1, ret;
enum lttng_error_code error_code_ret;
LTTNG_ASSERT(event_notifier_group_notification_fd);
ret = kernctl_create_event_notifier_group_notification_fd(
- kernel_tracer_event_notifier_group_fd);
+ kernel_tracer_event_notifier_group_fd);
if (ret < 0) {
PERROR("Failed to create kernel event notifier group notification file descriptor");
error_code_ret = LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD;
ret = fcntl(local_fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
PERROR("Failed to set FD_CLOEXEC on kernel event notifier group notification file descriptor: fd = %d",
- local_fd);
+ local_fd);
error_code_ret = LTTNG_ERR_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD;
goto error;
}
- DBG("Created kernel notifier group notification file descriptor: fd = %d",
- local_fd);
+ DBG("Created kernel notifier group notification file descriptor: fd = %d", local_fd);
error_code_ret = LTTNG_OK;
*event_notifier_group_notification_fd = local_fd;
local_fd = -1;
ret = close(local_fd);
if (ret) {
PERROR("Failed to close kernel event notifier group notification file descriptor: fd = %d",
- local_fd);
+ local_fd);
}
}
return error_code_ret;
}
-enum lttng_error_code kernel_destroy_event_notifier_group_notification_fd(
- int event_notifier_group_notification_fd)
+enum lttng_error_code
+kernel_destroy_event_notifier_group_notification_fd(int event_notifier_group_notification_fd)
{
enum lttng_error_code ret_code = LTTNG_OK;
DBG("Closing event notifier group notification file descriptor: fd = %d",
- event_notifier_group_notification_fd);
+ event_notifier_group_notification_fd);
if (event_notifier_group_notification_fd >= 0) {
const int ret = close(event_notifier_group_notification_fd);
if (ret) {
PERROR("Failed to close event notifier group notification file descriptor: fd = %d",
- event_notifier_group_notification_fd);
+ event_notifier_group_notification_fd);
}
}
return ret_code;
}
-static
-unsigned long hash_trigger(const struct lttng_trigger *trigger)
+static unsigned long hash_trigger(const struct lttng_trigger *trigger)
{
- const struct lttng_condition *condition =
- lttng_trigger_get_const_condition(trigger);
+ const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
return lttng_condition_hash(condition);
}
-static
-int match_trigger(struct cds_lfht_node *node, const void *key)
+static int match_trigger(struct cds_lfht_node *node, const void *key)
{
const struct ltt_kernel_event_notifier_rule *event_notifier_rule;
const struct lttng_trigger *trigger = (lttng_trigger *) key;
- event_notifier_rule = caa_container_of(node,
- const struct ltt_kernel_event_notifier_rule, ht_node);
+ event_notifier_rule =
+ caa_container_of(node, const struct ltt_kernel_event_notifier_rule, ht_node);
return lttng_trigger_is_equal(trigger, event_notifier_rule->trigger);
}
static enum lttng_error_code kernel_create_event_notifier_rule(
- struct lttng_trigger *trigger,
- const struct lttng_credentials *creds, uint64_t token)
+ struct lttng_trigger *trigger, const struct lttng_credentials *creds, uint64_t token)
{
int err, fd, ret = 0;
enum lttng_error_code error_code_ret;
LTTNG_ASSERT(condition_type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
/* Does not acquire a reference. */
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(event_rule);
event_rule_type = lttng_event_rule_get_type(event_rule);
LTTNG_ASSERT(event_rule_type != LTTNG_EVENT_RULE_TYPE_UNKNOWN);
- error_code_ret = trace_kernel_create_event_notifier_rule(trigger, token,
- lttng_condition_event_rule_matches_get_error_counter_index(
- condition),
- &event_notifier_rule);
+ error_code_ret = trace_kernel_create_event_notifier_rule(
+ trigger,
+ token,
+ lttng_condition_event_rule_matches_get_error_counter_index(condition),
+ &event_notifier_rule);
if (error_code_ret != LTTNG_OK) {
goto error;
}
- error_code_ret = trace_kernel_init_event_notifier_from_event_rule(
- event_rule, &kernel_event_notifier);
+ error_code_ret = trace_kernel_init_event_notifier_from_event_rule(event_rule,
+ &kernel_event_notifier);
if (error_code_ret != LTTNG_OK) {
goto free_event;
}
kernel_event_notifier.event.token = event_notifier_rule->token;
kernel_event_notifier.error_counter_idx =
- lttng_condition_event_rule_matches_get_error_counter_index(
- condition);
+ lttng_condition_event_rule_matches_get_error_counter_index(condition);
- fd = kernctl_create_event_notifier(
- kernel_tracer_event_notifier_group_fd,
- &kernel_event_notifier);
+ fd = kernctl_create_event_notifier(kernel_tracer_event_notifier_group_fd,
+ &kernel_event_notifier);
if (fd < 0) {
switch (-fd) {
case EEXIST:
break;
case ENOENT:
WARN("Failed to create kernel event notifier: not found: name = '%s'",
- kernel_event_notifier.event.name);
+ kernel_event_notifier.event.name);
error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
break;
default:
PERROR("Failed to create kernel event notifier: error code = %d, name = '%s'",
- fd, kernel_event_notifier.event.name);
+ fd,
+ kernel_event_notifier.event.name);
error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
}
goto free_event;
err = fcntl(event_notifier_rule->fd, F_SETFD, FD_CLOEXEC);
if (err < 0) {
PERROR("Failed to set FD_CLOEXEC on kernel event notifier file descriptor: fd = %d",
- fd);
+ fd);
error_code_ret = LTTNG_ERR_FATAL;
goto set_cloexec_error;
}
}
}
- if (lttng_event_rule_get_type(event_rule) ==
- LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE) {
+ if (lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE) {
ret = userspace_probe_event_rule_add_callsites(
- event_rule, creds, event_notifier_rule->fd);
+ event_rule, creds, event_notifier_rule->fd);
if (ret) {
error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
goto add_callsite_error;
/* Set the capture bytecode if any. */
cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &capture_bytecode_count);
+ condition, &capture_bytecode_count);
LTTNG_ASSERT(cond_status == LTTNG_CONDITION_STATUS_OK);
for (i = 0; i < capture_bytecode_count; i++) {
const struct lttng_bytecode *capture_bytecode =
- lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_capture_bytecode_at_index(condition,
+ i);
if (capture_bytecode == NULL) {
ERR("Unexpected NULL capture bytecode on condition");
ret = kernctl_capture(event_notifier_rule->fd, capture_bytecode);
if (ret < 0) {
ERR("Failed to set capture bytecode on event notifier rule fd: fd = %d",
- event_notifier_rule->fd);
+ event_notifier_rule->fd);
error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
goto capture_error;
}
/* Add trigger to kernel token mapping in the hash table. */
rcu_read_lock();
- cds_lfht_add(kernel_token_to_event_notifier_rule_ht, hash_trigger(trigger),
- &event_notifier_rule->ht_node);
+ cds_lfht_add(kernel_token_to_event_notifier_rule_ht,
+ hash_trigger(trigger),
+ &event_notifier_rule->ht_node);
rcu_read_unlock();
DBG("Created kernel event notifier: name = '%s', fd = %d",
- kernel_event_notifier.event.name,
- event_notifier_rule->fd);
+ kernel_event_notifier.event.name,
+ event_notifier_rule->fd);
return LTTNG_OK;
enable_error:
set_cloexec_error:
filter_error:
- {
- const int close_ret = close(event_notifier_rule->fd);
+{
+ const int close_ret = close(event_notifier_rule->fd);
- if (close_ret) {
- PERROR("Failed to close kernel event notifier file descriptor: fd = %d",
- event_notifier_rule->fd);
- }
+ if (close_ret) {
+ PERROR("Failed to close kernel event notifier file descriptor: fd = %d",
+ event_notifier_rule->fd);
}
+}
free_event:
free(event_notifier_rule);
error:
return error_code_ret;
}
-enum lttng_error_code kernel_register_event_notifier(
- struct lttng_trigger *trigger,
- const struct lttng_credentials *cmd_creds)
+enum lttng_error_code kernel_register_event_notifier(struct lttng_trigger *trigger,
+ const struct lttng_credentials *cmd_creds)
{
enum lttng_error_code ret;
enum lttng_condition_status status;
enum lttng_domain_type domain_type;
const struct lttng_event_rule *event_rule;
- const struct lttng_condition *const condition =
- lttng_trigger_get_const_condition(trigger);
+ const struct lttng_condition *const condition = lttng_trigger_get_const_condition(trigger);
const uint64_t token = lttng_trigger_get_tracer_token(trigger);
LTTNG_ASSERT(condition);
/* Does not acquire a reference to the event rule. */
- status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
domain_type = lttng_event_rule_get_domain_type(event_rule);
return ret;
}
-enum lttng_error_code kernel_unregister_event_notifier(
- const struct lttng_trigger *trigger)
+enum lttng_error_code kernel_unregister_event_notifier(const struct lttng_trigger *trigger)
{
struct ltt_kernel_event_notifier_rule *token_event_rule_element;
struct cds_lfht_node *node;
rcu_read_lock();
cds_lfht_lookup(kernel_token_to_event_notifier_rule_ht,
- hash_trigger(trigger), match_trigger, trigger, &iter);
+ hash_trigger(trigger),
+ match_trigger,
+ trigger,
+ &iter);
node = cds_lfht_iter_get_node(&iter);
if (!node) {
goto error;
}
- token_event_rule_element = caa_container_of(node,
- struct ltt_kernel_event_notifier_rule, ht_node);
+ token_event_rule_element =
+ caa_container_of(node, struct ltt_kernel_event_notifier_rule, ht_node);
ret = kernel_disable_event_notifier_rule(token_event_rule_element);
if (ret) {
*/
#define _LGPL_SOURCE
-#include <stdbool.h>
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-syscall.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
-#include "lttng-sessiond.hpp"
-#include "kernel.hpp"
-#include "lttng-syscall.hpp"
-#include "utils.hpp"
+#include <stdbool.h>
/* Global syscall table. */
struct syscall *syscall_table;
char name[SYSCALL_NAME_LEN];
#if (SYSCALL_NAME_LEN == 255)
-#define SYSCALL_NAME_LEN_SCANF_IS_A_BROKEN_API "254"
+#define SYSCALL_NAME_LEN_SCANF_IS_A_BROKEN_API "254"
#endif
DBG3("Syscall init system call table");
}
while (fscanf(fp,
- "syscall { index = %zu; \
+ "syscall { index = %zu; \
name = %" SYSCALL_NAME_LEN_SCANF_IS_A_BROKEN_API "[^;]; \
bitness = %u; };\n",
- &index, name, &bitness) == 3) {
+ &index,
+ name,
+ &bitness) == 3) {
at_least_one_syscall = true;
if (index >= nbmem) {
struct syscall *new_list;
goto error;
}
- DBG("Reallocating syscall table from %zu to %zu entries", nbmem,
- new_nbmem);
- new_list = (struct syscall *) realloc(syscall_table, new_nbmem * sizeof(*new_list));
+ DBG("Reallocating syscall table from %zu to %zu entries", nbmem, new_nbmem);
+ new_list = (struct syscall *) realloc(syscall_table,
+ new_nbmem * sizeof(*new_list));
if (!new_list) {
ret = -errno;
PERROR("syscall list realloc");
}
/* Zero out the new memory. */
- memset(new_list + nbmem, 0,
- (new_nbmem - nbmem) * sizeof(*new_list));
+ memset(new_list + nbmem, 0, (new_nbmem - nbmem) * sizeof(*new_list));
nbmem = new_nbmem;
syscall_table = new_list;
}
syscall_table[index].index = index;
syscall_table[index].bitness = bitness;
- if (lttng_strncpy(syscall_table[index].name, name,
- sizeof(syscall_table[index].name))) {
+ if (lttng_strncpy(
+ syscall_table[index].name, name, sizeof(syscall_table[index].name))) {
ret = -EINVAL;
free(syscall_table);
syscall_table = NULL;
return;
}
- cds_lfht_for_each_entry(ht->ht, &iter.iter, ksyscall, node.node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, ksyscall, node.node) {
int ret;
ret = lttng_ht_del(ht, &iter);
* syscall at index in the syscall table.
*/
static void update_event_syscall_bitness(struct lttng_event *events,
- unsigned int index, unsigned int syscall_index)
+ unsigned int index,
+ unsigned int syscall_index)
{
LTTNG_ASSERT(events);
if (syscall_table[index].bitness == 32) {
- events[syscall_index].flags = (lttng_event_flag) (events[syscall_index].flags | LTTNG_EVENT_FLAG_SYSCALL_32);
+ events[syscall_index].flags = (lttng_event_flag) (events[syscall_index].flags |
+ LTTNG_EVENT_FLAG_SYSCALL_32);
} else {
- events[syscall_index].flags = (lttng_event_flag) (events[syscall_index].flags | LTTNG_EVENT_FLAG_SYSCALL_64);
+ events[syscall_index].flags = (lttng_event_flag) (events[syscall_index].flags |
+ LTTNG_EVENT_FLAG_SYSCALL_64);
}
}
*
* Return 0 on success else -LTTNG_ERR_NOMEM.
*/
-static int add_syscall_to_ht(struct lttng_ht *ht, unsigned int index,
- unsigned int syscall_index)
+static int add_syscall_to_ht(struct lttng_ht *ht, unsigned int index, unsigned int syscall_index)
{
int ret;
struct syscall *ksyscall;
goto error;
}
- strncpy(ksyscall->name, syscall_table[index].name,
- sizeof(ksyscall->name));
+ strncpy(ksyscall->name, syscall_table[index].name, sizeof(ksyscall->name));
ksyscall->bitness = syscall_table[index].bitness;
ksyscall->index = syscall_index;
lttng_ht_node_init_str(&ksyscall->node, ksyscall->name);
}
/* Copy the event information in the event's array. */
- strncpy(events[index].name, syscall_table[i].name,
- sizeof(events[index].name));
+ strncpy(events[index].name, syscall_table[i].name, sizeof(events[index].name));
update_event_syscall_bitness(events, i, index);
events[index].type = LTTNG_EVENT_SYSCALL;
/* This makes the command line not print the enabled/disabled field. */
*/
#define _LGPL_SOURCE
+#include "agent-thread.hpp"
+#include "agent.hpp"
+#include "buffer-registry.hpp"
+#include "channel.hpp"
+#include "client.hpp"
+#include "cmd.hpp"
+#include "consumer.hpp"
+#include "context.hpp"
+#include "dispatch.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "event.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "manage-apps.hpp"
+#include "manage-kernel.hpp"
+#include "modprobe.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread.hpp"
+#include "notify-apps.hpp"
+#include "register.hpp"
+#include "rotation-thread.hpp"
+#include "save.hpp"
+#include "sessiond-config.hpp"
+#include "testpoint.hpp"
+#include "thread.hpp"
+#include "timer.hpp"
+#include "ust-consumer.hpp"
+#include "ust-sigbus.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/socket.hpp>
+#include <common/config/session-config.hpp>
+#include <common/daemonize.hpp>
+#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/futex.hpp>
+#include <common/ini-config/ini-config.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/logging-utils.hpp>
+#include <common/path.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/event-internal.hpp>
+
+#include <ctype.h>
#include <getopt.h>
#include <grp.h>
+#include <inttypes.h>
#include <limits.h>
#include <paths.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <inttypes.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <urcu/uatomic.h>
#include <unistd.h>
-#include <ctype.h>
-
-#include <common/common.hpp>
-#include <common/compat/socket.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/defaults.hpp>
-#include <common/kernel-consumer/kernel-consumer.hpp>
-#include <common/futex.hpp>
-#include <common/relayd/relayd.hpp>
-#include <common/utils.hpp>
-#include <common/path.hpp>
-#include <common/daemonize.hpp>
-#include <common/config/session-config.hpp>
-#include <common/ini-config/ini-config.hpp>
-#include <common/dynamic-buffer.hpp>
-#include <common/logging-utils.hpp>
-
-#include <lttng/event-internal.hpp>
-#include "lttng-sessiond.hpp"
-#include "buffer-registry.hpp"
-#include "channel.hpp"
-#include "cmd.hpp"
-#include "consumer.hpp"
-#include "context.hpp"
-#include "event.hpp"
-#include "event-notifier-error-accounting.hpp"
-#include "kernel.hpp"
-#include "kernel-consumer.hpp"
-#include "lttng-ust-ctl.hpp"
-#include "ust-consumer.hpp"
-#include "utils.hpp"
-#include "fd-limit.hpp"
-#include "health-sessiond.hpp"
-#include "testpoint.hpp"
-#include "notify-apps.hpp"
-#include "agent-thread.hpp"
-#include "save.hpp"
-#include "notification-thread.hpp"
-#include "notification-thread-commands.hpp"
-#include "rotation-thread.hpp"
-#include "agent.hpp"
-#include "sessiond-config.hpp"
-#include "timer.hpp"
-#include "thread.hpp"
-#include "client.hpp"
-#include "dispatch.hpp"
-#include "register.hpp"
-#include "manage-apps.hpp"
-#include "manage-kernel.hpp"
-#include "modprobe.hpp"
-#include "ust-sigbus.hpp"
+#include <urcu/uatomic.h>
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
#include <lttng-sessiond.8.h>
#else
-NULL
+ NULL
#endif
-;
+ ;
#define EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX 65535
-#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR \
- "event-notifier-error-buffer-size"
+#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "event-notifier-error-buffer-size"
#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR \
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-kernel"
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-kernel"
#define EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR \
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-userspace"
-
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_BASE_OPTION_STR "-userspace"
const char *progname;
static int lockfile_fd = -1;
/*
* Section name to look for in the daemon configuration file.
*/
-static const char * const config_section_name = "sessiond";
+static const char *const config_section_name = "sessiond";
/* Am I root or not. Set to 1 if the daemon is running as root */
static int is_root;
return;
}
- DBG("Waiting for complete teardown of consumerd (PID: %d)",
- consumer_data->pid);
+ DBG("Waiting for complete teardown of consumerd (PID: %d)", consumer_data->pid);
ret = waitpid(consumer_data->pid, &status, 0);
if (ret == -1) {
PERROR("consumerd waitpid pid: %d", consumer_data->pid)
- } else if (!WIFEXITED(status)) {
- ERR("consumerd termination with error: %d",
- WEXITSTATUS(ret));
+ } else if (!WIFEXITED(status)) {
+ ERR("consumerd termination with error: %d", WEXITSTATUS(ret));
}
consumer_data->pid = 0;
}
PERROR("remove pidfile %s", the_config.pid_file_path.value);
}
- DBG("Removing sessiond and consumerd content of directory %s",
- the_config.rundir.value);
+ DBG("Removing sessiond and consumerd content of directory %s", the_config.rundir.value);
/* sessiond */
DBG("Removing %s", the_config.pid_file_path.value);
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-c, --client-sock");
+ "-c, --client-sock");
} else {
- config_string_set(&the_config.client_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.client_unix_sock_path, strdup(arg));
if (!the_config.client_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-a, --apps-sock");
+ "-a, --apps-sock");
} else {
- config_string_set(&the_config.apps_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.apps_unix_sock_path, strdup(arg));
if (!the_config.apps_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-g, --group");
+ "-g, --group");
} else {
- config_string_set(&the_config.tracing_group_name,
- strdup(arg));
+ config_string_set(&the_config.tracing_group_name, strdup(arg));
if (!the_config.tracing_group_name.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--kconsumerd-err-sock");
+ "--kconsumerd-err-sock");
} else {
- config_string_set(
- &the_config.kconsumerd_err_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.kconsumerd_err_unix_sock_path, strdup(arg));
if (!the_config.kconsumerd_err_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--kconsumerd-cmd-sock");
+ "--kconsumerd-cmd-sock");
} else {
- config_string_set(
- &the_config.kconsumerd_cmd_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.kconsumerd_cmd_unix_sock_path, strdup(arg));
if (!the_config.kconsumerd_cmd_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--ustconsumerd64-err-sock");
+ "--ustconsumerd64-err-sock");
} else {
- config_string_set(
- &the_config.consumerd64_err_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd64_err_unix_sock_path, strdup(arg));
if (!the_config.consumerd64_err_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--ustconsumerd64-cmd-sock");
+ "--ustconsumerd64-cmd-sock");
} else {
- config_string_set(
- &the_config.consumerd64_cmd_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd64_cmd_unix_sock_path, strdup(arg));
if (!the_config.consumerd64_cmd_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--ustconsumerd32-err-sock");
+ "--ustconsumerd32-err-sock");
} else {
- config_string_set(
- &the_config.consumerd32_err_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd32_err_unix_sock_path, strdup(arg));
if (!the_config.consumerd32_err_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--ustconsumerd32-cmd-sock");
+ "--ustconsumerd32-cmd-sock");
} else {
- config_string_set(
- &the_config.consumerd32_cmd_unix_sock_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd32_cmd_unix_sock_path, strdup(arg));
if (!the_config.consumerd32_cmd_unix_sock_path.value) {
ret = -ENOMEM;
PERROR("strdup");
}
/* Clamp value to [0, 3] */
the_config.verbose = the_config.verbose < 0 ?
- 0 :
- (the_config.verbose <= 3 ? the_config.verbose :
- 3);
+ 0 :
+ (the_config.verbose <= 3 ? the_config.verbose : 3);
} else if (string_match(optname, "verbose-consumer")) {
if (arg) {
the_config.verbose_consumer = config_parse_value(arg);
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--consumerd32-path");
+ "--consumerd32-path");
} else {
- config_string_set(&the_config.consumerd32_bin_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd32_bin_path, strdup(arg));
if (!the_config.consumerd32_bin_path.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--consumerd32-libdir");
+ "--consumerd32-libdir");
} else {
- config_string_set(&the_config.consumerd32_lib_dir,
- strdup(arg));
+ config_string_set(&the_config.consumerd32_lib_dir, strdup(arg));
if (!the_config.consumerd32_lib_dir.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--consumerd64-path");
+ "--consumerd64-path");
} else {
- config_string_set(&the_config.consumerd64_bin_path,
- strdup(arg));
+ config_string_set(&the_config.consumerd64_bin_path, strdup(arg));
if (!the_config.consumerd64_bin_path.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--consumerd64-libdir");
+ "--consumerd64-libdir");
} else {
- config_string_set(&the_config.consumerd64_lib_dir,
- strdup(arg));
+ config_string_set(&the_config.consumerd64_lib_dir, strdup(arg));
if (!the_config.consumerd64_lib_dir.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-p, --pidfile");
+ "-p, --pidfile");
} else {
- config_string_set(
- &the_config.pid_file_path, strdup(arg));
+ config_string_set(&the_config.pid_file_path, strdup(arg));
if (!the_config.pid_file_path.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--agent-tcp-port");
+ "--agent-tcp-port");
} else {
unsigned long v;
ERR("Port overflow in --agent-tcp-port parameter: %s", arg);
return -1;
}
- the_config.agent_tcp_port.begin =
- the_config.agent_tcp_port.end = (int) v;
+ the_config.agent_tcp_port.begin = the_config.agent_tcp_port.end = (int) v;
DBG3("Agent TCP port set to non default: %i", (int) v);
}
} else if (string_match(optname, "load") || opt == 'l') {
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-l, --load");
+ "-l, --load");
} else {
- config_string_set(&the_config.load_session_path,
- strdup(arg));
+ config_string_set(&the_config.load_session_path, strdup(arg));
if (!the_config.load_session_path.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--kmod-probes");
+ "--kmod-probes");
} else {
- config_string_set(&the_config.kmod_probes_list,
- strdup(arg));
+ config_string_set(&the_config.kmod_probes_list, strdup(arg));
if (!the_config.kmod_probes_list.value) {
PERROR("strdup");
ret = -ENOMEM;
}
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "--extra-kmod-probes");
+ "--extra-kmod-probes");
} else {
- config_string_set(&the_config.kmod_extra_probes_list,
- strdup(arg));
+ config_string_set(&the_config.kmod_extra_probes_list, strdup(arg));
if (!the_config.kmod_extra_probes_list.value) {
PERROR("strdup");
ret = -ENOMEM;
v = strtoul(arg, NULL, 0);
if (errno != 0 || !isdigit(arg[0])) {
ERR("Wrong value in --%s parameter: %s",
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, arg);
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR,
+ arg);
return -1;
}
if (v == 0 || v >= EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX) {
ERR("Value out of range for --%s parameter: %s",
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR, arg);
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_KERNEL_OPTION_STR,
+ arg);
return -1;
}
the_config.event_notifier_buffer_size_kernel = (int) v;
DBG3("Number of event notifier error buffer kernel size to non default: %i",
- the_config.event_notifier_buffer_size_kernel);
+ the_config.event_notifier_buffer_size_kernel);
goto end;
} else if (string_match(optname, EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR)) {
unsigned long v;
v = strtoul(arg, NULL, 0);
if (errno != 0 || !isdigit(arg[0])) {
ERR("Wrong value in --%s parameter: %s",
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, arg);
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR,
+ arg);
return -1;
}
if (v == 0 || v >= EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX) {
ERR("Value out of range for --%s parameter: %s",
- EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR, arg);
+ EVENT_NOTIFIER_ERROR_BUFFER_SIZE_USERSPACE_OPTION_STR,
+ arg);
return -1;
}
the_config.event_notifier_buffer_size_userspace = (int) v;
DBG3("Number of event notifier error buffer userspace size to non default: %i",
- the_config.event_notifier_buffer_size_userspace);
+ the_config.event_notifier_buffer_size_userspace);
goto end;
} else if (string_match(optname, "config") || opt == 'f') {
/* This is handled in set_options() thus silent skip. */
const char *opt_name = "unknown";
int i;
- for (i = 0; i < sizeof(long_options) / sizeof(struct option);
- i++) {
+ for (i = 0; i < sizeof(long_options) / sizeof(struct option); i++) {
if (opt == long_options[i].val) {
opt_name = long_options[i].name;
break;
}
}
- WARN("Invalid argument provided for option \"%s\", using default value.",
- opt_name);
+ WARN("Invalid argument provided for option \"%s\", using default value.", opt_name);
}
return ret;
* return value conventions.
*/
static int config_entry_handler(const struct config_entry *entry,
- void *unused __attribute__((unused)))
+ void *unused __attribute__((unused)))
{
int ret = 0, i;
}
}
- for (i = 0; i < (sizeof(long_options) / sizeof(struct option)) - 1;
- i++) {
-
+ for (i = 0; i < (sizeof(long_options) / sizeof(struct option)) - 1; i++) {
/* Ignore if not fully matched. */
if (strcmp(entry->name, long_options[i].name)) {
continue;
if (ret <= 0) {
if (ret) {
WARN("Invalid configuration value \"%s\" for option %s",
- entry->value, entry->name);
+ entry->value,
+ entry->name);
}
/* False, skip boolean config option. */
goto end;
return ret;
}
-static void print_version(void) {
+static void print_version(void)
+{
fprintf(stdout, "%s\n", VERSION);
}
char *config_path = NULL;
optstring = utils_generate_optstring(long_options,
- sizeof(long_options) / sizeof(struct option));
+ sizeof(long_options) / sizeof(struct option));
if (!optstring) {
ret = -ENOMEM;
goto end;
}
/* Check for the --config option */
- while ((c = getopt_long(argc, argv, optstring, long_options,
- &option_index)) != -1) {
+ while ((c = getopt_long(argc, argv, optstring, long_options, &option_index)) != -1) {
if (c == '?') {
ret = -EINVAL;
goto end;
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
- "-f, --config");
+ "-f, --config");
} else {
free(config_path);
config_path = utils_expand_path(optarg);
}
}
- ret = config_get_section_entries(config_path, config_section_name,
- config_entry_handler, NULL);
+ ret = config_get_section_entries(
+ config_path, config_section_name, config_entry_handler, NULL);
if (ret) {
if (ret > 0) {
ERR("Invalid configuration option at line %i", ret);
* getopt_long() will not set option_index if it encounters a
* short option.
*/
- c = getopt_long(argc, argv, optstring, long_options,
- &option_index);
+ c = getopt_long(argc, argv, optstring, long_options, &option_index);
if (c == -1) {
break;
}
* Pass NULL as the long option name if popt left the index
* unset.
*/
- ret = set_option(c, optarg,
- option_index < 0 ? NULL :
- long_options[option_index].name);
+ ret = set_option(
+ c, optarg, option_index < 0 ? NULL : long_options[option_index].name);
if (ret < 0) {
break;
}
int ret;
gid_t gid;
- ret = utils_get_group_id(
- the_config.tracing_group_name.value, true, &gid);
+ ret = utils_get_group_id(the_config.tracing_group_name.value, true, &gid);
if (ret) {
/* Default to root group. */
gid = 0;
/* lttng client socket path */
ret = chown(the_config.client_unix_sock_path.value, 0, gid);
if (ret < 0) {
- ERR("Unable to set group on %s",
- the_config.client_unix_sock_path.value);
+ ERR("Unable to set group on %s", the_config.client_unix_sock_path.value);
PERROR("chown");
}
/* kconsumer error socket path */
ret = chown(the_kconsumer_data.err_unix_sock_path, 0, 0);
if (ret < 0) {
- ERR("Unable to set group on %s",
- the_kconsumer_data.err_unix_sock_path);
+ ERR("Unable to set group on %s", the_kconsumer_data.err_unix_sock_path);
PERROR("chown");
}
/* 64-bit ustconsumer error socket path */
ret = chown(the_ustconsumer64_data.err_unix_sock_path, 0, 0);
if (ret < 0) {
- ERR("Unable to set group on %s",
- the_ustconsumer64_data.err_unix_sock_path);
+ ERR("Unable to set group on %s", the_ustconsumer64_data.err_unix_sock_path);
PERROR("chown");
}
/* 32-bit ustconsumer compat32 error socket path */
ret = chown(the_ustconsumer32_data.err_unix_sock_path, 0, 0);
if (ret < 0) {
- ERR("Unable to set group on %s",
- the_ustconsumer32_data.err_unix_sock_path);
+ ERR("Unable to set group on %s", the_ustconsumer32_data.err_unix_sock_path);
PERROR("chown");
}
if (is_root) {
gid_t gid;
- ret = utils_get_group_id(the_config.tracing_group_name.value,
- true, &gid);
+ ret = utils_get_group_id(the_config.tracing_group_name.value, true, &gid);
if (ret) {
/* Default to root group. */
gid = 0;
}
/* Create the consumerd error unix socket */
- consumer_data->err_sock =
- lttcomm_create_unix_sock(consumer_data->err_unix_sock_path);
+ consumer_data->err_sock = lttcomm_create_unix_sock(consumer_data->err_unix_sock_path);
if (consumer_data->err_sock < 0) {
ERR("Create unix sock failed: %s", consumer_data->err_unix_sock_path);
ret = -1;
}
/* File permission MUST be 660 */
- ret = chmod(consumer_data->err_unix_sock_path,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ ret = chmod(consumer_data->err_unix_sock_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret < 0) {
ERR("Set file permissions failed: %s", consumer_data->err_unix_sock_path);
PERROR("chmod");
* Simply stop all worker threads, leaving main() return gracefully after
* joining all threads and calling cleanup().
*/
-static void sighandler(int sig, siginfo_t *siginfo,
- void *arg __attribute__((unused)))
+static void sighandler(int sig, siginfo_t *siginfo, void *arg __attribute__((unused)))
{
switch (sig) {
case SIGINT:
goto end;
}
- ret = asprintf(&env_value, "LTTNG_UST_CLOCK_PLUGIN=%s",
- the_config.lttng_ust_clock_plugin.value);
+ ret = asprintf(
+ &env_value, "LTTNG_UST_CLOCK_PLUGIN=%s", the_config.lttng_ust_clock_plugin.value);
if (ret < 0) {
PERROR("asprintf");
goto end;
}
DBG("Updated LTTNG_UST_CLOCK_PLUGIN environment variable to \"%s\"",
- the_config.lttng_ust_clock_plugin.value);
+ the_config.lttng_ust_clock_plugin.value);
end:
return ret;
}
session_lock_list();
/* Initiate the destruction of all sessions. */
- cds_list_for_each_entry_safe(session, tmp,
- &session_list->head, list) {
+ cds_list_for_each_entry_safe (session, tmp, &session_list->head, list) {
if (!session_get(session)) {
continue;
}
goto unlock_session;
}
(void) cmd_stop_trace(session);
- (void) cmd_destroy_session(
- session, the_notification_thread_handle, NULL);
+ (void) cmd_destroy_session(session, the_notification_thread_handle, NULL);
unlock_session:
session_unlock(session);
session_put(session);
* List all triggers as "root" since we wish to unregister all triggers.
*/
ret_code = notification_thread_command_list_triggers(
- the_notification_thread_handle, creds.uid.value,
- &triggers);
+ the_notification_thread_handle, creds.uid.value, &triggers);
if (ret_code != LTTNG_OK) {
ERR("Failed to list triggers while unregistering all triggers");
goto end;
for (i = 0; i < trigger_count; i++) {
uid_t trigger_owner;
const char *trigger_name;
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
LTTNG_ASSERT(trigger);
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_owner);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
+ trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name :
+ "(anonymous)";
DBG("Unregistering trigger: trigger owner uid = %d, trigger name = '%s'",
- (int) trigger_owner, trigger_name);
+ (int) trigger_owner,
+ trigger_name);
- ret_code = cmd_unregister_trigger(&creds, trigger,
- the_notification_thread_handle);
+ ret_code = cmd_unregister_trigger(&creds, trigger, the_notification_thread_handle);
if (ret_code != LTTNG_OK) {
ERR("Failed to unregister trigger: trigger owner uid = %d, trigger name = '%s', error: '%s'",
- (int) trigger_owner, trigger_name,
- lttng_strerror(-ret_code));
+ (int) trigger_owner,
+ trigger_name,
+ lttng_strerror(-ret_code));
/* Continue to unregister the remaining triggers. */
}
}
* be leaked as the process forks a run-as worker (and performs
* no exec*()). The same would apply to any opened fd.
*/
- return run_as_create_worker(
- procname, run_as_worker_post_fork_cleanup, &the_config);
+ return run_as_create_worker(procname, run_as_worker_post_fork_cleanup, &the_config);
}
static void sessiond_uuid_log(void)
{
int ret = 0, retval = 0;
const char *env_app_timeout;
- struct lttng_pipe *ust32_channel_monitor_pipe = NULL,
- *ust64_channel_monitor_pipe = NULL,
- *kernel_channel_monitor_pipe = NULL;
+ struct lttng_pipe *ust32_channel_monitor_pipe = NULL, *ust64_channel_monitor_pipe = NULL,
+ *kernel_channel_monitor_pipe = NULL;
struct timer_thread_parameters timer_thread_parameters;
/* Rotation thread handle. */
struct rotation_thread_handle *rotation_thread_handle = NULL;
/* Apply config. */
lttng_opt_verbose = the_config.verbose;
lttng_opt_quiet = the_config.quiet;
- the_kconsumer_data.err_unix_sock_path =
- the_config.kconsumerd_err_unix_sock_path.value;
- the_kconsumer_data.cmd_unix_sock_path =
- the_config.kconsumerd_cmd_unix_sock_path.value;
- the_ustconsumer32_data.err_unix_sock_path =
- the_config.consumerd32_err_unix_sock_path.value;
- the_ustconsumer32_data.cmd_unix_sock_path =
- the_config.consumerd32_cmd_unix_sock_path.value;
- the_ustconsumer64_data.err_unix_sock_path =
- the_config.consumerd64_err_unix_sock_path.value;
- the_ustconsumer64_data.cmd_unix_sock_path =
- the_config.consumerd64_cmd_unix_sock_path.value;
+ the_kconsumer_data.err_unix_sock_path = the_config.kconsumerd_err_unix_sock_path.value;
+ the_kconsumer_data.cmd_unix_sock_path = the_config.kconsumerd_cmd_unix_sock_path.value;
+ the_ustconsumer32_data.err_unix_sock_path = the_config.consumerd32_err_unix_sock_path.value;
+ the_ustconsumer32_data.cmd_unix_sock_path = the_config.consumerd32_cmd_unix_sock_path.value;
+ the_ustconsumer64_data.err_unix_sock_path = the_config.consumerd64_err_unix_sock_path.value;
+ the_ustconsumer64_data.cmd_unix_sock_path = the_config.consumerd64_cmd_unix_sock_path.value;
set_clock_plugin_env();
sessiond_config_log(&the_config);
if (the_config.daemonize || the_config.background) {
int i;
- ret = lttng_daemonize(&the_child_ppid, &recv_child_signal,
- !the_config.background);
+ ret = lttng_daemonize(&the_child_ppid, &recv_child_signal, !the_config.background);
if (ret < 0) {
retval = -1;
goto exit_options;
goto stop_threads;
}
the_kconsumer_data.channel_monitor_pipe =
- lttng_pipe_release_writefd(
- kernel_channel_monitor_pipe);
+ lttng_pipe_release_writefd(kernel_channel_monitor_pipe);
if (the_kconsumer_data.channel_monitor_pipe < 0) {
retval = -1;
goto stop_threads;
goto stop_threads;
}
the_ustconsumer32_data.channel_monitor_pipe =
- lttng_pipe_release_writefd(ust32_channel_monitor_pipe);
+ lttng_pipe_release_writefd(ust32_channel_monitor_pipe);
if (the_ustconsumer32_data.channel_monitor_pipe < 0) {
retval = -1;
goto stop_threads;
retval = -1;
goto stop_threads;
}
- timer_thread_parameters.rotation_thread_job_queue =
- rotation_timer_queue;
+ timer_thread_parameters.rotation_thread_job_queue = rotation_timer_queue;
ust64_channel_monitor_pipe = lttng_pipe_open(0);
if (!ust64_channel_monitor_pipe) {
goto stop_threads;
}
the_ustconsumer64_data.channel_monitor_pipe =
- lttng_pipe_release_writefd(ust64_channel_monitor_pipe);
+ lttng_pipe_release_writefd(ust64_channel_monitor_pipe);
if (the_ustconsumer64_data.channel_monitor_pipe < 0) {
retval = -1;
goto stop_threads;
}
event_notifier_error_accounting_status = event_notifier_error_accounting_init(
- the_config.event_notifier_buffer_size_kernel,
- the_config.event_notifier_buffer_size_userspace);
+ the_config.event_notifier_buffer_size_kernel,
+ the_config.event_notifier_buffer_size_userspace);
if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Failed to initialize event notifier error accounting system");
retval = -1;
}
/* notification_thread_data acquires the pipes' read side. */
- the_notification_thread_handle = notification_thread_handle_create(
- ust32_channel_monitor_pipe, ust64_channel_monitor_pipe,
- kernel_channel_monitor_pipe);
+ the_notification_thread_handle =
+ notification_thread_handle_create(ust32_channel_monitor_pipe,
+ ust64_channel_monitor_pipe,
+ kernel_channel_monitor_pipe);
if (!the_notification_thread_handle) {
retval = -1;
ERR("Failed to create notification thread shared data");
}
/* Create notification thread. */
- notification_thread = launch_notification_thread(
- the_notification_thread_handle);
+ notification_thread = launch_notification_thread(the_notification_thread_handle);
if (!notification_thread) {
retval = -1;
goto stop_threads;
}
/* rotation_thread_data acquires the pipes' read side. */
- rotation_thread_handle = rotation_thread_handle_create(
- rotation_timer_queue, the_notification_thread_handle);
+ rotation_thread_handle =
+ rotation_thread_handle_create(rotation_timer_queue, the_notification_thread_handle);
if (!rotation_thread_handle) {
retval = -1;
ERR("Failed to create rotation thread shared data");
goto stop_threads;
}
- if (!launch_ust_dispatch_thread(&ust_cmd_queue, apps_cmd_pipe[1],
- apps_cmd_notify_pipe[1])) {
+ if (!launch_ust_dispatch_thread(&ust_cmd_queue, apps_cmd_pipe[1], apps_cmd_notify_pipe[1])) {
retval = -1;
goto stop_threads;
}
/* Create thread to manage application registration. */
- register_apps_thread = launch_application_registration_thread(
- &ust_cmd_queue);
+ register_apps_thread = launch_application_registration_thread(&ust_cmd_queue);
if (!register_apps_thread) {
retval = -1;
goto stop_threads;
if (kernel_get_notification_fd() >= 0) {
ret = notification_thread_command_add_tracer_event_source(
- the_notification_thread_handle,
- kernel_get_notification_fd(),
- LTTNG_DOMAIN_KERNEL);
+ the_notification_thread_handle,
+ kernel_get_notification_fd(),
+ LTTNG_DOMAIN_KERNEL);
if (ret != LTTNG_OK) {
ERR("Failed to add kernel trigger event source to notification thread");
retval = -1;
}
/* Load sessions. */
- ret = config_load_session(
- the_config.load_session_path.value, NULL, 1, 1, NULL);
+ ret = config_load_session(the_config.load_session_path.value, NULL, 1, 1, NULL);
if (ret) {
ERR("Session load failed: %s", error_get_str(ret));
retval = -1;
*/
if (is_root && !the_config.no_kernel) {
DBG("Unloading kernel modules");
- modprobe_remove_lttng_all();
+ modprobe_remove_lttng_all();
}
rcu_thread_offline();
* of the active session and channels at the moment of the teardown.
*/
if (the_notification_thread_handle) {
- notification_thread_handle_destroy(
- the_notification_thread_handle);
+ notification_thread_handle_destroy(the_notification_thread_handle);
}
lttng_pipe_destroy(ust32_channel_monitor_pipe);
lttng_pipe_destroy(ust64_channel_monitor_pipe);
*
*/
+#include "health-sessiond.hpp"
#include "manage-apps.hpp"
#include "testpoint.hpp"
-#include "health-sessiond.hpp"
-#include "utils.hpp"
#include "thread.hpp"
+#include "utils.hpp"
namespace {
struct thread_notifiers {
uint32_t nb_fd;
struct lttng_poll_event events;
struct thread_notifiers *notifiers = (thread_notifiers *) data;
- const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(
- notifiers->quit_pipe);
+ const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(notifiers->quit_pipe);
DBG("[thread] Manage application started");
goto error_poll_create;
}
- ret = lttng_poll_add(&events, notifiers->apps_cmd_pipe_read_fd,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(&events, notifiers->apps_cmd_pipe_read_fd, LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
goto error;
}
restart:
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- DBG("Apps thread return from poll on %d fds",
- LTTNG_POLL_GETNB(&events));
+ DBG("Apps thread return from poll on %d fds", LTTNG_POLL_GETNB(&events));
health_poll_exit();
if (ret < 0) {
/*
int sock;
/* Empty pipe */
- size_ret = lttng_read(
- notifiers->apps_cmd_pipe_read_fd,
- &sock, sizeof(sock));
+ size_ret = lttng_read(notifiers->apps_cmd_pipe_read_fd,
+ &sock,
+ sizeof(sock));
if (size_ret < sizeof(sock)) {
PERROR("read apps cmd pipe");
goto error;
/* Socket closed on remote end. */
ust_app_unregister(pollfd);
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
}
notifiers->apps_cmd_pipe_read_fd = apps_cmd_pipe_read_fd;
thread = lttng_thread_create("UST application management",
- thread_application_management,
- shutdown_application_management_thread,
- cleanup_application_management_thread,
- notifiers);
+ thread_application_management,
+ shutdown_application_management_thread,
+ cleanup_application_management_thread,
+ notifiers);
if (!thread) {
goto error;
}
*
*/
-#include <signal.h>
-
-#include <common/pipe.hpp>
-#include <common/utils.hpp>
-
+#include "health-sessiond.hpp"
#include "manage-consumer.hpp"
#include "testpoint.hpp"
-#include "health-sessiond.hpp"
-#include "utils.hpp"
#include "thread.hpp"
#include "ust-consumer.hpp"
+#include "utils.hpp"
+
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
+
+#include <signal.h>
namespace {
struct thread_notifiers {
sem_post(¬ifiers->ready);
}
-static void mark_thread_intialization_as_failed(
- struct thread_notifiers *notifiers)
+static void mark_thread_intialization_as_failed(struct thread_notifiers *notifiers)
{
ERR("Consumer management thread entering error state");
notifiers->initialization_result = -1;
DBG2("Receiving code from consumer err_sock");
/* Getting status code from kconsumerd */
- ret = lttcomm_recv_unix_sock(sock, &code,
- sizeof(enum lttcomm_return_code));
+ ret = lttcomm_recv_unix_sock(sock, &code, sizeof(enum lttcomm_return_code));
if (ret <= 0) {
mark_thread_intialization_as_failed(notifiers);
goto error;
health_code_update();
if (code != LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) {
ERR("consumer error when waiting for SOCK_READY : %s",
- lttcomm_get_readable_code((lttcomm_return_code) -code));
+ lttcomm_get_readable_code((lttcomm_return_code) -code));
mark_thread_intialization_as_failed(notifiers);
goto error;
}
/* Connect both command and metadata sockets. */
- consumer_data->cmd_sock =
- lttcomm_connect_unix_sock(
- consumer_data->cmd_unix_sock_path);
- consumer_data->metadata_fd =
- lttcomm_connect_unix_sock(
- consumer_data->cmd_unix_sock_path);
+ consumer_data->cmd_sock = lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
+ consumer_data->metadata_fd = lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
if (consumer_data->cmd_sock < 0 || consumer_data->metadata_fd < 0) {
PERROR("consumer connect cmd socket");
mark_thread_intialization_as_failed(notifiers);
pthread_mutex_init(consumer_data->metadata_sock.lock, NULL);
DBG("Consumer command socket ready (fd: %d)", consumer_data->cmd_sock);
- DBG("Consumer metadata socket ready (fd: %d)",
- consumer_data->metadata_fd);
+ DBG("Consumer metadata socket ready (fd: %d)", consumer_data->metadata_fd);
/*
* Remove the consumerd error sock since we've established a connection.
}
/* Add metadata socket that is successfully connected. */
- ret = lttng_poll_add(&events, consumer_data->metadata_fd,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(&events, consumer_data->metadata_fd, LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
mark_thread_intialization_as_failed(notifiers);
goto error;
pthread_mutex_unlock(cmd_socket_wrapper->lock);
ret = consumer_send_channel_monitor_pipe(cmd_socket_wrapper,
- consumer_data->channel_monitor_pipe);
+ consumer_data->channel_monitor_pipe);
if (ret) {
mark_thread_intialization_as_failed(notifiers);
goto error;
should_quit = 1;
} else if (pollfd == sock) {
/* Event on the consumerd socket */
- if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)
- && !(revents & LPOLLIN)) {
+ if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP) &&
+ !(revents & LPOLLIN)) {
ERR("consumer err socket second poll error");
goto error;
}
health_code_update();
/* Wait for any kconsumerd error */
- ret = lttcomm_recv_unix_sock(sock, &code,
- sizeof(enum lttcomm_return_code));
+ ret = lttcomm_recv_unix_sock(
+ sock, &code, sizeof(enum lttcomm_return_code));
if (ret <= 0) {
ERR("consumer closed the command socket");
goto error;
}
ERR("consumer return code : %s",
- lttcomm_get_readable_code((lttcomm_return_code) -code));
+ lttcomm_get_readable_code((lttcomm_return_code) -code));
goto exit;
} else if (pollfd == consumer_data->metadata_fd) {
- if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)
- && !(revents & LPOLLIN)) {
+ if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP) &&
+ !(revents & LPOLLIN)) {
ERR("consumer err metadata socket second poll error");
goto error;
}
/* UST metadata requests */
- ret = ust_consumer_metadata_request(
- &consumer_data->metadata_sock);
+ ret = ust_consumer_metadata_request(&consumer_data->metadata_sock);
if (ret < 0) {
ERR("Handling metadata request");
goto error;
if (consumer_data->type == LTTNG_CONSUMER_KERNEL) {
uatomic_set(&the_kernel_consumerd_state, CONSUMER_ERROR);
} else if (consumer_data->type == LTTNG_CONSUMER64_UST ||
- consumer_data->type == LTTNG_CONSUMER32_UST) {
+ consumer_data->type == LTTNG_CONSUMER32_UST) {
uatomic_set(&the_ust_consumerd_state, CONSUMER_ERROR);
} else {
/* Code flow error... */
}
consumer_data->cmd_sock = -1;
}
- if (consumer_data->metadata_sock.fd_ptr &&
- *consumer_data->metadata_sock.fd_ptr >= 0) {
+ if (consumer_data->metadata_sock.fd_ptr && *consumer_data->metadata_sock.fd_ptr >= 0) {
ret = close(*consumer_data->metadata_sock.fd_ptr);
if (ret) {
PERROR("close");
sem_init(¬ifiers->ready, 0, 0);
thread = lttng_thread_create("Consumer management",
- thread_consumer_management,
- shutdown_consumer_management_thread,
- cleanup_consumer_management_thread,
- notifiers);
+ thread_consumer_management,
+ shutdown_consumer_management_thread,
+ cleanup_consumer_management_thread,
+ notifiers);
if (!thread) {
goto error;
}
*
*/
-#include <common/pipe.hpp>
-#include <common/utils.hpp>
-
+#include "health-sessiond.hpp"
+#include "kernel-consumer.hpp"
+#include "kernel.hpp"
#include "manage-kernel.hpp"
#include "testpoint.hpp"
-#include "health-sessiond.hpp"
-#include "utils.hpp"
#include "thread.hpp"
-#include "kernel.hpp"
-#include "kernel-consumer.hpp"
+#include "utils.hpp"
+
+#include <common/pipe.hpp>
+#include <common/utils.hpp>
namespace {
struct thread_notifiers {
DBG("Updating kernel poll set");
session_lock_list();
- cds_list_for_each_entry(session, &session_list->head, list) {
+ cds_list_for_each_entry (session, &session_list->head, list) {
if (!session_get(session)) {
continue;
}
continue;
}
- cds_list_for_each_entry(channel,
- &session->kernel_session->channel_list.head, list) {
+ cds_list_for_each_entry (
+ channel, &session->kernel_session->channel_list.head, list) {
/* Add channel fd to the kernel poll set */
ret = lttng_poll_add(events, channel->fd, LPOLLIN | LPOLLRDNORM);
if (ret < 0) {
DBG("Updating kernel streams for channel fd %d", fd);
session_lock_list();
- cds_list_for_each_entry(session, &session_list->head, list) {
+ cds_list_for_each_entry (session, &session_list->head, list) {
if (!session_get(session)) {
continue;
}
}
ksess = session->kernel_session;
- cds_list_for_each_entry(channel,
- &ksess->channel_list.head, list) {
+ cds_list_for_each_entry (channel, &ksess->channel_list.head, list) {
struct lttng_ht_iter iter;
struct consumer_socket *socket;
* means that tracing is started so it is safe to send
* our updated stream fds.
*/
- if (ksess->consumer_fds_sent != 1
- || ksess->consumer == NULL) {
+ if (ksess->consumer_fds_sent != 1 || ksess->consumer == NULL) {
ret = -1;
goto error;
}
rcu_read_lock();
- cds_lfht_for_each_entry(ksess->consumer->socks->ht,
- &iter.iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
- ret = kernel_consumer_send_channel_streams(socket,
- channel, ksess,
- session->output_traces ? 1 : 0);
+ ret = kernel_consumer_send_channel_streams(
+ socket, channel, ksess, session->output_traces ? 1 : 0);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
rcu_read_unlock();
goto error_poll_create;
}
- ret = lttng_poll_add(&events,
- notifiers->kernel_poll_pipe_read_fd,
- LPOLLIN);
+ ret = lttng_poll_add(&events, notifiers->kernel_poll_pipe_read_fd, LPOLLIN);
if (ret < 0) {
goto error;
}
- ret = lttng_poll_add(&events,
- thread_quit_pipe_fd,
- LPOLLIN);
+ ret = lttng_poll_add(&events, thread_quit_pipe_fd, LPOLLIN);
if (ret < 0) {
goto error;
}
restart:
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- DBG("Thread kernel return from poll on %d fds",
- LTTNG_POLL_GETNB(&events));
+ DBG("Thread kernel return from poll on %d fds", LTTNG_POLL_GETNB(&events));
health_poll_exit();
if (ret < 0) {
/*
} else if (ret == 0) {
/* Should not happen since timeout is infinite */
ERR("Return value of poll is 0 with an infinite timeout.\n"
- "This should not have happened! Continuing...");
+ "This should not have happened! Continuing...");
continue;
}
/* Check for data on kernel pipe */
if (revents & LPOLLIN) {
if (pollfd == notifiers->kernel_poll_pipe_read_fd) {
- (void) lttng_read(notifiers->kernel_poll_pipe_read_fd,
- &tmp, 1);
+ (void) lttng_read(
+ notifiers->kernel_poll_pipe_read_fd, &tmp, 1);
/*
- * Ret value is useless here, if this pipe gets any actions an
- * update is required anyway.
+ * Ret value is useless here, if this pipe gets any actions
+ * an update is required anyway.
*/
update_poll_flag = 1;
continue;
health_error();
ERR("Health error occurred in %s", __func__);
WARN("Kernel thread died unexpectedly. "
- "Kernel tracing can continue but CPU hotplug is disabled.");
+ "Kernel tracing can continue but CPU hotplug is disabled.");
}
health_unregister(the_health_sessiond);
DBG("Kernel thread dying");
notifiers->kernel_poll_pipe_read_fd = kernel_poll_pipe_read_fd;
thread = lttng_thread_create("Kernel management",
- thread_kernel_management,
- shutdown_kernel_management_thread,
- cleanup_kernel_management_thread,
- notifiers);
+ thread_kernel_management,
+ shutdown_kernel_management_thread,
+ cleanup_kernel_management_thread,
+ notifiers);
if (!thread) {
goto error;
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
+#include "kern-modules.hpp"
+#include "lttng-sessiond.hpp"
+#include "modprobe.hpp"
#include <common/common.hpp>
#include <common/utils.hpp>
-#include "modprobe.hpp"
-#include "kern-modules.hpp"
-#include "lttng-sessiond.hpp"
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
/* LTTng kernel tracer mandatory core modules list */
struct kern_modules_param kern_modules_control_core[] = {
/**
* @brief Logging function for libkmod integration.
*/
-static ATTR_FORMAT_PRINTF(6, 0)
-void log_kmod(void *data __attribute__((unused)),
- int priority __attribute__((unused)),
- const char *file __attribute__((unused)),
- int line __attribute__((unused)),
- const char *fn __attribute__((unused)),
- const char *format, va_list args)
+static ATTR_FORMAT_PRINTF(6, 0) void log_kmod(void *data __attribute__((unused)),
+ int priority __attribute__((unused)),
+ const char *file __attribute__((unused)),
+ int line __attribute__((unused)),
+ const char *fn __attribute__((unused)),
+ const char *format,
+ va_list args)
{
char *str;
* @returns \c 0 on success
* \c < 0 on error
*/
-static int modprobe_lttng(struct kern_modules_param *modules,
- int entries)
+static int modprobe_lttng(struct kern_modules_param *modules, int entries)
{
int ret = 0, i;
struct kmod_ctx *ctx;
goto error;
}
- ret = kmod_module_probe_insert_module(mod, 0,
- NULL, NULL, NULL, NULL);
+ ret = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
if (ret == -EEXIST) {
DBG("Module %s is already loaded", modules[i].name);
ret = 0;
} else if (ret < 0) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
- ERR("Unable to load required module %s",
- modules[i].name);
+ ERR("Unable to load required module %s", modules[i].name);
goto error;
} else {
DBG("Unable to load optional module %s; continuing",
- modules[i].name);
+ modules[i].name);
ret = 0;
}
} else {
* @returns \c 0 on success
* \c < 0 on error
*/
-static int rmmod_recurse(struct kmod_module *mod) {
+static int rmmod_recurse(struct kmod_module *mod)
+{
int ret = 0;
struct kmod_list *deps, *itr;
deps = kmod_module_get_dependencies(mod);
if (deps != NULL) {
- kmod_list_foreach(itr, deps) {
+ kmod_list_foreach(itr, deps)
+ {
struct kmod_module *dep = kmod_module_get_module(itr);
if (kmod_module_get_refcnt(dep) == 0) {
- DBG("Recursive remove module %s",
- kmod_module_get_name(dep));
+ DBG("Recursive remove module %s", kmod_module_get_name(dep));
rmmod_recurse(dep);
}
kmod_module_unref(dep);
* @param entries Number of modules in the list
*
*/
-static void modprobe_remove_lttng(const struct kern_modules_param *modules,
- int entries)
+static void modprobe_remove_lttng(const struct kern_modules_param *modules, int entries)
{
int ret = 0, i;
struct kmod_ctx *ctx;
ret = rmmod_recurse(mod);
if (ret == -EEXIST) {
DBG("Module %s is not in kernel.", modules[i].name);
- } else if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED && ret < 0) {
+ } else if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED &&
+ ret < 0) {
ERR("Unable to remove module %s", modules[i].name);
} else {
- DBG("Modprobe removal successful %s",
- modules[i].name);
+ DBG("Modprobe removal successful %s", modules[i].name);
}
kmod_module_unref(mod);
#else /* HAVE_KMOD */
-static int modprobe_lttng(struct kern_modules_param *modules,
- int entries)
+static int modprobe_lttng(struct kern_modules_param *modules, int entries)
{
int ret = 0, i;
char modprobe[256];
for (i = 0; i < entries; i++) {
- ret = snprintf(modprobe, sizeof(modprobe),
- "/sbin/modprobe %s%s",
- modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED ? "" : "-q ",
- modules[i].name);
+ ret = snprintf(modprobe,
+ sizeof(modprobe),
+ "/sbin/modprobe %s%s",
+ modules[i].load_policy ==
+ KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED ?
+ "" :
+ "-q ",
+ modules[i].name);
if (ret < 0) {
PERROR("snprintf modprobe");
goto error;
if (ret == -1) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
ERR("Unable to launch modprobe for required module %s",
- modules[i].name);
+ modules[i].name);
goto error;
} else {
DBG("Unable to launch modprobe for optional module %s; continuing",
- modules[i].name);
+ modules[i].name);
ret = 0;
}
} else if (WEXITSTATUS(ret) != 0) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
- ERR("Unable to load required module %s",
- modules[i].name);
+ ERR("Unable to load required module %s", modules[i].name);
goto error;
} else {
DBG("Unable to load optional module %s; continuing",
- modules[i].name);
+ modules[i].name);
ret = 0;
}
} else {
return ret;
}
-static void modprobe_remove_lttng(const struct kern_modules_param *modules,
- int entries)
+static void modprobe_remove_lttng(const struct kern_modules_param *modules, int entries)
{
int ret = 0, i;
char modprobe[256];
if (!modules[i].loaded) {
continue;
}
- ret = snprintf(modprobe, sizeof(modprobe),
- "/sbin/modprobe -r -q %s",
- modules[i].name);
+ ret = snprintf(
+ modprobe, sizeof(modprobe), "/sbin/modprobe -r -q %s", modules[i].name);
if (ret < 0) {
PERROR("snprintf modprobe -r");
return;
if (ret == -1) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
ERR("Unable to launch modprobe -r for required module %s",
- modules[i].name);
+ modules[i].name);
} else {
DBG("Unable to launch modprobe -r for optional module %s",
- modules[i].name);
+ modules[i].name);
}
} else if (WEXITSTATUS(ret) != 0) {
if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
- ERR("Unable to remove required module %s",
- modules[i].name);
+ ERR("Unable to remove required module %s", modules[i].name);
} else {
- DBG("Unable to remove optional module %s",
- modules[i].name);
+ DBG("Unable to remove optional module %s", modules[i].name);
}
} else {
DBG("Modprobe removal successful %s", modules[i].name);
*/
void modprobe_remove_lttng_control(void)
{
- modprobe_remove_lttng(kern_modules_control_core,
- ARRAY_SIZE(kern_modules_control_core));
+ modprobe_remove_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
static void free_probes(void)
*/
int modprobe_lttng_control(void)
{
- return modprobe_lttng(kern_modules_control_core,
- ARRAY_SIZE(kern_modules_control_core));
+ return modprobe_lttng(kern_modules_control_core, ARRAY_SIZE(kern_modules_control_core));
}
/**
nr_probes = probes_capacity = def_len;
for (i = 0; i < def_len; ++i) {
- char* name = strdup(kern_modules_probes_default[i].name);
+ char *name = strdup(kern_modules_probes_default[i].name);
if (!name) {
PERROR("strdup probe item");
*
*/
-#include <lttng/trigger/trigger.h>
-#include <lttng/lttng-error.h>
-#include "notification-thread.hpp"
#include "notification-thread-commands.hpp"
+#include "notification-thread.hpp"
+
#include <common/error.hpp>
-#include <unistd.h>
-#include <stdint.h>
+
+#include <lttng/lttng-error.h>
+#include <lttng/trigger/trigger.h>
+
#include <inttypes.h>
+#include <stdint.h>
+#include <unistd.h>
-static
-void init_notification_thread_command(struct notification_thread_command *cmd)
+static void init_notification_thread_command(struct notification_thread_command *cmd)
{
CDS_INIT_LIST_HEAD(&cmd->cmd_list_node);
lttng_waiter_init(&cmd->reply_waiter);
}
-static
-int run_command_wait(struct notification_thread_handle *handle,
- struct notification_thread_command *cmd)
+static int run_command_wait(struct notification_thread_handle *handle,
+ struct notification_thread_command *cmd)
{
int ret;
uint64_t notification_counter = 1;
pthread_mutex_lock(&handle->cmd_queue.lock);
/* Add to queue. */
- cds_list_add_tail(&cmd->cmd_list_node,
- &handle->cmd_queue.list);
+ cds_list_add_tail(&cmd->cmd_list_node, &handle->cmd_queue.list);
/* Wake-up thread. */
- ret = lttng_write(handle->cmd_queue.event_fd,
- ¬ification_counter, sizeof(notification_counter));
+ ret = lttng_write(
+ handle->cmd_queue.event_fd, ¬ification_counter, sizeof(notification_counter));
if (ret != sizeof(notification_counter)) {
PERROR("write to notification thread's queue event fd");
/*
return -1;
}
-static
-struct notification_thread_command *notification_thread_command_copy(
- const struct notification_thread_command *original_cmd)
+static struct notification_thread_command *
+notification_thread_command_copy(const struct notification_thread_command *original_cmd)
{
struct notification_thread_command *new_cmd;
return new_cmd;
}
-static
-int run_command_no_wait(struct notification_thread_handle *handle,
- const struct notification_thread_command *in_cmd)
+static int run_command_no_wait(struct notification_thread_handle *handle,
+ const struct notification_thread_command *in_cmd)
{
int ret;
uint64_t notification_counter = 1;
- struct notification_thread_command *new_cmd =
- notification_thread_command_copy(in_cmd);
+ struct notification_thread_command *new_cmd = notification_thread_command_copy(in_cmd);
if (!new_cmd) {
goto error;
pthread_mutex_lock(&handle->cmd_queue.lock);
/* Add to queue. */
- cds_list_add_tail(&new_cmd->cmd_list_node,
- &handle->cmd_queue.list);
+ cds_list_add_tail(&new_cmd->cmd_list_node, &handle->cmd_queue.list);
/* Wake-up thread. */
- ret = lttng_write(handle->cmd_queue.event_fd,
- ¬ification_counter, sizeof(notification_counter));
+ ret = lttng_write(
+ handle->cmd_queue.event_fd, ¬ification_counter, sizeof(notification_counter));
if (ret != sizeof(notification_counter)) {
PERROR("write to notification thread's queue event fd");
/*
return -1;
}
-enum lttng_error_code notification_thread_command_register_trigger(
- struct notification_thread_handle *handle,
- struct lttng_trigger *trigger,
- bool is_trigger_anonymous)
+enum lttng_error_code
+notification_thread_command_register_trigger(struct notification_thread_handle *handle,
+ struct lttng_trigger *trigger,
+ bool is_trigger_anonymous)
{
int ret;
enum lttng_error_code ret_code;
cmd.type = NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER;
lttng_trigger_get(trigger);
cmd.parameters.register_trigger.trigger = trigger;
- cmd.parameters.register_trigger.is_trigger_anonymous =
- is_trigger_anonymous;
+ cmd.parameters.register_trigger.is_trigger_anonymous = is_trigger_anonymous;
ret = run_command_wait(handle, &cmd);
if (ret) {
return ret_code;
}
-enum lttng_error_code notification_thread_command_unregister_trigger(
- struct notification_thread_handle *handle,
- const struct lttng_trigger *trigger)
+enum lttng_error_code
+notification_thread_command_unregister_trigger(struct notification_thread_handle *handle,
+ const struct lttng_trigger *trigger)
{
int ret;
enum lttng_error_code ret_code;
return ret_code;
}
-enum lttng_error_code notification_thread_command_add_session(
- struct notification_thread_handle *handle,
- uint64_t session_id, const char *session_name, uid_t session_uid, gid_t session_gid)
+enum lttng_error_code
+notification_thread_command_add_session(struct notification_thread_handle *handle,
+ uint64_t session_id,
+ const char *session_name,
+ uid_t session_uid,
+ gid_t session_gid)
{
int ret;
enum lttng_error_code ret_code;
return ret_code;
}
-enum lttng_error_code notification_thread_command_remove_session(
- struct notification_thread_handle *handle,
- uint64_t session_id)
+enum lttng_error_code
+notification_thread_command_remove_session(struct notification_thread_handle *handle,
+ uint64_t session_id)
{
int ret;
enum lttng_error_code ret_code;
return ret_code;
}
-enum lttng_error_code notification_thread_command_add_channel(
- struct notification_thread_handle *handle,
- uint64_t session_id,
- char *channel_name, uint64_t key,
- enum lttng_domain_type domain, uint64_t capacity)
+enum lttng_error_code
+notification_thread_command_add_channel(struct notification_thread_handle *handle,
+ uint64_t session_id,
+ char *channel_name,
+ uint64_t key,
+ enum lttng_domain_type domain,
+ uint64_t capacity)
{
int ret;
enum lttng_error_code ret_code;
}
enum lttng_error_code notification_thread_command_remove_channel(
- struct notification_thread_handle *handle,
- uint64_t key, enum lttng_domain_type domain)
+ struct notification_thread_handle *handle, uint64_t key, enum lttng_domain_type domain)
{
int ret;
enum lttng_error_code ret_code;
return ret_code;
}
-enum lttng_error_code notification_thread_command_session_rotation_ongoing(
- struct notification_thread_handle *handle,
- uint64_t session_id,
- uint64_t trace_archive_chunk_id)
+enum lttng_error_code
+notification_thread_command_session_rotation_ongoing(struct notification_thread_handle *handle,
+ uint64_t session_id,
+ uint64_t trace_archive_chunk_id)
{
int ret;
enum lttng_error_code ret_code;
cmd.type = NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING;
cmd.parameters.session_rotation.session_id = session_id;
- cmd.parameters.session_rotation.trace_archive_chunk_id =
- trace_archive_chunk_id;
+ cmd.parameters.session_rotation.trace_archive_chunk_id = trace_archive_chunk_id;
ret = run_command_wait(handle, &cmd);
if (ret) {
}
enum lttng_error_code notification_thread_command_session_rotation_completed(
- struct notification_thread_handle *handle,
- uint64_t session_id,
- uint64_t trace_archive_chunk_id,
- struct lttng_trace_archive_location *location)
+ struct notification_thread_handle *handle,
+ uint64_t session_id,
+ uint64_t trace_archive_chunk_id,
+ struct lttng_trace_archive_location *location)
{
int ret;
enum lttng_error_code ret_code;
cmd.type = NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED;
cmd.parameters.session_rotation.session_id = session_id;
- cmd.parameters.session_rotation.trace_archive_chunk_id =
- trace_archive_chunk_id;
+ cmd.parameters.session_rotation.trace_archive_chunk_id = trace_archive_chunk_id;
cmd.parameters.session_rotation.location = location;
ret = run_command_wait(handle, &cmd);
return ret_code;
}
-enum lttng_error_code notification_thread_command_add_tracer_event_source(
- struct notification_thread_handle *handle,
- int tracer_event_source_fd,
- enum lttng_domain_type domain)
+enum lttng_error_code
+notification_thread_command_add_tracer_event_source(struct notification_thread_handle *handle,
+ int tracer_event_source_fd,
+ enum lttng_domain_type domain)
{
int ret;
enum lttng_error_code ret_code;
init_notification_thread_command(&cmd);
cmd.type = NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE;
- cmd.parameters.tracer_event_source.tracer_event_source_fd =
- tracer_event_source_fd;
+ cmd.parameters.tracer_event_source.tracer_event_source_fd = tracer_event_source_fd;
cmd.parameters.tracer_event_source.domain = domain;
ret = run_command_wait(handle, &cmd);
return ret_code;
}
-enum lttng_error_code notification_thread_command_remove_tracer_event_source(
- struct notification_thread_handle *handle,
- int tracer_event_source_fd)
+enum lttng_error_code
+notification_thread_command_remove_tracer_event_source(struct notification_thread_handle *handle,
+ int tracer_event_source_fd)
{
int ret;
enum lttng_error_code ret_code;
init_notification_thread_command(&cmd);
cmd.type = NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE;
- cmd.parameters.tracer_event_source.tracer_event_source_fd =
- tracer_event_source_fd;
+ cmd.parameters.tracer_event_source.tracer_event_source_fd = tracer_event_source_fd;
ret = run_command_wait(handle, &cmd);
if (ret) {
}
enum lttng_error_code notification_thread_command_list_triggers(
- struct notification_thread_handle *handle,
- uid_t uid,
- struct lttng_triggers **triggers)
+ struct notification_thread_handle *handle, uid_t uid, struct lttng_triggers **triggers)
{
int ret;
enum lttng_error_code ret_code;
return ret_code;
}
-void notification_thread_command_quit(
- struct notification_thread_handle *handle)
+void notification_thread_command_quit(struct notification_thread_handle *handle)
{
int ret;
struct notification_thread_command cmd = {};
}
int notification_thread_client_communication_update(
- struct notification_thread_handle *handle,
- notification_client_id id,
- enum client_transmission_status transmission_status)
+ struct notification_thread_handle *handle,
+ notification_client_id id,
+ enum client_transmission_status transmission_status)
{
struct notification_thread_command cmd = {};
return run_command_no_wait(handle, &cmd);
}
-enum lttng_error_code notification_thread_command_get_trigger(
- struct notification_thread_handle *handle,
- const struct lttng_trigger *trigger,
- struct lttng_trigger **real_trigger)
+enum lttng_error_code
+notification_thread_command_get_trigger(struct notification_thread_handle *handle,
+ const struct lttng_trigger *trigger,
+ struct lttng_trigger **real_trigger)
{
int ret;
enum lttng_error_code ret_code;
* Takes ownership of the payload if present.
*/
struct lttng_event_notifier_notification *lttng_event_notifier_notification_create(
- uint64_t tracer_token,
- enum lttng_domain_type domain,
- char *payload,
- size_t payload_size)
+ uint64_t tracer_token, enum lttng_domain_type domain, char *payload, size_t payload_size)
{
struct lttng_event_notifier_notification *notification = NULL;
}
void lttng_event_notifier_notification_destroy(
- struct lttng_event_notifier_notification *notification)
+ struct lttng_event_notifier_notification *notification)
{
if (!notification) {
return;
#include "lttng/action/action.h"
#include "lttng/trigger/trigger-internal.hpp"
#define _LGPL_SOURCE
-#include <urcu.h>
-#include <urcu/rculfhash.h>
+#include "condition-internal.hpp"
+#include "event-notifier-error-accounting.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread.hpp"
#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
#include <common/error.hpp>
#include <common/futex.hpp>
-#include <common/unix.hpp>
-#include <common/dynamic-buffer.hpp>
#include <common/hashtable/utils.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/macros.hpp>
-#include <lttng/condition/condition.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/unix.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
-#include <lttng/domain-internal.hpp>
-#include <lttng/notification/notification-internal.hpp>
-#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/condition/condition.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/session-consumed-size-internal.hpp>
#include <lttng/condition/session-rotation-internal.hpp>
-#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/domain-internal.hpp>
-#include <lttng/notification/channel-internal.hpp>
-#include <lttng/trigger/trigger-internal.hpp>
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/location-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/trigger/trigger-internal.hpp>
+#include <fcntl.h>
+#include <inttypes.h>
#include <time.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <fcntl.h>
-
-#include "condition-internal.hpp"
-#include "event-notifier-error-accounting.hpp"
-#include "notification-thread.hpp"
-#include "notification-thread-events.hpp"
-#include "notification-thread-commands.hpp"
-#include "lttng-sessiond.hpp"
-#include "kernel.hpp"
+#include <urcu.h>
+#include <urcu/rculfhash.h>
-#define CLIENT_POLL_EVENTS_IN (LPOLLIN | LPOLLRDHUP)
+#define CLIENT_POLL_EVENTS_IN (LPOLLIN | LPOLLRDHUP)
#define CLIENT_POLL_EVENTS_IN_OUT (CLIENT_POLL_EVENTS_IN | LPOLLOUT)
/* The tracers currently limit the capture size to PIPE_BUF (4kb on linux). */
static unsigned long hash_channel_key(struct channel_key *key);
static int evaluate_buffer_condition(const struct lttng_condition *condition,
- struct lttng_evaluation **evaluation,
- const struct notification_thread_state *state,
- const struct channel_state_sample *previous_sample,
- const struct channel_state_sample *latest_sample,
- struct channel_info *channel_info);
-static
-int send_evaluation_to_clients(const struct lttng_trigger *trigger,
- const struct lttng_evaluation *evaluation,
- struct notification_client_list *client_list,
- struct notification_thread_state *state,
- uid_t channel_uid, gid_t channel_gid);
-
+ struct lttng_evaluation **evaluation,
+ const struct notification_thread_state *state,
+ const struct channel_state_sample *previous_sample,
+ const struct channel_state_sample *latest_sample,
+ struct channel_info *channel_info);
+static int send_evaluation_to_clients(const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
+ struct notification_client_list *client_list,
+ struct notification_thread_state *state,
+ uid_t channel_uid,
+ gid_t channel_gid);
/* session_info API */
-static
-void session_info_destroy(void *_data);
-static
-void session_info_get(struct session_info *session_info);
-static
-void session_info_put(struct session_info *session_info);
-static
-struct session_info *session_info_create(uint64_t id,
- const char *name,
- uid_t uid,
- gid_t gid,
- struct lttng_session_trigger_list *trigger_list,
- struct cds_lfht *sessions_ht);
-static void session_info_add_channel(
- struct session_info *session_info, struct channel_info *channel_info);
-static
-void session_info_remove_channel(struct session_info *session_info,
- struct channel_info *channel_info);
+static void session_info_destroy(void *_data);
+static void session_info_get(struct session_info *session_info);
+static void session_info_put(struct session_info *session_info);
+static struct session_info *session_info_create(uint64_t id,
+ const char *name,
+ uid_t uid,
+ gid_t gid,
+ struct lttng_session_trigger_list *trigger_list,
+ struct cds_lfht *sessions_ht);
+static void session_info_add_channel(struct session_info *session_info,
+ struct channel_info *channel_info);
+static void session_info_remove_channel(struct session_info *session_info,
+ struct channel_info *channel_info);
/* lttng_session_trigger_list API */
-static
-struct lttng_session_trigger_list *lttng_session_trigger_list_create(
- const char *session_name,
- struct cds_lfht *session_triggers_ht);
-static
-struct lttng_session_trigger_list *lttng_session_trigger_list_build(
- const struct notification_thread_state *state,
- const char *session_name);
-static
-void lttng_session_trigger_list_destroy(
- struct lttng_session_trigger_list *list);
-static
-int lttng_session_trigger_list_add(struct lttng_session_trigger_list *list,
- struct lttng_trigger *trigger);
-
-static
-int client_handle_transmission_status(
- struct notification_client *client,
- enum client_transmission_status transmission_status,
- struct notification_thread_state *state);
-
-static
-int handle_one_event_notifier_notification(
- struct notification_thread_state *state,
- int pipe, enum lttng_domain_type domain);
-
-static
-void free_lttng_trigger_ht_element_rcu(struct rcu_head *node);
-
-static
-int match_client_socket(struct cds_lfht_node *node, const void *key)
+static struct lttng_session_trigger_list *
+lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *session_triggers_ht);
+static struct lttng_session_trigger_list *
+lttng_session_trigger_list_build(const struct notification_thread_state *state,
+ const char *session_name);
+static void lttng_session_trigger_list_destroy(struct lttng_session_trigger_list *list);
+static int lttng_session_trigger_list_add(struct lttng_session_trigger_list *list,
+ struct lttng_trigger *trigger);
+
+static int client_handle_transmission_status(struct notification_client *client,
+ enum client_transmission_status transmission_status,
+ struct notification_thread_state *state);
+
+static int handle_one_event_notifier_notification(struct notification_thread_state *state,
+ int pipe,
+ enum lttng_domain_type domain);
+
+static void free_lttng_trigger_ht_element_rcu(struct rcu_head *node);
+
+static int match_client_socket(struct cds_lfht_node *node, const void *key)
{
/* This double-cast is intended to supress pointer-to-cast warning. */
const int socket = (int) (intptr_t) key;
- const struct notification_client *client = caa_container_of(node,
- struct notification_client, client_socket_ht_node);
+ const struct notification_client *client =
+ caa_container_of(node, struct notification_client, client_socket_ht_node);
return client->socket == socket;
}
-static
-int match_client_id(struct cds_lfht_node *node, const void *key)
+static int match_client_id(struct cds_lfht_node *node, const void *key)
{
/* This double-cast is intended to supress pointer-to-cast warning. */
const notification_client_id id = *((notification_client_id *) key);
- const struct notification_client *client = lttng::utils::container_of(
- node, ¬ification_client::client_id_ht_node);
+ const struct notification_client *client =
+ lttng::utils::container_of(node, ¬ification_client::client_id_ht_node);
return client->id == id;
}
-static
-int match_channel_trigger_list(struct cds_lfht_node *node, const void *key)
+static int match_channel_trigger_list(struct cds_lfht_node *node, const void *key)
{
struct channel_key *channel_key = (struct channel_key *) key;
struct lttng_channel_trigger_list *trigger_list;
- trigger_list = caa_container_of(node, struct lttng_channel_trigger_list,
- channel_triggers_ht_node);
+ trigger_list =
+ caa_container_of(node, struct lttng_channel_trigger_list, channel_triggers_ht_node);
return !!((channel_key->key == trigger_list->channel_key.key) &&
- (channel_key->domain == trigger_list->channel_key.domain));
+ (channel_key->domain == trigger_list->channel_key.domain));
}
-static
-int match_session_trigger_list(struct cds_lfht_node *node, const void *key)
+static int match_session_trigger_list(struct cds_lfht_node *node, const void *key)
{
const char *session_name = (const char *) key;
struct lttng_session_trigger_list *trigger_list;
- trigger_list = caa_container_of(node, struct lttng_session_trigger_list,
- session_triggers_ht_node);
+ trigger_list =
+ caa_container_of(node, struct lttng_session_trigger_list, session_triggers_ht_node);
return !!(strcmp(trigger_list->session_name, session_name) == 0);
}
-static
-int match_channel_state_sample(struct cds_lfht_node *node, const void *key)
+static int match_channel_state_sample(struct cds_lfht_node *node, const void *key)
{
struct channel_key *channel_key = (struct channel_key *) key;
struct channel_state_sample *sample;
- sample = caa_container_of(node, struct channel_state_sample,
- channel_state_ht_node);
+ sample = caa_container_of(node, struct channel_state_sample, channel_state_ht_node);
return !!((channel_key->key == sample->key.key) &&
- (channel_key->domain == sample->key.domain));
+ (channel_key->domain == sample->key.domain));
}
-static
-int match_channel_info(struct cds_lfht_node *node, const void *key)
+static int match_channel_info(struct cds_lfht_node *node, const void *key)
{
struct channel_key *channel_key = (struct channel_key *) key;
struct channel_info *channel_info;
- channel_info = caa_container_of(node, struct channel_info,
- channels_ht_node);
+ channel_info = caa_container_of(node, struct channel_info, channels_ht_node);
return !!((channel_key->key == channel_info->key.key) &&
- (channel_key->domain == channel_info->key.domain));
+ (channel_key->domain == channel_info->key.domain));
}
-static
-int match_trigger(struct cds_lfht_node *node, const void *key)
+static int match_trigger(struct cds_lfht_node *node, const void *key)
{
struct lttng_trigger *trigger_key = (struct lttng_trigger *) key;
struct lttng_trigger_ht_element *trigger_ht_element;
- trigger_ht_element = caa_container_of(node, struct lttng_trigger_ht_element,
- node);
+ trigger_ht_element = caa_container_of(node, struct lttng_trigger_ht_element, node);
return !!lttng_trigger_is_equal(trigger_key, trigger_ht_element->trigger);
}
-static
-int match_trigger_token(struct cds_lfht_node *node, const void *key)
+static int match_trigger_token(struct cds_lfht_node *node, const void *key)
{
const uint64_t *_key = (uint64_t *) key;
struct notification_trigger_tokens_ht_element *element;
- element = caa_container_of(node,
- struct notification_trigger_tokens_ht_element, node);
+ element = caa_container_of(node, struct notification_trigger_tokens_ht_element, node);
return *_key == element->token;
}
-static
-int match_client_list_condition(struct cds_lfht_node *node, const void *key)
+static int match_client_list_condition(struct cds_lfht_node *node, const void *key)
{
struct lttng_condition *condition_key = (struct lttng_condition *) key;
struct notification_client_list *client_list;
LTTNG_ASSERT(condition_key);
- client_list = caa_container_of(node, struct notification_client_list,
- notification_trigger_clients_ht_node);
+ client_list = caa_container_of(
+ node, struct notification_client_list, notification_trigger_clients_ht_node);
condition = client_list->condition;
return !!lttng_condition_is_equal(condition_key, condition);
}
-static
-int match_session_info(struct cds_lfht_node *node, const void *key)
+static int match_session_info(struct cds_lfht_node *node, const void *key)
{
const auto session_id = *((uint64_t *) key);
- const auto *session_info = lttng::utils::container_of(
- node, &session_info::sessions_ht_node);
+ const auto *session_info =
+ lttng::utils::container_of(node, &session_info::sessions_ht_node);
return session_id == session_info->id;
}
-static
-unsigned long hash_session_info_id(uint64_t id)
+static unsigned long hash_session_info_id(uint64_t id)
{
return hash_key_u64(&id, lttng_ht_seed);
}
-static
-unsigned long hash_session_info(const struct session_info *session_info)
+static unsigned long hash_session_info(const struct session_info *session_info)
{
return hash_session_info_id(session_info->id);
}
-static
-struct session_info *get_session_info_by_id(
- const struct notification_thread_state *state, uint64_t id)
+static struct session_info *get_session_info_by_id(const struct notification_thread_state *state,
+ uint64_t id)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
lttng::urcu::read_lock_guard read_lock_guard;
- cds_lfht_lookup(state->sessions_ht,
- hash_session_info_id(id),
- match_session_info,
- &id,
- &iter);
+ cds_lfht_lookup(
+ state->sessions_ht, hash_session_info_id(id), match_session_info, &id, &iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
- auto session_info = lttng::utils::container_of(node, &session_info::sessions_ht_node);
+ auto session_info =
+ lttng::utils::container_of(node, &session_info::sessions_ht_node);
session_info_get(session_info);
return session_info;
return NULL;
}
-static
-struct session_info *get_session_info_by_name(
- const struct notification_thread_state *state, const char *name)
+static struct session_info *get_session_info_by_name(const struct notification_thread_state *state,
+ const char *name)
{
uint64_t session_id;
const auto found = sample_session_id_by_name(name, &session_id);
return found ? get_session_info_by_id(state, session_id) : NULL;
}
-static
-const char *notification_command_type_str(
- enum notification_thread_command_type type)
+static const char *notification_command_type_str(enum notification_thread_command_type type)
{
switch (type) {
case NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER:
* Match trigger based on name and credentials only.
* Name duplication is NOT allowed for the same uid.
*/
-static
-int match_trigger_by_name_uid(struct cds_lfht_node *node,
- const void *key)
+static int match_trigger_by_name_uid(struct cds_lfht_node *node, const void *key)
{
bool match = false;
const char *element_trigger_name;
enum lttng_trigger_status status;
const struct lttng_credentials *key_creds;
const struct lttng_credentials *node_creds;
- const struct lttng_trigger *trigger_key =
- (const struct lttng_trigger *) key;
+ const struct lttng_trigger *trigger_key = (const struct lttng_trigger *) key;
const struct lttng_trigger_ht_element *trigger_ht_element =
- caa_container_of(node,
- struct lttng_trigger_ht_element,
- node_by_name_uid);
+ caa_container_of(node, struct lttng_trigger_ht_element, node_by_name_uid);
- status = lttng_trigger_get_name(trigger_ht_element->trigger,
- &element_trigger_name);
- element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ?
- element_trigger_name : NULL;
+ status = lttng_trigger_get_name(trigger_ht_element->trigger, &element_trigger_name);
+ element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? element_trigger_name : NULL;
status = lttng_trigger_get_name(trigger_key, &key_name);
key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : NULL;
/*
* Hash trigger based on name and credentials only.
*/
-static
-unsigned long hash_trigger_by_name_uid(const struct lttng_trigger *trigger)
+static unsigned long hash_trigger_by_name_uid(const struct lttng_trigger *trigger)
{
unsigned long hash = 0;
const struct lttng_credentials *trigger_creds;
trigger_creds = lttng_trigger_get_credentials(trigger);
hash ^= hash_key_ulong((void *) (unsigned long) LTTNG_OPTIONAL_GET(trigger_creds->uid),
- lttng_ht_seed);
+ lttng_ht_seed);
return hash;
}
-static
-unsigned long hash_channel_key(struct channel_key *key)
+static unsigned long hash_channel_key(struct channel_key *key)
{
unsigned long key_hash = hash_key_u64(&key->key, lttng_ht_seed);
- unsigned long domain_hash = hash_key_ulong(
- (void *) (unsigned long) key->domain, lttng_ht_seed);
+ unsigned long domain_hash =
+ hash_key_ulong((void *) (unsigned long) key->domain, lttng_ht_seed);
return key_hash ^ domain_hash;
}
-static
-unsigned long hash_client_socket(int socket)
+static unsigned long hash_client_socket(int socket)
{
return hash_key_ulong((void *) (unsigned long) socket, lttng_ht_seed);
}
-static
-unsigned long hash_client_id(notification_client_id id)
+static unsigned long hash_client_id(notification_client_id id)
{
return hash_key_u64(&id, lttng_ht_seed);
}
* For instance, a condition bound to a channel will be evaluated everytime
* the channel's state is changed by a channel monitoring sample.
*/
-static
-enum lttng_object_type get_condition_binding_object(
- const struct lttng_condition *condition)
+static enum lttng_object_type get_condition_binding_object(const struct lttng_condition *condition)
{
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
}
}
-static
-void free_channel_info_rcu(struct rcu_head *node)
+static void free_channel_info_rcu(struct rcu_head *node)
{
free(lttng::utils::container_of(node, &channel_info::rcu_node));
}
-static
-void channel_info_destroy(struct channel_info *channel_info)
+static void channel_info_destroy(struct channel_info *channel_info)
{
if (!channel_info) {
return;
}
if (channel_info->session_info) {
- session_info_remove_channel(channel_info->session_info,
- channel_info);
+ session_info_remove_channel(channel_info->session_info, channel_info);
session_info_put(channel_info->session_info);
}
if (channel_info->name) {
call_rcu(&channel_info->rcu_node, free_channel_info_rcu);
}
-static
-void free_session_info_rcu(struct rcu_head *node)
+static void free_session_info_rcu(struct rcu_head *node)
{
free(lttng::utils::container_of(node, &session_info::rcu_node));
}
/* Don't call directly, use the ref-counting mechanism. */
-static
-void session_info_destroy(void *_data)
+static void session_info_destroy(void *_data)
{
struct session_info *session_info = (struct session_info *) _data;
int ret;
lttng_session_trigger_list_destroy(session_info->trigger_list);
rcu_read_lock();
- cds_lfht_del(session_info->sessions_ht,
- &session_info->sessions_ht_node);
+ cds_lfht_del(session_info->sessions_ht, &session_info->sessions_ht_node);
rcu_read_unlock();
free(session_info->name);
lttng_trace_archive_location_put(session_info->last_state_sample.rotation.location);
call_rcu(&session_info->rcu_node, free_session_info_rcu);
}
-static
-void session_info_get(struct session_info *session_info)
+static void session_info_get(struct session_info *session_info)
{
if (!session_info) {
return;
lttng_ref_get(&session_info->ref);
}
-static
-void session_info_put(struct session_info *session_info)
+static void session_info_put(struct session_info *session_info)
{
if (!session_info) {
return;
lttng_ref_put(&session_info->ref);
}
-static
-struct session_info *session_info_create(uint64_t id,
- const char *name,
- uid_t uid,
- gid_t gid,
- struct lttng_session_trigger_list *trigger_list,
- struct cds_lfht *sessions_ht)
+static struct session_info *session_info_create(uint64_t id,
+ const char *name,
+ uid_t uid,
+ gid_t gid,
+ struct lttng_session_trigger_list *trigger_list,
+ struct cds_lfht *sessions_ht)
{
struct session_info *session_info;
lttng_ref_init(&session_info->ref, session_info_destroy);
- session_info->channel_infos_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ session_info->channel_infos_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!session_info->channel_infos_ht) {
goto error;
}
return NULL;
}
-static
-void session_info_add_channel(struct session_info *session_info,
- struct channel_info *channel_info)
+static void session_info_add_channel(struct session_info *session_info,
+ struct channel_info *channel_info)
{
rcu_read_lock();
cds_lfht_add(session_info->channel_infos_ht,
- hash_channel_key(&channel_info->key),
- &channel_info->session_info_channels_ht_node);
+ hash_channel_key(&channel_info->key),
+ &channel_info->session_info_channels_ht_node);
rcu_read_unlock();
}
-static
-void session_info_remove_channel(struct session_info *session_info,
- struct channel_info *channel_info)
+static void session_info_remove_channel(struct session_info *session_info,
+ struct channel_info *channel_info)
{
rcu_read_lock();
- cds_lfht_del(session_info->channel_infos_ht,
- &channel_info->session_info_channels_ht_node);
+ cds_lfht_del(session_info->channel_infos_ht, &channel_info->session_info_channels_ht_node);
rcu_read_unlock();
}
-static
-struct channel_info *channel_info_create(const char *channel_name,
- struct channel_key *channel_key, uint64_t channel_capacity,
- struct session_info *session_info)
+static struct channel_info *channel_info_create(const char *channel_name,
+ struct channel_key *channel_key,
+ uint64_t channel_capacity,
+ struct session_info *session_info)
{
struct channel_info *channel_info = zmalloc<struct channel_info>();
return urcu_ref_get_unless_zero(&list->ref);
}
-static
-void free_notification_client_list_rcu(struct rcu_head *node)
+static void free_notification_client_list_rcu(struct rcu_head *node)
{
- free(caa_container_of(node, struct notification_client_list,
- rcu_node));
+ free(caa_container_of(node, struct notification_client_list, rcu_node));
}
-static
-void notification_client_list_release(struct urcu_ref *list_ref)
+static void notification_client_list_release(struct urcu_ref *list_ref)
{
struct notification_client_list *list =
- lttng::utils::container_of(list_ref, ¬ification_client_list::ref);
+ lttng::utils::container_of(list_ref, ¬ification_client_list::ref);
struct notification_client_list_element *client_list_element, *tmp;
lttng_condition_put(list->condition);
rcu_read_lock();
cds_lfht_del(list->notification_trigger_clients_ht,
- &list->notification_trigger_clients_ht_node);
+ &list->notification_trigger_clients_ht_node);
rcu_read_unlock();
list->notification_trigger_clients_ht = NULL;
}
- cds_list_for_each_entry_safe(client_list_element, tmp,
- &list->clients_list, node) {
+ cds_list_for_each_entry_safe (client_list_element, tmp, &list->clients_list, node) {
free(client_list_element);
}
call_rcu(&list->rcu_node, free_notification_client_list_rcu);
}
-static
-bool condition_applies_to_client(const struct lttng_condition *condition,
- struct notification_client *client)
+static bool condition_applies_to_client(const struct lttng_condition *condition,
+ struct notification_client *client)
{
bool applies = false;
struct lttng_condition_list_element *condition_list_element;
- cds_list_for_each_entry(condition_list_element, &client->condition_list,
- node) {
- applies = lttng_condition_is_equal(
- condition_list_element->condition,
- condition);
+ cds_list_for_each_entry (condition_list_element, &client->condition_list, node) {
+ applies = lttng_condition_is_equal(condition_list_element->condition, condition);
if (applies) {
break;
}
return applies;
}
-static
-struct notification_client_list *notification_client_list_create(
- struct notification_thread_state *state,
- const struct lttng_condition *condition)
+static struct notification_client_list *
+notification_client_list_create(struct notification_thread_state *state,
+ const struct lttng_condition *condition)
{
struct notification_client *client;
struct cds_lfht_iter iter;
client_list->condition = lttng_condition_copy(condition);
/* Build a list of clients to which this new condition applies. */
- cds_lfht_for_each_entry (state->client_socket_ht, &iter, client,
- client_socket_ht_node) {
+ cds_lfht_for_each_entry (state->client_socket_ht, &iter, client, client_socket_ht_node) {
struct notification_client_list_element *client_list_element;
if (!condition_applies_to_client(condition, client)) {
cds_list_add(&client_list_element->node, &client_list->clients_list);
}
- client_list->notification_trigger_clients_ht =
- state->notification_trigger_clients_ht;
+ client_list->notification_trigger_clients_ht = state->notification_trigger_clients_ht;
rcu_read_lock();
/*
* Add the client list to the global list of client list.
*/
cds_lfht_add_unique(state->notification_trigger_clients_ht,
- lttng_condition_hash(client_list->condition),
- match_client_list_condition,
- client_list->condition,
- &client_list->notification_trigger_clients_ht_node);
+ lttng_condition_hash(client_list->condition),
+ match_client_list_condition,
+ client_list->condition,
+ &client_list->notification_trigger_clients_ht_node);
rcu_read_unlock();
goto end;
}
/* Provides a reference to the returned list. */
-static
-struct notification_client_list *get_client_list_from_condition(
- struct notification_thread_state *state,
- const struct lttng_condition *condition)
+static struct notification_client_list *
+get_client_list_from_condition(struct notification_thread_state *state,
+ const struct lttng_condition *condition)
{
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
&iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
- list = lttng::utils::container_of(node,
- ¬ification_client_list::notification_trigger_clients_ht_node);
+ list = lttng::utils::container_of(
+ node, ¬ification_client_list::notification_trigger_clients_ht_node);
list = notification_client_list_get(list) ? list : NULL;
}
return list;
}
-static
-int evaluate_channel_condition_for_client(
- const struct lttng_condition *condition,
- struct notification_thread_state *state,
- struct lttng_evaluation **evaluation,
- uid_t *session_uid, gid_t *session_gid)
+static int evaluate_channel_condition_for_client(const struct lttng_condition *condition,
+ struct notification_thread_state *state,
+ struct lttng_evaluation **evaluation,
+ uid_t *session_uid,
+ gid_t *session_gid)
{
int ret;
struct cds_lfht_iter iter;
rcu_read_lock();
/* Find the channel associated with the condition. */
- cds_lfht_for_each_entry(state->channel_triggers_ht, &iter,
- channel_trigger_list, channel_triggers_ht_node) {
+ cds_lfht_for_each_entry (
+ state->channel_triggers_ht, &iter, channel_trigger_list, channel_triggers_ht_node) {
struct lttng_trigger_list_element *element;
- cds_list_for_each_entry(element, &channel_trigger_list->list, node) {
+ cds_list_for_each_entry (element, &channel_trigger_list->list, node) {
const struct lttng_condition *current_condition =
- lttng_trigger_get_const_condition(
- element->trigger);
+ lttng_trigger_get_const_condition(element->trigger);
LTTNG_ASSERT(current_condition);
- if (!lttng_condition_is_equal(condition,
- current_condition)) {
+ if (!lttng_condition_is_equal(condition, current_condition)) {
continue;
}
}
}
- if (!channel_key){
+ if (!channel_key) {
/* No channel found; normal exit. */
DBG("No known channel associated with newly subscribed-to condition");
ret = 0;
&iter);
node = cds_lfht_iter_get_node(&iter);
LTTNG_ASSERT(node);
- channel_info = caa_container_of(node, struct channel_info,
- channels_ht_node);
+ channel_info = caa_container_of(node, struct channel_info, channels_ht_node);
/* Retrieve the channel's last sample, if it exists. */
cds_lfht_lookup(state->channel_state_ht,
&iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
- last_sample = caa_container_of(node,
- struct channel_state_sample,
- channel_state_ht_node);
+ last_sample =
+ caa_container_of(node, struct channel_state_sample, channel_state_ht_node);
} else {
/* Nothing to evaluate, no sample was ever taken. Normal exit */
DBG("No channel sample associated with newly subscribed-to condition");
goto end;
}
- ret = evaluate_buffer_condition(condition, evaluation, state,
- NULL, last_sample,
- channel_info);
+ ret = evaluate_buffer_condition(
+ condition, evaluation, state, NULL, last_sample, channel_info);
if (ret) {
WARN("Fatal error occurred while evaluating a newly subscribed-to condition");
goto end;
return ret;
}
-static
-const char *get_condition_session_name(const struct lttng_condition *condition)
+static const char *get_condition_session_name(const struct lttng_condition *condition)
{
const char *session_name = NULL;
enum lttng_condition_status status;
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
- status = lttng_condition_buffer_usage_get_session_name(
- condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(condition, &session_name);
break;
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
- status = lttng_condition_session_consumed_size_get_session_name(
- condition, &session_name);
+ status = lttng_condition_session_consumed_size_get_session_name(condition,
+ &session_name);
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
- status = lttng_condition_session_rotation_get_session_name(
- condition, &session_name);
+ status =
+ lttng_condition_session_rotation_get_session_name(condition, &session_name);
break;
default:
abort();
return session_name;
}
-static
-bool evaluate_session_rotation_ongoing_condition(const struct lttng_condition *condition
- __attribute__((unused)),
- const struct session_state_sample *sample)
+static bool evaluate_session_rotation_ongoing_condition(const struct lttng_condition *condition
+ __attribute__((unused)),
+ const struct session_state_sample *sample)
{
return sample->rotation.ongoing;
}
-static
-bool evaluate_session_consumed_size_condition(
- const struct lttng_condition *condition,
- const struct session_state_sample *sample)
+static bool evaluate_session_consumed_size_condition(const struct lttng_condition *condition,
+ const struct session_state_sample *sample)
{
uint64_t threshold;
const struct lttng_condition_session_consumed_size *size_condition =
- lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ lttng::utils::container_of(condition,
+ <tng_condition_session_consumed_size::parent);
threshold = size_condition->consumed_threshold_bytes.value;
- DBG("Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
- threshold, sample->consumed_data_size);
+ DBG("Session consumed size condition being evaluated: threshold = %" PRIu64
+ ", current size = %" PRIu64,
+ threshold,
+ sample->consumed_data_size);
return sample->consumed_data_size >= threshold;
}
* state transition. A client subscribed or a trigger was registered and
* we wish to perform an initial evaluation.
*/
-static
-int evaluate_session_condition(
- const struct lttng_condition *condition,
- const struct session_info *session_info,
- const struct session_state_sample *new_state,
- struct lttng_evaluation **evaluation)
+static int evaluate_session_condition(const struct lttng_condition *condition,
+ const struct session_info *session_info,
+ const struct session_state_sample *new_state,
+ struct lttng_evaluation **evaluation)
{
int ret;
bool previous_result, newest_result;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
if (new_state) {
previous_result = evaluate_session_rotation_ongoing_condition(
- condition, &session_info->last_state_sample);
- newest_result = evaluate_session_rotation_ongoing_condition(
- condition, new_state);
+ condition, &session_info->last_state_sample);
+ newest_result =
+ evaluate_session_rotation_ongoing_condition(condition, new_state);
} else {
previous_result = false;
newest_result = evaluate_session_rotation_ongoing_condition(
- condition, &session_info->last_state_sample);
+ condition, &session_info->last_state_sample);
}
break;
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
if (new_state) {
previous_result = evaluate_session_consumed_size_condition(
- condition, &session_info->last_state_sample);
- newest_result = evaluate_session_consumed_size_condition(
- condition, new_state);
+ condition, &session_info->last_state_sample);
+ newest_result =
+ evaluate_session_consumed_size_condition(condition, new_state);
} else {
previous_result = false;
newest_result = evaluate_session_consumed_size_condition(
- condition, &session_info->last_state_sample);
+ condition, &session_info->last_state_sample);
}
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
{
- const auto rotation_id = new_state ?
- new_state->rotation.id :
- session_info->last_state_sample.rotation.id;
+ const auto rotation_id = new_state ? new_state->rotation.id :
+ session_info->last_state_sample.rotation.id;
*evaluation = lttng_evaluation_session_rotation_ongoing_create(rotation_id);
break;
/* Callee acquires a reference to location. */
*evaluation = lttng_evaluation_session_rotation_completed_create(
- rotation_id, sample.rotation.location);
+ rotation_id, sample.rotation.location);
break;
}
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
{
const auto latest_session_consumed_total = new_state ?
- new_state->consumed_data_size :
- session_info->last_state_sample.consumed_data_size;
+ new_state->consumed_data_size :
+ session_info->last_state_sample.consumed_data_size;
*evaluation = lttng_evaluation_session_consumed_size_create(
- latest_session_consumed_total);
+ latest_session_consumed_total);
break;
}
default:
if (!*evaluation) {
/* Fatal error. */
ERR("Failed to create session condition evaluation: session name = `%s`",
- session_info->name);
+ session_info->name);
ret = -1;
goto end;
}
return ret;
}
-static
-int evaluate_condition_for_client(const struct lttng_trigger *trigger,
- const struct lttng_condition *condition,
- struct notification_client *client,
- struct notification_thread_state *state)
+static int evaluate_condition_for_client(const struct lttng_trigger *trigger,
+ const struct lttng_condition *condition,
+ struct notification_client *client,
+ struct notification_thread_state *state)
{
int ret;
struct lttng_evaluation *evaluation = NULL;
if (!session_info) {
/* Not an error, the session doesn't exist yet. */
DBG("Session not found while evaluating session condition for client: session name = `%s`",
- session_name);
+ session_name);
ret = 0;
goto end;
}
break;
}
case LTTNG_OBJECT_TYPE_CHANNEL:
- ret = evaluate_channel_condition_for_client(condition, state,
- &evaluation, &object_uid, &object_gid);
+ ret = evaluate_channel_condition_for_client(
+ condition, state, &evaluation, &object_uid, &object_gid);
break;
case LTTNG_OBJECT_TYPE_NONE:
DBG("Newly subscribed-to condition not bound to object, nothing to evaluate");
/* Send evaluation result to the newly-subscribed client. */
DBG("Newly subscribed-to condition evaluated to true, notifying client");
- ret = send_evaluation_to_clients(trigger, evaluation, &client_list,
- state, object_uid, object_gid);
+ ret = send_evaluation_to_clients(
+ trigger, evaluation, &client_list, state, object_uid, object_gid);
end:
return ret;
}
-static
-int notification_thread_client_subscribe(struct notification_client *client,
- struct lttng_condition *condition,
- struct notification_thread_state *state,
- enum lttng_notification_channel_status *_status)
+static int notification_thread_client_subscribe(struct notification_client *client,
+ struct lttng_condition *condition,
+ struct notification_thread_state *state,
+ enum lttng_notification_channel_status *_status)
{
int ret = 0;
struct notification_client_list *client_list = NULL;
struct lttng_condition_list_element *condition_list_element = NULL;
struct notification_client_list_element *client_list_element = NULL;
struct lttng_trigger_ht_element *trigger_ht_element;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
/*
* Ensure that the client has not already subscribed to this condition
* before.
*/
- cds_list_for_each_entry(condition_list_element, &client->condition_list, node) {
- if (lttng_condition_is_equal(condition_list_element->condition,
- condition)) {
+ cds_list_for_each_entry (condition_list_element, &client->condition_list, node) {
+ if (lttng_condition_is_equal(condition_list_element->condition, condition)) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED;
goto end;
}
condition = NULL;
cds_list_add(&condition_list_element->node, &client->condition_list);
- client_list = get_client_list_from_condition(
- state, condition_list_element->condition);
+ client_list = get_client_list_from_condition(state, condition_list_element->condition);
if (!client_list) {
/*
* No notification-emiting trigger registered with this
* all triggers that have a `notify` action that have this condition.
*/
pthread_mutex_lock(&client_list->lock);
- cds_list_for_each_entry(trigger_ht_element,
- &client_list->triggers_list, client_list_trigger_node) {
- if (evaluate_condition_for_client(trigger_ht_element->trigger, condition_list_element->condition,
- client, state)) {
+ cds_list_for_each_entry (
+ trigger_ht_element, &client_list->triggers_list, client_list_trigger_node) {
+ if (evaluate_condition_for_client(trigger_ht_element->trigger,
+ condition_list_element->condition,
+ client,
+ state)) {
WARN("Evaluation of a condition on client subscription failed, aborting.");
ret = -1;
free(client_list_element);
return ret;
}
-static
-int notification_thread_client_unsubscribe(
- struct notification_client *client,
- struct lttng_condition *condition,
- struct notification_thread_state *state,
- enum lttng_notification_channel_status *_status)
+static int notification_thread_client_unsubscribe(struct notification_client *client,
+ struct lttng_condition *condition,
+ struct notification_thread_state *state,
+ enum lttng_notification_channel_status *_status)
{
struct notification_client_list *client_list;
- struct lttng_condition_list_element *condition_list_element,
- *condition_tmp;
- struct notification_client_list_element *client_list_element,
- *client_tmp;
+ struct lttng_condition_list_element *condition_list_element, *condition_tmp;
+ struct notification_client_list_element *client_list_element, *client_tmp;
bool condition_found = false;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
/* Remove the condition from the client's condition list. */
- cds_list_for_each_entry_safe(condition_list_element, condition_tmp,
- &client->condition_list, node) {
- if (!lttng_condition_is_equal(condition_list_element->condition,
- condition)) {
+ cds_list_for_each_entry_safe (
+ condition_list_element, condition_tmp, &client->condition_list, node) {
+ if (!lttng_condition_is_equal(condition_list_element->condition, condition)) {
continue;
}
* will be destroyed at the end.
*/
if (condition != condition_list_element->condition) {
- lttng_condition_destroy(
- condition_list_element->condition);
+ lttng_condition_destroy(condition_list_element->condition);
}
free(condition_list_element);
condition_found = true;
}
pthread_mutex_lock(&client_list->lock);
- cds_list_for_each_entry_safe(client_list_element, client_tmp,
- &client_list->clients_list, node) {
+ cds_list_for_each_entry_safe (
+ client_list_element, client_tmp, &client_list->clients_list, node) {
if (client_list_element->client->id != client->id) {
continue;
}
return 0;
}
-static
-void free_notification_client_rcu(struct rcu_head *node)
+static void free_notification_client_rcu(struct rcu_head *node)
{
free(lttng::utils::container_of(node, ¬ification_client::rcu_node));
}
-static
-void notification_client_destroy(struct notification_client *client)
+static void notification_client_destroy(struct notification_client *client)
{
if (!client) {
return;
* Call with rcu_read_lock held (and hold for the lifetime of the returned
* client pointer).
*/
-static
-struct notification_client *get_client_from_socket(int socket,
- struct notification_thread_state *state)
+static struct notification_client *get_client_from_socket(int socket,
+ struct notification_thread_state *state)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
goto end;
}
- client = caa_container_of(node, struct notification_client,
- client_socket_ht_node);
+ client = caa_container_of(node, struct notification_client, client_socket_ht_node);
end:
return client;
}
* Call with rcu_read_lock held (and hold for the lifetime of the returned
* client pointer).
*/
-static
-struct notification_client *get_client_from_id(notification_client_id id,
- struct notification_thread_state *state)
+static struct notification_client *get_client_from_id(notification_client_id id,
+ struct notification_thread_state *state)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
ASSERT_RCU_READ_LOCKED();
- cds_lfht_lookup(state->client_id_ht,
- hash_client_id(id),
- match_client_id,
- &id,
- &iter);
+ cds_lfht_lookup(state->client_id_ht, hash_client_id(id), match_client_id, &id, &iter);
node = cds_lfht_iter_get_node(&iter);
if (!node) {
goto end;
}
- client = caa_container_of(node, struct notification_client,
- client_id_ht_node);
+ client = caa_container_of(node, struct notification_client, client_id_ht_node);
end:
return client;
}
-static
-bool buffer_usage_condition_applies_to_channel(
- const struct lttng_condition *condition,
- const struct channel_info *channel_info)
+static bool buffer_usage_condition_applies_to_channel(const struct lttng_condition *condition,
+ const struct channel_info *channel_info)
{
enum lttng_condition_status status;
enum lttng_domain_type condition_domain;
const char *condition_session_name = NULL;
const char *condition_channel_name = NULL;
- status = lttng_condition_buffer_usage_get_domain_type(condition,
- &condition_domain);
+ status = lttng_condition_buffer_usage_get_domain_type(condition, &condition_domain);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
if (channel_info->key.domain != condition_domain) {
goto fail;
}
- status = lttng_condition_buffer_usage_get_session_name(
- condition, &condition_session_name);
+ status = lttng_condition_buffer_usage_get_session_name(condition, &condition_session_name);
LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_session_name);
- status = lttng_condition_buffer_usage_get_channel_name(
- condition, &condition_channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(condition, &condition_channel_name);
LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_channel_name);
if (strcmp(channel_info->session_info->name, condition_session_name)) {
return false;
}
-static
-bool trigger_applies_to_channel(const struct lttng_trigger *trigger,
- const struct channel_info *channel_info)
+static bool trigger_applies_to_channel(const struct lttng_trigger *trigger,
+ const struct channel_info *channel_info)
{
const struct lttng_condition *condition;
bool trigger_applies;
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
- trigger_applies = buffer_usage_condition_applies_to_channel(
- condition, channel_info);
+ trigger_applies =
+ buffer_usage_condition_applies_to_channel(condition, channel_info);
break;
default:
goto fail;
}
/* Must be called with RCU read lock held. */
-static
-struct lttng_session_trigger_list *get_session_trigger_list(
- struct notification_thread_state *state,
- const char *session_name)
+static struct lttng_session_trigger_list *
+get_session_trigger_list(struct notification_thread_state *state, const char *session_name)
{
struct lttng_session_trigger_list *list = NULL;
struct cds_lfht_node *node;
* will be initialized when the session is created.
*/
DBG("No trigger list found for session \"%s\" as it is not yet known to the notification system",
- session_name);
+ session_name);
goto end;
}
- list = caa_container_of(node,
- struct lttng_session_trigger_list,
- session_triggers_ht_node);
+ list = caa_container_of(node, struct lttng_session_trigger_list, session_triggers_ht_node);
end:
return list;
}
* Allocate an empty lttng_session_trigger_list for the session named
* 'session_name'.
*/
-static
-struct lttng_session_trigger_list *lttng_session_trigger_list_create(
- const char *session_name,
- struct cds_lfht *session_triggers_ht)
+static struct lttng_session_trigger_list *
+lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *session_triggers_ht)
{
struct lttng_session_trigger_list *list = NULL;
char *session_name_copy = strdup(session_name);
rcu_read_lock();
/* Publish the list through the session_triggers_ht. */
cds_lfht_add(session_triggers_ht,
- hash_key_str(session_name, lttng_ht_seed),
- &list->session_triggers_ht_node);
+ hash_key_str(session_name, lttng_ht_seed),
+ &list->session_triggers_ht_node);
rcu_read_unlock();
end:
return list;
}
-static
-void free_session_trigger_list_rcu(struct rcu_head *node)
+static void free_session_trigger_list_rcu(struct rcu_head *node)
{
struct lttng_session_trigger_list *list =
- caa_container_of(node, struct lttng_session_trigger_list, rcu_node);
+ caa_container_of(node, struct lttng_session_trigger_list, rcu_node);
free(list->session_name);
free(list);
}
-static
-void lttng_session_trigger_list_destroy(struct lttng_session_trigger_list *list)
+static void lttng_session_trigger_list_destroy(struct lttng_session_trigger_list *list)
{
struct lttng_trigger_list_element *trigger_list_element, *tmp;
/* Empty the list element by element, and then free the list itself. */
- cds_list_for_each_entry_safe(trigger_list_element, tmp,
- &list->list, node) {
+ cds_list_for_each_entry_safe (trigger_list_element, tmp, &list->list, node) {
cds_list_del(&trigger_list_element->node);
free(trigger_list_element);
}
rcu_read_lock();
/* Unpublish the list from the session_triggers_ht. */
- cds_lfht_del(list->session_triggers_ht,
- &list->session_triggers_ht_node);
+ cds_lfht_del(list->session_triggers_ht, &list->session_triggers_ht_node);
rcu_read_unlock();
call_rcu(&list->rcu_node, free_session_trigger_list_rcu);
}
-static
-int lttng_session_trigger_list_add(struct lttng_session_trigger_list *list,
- struct lttng_trigger *trigger)
+static int lttng_session_trigger_list_add(struct lttng_session_trigger_list *list,
+ struct lttng_trigger *trigger)
{
int ret = 0;
- struct lttng_trigger_list_element *new_element =
- zmalloc<lttng_trigger_list_element>();
+ struct lttng_trigger_list_element *new_element = zmalloc<lttng_trigger_list_element>();
if (!new_element) {
ret = -1;
return ret;
}
-static
-bool trigger_applies_to_session(const struct lttng_trigger *trigger,
- const char *session_name)
+static bool trigger_applies_to_session(const struct lttng_trigger *trigger,
+ const char *session_name)
{
bool applies = false;
const struct lttng_condition *condition;
* Allocate and initialize an lttng_session_trigger_list which contains
* all triggers that apply to the session named 'session_name'.
*/
-static
-struct lttng_session_trigger_list *lttng_session_trigger_list_build(
- const struct notification_thread_state *state,
- const char *session_name)
+static struct lttng_session_trigger_list *
+lttng_session_trigger_list_build(const struct notification_thread_state *state,
+ const char *session_name)
{
int trigger_count = 0;
struct lttng_session_trigger_list *session_trigger_list = NULL;
struct lttng_trigger_ht_element *trigger_ht_element = NULL;
struct cds_lfht_iter iter;
- session_trigger_list = lttng_session_trigger_list_create(session_name,
- state->session_triggers_ht);
+ session_trigger_list =
+ lttng_session_trigger_list_create(session_name, state->session_triggers_ht);
/* Add all triggers applying to the session named 'session_name'. */
- cds_lfht_for_each_entry(state->triggers_ht, &iter, trigger_ht_element,
- node) {
+ cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
int ret;
- if (!trigger_applies_to_session(trigger_ht_element->trigger,
- session_name)) {
+ if (!trigger_applies_to_session(trigger_ht_element->trigger, session_name)) {
continue;
}
ret = lttng_session_trigger_list_add(session_trigger_list,
- trigger_ht_element->trigger);
+ trigger_ht_element->trigger);
if (ret) {
goto error;
}
trigger_count++;
}
- DBG("Found %i triggers that apply to newly created session",
- trigger_count);
+ DBG("Found %i triggers that apply to newly created session", trigger_count);
return session_trigger_list;
error:
lttng_session_trigger_list_destroy(session_trigger_list);
return NULL;
}
-static
-struct session_info *create_and_publish_session_info(struct notification_thread_state *state,
- uint64_t id,
- const char *name,
- uid_t uid,
- gid_t gid)
+static struct session_info *create_and_publish_session_info(struct notification_thread_state *state,
+ uint64_t id,
+ const char *name,
+ uid_t uid,
+ gid_t gid)
{
struct session_info *session = NULL;
struct lttng_session_trigger_list *trigger_list;
goto error;
}
- session = session_info_create(id, name, uid, gid, trigger_list,
- state->sessions_ht);
+ session = session_info_create(id, name, uid, gid, trigger_list, state->sessions_ht);
if (!session) {
ERR("Failed to allocation session info for session \"%s\" (uid = %i, gid = %i)",
- name, uid, gid);
+ name,
+ uid,
+ gid);
lttng_session_trigger_list_destroy(trigger_list);
goto error;
}
/* Transferred ownership to the new session. */
trigger_list = NULL;
- if (cds_lfht_add_unique(state->sessions_ht, hash_session_info(session), match_session_info,
- &id, &session->sessions_ht_node) != &session->sessions_ht_node) {
+ if (cds_lfht_add_unique(state->sessions_ht,
+ hash_session_info(session),
+ match_session_info,
+ &id,
+ &session->sessions_ht_node) != &session->sessions_ht_node) {
ERR("Duplicate session found: name = `%s`, id = %" PRIu64, name, id);
goto error;
}
return NULL;
}
-static
-int handle_notification_thread_command_add_channel(struct notification_thread_state *state,
- uint64_t session_id,
- const char *channel_name,
- enum lttng_domain_type channel_domain,
- uint64_t channel_key_int,
- uint64_t channel_capacity,
- enum lttng_error_code *cmd_result)
+static int handle_notification_thread_command_add_channel(struct notification_thread_state *state,
+ uint64_t session_id,
+ const char *channel_name,
+ enum lttng_domain_type channel_domain,
+ uint64_t channel_key_int,
+ uint64_t channel_capacity,
+ enum lttng_error_code *cmd_result)
{
struct cds_list_head trigger_list;
struct channel_info *new_channel_info = NULL;
struct cds_lfht_iter iter;
struct session_info *session_info = NULL;
- DBG("Adding channel: channel name = `%s`, session id = %" PRIu64 ", channel key = %" PRIu64 ", domain = %s",
- channel_name, session_id, channel_key_int,
- lttng_domain_type_str(channel_domain));
+ DBG("Adding channel: channel name = `%s`, session id = %" PRIu64 ", channel key = %" PRIu64
+ ", domain = %s",
+ channel_name,
+ session_id,
+ channel_key_int,
+ lttng_domain_type_str(channel_domain));
CDS_INIT_LIST_HEAD(&trigger_list);
if (!session_info) {
/* Fatal logic error. */
ERR("Failed to find session while adding channel: session id = %" PRIu64,
- session_id);
+ session_id);
goto error;
}
- new_channel_info = channel_info_create(channel_name, &channel_key,
- channel_capacity, session_info);
+ new_channel_info =
+ channel_info_create(channel_name, &channel_key, channel_capacity, session_info);
if (!new_channel_info) {
goto error;
}
rcu_read_lock();
/* Build a list of all triggers applying to the new channel. */
- cds_lfht_for_each_entry(state->triggers_ht, &iter, trigger_ht_element,
- node) {
+ cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
struct lttng_trigger_list_element *new_element;
- if (!trigger_applies_to_channel(trigger_ht_element->trigger,
- new_channel_info)) {
+ if (!trigger_applies_to_channel(trigger_ht_element->trigger, new_channel_info)) {
continue;
}
}
rcu_read_unlock();
- DBG("Found %i triggers that apply to newly added channel",
- trigger_count);
+ DBG("Found %i triggers that apply to newly added channel", trigger_count);
channel_trigger_list = zmalloc<lttng_channel_trigger_list>();
if (!channel_trigger_list) {
goto error;
rcu_read_lock();
/* Add channel to the channel_ht which owns the channel_infos. */
cds_lfht_add(state->channels_ht,
- hash_channel_key(&new_channel_info->key),
- &new_channel_info->channels_ht_node);
+ hash_channel_key(&new_channel_info->key),
+ &new_channel_info->channels_ht_node);
/*
* Add the list of triggers associated with this channel to the
* channel_triggers_ht.
*/
cds_lfht_add(state->channel_triggers_ht,
- hash_channel_key(&new_channel_info->key),
- &channel_trigger_list->channel_triggers_ht_node);
+ hash_channel_key(&new_channel_info->key),
+ &channel_trigger_list->channel_triggers_ht_node);
rcu_read_unlock();
session_info_put(session_info);
*cmd_result = LTTNG_OK;
return 1;
}
-static
-int handle_notification_thread_command_add_session(struct notification_thread_state *state,
- uint64_t session_id,
- const char *session_name,
- uid_t session_uid,
- gid_t session_gid,
- enum lttng_error_code *cmd_result)
+static int handle_notification_thread_command_add_session(struct notification_thread_state *state,
+ uint64_t session_id,
+ const char *session_name,
+ uid_t session_uid,
+ gid_t session_gid,
+ enum lttng_error_code *cmd_result)
{
int ret;
- DBG("Adding session: session name = `%s`, session id = %" PRIu64 ", session uid = %d, session gid = %d",
- session_name, session_id, session_uid, session_gid);
+ DBG("Adding session: session name = `%s`, session id = %" PRIu64
+ ", session uid = %d, session gid = %d",
+ session_name,
+ session_id,
+ session_uid,
+ session_gid);
- auto session = create_and_publish_session_info(state, session_id, session_name, session_uid, session_gid);
+ auto session = create_and_publish_session_info(
+ state, session_id, session_name, session_uid, session_gid);
if (!session) {
- PERROR("Failed to add session: session name = `%s`, session id = %" PRIu64 ", session uid = %d, session gid = %d",
- session_name, session_id, session_uid, session_gid);
+ PERROR("Failed to add session: session name = `%s`, session id = %" PRIu64
+ ", session uid = %d, session gid = %d",
+ session_name,
+ session_id,
+ session_uid,
+ session_gid);
ret = -1;
*cmd_result = LTTNG_ERR_NOMEM;
goto end;
return ret;
}
-static
-int handle_notification_thread_command_remove_session(
- struct notification_thread_state *state,
- uint64_t session_id,
- enum lttng_error_code *cmd_result)
+static int
+handle_notification_thread_command_remove_session(struct notification_thread_state *state,
+ uint64_t session_id,
+ enum lttng_error_code *cmd_result)
{
int ret;
return ret;
}
-static
-void free_channel_trigger_list_rcu(struct rcu_head *node)
+static void free_channel_trigger_list_rcu(struct rcu_head *node)
{
- free(caa_container_of(node, struct lttng_channel_trigger_list,
- rcu_node));
+ free(caa_container_of(node, struct lttng_channel_trigger_list, rcu_node));
}
-static
-void free_channel_state_sample_rcu(struct rcu_head *node)
+static void free_channel_state_sample_rcu(struct rcu_head *node)
{
- free(caa_container_of(node, struct channel_state_sample,
- rcu_node));
+ free(caa_container_of(node, struct channel_state_sample, rcu_node));
}
-static
-int handle_notification_thread_command_remove_channel(
- struct notification_thread_state *state,
- uint64_t channel_key, enum lttng_domain_type domain,
- enum lttng_error_code *cmd_result)
+static int
+handle_notification_thread_command_remove_channel(struct notification_thread_state *state,
+ uint64_t channel_key,
+ enum lttng_domain_type domain,
+ enum lttng_error_code *cmd_result)
{
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
struct channel_info *channel_info;
DBG("Removing channel key = %" PRIu64 " in %s domain",
- channel_key, lttng_domain_type_str(domain));
+ channel_key,
+ lttng_domain_type_str(domain));
rcu_read_lock();
}
/* Free the list of triggers associated with this channel. */
- trigger_list = caa_container_of(node, struct lttng_channel_trigger_list,
- channel_triggers_ht_node);
- cds_list_for_each_entry_safe(trigger_list_element, tmp,
- &trigger_list->list, node) {
+ trigger_list =
+ caa_container_of(node, struct lttng_channel_trigger_list, channel_triggers_ht_node);
+ cds_list_for_each_entry_safe (trigger_list_element, tmp, &trigger_list->list, node) {
cds_list_del(&trigger_list_element->node);
free(trigger_list_element);
}
* received a sample.
*/
if (node) {
- struct channel_state_sample *sample = caa_container_of(node,
- struct channel_state_sample,
- channel_state_ht_node);
+ struct channel_state_sample *sample =
+ caa_container_of(node, struct channel_state_sample, channel_state_ht_node);
cds_lfht_del(state->channel_state_ht, node);
call_rcu(&sample->rcu_node, free_channel_state_sample_rcu);
}
/* Remove the channel from the channels_ht and free it. */
- cds_lfht_lookup(state->channels_ht,
- hash_channel_key(&key),
- match_channel_info,
- &key,
- &iter);
+ cds_lfht_lookup(
+ state->channels_ht, hash_channel_key(&key), match_channel_info, &key, &iter);
node = cds_lfht_iter_get_node(&iter);
LTTNG_ASSERT(node);
- channel_info = caa_container_of(node, struct channel_info,
- channels_ht_node);
+ channel_info = caa_container_of(node, struct channel_info, channels_ht_node);
cds_lfht_del(state->channels_ht, node);
channel_info_destroy(channel_info);
end:
return 0;
}
-static
-int handle_notification_thread_command_session_rotation(
- struct notification_thread_state *state,
- enum notification_thread_command_type cmd_type,
- uint64_t session_id,
- uint64_t trace_archive_chunk_id,
- struct lttng_trace_archive_location *location,
- enum lttng_error_code *_cmd_result)
+static int
+handle_notification_thread_command_session_rotation(struct notification_thread_state *state,
+ enum notification_thread_command_type cmd_type,
+ uint64_t session_id,
+ uint64_t trace_archive_chunk_id,
+ struct lttng_trace_archive_location *location,
+ enum lttng_error_code *_cmd_result)
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
if (!session_info) {
/* Fatal logic error. */
ERR("Failed to find session while handling rotation state change: session id = %" PRIu64,
- session_id);
+ session_id);
ret = -1;
cmd_result = LTTNG_ERR_FATAL;
goto end;
};
new_session_state.rotation.ongoing = cmd_type ==
- NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING;
+ NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING;
new_session_state.rotation.id = trace_archive_chunk_id;
trigger_list = get_session_trigger_list(state, session_info->name);
LTTNG_ASSERT(trigger_list);
- cds_list_for_each_entry(trigger_list_element, &trigger_list->list,
- node) {
+ cds_list_for_each_entry (trigger_list_element, &trigger_list->list, node) {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
struct notification_client_list *client_list;
LTTNG_ASSERT(condition);
ret = evaluate_session_condition(
- condition, session_info, &new_session_state, &evaluation);
+ condition, session_info, &new_session_state, &evaluation);
if (ret) {
ret = -1;
cmd_result = LTTNG_ERR_NOMEM;
*/
client_list = get_client_list_from_condition(state, condition);
executor_status = action_executor_enqueue_trigger(
- state->executor, trigger, evaluation,
- &session_creds, client_list);
+ state->executor, trigger, evaluation, &session_creds, client_list);
notification_client_list_put(client_list);
evaluation = NULL;
switch (executor_status) {
return ret;
}
-static
-int handle_notification_thread_command_add_tracer_event_source(
- struct notification_thread_state *state,
- int tracer_event_source_fd,
- enum lttng_domain_type domain_type,
- enum lttng_error_code *_cmd_result)
+static int
+handle_notification_thread_command_add_tracer_event_source(struct notification_thread_state *state,
+ int tracer_event_source_fd,
+ enum lttng_domain_type domain_type,
+ enum lttng_error_code *_cmd_result)
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
cds_list_add(&element->node, &state->tracer_event_sources_list);
DBG3("Adding tracer event source fd to poll set: tracer_event_source_fd = %d, domain = '%s'",
- tracer_event_source_fd,
- lttng_domain_type_str(domain_type));
+ tracer_event_source_fd,
+ lttng_domain_type_str(domain_type));
/* Adding the read side pipe to the event poll. */
ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLPRI | LPOLLIN);
if (ret < 0) {
ERR("Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
- tracer_event_source_fd,
- lttng_domain_type_str(element->domain));
+ tracer_event_source_fd,
+ lttng_domain_type_str(element->domain));
cds_list_del(&element->node);
free(element);
goto end;
return ret;
}
-static
-int drain_event_notifier_notification_pipe(
- struct notification_thread_state *state,
- int pipe, enum lttng_domain_type domain)
+static int drain_event_notifier_notification_pipe(struct notification_thread_state *state,
+ int pipe,
+ enum lttng_domain_type domain)
{
struct lttng_poll_event events = {};
int ret;
ret = lttng_poll_add(&events, pipe, LPOLLIN);
if (ret < 0) {
ERR("Error adding fd event notifier notification pipe to lttng_poll_event: fd = %d",
- pipe);
+ pipe);
goto end;
}
ret = handle_one_event_notifier_notification(state, pipe, domain);
if (ret) {
ERR("Error consuming an event notifier notification from pipe: fd = %d",
- pipe);
+ pipe);
}
}
end:
return ret;
}
-static
-struct notification_event_tracer_event_source_element *
+static struct notification_event_tracer_event_source_element *
find_tracer_event_source_element(struct notification_thread_state *state,
- int tracer_event_source_fd)
+ int tracer_event_source_fd)
{
struct notification_event_tracer_event_source_element *source_element;
- cds_list_for_each_entry(source_element,
- &state->tracer_event_sources_list, node) {
+ cds_list_for_each_entry (source_element, &state->tracer_event_sources_list, node) {
if (source_element->fd == tracer_event_source_fd) {
goto end;
}
return source_element;
}
-static
-int remove_tracer_event_source_from_pollset(
- struct notification_thread_state *state,
- struct notification_event_tracer_event_source_element *source_element)
+static int remove_tracer_event_source_from_pollset(
+ struct notification_thread_state *state,
+ struct notification_event_tracer_event_source_element *source_element)
{
int ret = 0;
LTTNG_ASSERT(source_element->is_fd_in_poll_set);
DBG3("Removing tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
- source_element->fd,
- lttng_domain_type_str(source_element->domain));
+ source_element->fd,
+ lttng_domain_type_str(source_element->domain));
/* Removing the fd from the event poll set. */
ret = lttng_poll_del(&state->events, source_element->fd);
if (ret < 0) {
ERR("Failed to remove tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
- source_element->fd,
- lttng_domain_type_str(source_element->domain));
+ source_element->fd,
+ lttng_domain_type_str(source_element->domain));
ret = -1;
goto end;
}
*/
state->restart_poll = true;
- ret = drain_event_notifier_notification_pipe(state, source_element->fd,
- source_element->domain);
+ ret = drain_event_notifier_notification_pipe(
+ state, source_element->fd, source_element->domain);
if (ret) {
ERR("Error draining event notifier notification: tracer_event_source_fd = %d, domain = %s",
- source_element->fd,
- lttng_domain_type_str(source_element->domain));
+ source_element->fd,
+ lttng_domain_type_str(source_element->domain));
ret = -1;
goto end;
}
return ret;
}
-int handle_notification_thread_tracer_event_source_died(
- struct notification_thread_state *state,
- int tracer_event_source_fd)
+int handle_notification_thread_tracer_event_source_died(struct notification_thread_state *state,
+ int tracer_event_source_fd)
{
int ret = 0;
struct notification_event_tracer_event_source_element *source_element;
- source_element = find_tracer_event_source_element(state,
- tracer_event_source_fd);
+ source_element = find_tracer_event_source_element(state, tracer_event_source_fd);
LTTNG_ASSERT(source_element);
return ret;
}
-static
-int handle_notification_thread_command_remove_tracer_event_source(
- struct notification_thread_state *state,
- int tracer_event_source_fd,
- enum lttng_error_code *_cmd_result)
+static int handle_notification_thread_command_remove_tracer_event_source(
+ struct notification_thread_state *state,
+ int tracer_event_source_fd,
+ enum lttng_error_code *_cmd_result)
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
struct notification_event_tracer_event_source_element *source_element = NULL;
- source_element = find_tracer_event_source_element(state,
- tracer_event_source_fd);
+ source_element = find_tracer_event_source_element(state, tracer_event_source_fd);
LTTNG_ASSERT(source_element);
return ret;
}
-static int handle_notification_thread_command_list_triggers(
- struct notification_thread_handle *handle __attribute__((unused)),
- struct notification_thread_state *state,
- uid_t client_uid,
- struct lttng_triggers **triggers,
- enum lttng_error_code *_cmd_result)
+static int
+handle_notification_thread_command_list_triggers(struct notification_thread_handle *handle
+ __attribute__((unused)),
+ struct notification_thread_state *state,
+ uid_t client_uid,
+ struct lttng_triggers **triggers,
+ enum lttng_error_code *_cmd_result)
{
int ret = 0;
enum lttng_error_code cmd_result = LTTNG_OK;
goto end;
}
- cds_lfht_for_each_entry(state->triggers_ht, &iter,
- trigger_ht_element, node) {
+ cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
/*
* Only return the triggers to which the client has access.
* The root user has visibility over all triggers.
continue;
}
- ret = lttng_triggers_add(local_triggers,
- trigger_ht_element->trigger);
+ ret = lttng_triggers_add(local_triggers, trigger_ht_element->trigger);
if (ret < 0) {
/* Not a fatal error. */
ret = 0;
}
static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
- const char **trigger_name,
- uid_t *trigger_owner_uid)
+ const char **trigger_name,
+ uid_t *trigger_owner_uid)
{
enum lttng_trigger_status trigger_status;
abort();
}
- trigger_status = lttng_trigger_get_owner_uid(trigger,
- trigger_owner_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, trigger_owner_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
}
-static int handle_notification_thread_command_get_trigger(
- struct notification_thread_state *state,
- const struct lttng_trigger *trigger,
- struct lttng_trigger **registered_trigger,
- enum lttng_error_code *_cmd_result)
+static int handle_notification_thread_command_get_trigger(struct notification_thread_state *state,
+ const struct lttng_trigger *trigger,
+ struct lttng_trigger **registered_trigger,
+ enum lttng_error_code *_cmd_result)
{
int ret = -1;
struct cds_lfht_iter iter;
rcu_read_lock();
- cds_lfht_for_each_entry(
- state->triggers_ht, &iter, trigger_ht_element, node) {
- if (lttng_trigger_is_equal(
- trigger, trigger_ht_element->trigger)) {
+ cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
+ if (lttng_trigger_is_equal(trigger, trigger_ht_element->trigger)) {
/* Take one reference on the return trigger. */
*registered_trigger = trigger_ht_element->trigger;
lttng_trigger_get(*registered_trigger);
/* Not a fatal error if the trigger is not found. */
get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
DBG("Failed to retrieve registered version of trigger: trigger name = '%s', trigger owner uid = %d",
- trigger_name, (int) trigger_owner_uid);
+ trigger_name,
+ (int) trigger_owner_uid);
ret = 0;
return ret;
}
-static
-bool condition_is_supported(struct lttng_condition *condition)
+static bool condition_is_supported(struct lttng_condition *condition)
{
bool is_supported;
int ret;
enum lttng_domain_type domain;
- ret = lttng_condition_buffer_usage_get_domain_type(condition,
- &domain);
+ ret = lttng_condition_buffer_usage_get_domain_type(condition, &domain);
LTTNG_ASSERT(ret == 0);
if (domain != LTTNG_DOMAIN_KERNEL) {
const struct lttng_event_rule *event_rule;
enum lttng_domain_type domain;
const enum lttng_condition_status status =
- lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
}
/* Must be called with RCU read lock held. */
-static
-int bind_trigger_to_matching_session(struct lttng_trigger *trigger,
- struct notification_thread_state *state)
+static int bind_trigger_to_matching_session(struct lttng_trigger *trigger,
+ struct notification_thread_state *state)
{
int ret = 0;
const struct lttng_condition *condition;
trigger_list = get_session_trigger_list(state, session_name);
if (!trigger_list) {
DBG("Unable to bind trigger applying to session \"%s\" as it is not yet known to the notification system",
- session_name);
+ session_name);
goto end;
-
}
- DBG("Newly registered trigger bound to session \"%s\"",
- session_name);
+ DBG("Newly registered trigger bound to session \"%s\"", session_name);
ret = lttng_session_trigger_list_add(trigger_list, trigger);
end:
return ret;
}
/* Must be called with RCU read lock held. */
-static
-int bind_trigger_to_matching_channels(struct lttng_trigger *trigger,
- struct notification_thread_state *state)
+static int bind_trigger_to_matching_channels(struct lttng_trigger *trigger,
+ struct notification_thread_state *state)
{
int ret = 0;
struct cds_lfht_node *node;
ASSERT_RCU_READ_LOCKED();
- cds_lfht_for_each_entry(state->channels_ht, &iter, channel,
- channels_ht_node) {
+ cds_lfht_for_each_entry (state->channels_ht, &iter, channel, channels_ht_node) {
struct lttng_trigger_list_element *trigger_list_element;
struct lttng_channel_trigger_list *trigger_list;
struct cds_lfht_iter lookup_iter;
&lookup_iter);
node = cds_lfht_iter_get_node(&lookup_iter);
LTTNG_ASSERT(node);
- trigger_list = caa_container_of(node,
- struct lttng_channel_trigger_list,
- channel_triggers_ht_node);
+ trigger_list = caa_container_of(
+ node, struct lttng_channel_trigger_list, channel_triggers_ht_node);
trigger_list_element = zmalloc<lttng_trigger_list_element>();
if (!trigger_list_element) {
CDS_INIT_LIST_HEAD(&trigger_list_element->node);
trigger_list_element->trigger = trigger;
cds_list_add(&trigger_list_element->node, &trigger_list->list);
- DBG("Newly registered trigger bound to channel \"%s\"",
- channel->name);
+ DBG("Newly registered trigger bound to channel \"%s\"", channel->name);
}
end:
return ret;
}
-static
-bool is_trigger_action_notify(const struct lttng_trigger *trigger)
+static bool is_trigger_action_notify(const struct lttng_trigger *trigger)
{
bool is_notify = false;
unsigned int i, count;
enum lttng_action_status action_status;
- const struct lttng_action *action =
- lttng_trigger_get_const_action(trigger);
+ const struct lttng_action *action = lttng_trigger_get_const_action(trigger);
enum lttng_action_type action_type;
LTTNG_ASSERT(action);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
for (i = 0; i < count; i++) {
- const struct lttng_action *inner_action =
- lttng_action_list_get_at_index(
- action, i);
+ const struct lttng_action *inner_action = lttng_action_list_get_at_index(action, i);
action_type = lttng_action_get_type(inner_action);
if (action_type == LTTNG_ACTION_TYPE_NOTIFY) {
}
static bool trigger_name_taken(struct notification_thread_state *state,
- const struct lttng_trigger *trigger)
+ const struct lttng_trigger *trigger)
{
struct cds_lfht_iter iter;
return !!cds_lfht_iter_get_node(&iter);
}
-static
-enum lttng_error_code generate_trigger_name(
- struct notification_thread_state *state,
- struct lttng_trigger *trigger, const char **name)
+static enum lttng_error_code generate_trigger_name(struct notification_thread_state *state,
+ struct lttng_trigger *trigger,
+ const char **name)
{
enum lttng_error_code ret_code = LTTNG_OK;
bool taken = false;
enum lttng_trigger_status status;
do {
- const int ret = lttng_trigger_generate_name(trigger,
- state->trigger_id.name_offset++);
+ const int ret =
+ lttng_trigger_generate_name(trigger, state->trigger_id.name_offset++);
if (ret) {
/* The only reason this can fail right now. */
ret_code = LTTNG_ERR_NOMEM;
return ret_code;
}
-static inline
-void notif_thread_state_remove_trigger_ht_elem(
- struct notification_thread_state *state,
- struct lttng_trigger_ht_element *trigger_ht_element)
+static inline void
+notif_thread_state_remove_trigger_ht_elem(struct notification_thread_state *state,
+ struct lttng_trigger_ht_element *trigger_ht_element)
{
LTTNG_ASSERT(state);
LTTNG_ASSERT(trigger_ht_element);
cds_lfht_del(state->triggers_by_name_uid_ht, &trigger_ht_element->node_by_name_uid);
}
-static
-enum lttng_error_code setup_tracer_notifier(
- struct notification_thread_state *state,
- struct lttng_trigger *trigger)
+static enum lttng_error_code setup_tracer_notifier(struct notification_thread_state *state,
+ struct lttng_trigger *trigger)
{
enum lttng_error_code ret;
enum event_notifier_error_accounting_status error_accounting_status;
trigger_tokens_ht_element->trigger = trigger;
node = cds_lfht_add_unique(state->trigger_tokens_ht,
- hash_key_u64(&trigger_tokens_ht_element->token, lttng_ht_seed),
- match_trigger_token,
- &trigger_tokens_ht_element->token,
- &trigger_tokens_ht_element->node);
+ hash_key_u64(&trigger_tokens_ht_element->token, lttng_ht_seed),
+ match_trigger_token,
+ &trigger_tokens_ht_element->token,
+ &trigger_tokens_ht_element->node);
if (node != &trigger_tokens_ht_element->node) {
ret = LTTNG_ERR_TRIGGER_EXISTS;
goto error_free_ht_element;
}
error_accounting_status = event_notifier_error_accounting_register_event_notifier(
- trigger, &error_counter_index);
+ trigger, &error_counter_index);
if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
- if (error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
+ if (error_accounting_status ==
+ EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
DBG("Trigger list error accounting counter full.");
ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL;
} else {
goto error_remove_ht_element;
}
- lttng_condition_event_rule_matches_set_error_counter_index(
- condition, error_counter_index);
+ lttng_condition_event_rule_matches_set_error_counter_index(condition, error_counter_index);
ret = LTTNG_OK;
goto end;
* If a non-fatal error occurs, just set the cmd_result to the appropriate
* error code.
*/
-static
-int handle_notification_thread_command_register_trigger(
- struct notification_thread_state *state,
- struct lttng_trigger *trigger,
- bool is_trigger_anonymous,
- enum lttng_error_code *cmd_result)
+static int
+handle_notification_thread_command_register_trigger(struct notification_thread_state *state,
+ struct lttng_trigger *trigger,
+ bool is_trigger_anonymous,
+ enum lttng_error_code *cmd_result)
{
int ret = 0;
struct lttng_condition *condition;
struct notification_client_list *client_list = NULL;
struct lttng_trigger_ht_element *trigger_ht_element = NULL;
struct cds_lfht_node *node;
- const char* trigger_name;
+ const char *trigger_name;
bool free_trigger = true;
struct lttng_evaluation *evaluation = NULL;
struct lttng_credentials object_creds;
uid_t object_uid;
gid_t object_gid;
enum action_executor_status executor_status;
- const uint64_t trigger_tracer_token =
- state->trigger_id.next_tracer_token++;
+ const uint64_t trigger_tracer_token = state->trigger_id.next_tracer_token++;
rcu_read_lock();
lttng_trigger_set_tracer_token(trigger, trigger_tracer_token);
if (!is_trigger_anonymous) {
- if (lttng_trigger_get_name(trigger, &trigger_name) ==
- LTTNG_TRIGGER_STATUS_UNSET) {
+ if (lttng_trigger_get_name(trigger, &trigger_name) == LTTNG_TRIGGER_STATUS_UNSET) {
const enum lttng_error_code ret_code =
- generate_trigger_name(state, trigger,
- &trigger_name);
+ generate_trigger_name(state, trigger, &trigger_name);
if (ret_code != LTTNG_OK) {
/* Fatal error. */
trigger_ht_element->trigger = trigger;
node = cds_lfht_add_unique(state->triggers_ht,
- lttng_condition_hash(condition),
- match_trigger,
- trigger,
- &trigger_ht_element->node);
+ lttng_condition_hash(condition),
+ match_trigger,
+ trigger,
+ &trigger_ht_element->node);
if (node != &trigger_ht_element->node) {
/* Not a fatal error, simply report it to the client. */
*cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
}
node = cds_lfht_add_unique(state->triggers_by_name_uid_ht,
- hash_trigger_by_name_uid(trigger),
- match_trigger_by_name_uid,
- trigger,
- &trigger_ht_element->node_by_name_uid);
+ hash_trigger_by_name_uid(trigger),
+ match_trigger_by_name_uid,
+ trigger,
+ &trigger_ht_element->node_by_name_uid);
if (node != &trigger_ht_element->node_by_name_uid) {
/* Internal error: add to triggers_ht should have failed. */
ret = -1;
error_code = setup_tracer_notifier(state, trigger);
if (error_code != LTTNG_OK) {
- notif_thread_state_remove_trigger_ht_elem(state,
- trigger_ht_element);
+ notif_thread_state_remove_trigger_ht_elem(state, trigger_ht_element);
if (error_code == LTTNG_ERR_NOMEM) {
ret = -1;
} else {
*/
client_list = notification_client_list_create(state, condition);
if (!client_list) {
- ERR("Error creating notification client list for trigger %s", trigger->name);
+ ERR("Error creating notification client list for trigger %s",
+ trigger->name);
ret = -1;
goto error_free_ht_element;
}
CDS_INIT_LIST_HEAD(&trigger_ht_element->client_list_trigger_node);
pthread_mutex_lock(&client_list->lock);
- cds_list_add(&trigger_ht_element->client_list_trigger_node, &client_list->triggers_list);
+ cds_list_add(&trigger_ht_element->client_list_trigger_node,
+ &client_list->triggers_list);
pthread_mutex_unlock(&client_list->lock);
}
if (!session_info) {
/* Not an error, the session doesn't exist yet. */
DBG("Session not found while evaluating session condition during registration of trigger: session name = `%s`",
- session_name);
+ session_name);
ret = 0;
goto success;
}
break;
}
case LTTNG_OBJECT_TYPE_CHANNEL:
- ret = evaluate_channel_condition_for_client(condition, state,
- &evaluation, &object_uid,
- &object_gid);
+ ret = evaluate_channel_condition_for_client(
+ condition, state, &evaluation, &object_uid, &object_gid);
LTTNG_OPTIONAL_SET(&object_creds.uid, object_uid);
LTTNG_OPTIONAL_SET(&object_creds.gid, object_gid);
break;
goto error_free_ht_element;
}
- DBG("Newly registered trigger's condition evaluated to %s",
- evaluation ? "true" : "false");
+ DBG("Newly registered trigger's condition evaluated to %s", evaluation ? "true" : "false");
if (!evaluation) {
/* Evaluation yielded nothing. Normal exit. */
ret = 0;
* Ownership of `evaluation` transferred to the action executor
* no matter the result.
*/
- executor_status = action_executor_enqueue_trigger(state->executor,
- trigger, evaluation, &object_creds, client_list);
+ executor_status = action_executor_enqueue_trigger(
+ state->executor, trigger, evaluation, &object_creds, client_list);
evaluation = NULL;
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
success:
*cmd_result = LTTNG_OK;
DBG("Registered trigger: name = `%s`, tracer token = %" PRIu64,
- trigger_name, trigger_tracer_token);
+ trigger_name,
+ trigger_tracer_token);
goto end;
error_free_ht_element:
if (trigger_ht_element) {
/* Delayed removal due to RCU constraint on delete. */
- call_rcu(&trigger_ht_element->rcu_node,
- free_lttng_trigger_ht_element_rcu);
+ call_rcu(&trigger_ht_element->rcu_node, free_lttng_trigger_ht_element_rcu);
}
error:
if (free_trigger) {
return ret;
}
-static
-void free_lttng_trigger_ht_element_rcu(struct rcu_head *node)
+static void free_lttng_trigger_ht_element_rcu(struct rcu_head *node)
{
- free(caa_container_of(node, struct lttng_trigger_ht_element,
- rcu_node));
+ free(caa_container_of(node, struct lttng_trigger_ht_element, rcu_node));
}
-static
-void free_notification_trigger_tokens_ht_element_rcu(struct rcu_head *node)
+static void free_notification_trigger_tokens_ht_element_rcu(struct rcu_head *node)
{
- free(caa_container_of(node, struct notification_trigger_tokens_ht_element,
- rcu_node));
+ free(caa_container_of(node, struct notification_trigger_tokens_ht_element, rcu_node));
}
-static
-void teardown_tracer_notifier(struct notification_thread_state *state,
- const struct lttng_trigger *trigger)
+static void teardown_tracer_notifier(struct notification_thread_state *state,
+ const struct lttng_trigger *trigger)
{
struct cds_lfht_iter iter;
struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element;
- cds_lfht_for_each_entry(state->trigger_tokens_ht, &iter,
- trigger_tokens_ht_element, node) {
-
- if (!lttng_trigger_is_equal(trigger,
- trigger_tokens_ht_element->trigger)) {
+ cds_lfht_for_each_entry (state->trigger_tokens_ht, &iter, trigger_tokens_ht_element, node) {
+ if (!lttng_trigger_is_equal(trigger, trigger_tokens_ht_element->trigger)) {
continue;
}
event_notifier_error_accounting_unregister_event_notifier(
- trigger_tokens_ht_element->trigger);
+ trigger_tokens_ht_element->trigger);
/* TODO talk to all app and remove it */
DBG("Removed trigger from tokens_ht");
- cds_lfht_del(state->trigger_tokens_ht,
- &trigger_tokens_ht_element->node);
+ cds_lfht_del(state->trigger_tokens_ht, &trigger_tokens_ht_element->node);
call_rcu(&trigger_tokens_ht_element->rcu_node,
- free_notification_trigger_tokens_ht_element_rcu);
+ free_notification_trigger_tokens_ht_element_rcu);
break;
}
}
-static
-void remove_trigger_from_session_trigger_list(
- struct lttng_session_trigger_list *trigger_list,
- const struct lttng_trigger *trigger)
+static void
+remove_trigger_from_session_trigger_list(struct lttng_session_trigger_list *trigger_list,
+ const struct lttng_trigger *trigger)
{
bool found = false;
struct lttng_trigger_list_element *trigger_element, *tmp;
if (!found) {
ERR("Failed to find trigger associated with session: session name = `%s`",
- trigger_list->session_name);
+ trigger_list->session_name);
}
LTTNG_ASSERT(found);
}
-static
-int handle_notification_thread_command_unregister_trigger(
- struct notification_thread_state *state,
- const struct lttng_trigger *trigger,
- enum lttng_error_code *_cmd_reply)
+static int
+handle_notification_thread_command_unregister_trigger(struct notification_thread_state *state,
+ const struct lttng_trigger *trigger,
+ enum lttng_error_code *_cmd_reply)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *triggers_ht_node;
struct notification_client_list *client_list;
struct lttng_trigger_ht_element *trigger_ht_element = NULL;
- const struct lttng_condition *condition = lttng_trigger_get_const_condition(
- trigger);
+ const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
enum lttng_error_code cmd_reply;
rcu_read_lock();
- cds_lfht_lookup(state->triggers_ht,
- lttng_condition_hash(condition),
- match_trigger,
- trigger,
- &iter);
+ cds_lfht_lookup(
+ state->triggers_ht, lttng_condition_hash(condition), match_trigger, trigger, &iter);
triggers_ht_node = cds_lfht_iter_get_node(&iter);
if (!triggers_ht_node) {
cmd_reply = LTTNG_ERR_TRIGGER_NOT_FOUND;
cmd_reply = LTTNG_OK;
}
- trigger_ht_element = caa_container_of(triggers_ht_node,
- struct lttng_trigger_ht_element, node);
+ trigger_ht_element =
+ caa_container_of(triggers_ht_node, struct lttng_trigger_ht_element, node);
switch (get_condition_binding_object(condition)) {
case LTTNG_OBJECT_TYPE_CHANNEL:
*
* Iterate on all lists since we don't know the target channels' keys.
*/
- cds_lfht_for_each_entry(state->channel_triggers_ht, &iter, trigger_list,
- channel_triggers_ht_node) {
+ cds_lfht_for_each_entry (
+ state->channel_triggers_ht, &iter, trigger_list, channel_triggers_ht_node) {
struct lttng_trigger_list_element *trigger_element, *tmp;
- cds_list_for_each_entry_safe(
- trigger_element, tmp, &trigger_list->list, node) {
+ cds_list_for_each_entry_safe (
+ trigger_element, tmp, &trigger_list->list, node) {
if (!lttng_trigger_is_equal(trigger, trigger_element->trigger)) {
continue;
}
}
case LTTNG_OBJECT_TYPE_SESSION:
{
- auto session = get_session_info_by_name(
- state, get_condition_session_name(condition));
+ auto session =
+ get_session_info_by_name(state, get_condition_session_name(condition));
/* Session doesn't exist, no trigger to remove. */
if (!session) {
return 0;
}
-static
-int pop_cmd_queue(struct notification_thread_handle *handle,
- struct notification_thread_command **cmd)
+static int pop_cmd_queue(struct notification_thread_handle *handle,
+ struct notification_thread_command **cmd)
{
int ret;
uint64_t counter;
goto error_unlock;
}
- *cmd = cds_list_first_entry(&handle->cmd_queue.list,
- struct notification_thread_command, cmd_list_node);
+ *cmd = cds_list_first_entry(
+ &handle->cmd_queue.list, struct notification_thread_command, cmd_list_node);
cds_list_del(&((*cmd)->cmd_list_node));
ret = 0;
}
/* Returns 0 on success, 1 on exit requested, negative value on error. */
-int handle_notification_thread_command(
- struct notification_thread_handle *handle,
- struct notification_thread_state *state)
+int handle_notification_thread_command(struct notification_thread_handle *handle,
+ struct notification_thread_state *state)
{
int ret;
struct notification_thread_command *cmd;
goto error;
}
- DBG("Received `%s` command",
- notification_command_type_str(cmd->type));
+ DBG("Received `%s` command", notification_command_type_str(cmd->type));
switch (cmd->type) {
case NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER:
- ret = handle_notification_thread_command_register_trigger(state,
- cmd->parameters.register_trigger.trigger,
- cmd->parameters.register_trigger.is_trigger_anonymous,
- &cmd->reply_code);
+ ret = handle_notification_thread_command_register_trigger(
+ state,
+ cmd->parameters.register_trigger.trigger,
+ cmd->parameters.register_trigger.is_trigger_anonymous,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER:
ret = handle_notification_thread_command_unregister_trigger(
- state,
- cmd->parameters.unregister_trigger.trigger,
- &cmd->reply_code);
+ state, cmd->parameters.unregister_trigger.trigger, &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL:
ret = handle_notification_thread_command_add_channel(
- state,
- cmd->parameters.add_channel.session.id,
- cmd->parameters.add_channel.channel.name,
- cmd->parameters.add_channel.channel.domain,
- cmd->parameters.add_channel.channel.key,
- cmd->parameters.add_channel.channel.capacity,
- &cmd->reply_code);
+ state,
+ cmd->parameters.add_channel.session.id,
+ cmd->parameters.add_channel.channel.name,
+ cmd->parameters.add_channel.channel.domain,
+ cmd->parameters.add_channel.channel.key,
+ cmd->parameters.add_channel.channel.capacity,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL:
ret = handle_notification_thread_command_remove_channel(
- state, cmd->parameters.remove_channel.key,
- cmd->parameters.remove_channel.domain,
- &cmd->reply_code);
+ state,
+ cmd->parameters.remove_channel.key,
+ cmd->parameters.remove_channel.domain,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_ADD_SESSION:
- ret = handle_notification_thread_command_add_session(state,
- cmd->parameters.add_session.session_id,
- cmd->parameters.add_session.session_name,
- cmd->parameters.add_session.session_uid,
- cmd->parameters.add_session.session_gid, &cmd->reply_code);
+ ret = handle_notification_thread_command_add_session(
+ state,
+ cmd->parameters.add_session.session_id,
+ cmd->parameters.add_session.session_name,
+ cmd->parameters.add_session.session_uid,
+ cmd->parameters.add_session.session_gid,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION:
ret = handle_notification_thread_command_remove_session(
- state, cmd->parameters.remove_session.session_id, &cmd->reply_code);
+ state, cmd->parameters.remove_session.session_id, &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING:
case NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED:
ret = handle_notification_thread_command_session_rotation(
- state,
- cmd->type,
- cmd->parameters.session_rotation.session_id,
- cmd->parameters.session_rotation.trace_archive_chunk_id,
- cmd->parameters.session_rotation.location,
- &cmd->reply_code);
+ state,
+ cmd->type,
+ cmd->parameters.session_rotation.session_id,
+ cmd->parameters.session_rotation.trace_archive_chunk_id,
+ cmd->parameters.session_rotation.location,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE:
ret = handle_notification_thread_command_add_tracer_event_source(
- state,
- cmd->parameters.tracer_event_source.tracer_event_source_fd,
- cmd->parameters.tracer_event_source.domain,
- &cmd->reply_code);
+ state,
+ cmd->parameters.tracer_event_source.tracer_event_source_fd,
+ cmd->parameters.tracer_event_source.domain,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE:
ret = handle_notification_thread_command_remove_tracer_event_source(
- state,
- cmd->parameters.tracer_event_source.tracer_event_source_fd,
- &cmd->reply_code);
+ state,
+ cmd->parameters.tracer_event_source.tracer_event_source_fd,
+ &cmd->reply_code);
break;
case NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS:
{
struct lttng_triggers *triggers = NULL;
ret = handle_notification_thread_command_list_triggers(
- handle,
- state,
- cmd->parameters.list_triggers.uid,
- &triggers,
- &cmd->reply_code);
+ handle,
+ state,
+ cmd->parameters.list_triggers.uid,
+ &triggers,
+ &cmd->reply_code);
cmd->reply.list_triggers.triggers = triggers;
ret = 0;
break;
{
struct lttng_trigger *trigger = NULL;
- ret = handle_notification_thread_command_get_trigger(state,
- cmd->parameters.get_trigger.trigger, &trigger,
- &cmd->reply_code);
+ ret = handle_notification_thread_command_get_trigger(
+ state, cmd->parameters.get_trigger.trigger, &trigger, &cmd->reply_code);
cmd->reply.get_trigger.trigger = trigger;
break;
}
case NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE:
{
const enum client_transmission_status client_status =
- cmd->parameters.client_communication_update
- .status;
+ cmd->parameters.client_communication_update.status;
const notification_client_id client_id =
- cmd->parameters.client_communication_update.id;
+ cmd->parameters.client_communication_update.id;
struct notification_client *client;
rcu_read_lock();
* gracefully while this command was queued.
*/
DBG("Failed to find notification client to update communication status, client id = %" PRIu64,
- client_id);
+ client_id);
ret = 0;
} else {
- ret = client_handle_transmission_status(
- client, client_status, state);
+ ret = client_handle_transmission_status(client, client_status, state);
}
rcu_read_unlock();
break;
return -1;
}
-static
-int socket_set_non_blocking(int socket)
+static int socket_set_non_blocking(int socket)
{
int ret, flags;
return ret;
}
-static
-int client_reset_inbound_state(struct notification_client *client)
+static int client_reset_inbound_state(struct notification_client *client)
{
int ret;
-
lttng_payload_clear(&client->communication.inbound.payload);
client->communication.inbound.bytes_to_receive =
- sizeof(struct lttng_notification_channel_message);
- client->communication.inbound.msg_type =
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN;
+ sizeof(struct lttng_notification_channel_message);
+ client->communication.inbound.msg_type = LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN;
LTTNG_SOCK_SET_UID_CRED(&client->communication.inbound.creds, -1);
LTTNG_SOCK_SET_GID_CRED(&client->communication.inbound.creds, -1);
- ret = lttng_dynamic_buffer_set_size(
- &client->communication.inbound.payload.buffer,
- client->communication.inbound.bytes_to_receive);
+ ret = lttng_dynamic_buffer_set_size(&client->communication.inbound.payload.buffer,
+ client->communication.inbound.bytes_to_receive);
return ret;
}
-int handle_notification_thread_client_connect(
- struct notification_thread_state *state)
+int handle_notification_thread_client_connect(struct notification_thread_state *state)
{
int ret;
struct notification_client *client;
}
client->communication.current_poll_events = CLIENT_POLL_EVENTS_IN;
- ret = lttng_poll_add(&state->events, client->socket,
- client->communication.current_poll_events);
+ ret = lttng_poll_add(
+ &state->events, client->socket, client->communication.current_poll_events);
if (ret < 0) {
ERR("Failed to add notification channel client socket to poll set");
ret = 0;
goto error;
}
- DBG("Added new notification channel client socket (%i) to poll set",
- client->socket);
+ DBG("Added new notification channel client socket (%i) to poll set", client->socket);
rcu_read_lock();
cds_lfht_add(state->client_socket_ht,
- hash_client_socket(client->socket),
- &client->client_socket_ht_node);
- cds_lfht_add(state->client_id_ht,
- hash_client_id(client->id),
- &client->client_id_ht_node);
+ hash_client_socket(client->socket),
+ &client->client_socket_ht_node);
+ cds_lfht_add(state->client_id_ht, hash_client_id(client->id), &client->client_id_ht_node);
rcu_read_unlock();
return ret;
* RCU read-lock must be held by the caller.
* Client lock must _not_ be held by the caller.
*/
-static
-int notification_thread_client_disconnect(
- struct notification_client *client,
- struct notification_thread_state *state)
+static int notification_thread_client_disconnect(struct notification_client *client,
+ struct notification_thread_state *state)
{
int ret;
struct lttng_condition_list_element *condition_list_element, *tmp;
ret = lttng_poll_del(&state->events, client->socket);
if (ret) {
- ERR("Failed to remove client socket %d from poll set",
- client->socket);
+ ERR("Failed to remove client socket %d from poll set", client->socket);
}
/* Release all conditions to which the client was subscribed. */
- cds_list_for_each_entry_safe(condition_list_element, tmp,
- &client->condition_list, node) {
- (void) notification_thread_client_unsubscribe(client,
- condition_list_element->condition, state, NULL);
+ cds_list_for_each_entry_safe (condition_list_element, tmp, &client->condition_list, node) {
+ (void) notification_thread_client_unsubscribe(
+ client, condition_list_element->condition, state, NULL);
}
/*
return ret;
}
-int handle_notification_thread_client_disconnect(
- int client_socket, struct notification_thread_state *state)
+int handle_notification_thread_client_disconnect(int client_socket,
+ struct notification_thread_state *state)
{
int ret = 0;
struct notification_client *client;
rcu_read_lock();
- DBG("Closing client connection (socket fd = %i)",
- client_socket);
+ DBG("Closing client connection (socket fd = %i)", client_socket);
client = get_client_from_socket(client_socket, state);
if (!client) {
/* Internal state corruption, fatal error. */
- ERR("Unable to find client (socket fd = %i)",
- client_socket);
+ ERR("Unable to find client (socket fd = %i)", client_socket);
ret = -1;
goto end;
}
return ret;
}
-int handle_notification_thread_client_disconnect_all(
- struct notification_thread_state *state)
+int handle_notification_thread_client_disconnect_all(struct notification_thread_state *state)
{
struct cds_lfht_iter iter;
struct notification_client *client;
rcu_read_lock();
DBG("Closing all client connections");
- cds_lfht_for_each_entry(state->client_socket_ht, &iter, client,
- client_socket_ht_node) {
+ cds_lfht_for_each_entry (state->client_socket_ht, &iter, client, client_socket_ht_node) {
int ret;
- ret = notification_thread_client_disconnect(
- client, state);
+ ret = notification_thread_client_disconnect(client, state);
if (ret) {
error_encoutered = true;
}
return error_encoutered ? 1 : 0;
}
-int handle_notification_thread_trigger_unregister_all(
- struct notification_thread_state *state)
+int handle_notification_thread_trigger_unregister_all(struct notification_thread_state *state)
{
bool error_occurred = false;
struct cds_lfht_iter iter;
struct lttng_trigger_ht_element *trigger_ht_element;
rcu_read_lock();
- cds_lfht_for_each_entry(state->triggers_ht, &iter, trigger_ht_element,
- node) {
+ cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
int ret = handle_notification_thread_command_unregister_trigger(
- state, trigger_ht_element->trigger, NULL);
+ state, trigger_ht_element->trigger, NULL);
if (ret) {
error_occurred = true;
}
return error_occurred ? -1 : 0;
}
-static
-bool client_has_outbound_data_left(
- const struct notification_client *client)
+static bool client_has_outbound_data_left(const struct notification_client *client)
{
- const struct lttng_payload_view pv = lttng_payload_view_from_payload(
- &client->communication.outbound.payload, 0, -1);
+ const struct lttng_payload_view pv =
+ lttng_payload_view_from_payload(&client->communication.outbound.payload, 0, -1);
const bool has_data = pv.buffer.size != 0;
const bool has_fds = lttng_payload_view_get_fd_handle_count(&pv);
return has_data || has_fds;
}
-static
-int client_handle_transmission_status(
- struct notification_client *client,
- enum client_transmission_status transmission_status,
- struct notification_thread_state *state)
+static int client_handle_transmission_status(struct notification_client *client,
+ enum client_transmission_status transmission_status,
+ struct notification_thread_state *state)
{
int ret = 0;
pthread_mutex_lock(&client->lock);
current_poll_events = client->communication.current_poll_events;
new_poll_events = client_has_outbound_data_left(client) ?
- CLIENT_POLL_EVENTS_IN_OUT :
- CLIENT_POLL_EVENTS_IN;
+ CLIENT_POLL_EVENTS_IN_OUT :
+ CLIENT_POLL_EVENTS_IN;
client->communication.current_poll_events = new_poll_events;
pthread_mutex_unlock(&client->lock);
/* Update the monitored event set only if it changed. */
if (current_poll_events != new_poll_events) {
- ret = lttng_poll_mod(&state->events, client->socket,
- new_poll_events);
+ ret = lttng_poll_mod(&state->events, client->socket, new_poll_events);
if (ret) {
goto end;
}
}
/* Client lock must be acquired by caller. */
-static
-enum client_transmission_status client_flush_outgoing_queue(
- struct notification_client *client)
+static enum client_transmission_status
+client_flush_outgoing_queue(struct notification_client *client)
{
ssize_t ret;
size_t to_send_count;
enum client_transmission_status status;
- struct lttng_payload_view pv = lttng_payload_view_from_payload(
- &client->communication.outbound.payload, 0, -1);
- const int fds_to_send_count =
- lttng_payload_view_get_fd_handle_count(&pv);
+ struct lttng_payload_view pv =
+ lttng_payload_view_from_payload(&client->communication.outbound.payload, 0, -1);
+ const int fds_to_send_count = lttng_payload_view_get_fd_handle_count(&pv);
ASSERT_LOCKED(client->lock);
/* Send data. */
to_send_count = pv.buffer.size;
- DBG("Flushing client (socket fd = %i) outgoing queue",
- client->socket);
+ DBG("Flushing client (socket fd = %i) outgoing queue", client->socket);
- ret = lttcomm_send_unix_sock_non_block(client->socket,
- pv.buffer.data,
- to_send_count);
+ ret = lttcomm_send_unix_sock_non_block(client->socket, pv.buffer.data, to_send_count);
if ((ret >= 0 && ret < to_send_count)) {
DBG("Client (socket fd = %i) outgoing queue could not be completely flushed",
- client->socket);
+ client->socket);
to_send_count -= std::max(ret, (ssize_t) 0);
memmove(client->communication.outbound.payload.buffer.data,
- pv.buffer.data +
- pv.buffer.size - to_send_count,
- to_send_count);
- ret = lttng_dynamic_buffer_set_size(
- &client->communication.outbound.payload.buffer,
- to_send_count);
+ pv.buffer.data + pv.buffer.size - to_send_count,
+ to_send_count);
+ ret = lttng_dynamic_buffer_set_size(&client->communication.outbound.payload.buffer,
+ to_send_count);
if (ret) {
goto error;
}
} else if (ret < 0) {
/* Generic error, disable the client's communication. */
ERR("Failed to flush outgoing queue, disconnecting client (socket fd = %i)",
- client->socket);
+ client->socket);
client->communication.active = false;
status = CLIENT_TRANSMISSION_STATUS_FAIL;
goto end;
* direct caller knows that the transmission is complete, we
* need to set the buffer size to zero.
*/
- ret = lttng_dynamic_buffer_set_size(
- &client->communication.outbound.payload.buffer, 0);
+ ret = lttng_dynamic_buffer_set_size(&client->communication.outbound.payload.buffer,
+ 0);
if (ret) {
goto error;
}
goto end;
}
- ret = lttcomm_send_payload_view_fds_unix_sock_non_block(
- client->socket, &pv);
+ ret = lttcomm_send_payload_view_fds_unix_sock_non_block(client->socket, &pv);
if (ret < 0) {
/* Generic error, disable the client's communication. */
ERR("Failed to flush outgoing fds queue, disconnecting client (socket fd = %i)",
- client->socket);
+ client->socket);
client->communication.active = false;
status = CLIENT_TRANSMISSION_STATUS_FAIL;
goto end;
* need to clear the _fd_array for the queuing check.
*/
lttng_dynamic_pointer_array_clear(
- &client->communication.outbound.payload
- ._fd_handles);
+ &client->communication.outbound.payload._fd_handles);
}
end:
}
/* Client lock must _not_ be held by the caller. */
-static
-int client_send_command_reply(struct notification_client *client,
- struct notification_thread_state *state,
- enum lttng_notification_channel_status status)
+static int client_send_command_reply(struct notification_client *client,
+ struct notification_thread_state *state,
+ enum lttng_notification_channel_status status)
{
int ret;
struct lttng_notification_channel_command_reply reply = {
/* Enqueue buffer to outgoing queue and flush it. */
ret = lttng_dynamic_buffer_append(
- &client->communication.outbound.payload.buffer,
- buffer, sizeof(buffer));
+ &client->communication.outbound.payload.buffer, buffer, sizeof(buffer));
if (ret) {
goto error_unlock;
}
}
pthread_mutex_unlock(&client->lock);
- ret = client_handle_transmission_status(
- client, transmission_status, state);
+ ret = client_handle_transmission_status(client, transmission_status, state);
if (ret) {
goto error;
}
return -1;
}
-static
-int client_handle_message_unknown(struct notification_client *client,
- struct notification_thread_state *state __attribute__((unused)))
+static int client_handle_message_unknown(struct notification_client *client,
+ struct notification_thread_state *state
+ __attribute__((unused)))
{
int ret;
/*
LTTNG_ASSERT(sizeof(*msg) == client->communication.inbound.payload.buffer.size);
msg = (const struct lttng_notification_channel_message *)
- client->communication.inbound.payload.buffer.data;
+ client->communication.inbound.payload.buffer.data;
- if (msg->size == 0 ||
- msg->size > DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE) {
- ERR("Invalid notification channel message: length = %u",
- msg->size);
+ if (msg->size == 0 || msg->size > DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE) {
+ ERR("Invalid notification channel message: length = %u", msg->size);
ret = -1;
goto end;
}
client->communication.inbound.bytes_to_receive = msg->size;
client->communication.inbound.fds_to_receive = msg->fds;
client->communication.inbound.msg_type =
- (enum lttng_notification_channel_message_type) msg->type;
- ret = lttng_dynamic_buffer_set_size(
- &client->communication.inbound.payload.buffer, msg->size);
+ (enum lttng_notification_channel_message_type) msg->type;
+ ret = lttng_dynamic_buffer_set_size(&client->communication.inbound.payload.buffer,
+ msg->size);
/* msg is not valid anymore due to lttng_dynamic_buffer_set_size. */
msg = NULL;
return ret;
}
-static
-int client_handle_message_handshake(struct notification_client *client,
- struct notification_thread_state *state)
+static int client_handle_message_handshake(struct notification_client *client,
+ struct notification_thread_state *state)
{
int ret;
struct lttng_notification_channel_command_handshake *handshake_client;
const struct lttng_notification_channel_command_handshake handshake_reply = {
- .major = LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR,
- .minor = LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR,
+ .major = LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR,
+ .minor = LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR,
};
struct lttng_notification_channel_message msg_header;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
char send_buffer[sizeof(msg_header) + sizeof(handshake_reply)];
msg_header.type = LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE;
msg_header.fds = 0;
memcpy(send_buffer, &msg_header, sizeof(msg_header));
- memcpy(send_buffer + sizeof(msg_header), &handshake_reply,
- sizeof(handshake_reply));
+ memcpy(send_buffer + sizeof(msg_header), &handshake_reply, sizeof(handshake_reply));
- handshake_client =
- (struct lttng_notification_channel_command_handshake *)
- client->communication.inbound.payload.buffer
- .data;
+ handshake_client = (struct lttng_notification_channel_command_handshake *)
+ client->communication.inbound.payload.buffer.data;
client->major = handshake_client->major;
client->minor = handshake_client->minor;
if (!client->communication.inbound.creds_received) {
goto end;
}
- client->uid = LTTNG_SOCK_GET_UID_CRED(
- &client->communication.inbound.creds);
- client->gid = LTTNG_SOCK_GET_GID_CRED(
- &client->communication.inbound.creds);
- client->is_sessiond = LTTNG_SOCK_GET_PID_CRED(&client->communication.inbound.creds) == getpid();
+ client->uid = LTTNG_SOCK_GET_UID_CRED(&client->communication.inbound.creds);
+ client->gid = LTTNG_SOCK_GET_GID_CRED(&client->communication.inbound.creds);
+ client->is_sessiond = LTTNG_SOCK_GET_PID_CRED(&client->communication.inbound.creds) ==
+ getpid();
DBG("Received handshake from client: uid = %u, gid = %u, protocol version = %i.%i, client is sessiond = %s",
- client->uid, client->gid, (int) client->major,
- (int) client->minor,
- client->is_sessiond ? "true" : "false");
+ client->uid,
+ client->gid,
+ (int) client->major,
+ (int) client->minor,
+ client->is_sessiond ? "true" : "false");
- if (handshake_client->major !=
- LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR) {
+ if (handshake_client->major != LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_UNSUPPORTED_VERSION;
}
pthread_mutex_lock(&client->lock);
/* Outgoing queue will be flushed when the command reply is sent. */
ret = lttng_dynamic_buffer_append(
- &client->communication.outbound.payload.buffer, send_buffer,
- sizeof(send_buffer));
+ &client->communication.outbound.payload.buffer, send_buffer, sizeof(send_buffer));
if (ret) {
ERR("Failed to send protocol version to notification channel client");
goto end_unlock;
return ret;
}
-static
-int client_handle_message_subscription(
- struct notification_client *client,
- enum lttng_notification_channel_message_type msg_type,
- struct notification_thread_state *state)
+static int client_handle_message_subscription(struct notification_client *client,
+ enum lttng_notification_channel_message_type msg_type,
+ struct notification_thread_state *state)
{
int ret;
struct lttng_condition *condition;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_payload_view condition_view =
- lttng_payload_view_from_payload(
- &client->communication.inbound.payload,
- 0, -1);
+ lttng_payload_view_from_payload(&client->communication.inbound.payload, 0, -1);
size_t expected_condition_size;
/*
/* Ownership of condition is always transferred. */
if (msg_type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE) {
- ret = notification_thread_client_subscribe(
- client, condition, state, &status);
+ ret = notification_thread_client_subscribe(client, condition, state, &status);
} else {
- ret = notification_thread_client_unsubscribe(
- client, condition, state, &status);
+ ret = notification_thread_client_unsubscribe(client, condition, state, &status);
}
if (ret) {
return ret;
}
-static
-int client_dispatch_message(struct notification_client *client,
- struct notification_thread_state *state)
+static int client_dispatch_message(struct notification_client *client,
+ struct notification_thread_state *state)
{
int ret = 0;
if (client->communication.inbound.msg_type !=
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE &&
- client->communication.inbound.msg_type !=
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN &&
- !client->validated) {
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE &&
+ client->communication.inbound.msg_type !=
+ LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN &&
+ !client->validated) {
WARN("client attempted a command before handshake");
ret = -1;
goto end;
case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE:
case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE:
{
- ret = client_handle_message_subscription(client,
- client->communication.inbound.msg_type, state);
+ ret = client_handle_message_subscription(
+ client, client->communication.inbound.msg_type, state);
break;
}
default:
}
/* Incoming data from client. */
-int handle_notification_thread_client_in(
- struct notification_thread_state *state, int socket)
+int handle_notification_thread_client_in(struct notification_thread_state *state, int socket)
{
int ret = 0;
struct notification_client *client;
}
if (client->communication.inbound.bytes_to_receive == 0 &&
- client->communication.inbound.fds_to_receive != 0) {
+ client->communication.inbound.fds_to_receive != 0) {
/* Only FDs left to receive. */
goto receive_fds;
}
offset = client->communication.inbound.payload.buffer.size -
- client->communication.inbound.bytes_to_receive;
+ client->communication.inbound.bytes_to_receive;
if (client->communication.inbound.expect_creds) {
- recv_ret = lttcomm_recv_creds_unix_sock(socket,
- client->communication.inbound.payload.buffer.data + offset,
- client->communication.inbound.bytes_to_receive,
- &client->communication.inbound.creds);
+ recv_ret = lttcomm_recv_creds_unix_sock(
+ socket,
+ client->communication.inbound.payload.buffer.data + offset,
+ client->communication.inbound.bytes_to_receive,
+ &client->communication.inbound.creds);
if (recv_ret > 0) {
client->communication.inbound.expect_creds = false;
client->communication.inbound.creds_received = true;
}
} else {
- recv_ret = lttcomm_recv_unix_sock_non_block(socket,
- client->communication.inbound.payload.buffer.data + offset,
- client->communication.inbound.bytes_to_receive);
+ recv_ret = lttcomm_recv_unix_sock_non_block(
+ socket,
+ client->communication.inbound.payload.buffer.data + offset,
+ client->communication.inbound.bytes_to_receive);
}
if (recv_ret >= 0) {
client->communication.inbound.bytes_to_receive -= recv_ret;
/* Receive fds. */
if (client->communication.inbound.fds_to_receive != 0) {
ret = lttcomm_recv_payload_fds_unix_sock_non_block(
- client->socket,
- client->communication.inbound.fds_to_receive,
- &client->communication.inbound.payload);
+ client->socket,
+ client->communication.inbound.fds_to_receive,
+ &client->communication.inbound.payload);
if (ret > 0) {
/*
* Fds received. non blocking fds passing is all
*/
ssize_t expected_size;
- expected_size = sizeof(int) *
- client->communication.inbound
- .fds_to_receive;
+ expected_size = sizeof(int) * client->communication.inbound.fds_to_receive;
LTTNG_ASSERT(ret == expected_size);
client->communication.inbound.fds_to_receive = 0;
} else if (ret == 0) {
/* At this point the message is complete.*/
LTTNG_ASSERT(client->communication.inbound.bytes_to_receive == 0 &&
- client->communication.inbound.fds_to_receive == 0);
+ client->communication.inbound.fds_to_receive == 0);
ret = client_dispatch_message(client, state);
if (ret) {
/*
}
/* Client ready to receive outgoing data. */
-int handle_notification_thread_client_out(
- struct notification_thread_state *state, int socket)
+int handle_notification_thread_client_out(struct notification_thread_state *state, int socket)
{
int ret;
struct notification_client *client;
}
pthread_mutex_unlock(&client->lock);
- ret = client_handle_transmission_status(
- client, transmission_status, state);
+ ret = client_handle_transmission_status(client, transmission_status, state);
if (ret) {
goto end;
}
return ret;
}
-static
-bool evaluate_buffer_usage_condition(const struct lttng_condition *condition,
- const struct channel_state_sample *sample,
- uint64_t buffer_capacity)
+static bool evaluate_buffer_usage_condition(const struct lttng_condition *condition,
+ const struct channel_state_sample *sample,
+ uint64_t buffer_capacity)
{
bool result = false;
uint64_t threshold;
enum lttng_condition_type condition_type;
- const struct lttng_condition_buffer_usage *use_condition = lttng::utils::container_of(
- condition, <tng_condition_buffer_usage::parent);
+ const struct lttng_condition_buffer_usage *use_condition =
+ lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (use_condition->threshold_bytes.set) {
threshold = use_condition->threshold_bytes.value;
* that all channels matching my_chann* have the same size...)
*/
threshold = (uint64_t) (use_condition->threshold_ratio.value *
- (double) buffer_capacity);
+ (double) buffer_capacity);
}
condition_type = lttng_condition_get_type(condition);
if (condition_type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW) {
- DBG("Low buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
- threshold, sample->highest_usage);
+ DBG("Low buffer usage condition being evaluated: threshold = %" PRIu64
+ ", highest usage = %" PRIu64,
+ threshold,
+ sample->highest_usage);
/*
* The low condition should only be triggered once _all_ of the
result = true;
}
} else {
- DBG("High buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
- threshold, sample->highest_usage);
+ DBG("High buffer usage condition being evaluated: threshold = %" PRIu64
+ ", highest usage = %" PRIu64,
+ threshold,
+ sample->highest_usage);
/*
* For high buffer usage scenarios, we want to trigger whenever
return result;
}
-static
-int evaluate_buffer_condition(const struct lttng_condition *condition,
- struct lttng_evaluation **evaluation,
- const struct notification_thread_state *state __attribute__((unused)),
- const struct channel_state_sample *previous_sample,
- const struct channel_state_sample *latest_sample,
- struct channel_info *channel_info)
+static int evaluate_buffer_condition(const struct lttng_condition *condition,
+ struct lttng_evaluation **evaluation,
+ const struct notification_thread_state *state
+ __attribute__((unused)),
+ const struct channel_state_sample *previous_sample,
+ const struct channel_state_sample *latest_sample,
+ struct channel_info *channel_info)
{
int ret = 0;
enum lttng_condition_type condition_type;
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
if (caa_likely(previous_sample_available)) {
- previous_sample_result =
- evaluate_buffer_usage_condition(condition,
- previous_sample, channel_info->capacity);
+ previous_sample_result = evaluate_buffer_usage_condition(
+ condition, previous_sample, channel_info->capacity);
}
latest_sample_result = evaluate_buffer_usage_condition(
- condition, latest_sample,
- channel_info->capacity);
+ condition, latest_sample, channel_info->capacity);
break;
default:
/* Unknown condition type; internal error. */
abort();
}
- if (!latest_sample_result ||
- (previous_sample_result == latest_sample_result)) {
+ if (!latest_sample_result || (previous_sample_result == latest_sample_result)) {
/*
* Only trigger on a condition evaluation transition.
*
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
*evaluation = lttng_evaluation_buffer_usage_create(
- condition_type,
- latest_sample->highest_usage,
- channel_info->capacity);
+ condition_type, latest_sample->highest_usage, channel_info->capacity);
break;
default:
abort();
return ret;
}
-static
-int client_notification_overflow(struct notification_client *client)
+static int client_notification_overflow(struct notification_client *client)
{
int ret = 0;
struct lttng_notification_channel_message msg;
ASSERT_LOCKED(client->lock);
- DBG("Dropping notification addressed to client (socket fd = %i)",
- client->socket);
+ DBG("Dropping notification addressed to client (socket fd = %i)", client->socket);
if (client->communication.outbound.dropped_notification) {
/*
* The client already has a "notification dropped" message
client->communication.outbound.dropped_notification = true;
ret = lttng_dynamic_buffer_append(
- &client->communication.outbound.payload.buffer, &msg,
- sizeof(msg));
+ &client->communication.outbound.payload.buffer, &msg, sizeof(msg));
if (ret) {
PERROR("Failed to enqueue \"dropped notification\" message in client's (socket fd = %i) outgoing queue",
- client->socket);
+ client->socket);
}
end:
return ret;
}
-static int client_handle_transmission_status_wrapper(
- struct notification_client *client,
- enum client_transmission_status status,
- void *user_data)
+static int client_handle_transmission_status_wrapper(struct notification_client *client,
+ enum client_transmission_status status,
+ void *user_data)
{
- return client_handle_transmission_status(client, status,
- (struct notification_thread_state *) user_data);
+ return client_handle_transmission_status(
+ client, status, (struct notification_thread_state *) user_data);
}
-static
-int send_evaluation_to_clients(const struct lttng_trigger *trigger,
- const struct lttng_evaluation *evaluation,
- struct notification_client_list* client_list,
- struct notification_thread_state *state,
- uid_t object_uid, gid_t object_gid)
+static int send_evaluation_to_clients(const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
+ struct notification_client_list *client_list,
+ struct notification_thread_state *state,
+ uid_t object_uid,
+ gid_t object_gid)
{
const struct lttng_credentials creds = {
.uid = LTTNG_OPTIONAL_INIT_VALUE(object_uid),
};
return notification_client_list_send_evaluation(client_list,
- trigger, evaluation,
- &creds,
- client_handle_transmission_status_wrapper, state);
+ trigger,
+ evaluation,
+ &creds,
+ client_handle_transmission_status_wrapper,
+ state);
}
/*
* interference from external users (those could, for instance, unregister
* their triggers).
*/
-int notification_client_list_send_evaluation(
- struct notification_client_list *client_list,
- const struct lttng_trigger *trigger,
- const struct lttng_evaluation *evaluation,
- const struct lttng_credentials *source_object_creds,
- report_client_transmission_result_cb client_report,
- void *user_data)
+int notification_client_list_send_evaluation(struct notification_client_list *client_list,
+ const struct lttng_trigger *trigger,
+ const struct lttng_evaluation *evaluation,
+ const struct lttng_credentials *source_object_creds,
+ report_client_transmission_result_cb client_report,
+ void *user_data)
{
int ret = 0;
struct lttng_payload msg_payload;
.evaluation = (struct lttng_evaluation *) evaluation,
};
struct lttng_notification_channel_message msg_header;
- const struct lttng_credentials *trigger_creds =
- lttng_trigger_get_credentials(trigger);
+ const struct lttng_credentials *trigger_creds = lttng_trigger_get_credentials(trigger);
lttng_payload_init(&msg_payload);
msg_header.size = 0;
msg_header.fds = 0;
- ret = lttng_dynamic_buffer_append(&msg_payload.buffer, &msg_header,
- sizeof(msg_header));
+ ret = lttng_dynamic_buffer_append(&msg_payload.buffer, &msg_header, sizeof(msg_header));
if (ret) {
goto end;
}
}
/* Update payload size. */
- ((struct lttng_notification_channel_message *) msg_payload.buffer.data)
- ->size = (uint32_t)(
- msg_payload.buffer.size - sizeof(msg_header));
+ ((struct lttng_notification_channel_message *) msg_payload.buffer.data)->size =
+ (uint32_t) (msg_payload.buffer.size - sizeof(msg_header));
/* Update the payload number of fds. */
{
- const struct lttng_payload_view pv = lttng_payload_view_from_payload(
- &msg_payload, 0, -1);
+ const struct lttng_payload_view pv =
+ lttng_payload_view_from_payload(&msg_payload, 0, -1);
- ((struct lttng_notification_channel_message *)
- msg_payload.buffer.data)->fds = (uint32_t)
- lttng_payload_view_get_fd_handle_count(&pv);
+ ((struct lttng_notification_channel_message *) msg_payload.buffer.data)->fds =
+ (uint32_t) lttng_payload_view_get_fd_handle_count(&pv);
}
pthread_mutex_lock(&client_list->lock);
- cds_list_for_each_entry_safe(client_list_element, tmp,
- &client_list->clients_list, node) {
+ cds_list_for_each_entry_safe (client_list_element, tmp, &client_list->clients_list, node) {
enum client_transmission_status transmission_status;
- struct notification_client *client =
- client_list_element->client;
+ struct notification_client *client = client_list_element->client;
ret = 0;
pthread_mutex_lock(&client->lock);
if (source_object_creds) {
if (client->uid != lttng_credentials_get_uid(source_object_creds) &&
- client->gid != lttng_credentials_get_gid(source_object_creds) &&
- client->uid != 0) {
+ client->gid != lttng_credentials_get_gid(source_object_creds) &&
+ client->uid != 0) {
/*
* Client is not allowed to monitor this
* object.
}
DBG("Sending notification to client (fd = %i, %zu bytes)",
- client->socket, msg_payload.buffer.size);
+ client->socket,
+ msg_payload.buffer.size);
if (client_has_outbound_data_left(client)) {
/*
continue;
-skip_client:
+ skip_client:
pthread_mutex_unlock(&client->lock);
if (ret) {
/* Fatal error. */
return ret;
}
-static
-struct lttng_event_notifier_notification *recv_one_event_notifier_notification(
- int notification_pipe_read_fd, enum lttng_domain_type domain)
+static struct lttng_event_notifier_notification *
+recv_one_event_notifier_notification(int notification_pipe_read_fd, enum lttng_domain_type domain)
{
int ret;
uint64_t token;
struct lttng_kernel_abi_event_notifier_notification kernel_notification;
/* Init lttng_event_notifier_notification */
- switch(domain) {
+ switch (domain) {
case LTTNG_DOMAIN_UST:
reception_buffer = (void *) &ust_notification;
reception_size = sizeof(ust_notification);
* The monitoring pipe only holds messages smaller than PIPE_BUF,
* ensuring that read/write of tracer notifications are atomic.
*/
- ret = lttng_read(notification_pipe_read_fd, reception_buffer,
- reception_size);
+ ret = lttng_read(notification_pipe_read_fd, reception_buffer, reception_size);
if (ret != reception_size) {
PERROR("Failed to read from event source notification pipe: fd = %d, size to read = %zu, ret = %d",
- notification_pipe_read_fd, reception_size, ret);
+ notification_pipe_read_fd,
+ reception_size,
+ ret);
ret = -1;
goto end;
}
- switch(domain) {
+ switch (domain) {
case LTTNG_DOMAIN_UST:
token = ust_notification.token;
capture_buffer_size = ust_notification.capture_buf_size;
if (capture_buffer_size > MAX_CAPTURE_SIZE) {
ERR("Event notifier has a capture payload size which exceeds the maximum allowed size: capture_payload_size = %zu bytes, max allowed size = %d bytes",
- capture_buffer_size, MAX_CAPTURE_SIZE);
+ capture_buffer_size,
+ MAX_CAPTURE_SIZE);
goto end;
}
/* Fetch additional payload (capture). */
ret = lttng_read(notification_pipe_read_fd, capture_buffer, capture_buffer_size);
if (ret != capture_buffer_size) {
- ERR("Failed to read from event source pipe (fd = %i)",
- notification_pipe_read_fd);
+ ERR("Failed to read from event source pipe (fd = %i)", notification_pipe_read_fd);
goto end;
}
skip_capture:
- notification = lttng_event_notifier_notification_create(token, domain,
- capture_buffer, capture_buffer_size);
+ notification = lttng_event_notifier_notification_create(
+ token, domain, capture_buffer, capture_buffer_size);
if (notification == NULL) {
goto end;
}
return notification;
}
-static
-int dispatch_one_event_notifier_notification(struct notification_thread_state *state,
- struct lttng_event_notifier_notification *notification)
+static int
+dispatch_one_event_notifier_notification(struct notification_thread_state *state,
+ struct lttng_event_notifier_notification *notification)
{
struct cds_lfht_node *node;
struct cds_lfht_iter iter;
rcu_read_lock();
cds_lfht_lookup(state->trigger_tokens_ht,
hash_key_u64(¬ification->tracer_token, lttng_ht_seed),
- match_trigger_token, ¬ification->tracer_token, &iter);
+ match_trigger_token,
+ ¬ification->tracer_token,
+ &iter);
node = cds_lfht_iter_get_node(&iter);
if (caa_unlikely(!node)) {
/*
goto end_unlock;
}
- element = caa_container_of(node,
- struct notification_trigger_tokens_ht_element,
- node);
+ element = caa_container_of(node, struct notification_trigger_tokens_ht_element, node);
if (lttng_condition_event_rule_matches_get_capture_descriptor_count(
- lttng_trigger_get_const_condition(element->trigger),
- &capture_count) != LTTNG_CONDITION_STATUS_OK) {
+ lttng_trigger_get_const_condition(element->trigger), &capture_count) !=
+ LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to get capture count");
ret = -1;
goto end;
}
evaluation = lttng_evaluation_event_rule_matches_create(
- lttng::utils::container_of(lttng_trigger_get_const_condition(
- element->trigger),
- <tng_condition_event_rule_matches::parent),
- notification->capture_buffer,
- notification->capture_buf_size, false);
+ lttng::utils::container_of(lttng_trigger_get_const_condition(element->trigger),
+ <tng_condition_event_rule_matches::parent),
+ notification->capture_buffer,
+ notification->capture_buf_size,
+ false);
if (evaluation == NULL) {
ERR("Failed to create event rule matches evaluation while creating and enqueuing action executor job");
goto end_unlock;
}
- client_list = get_client_list_from_condition(state,
- lttng_trigger_get_const_condition(element->trigger));
- executor_status = action_executor_enqueue_trigger(state->executor,
- element->trigger, evaluation, NULL, client_list);
+ client_list = get_client_list_from_condition(
+ state, lttng_trigger_get_const_condition(element->trigger));
+ executor_status = action_executor_enqueue_trigger(
+ state->executor, element->trigger, evaluation, NULL, client_list);
switch (executor_status) {
case ACTION_EXECUTOR_STATUS_OK:
ret = 0;
break;
case ACTION_EXECUTOR_STATUS_OVERFLOW:
{
- struct notification_client_list_element *client_list_element,
- *tmp;
+ struct notification_client_list_element *client_list_element, *tmp;
/*
* Not a fatal error; this is expected and simply means the
/* Warn clients that a notification (or more) was dropped. */
pthread_mutex_lock(&client_list->lock);
- cds_list_for_each_entry_safe(client_list_element, tmp,
- &client_list->clients_list, node) {
+ cds_list_for_each_entry_safe (
+ client_list_element, tmp, &client_list->clients_list, node) {
enum client_transmission_status transmission_status;
- struct notification_client *client =
- client_list_element->client;
+ struct notification_client *client = client_list_element->client;
pthread_mutex_lock(&client->lock);
ret = client_notification_overflow(client);
goto next_client;
}
- transmission_status =
- client_flush_outgoing_queue(client);
- ret = client_handle_transmission_status(
- client, transmission_status, state);
+ transmission_status = client_flush_outgoing_queue(client);
+ ret = client_handle_transmission_status(client, transmission_status, state);
if (ret) {
/* Fatal error. */
goto next_client;
}
-next_client:
+ next_client:
pthread_mutex_unlock(&client->lock);
if (ret) {
break;
return ret;
}
-static
-int handle_one_event_notifier_notification(
- struct notification_thread_state *state,
- int pipe, enum lttng_domain_type domain)
+static int handle_one_event_notifier_notification(struct notification_thread_state *state,
+ int pipe,
+ enum lttng_domain_type domain)
{
int ret = 0;
struct lttng_event_notifier_notification *notification = NULL;
if (notification == NULL) {
/* Reception failed, don't consider it fatal. */
ERR("Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
- pipe, lttng_domain_type_str(domain));
+ pipe,
+ lttng_domain_type_str(domain));
goto end;
}
ret = dispatch_one_event_notifier_notification(state, notification);
if (ret) {
ERR("Error dispatching an event notifier notification from tracer: fd = %i, domain = %s",
- pipe, lttng_domain_type_str(domain));
+ pipe,
+ lttng_domain_type_str(domain));
goto end;
}
}
int handle_notification_thread_event_notification(struct notification_thread_state *state,
- int pipe, enum lttng_domain_type domain)
+ int pipe,
+ enum lttng_domain_type domain)
{
return handle_one_event_notifier_notification(state, pipe, domain);
}
-int handle_notification_thread_channel_sample(
- struct notification_thread_state *state, int pipe,
- enum lttng_domain_type domain)
+int handle_notification_thread_channel_sample(struct notification_thread_state *state,
+ int pipe,
+ enum lttng_domain_type domain)
{
int ret = 0;
struct lttcomm_consumer_channel_monitor_msg sample_msg;
*/
ret = lttng_read(pipe, &sample_msg, sizeof(sample_msg));
if (ret != sizeof(sample_msg)) {
- ERR("Failed to read from monitoring pipe (fd = %i)",
- pipe);
+ ERR("Failed to read from monitoring pipe (fd = %i)", pipe);
ret = -1;
goto end;
}
session = get_session_info_by_id(state, sample_msg.session_id);
if (!session) {
DBG("Received a sample for an unknown session from consumerd: session id = %" PRIu64,
- sample_msg.session_id);
+ sample_msg.session_id);
goto end_unlock;
}
session_trigger_list = get_session_trigger_list(state, session->name);
LTTNG_ASSERT(session_trigger_list);
- cds_list_for_each_entry(trigger_list_element, &session_trigger_list->list,
- node) {
+ cds_list_for_each_entry (trigger_list_element, &session_trigger_list->list, node) {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
struct notification_client_list *client_list = NULL;
LTTNG_ASSERT(condition);
ret = evaluate_session_condition(
- condition, session, &session_new_sample, &evaluation);
+ condition, session, &session_new_sample, &evaluation);
if (caa_unlikely(ret)) {
break;
}
*/
client_list = get_client_list_from_condition(state, condition);
executor_status = action_executor_enqueue_trigger(
- state->executor, trigger, evaluation,
- &session_creds, client_list);
+ state->executor, trigger, evaluation, &session_creds, client_list);
notification_client_list_put(client_list);
evaluation = NULL;
switch (executor_status) {
* channel's destruction before we get a chance to process that
* sample.
*/
- DBG("Received a sample for an unknown channel from consumerd, key = %" PRIu64 " in %s domain",
- channel_new_sample.key.key,
- lttng_domain_type_str(domain));
+ DBG("Received a sample for an unknown channel from consumerd, key = %" PRIu64
+ " in %s domain",
+ channel_new_sample.key.key,
+ lttng_domain_type_str(domain));
goto end_unlock;
}
- channel_info = caa_container_of(node, struct channel_info,
- channels_ht_node);
- DBG("Handling channel sample for channel %s (key = %" PRIu64 ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64", consumed since last sample = %" PRIu64")",
- channel_info->name,
- channel_new_sample.key.key,
- channel_info->session_info->name,
- channel_new_sample.highest_usage,
- channel_new_sample.lowest_usage,
- sample_msg.consumed_since_last_sample);
+ channel_info = caa_container_of(node, struct channel_info, channels_ht_node);
+ DBG("Handling channel sample for channel %s (key = %" PRIu64
+ ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64
+ ", consumed since last sample = %" PRIu64 ")",
+ channel_info->name,
+ channel_new_sample.key.key,
+ channel_info->session_info->name,
+ channel_new_sample.highest_usage,
+ channel_new_sample.lowest_usage,
+ sample_msg.consumed_since_last_sample);
/* Retrieve the channel's last sample, if it exists, and update it. */
cds_lfht_lookup(state->channel_state_ht,
struct channel_state_sample *stored_sample;
/* Update the sample stored. */
- stored_sample = caa_container_of(node,
- struct channel_state_sample,
- channel_state_ht_node);
+ stored_sample =
+ caa_container_of(node, struct channel_state_sample, channel_state_ht_node);
- memcpy(&channel_previous_sample, stored_sample,
- sizeof(channel_previous_sample));
+ memcpy(&channel_previous_sample, stored_sample, sizeof(channel_previous_sample));
stored_sample->highest_usage = channel_new_sample.highest_usage;
stored_sample->lowest_usage = channel_new_sample.lowest_usage;
previous_sample_available = true;
memcpy(stored_sample, &channel_new_sample, sizeof(*stored_sample));
cds_lfht_node_init(&stored_sample->channel_state_ht_node);
cds_lfht_add(state->channel_state_ht,
- hash_channel_key(&stored_sample->key),
- &stored_sample->channel_state_ht_node);
+ hash_channel_key(&stored_sample->key),
+ &stored_sample->channel_state_ht_node);
}
/* Find triggers associated with this channel. */
node = cds_lfht_iter_get_node(&iter);
LTTNG_ASSERT(node);
- channel_creds = (typeof(channel_creds)) {
+ channel_creds = (typeof(channel_creds)){
.uid = LTTNG_OPTIONAL_INIT_VALUE(channel_info->session_info->uid),
.gid = LTTNG_OPTIONAL_INIT_VALUE(channel_info->session_info->gid),
};
- channel_trigger_list = caa_container_of(node, struct lttng_channel_trigger_list,
- channel_triggers_ht_node);
- cds_list_for_each_entry(trigger_list_element, &channel_trigger_list->list,
- node) {
+ channel_trigger_list =
+ caa_container_of(node, struct lttng_channel_trigger_list, channel_triggers_ht_node);
+ cds_list_for_each_entry (trigger_list_element, &channel_trigger_list->list, node) {
const struct lttng_condition *condition;
struct lttng_trigger *trigger;
struct notification_client_list *client_list = NULL;
condition = lttng_trigger_get_const_condition(trigger);
LTTNG_ASSERT(condition);
- ret = evaluate_buffer_condition(condition, &evaluation, state,
- previous_sample_available ? &channel_previous_sample : NULL,
- &channel_new_sample,
- channel_info);
+ ret = evaluate_buffer_condition(
+ condition,
+ &evaluation,
+ state,
+ previous_sample_available ? &channel_previous_sample : NULL,
+ &channel_new_sample,
+ channel_info);
if (caa_unlikely(ret)) {
break;
}
*/
client_list = get_client_list_from_condition(state, condition);
executor_status = action_executor_enqueue_trigger(
- state->executor, trigger, evaluation,
- &channel_creds, client_list);
+ state->executor, trigger, evaluation, &channel_creds, client_list);
notification_client_list_put(client_list);
evaluation = NULL;
switch (executor_status) {
*/
#define _LGPL_SOURCE
-#include <lttng/trigger/trigger.h>
-#include <lttng/notification/channel-internal.hpp>
-#include <lttng/notification/notification-internal.hpp>
-#include <lttng/condition/condition-internal.hpp>
-#include <lttng/condition/buffer-usage-internal.hpp>
-#include <common/error.hpp>
-#include <common/config/session-config.hpp>
-#include <common/defaults.hpp>
-#include <common/utils.hpp>
-#include <common/align.hpp>
-#include <common/time.hpp>
-#include <sys/stat.h>
-#include <sys/eventfd.h>
-#include <time.h>
-#include <signal.h>
-
-#include "notification-thread.hpp"
-#include "notification-thread-events.hpp"
-#include "notification-thread-commands.hpp"
-#include "lttng-sessiond.hpp"
#include "health-sessiond.hpp"
-#include "thread.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread.hpp"
#include "testpoint.hpp"
+#include "thread.hpp"
-#include "kernel.hpp"
+#include <common/align.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/time.hpp>
+#include <common/utils.hpp>
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/trigger/trigger.h>
+
+#include <signal.h>
+#include <sys/eventfd.h>
+#include <sys/stat.h>
+#include <time.h>
#include <urcu.h>
#include <urcu/list.h>
#include <urcu/rculfhash.h>
/*
* Destroy the thread data previously created by the init function.
*/
-void notification_thread_handle_destroy(
- struct notification_thread_handle *handle)
+void notification_thread_handle_destroy(struct notification_thread_handle *handle)
{
int ret;
free(handle);
}
-struct notification_thread_handle *notification_thread_handle_create(
- struct lttng_pipe *ust32_channel_monitor_pipe,
- struct lttng_pipe *ust64_channel_monitor_pipe,
- struct lttng_pipe *kernel_channel_monitor_pipe)
+struct notification_thread_handle *
+notification_thread_handle_create(struct lttng_pipe *ust32_channel_monitor_pipe,
+ struct lttng_pipe *ust64_channel_monitor_pipe,
+ struct lttng_pipe *kernel_channel_monitor_pipe)
{
int ret;
struct notification_thread_handle *handle;
sem_init(&handle->ready, 0, 0);
- event_fd = eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE);
+ event_fd = eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE);
if (event_fd < 0) {
PERROR("event_fd creation");
goto error;
if (ust32_channel_monitor_pipe) {
handle->channel_monitoring_pipes.ust32_consumer =
- lttng_pipe_release_readfd(
- ust32_channel_monitor_pipe);
+ lttng_pipe_release_readfd(ust32_channel_monitor_pipe);
if (handle->channel_monitoring_pipes.ust32_consumer < 0) {
goto error;
}
}
if (ust64_channel_monitor_pipe) {
handle->channel_monitoring_pipes.ust64_consumer =
- lttng_pipe_release_readfd(
- ust64_channel_monitor_pipe);
+ lttng_pipe_release_readfd(ust64_channel_monitor_pipe);
if (handle->channel_monitoring_pipes.ust64_consumer < 0) {
goto error;
}
}
if (kernel_channel_monitor_pipe) {
handle->channel_monitoring_pipes.kernel_consumer =
- lttng_pipe_release_readfd(
- kernel_channel_monitor_pipe);
+ lttng_pipe_release_readfd(kernel_channel_monitor_pipe);
if (handle->channel_monitoring_pipes.kernel_consumer < 0) {
goto error;
}
return NULL;
}
-static
-char *get_notification_channel_sock_path(void)
+static char *get_notification_channel_sock_path(void)
{
int ret;
bool is_root = !getuid();
}
if (is_root) {
- ret = snprintf(sock_path, LTTNG_PATH_MAX,
- DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK);
+ ret = snprintf(
+ sock_path, LTTNG_PATH_MAX, DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK);
if (ret < 0) {
goto error;
}
goto error;
}
- ret = snprintf(sock_path, LTTNG_PATH_MAX,
- DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
- home_path);
+ ret = snprintf(sock_path,
+ LTTNG_PATH_MAX,
+ DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
+ home_path);
if (ret < 0) {
goto error;
}
return NULL;
}
-static
-void notification_channel_socket_destroy(int fd)
+static void notification_channel_socket_destroy(int fd)
{
int ret;
char *sock_path = get_notification_channel_sock_path();
}
}
-static
-int notification_channel_socket_create(void)
+static int notification_channel_socket_create(void)
{
int fd = -1, ret;
char *sock_path = get_notification_channel_sock_path();
- DBG("Creating notification channel UNIX socket at %s",
- sock_path);
+ DBG("Creating notification channel UNIX socket at %s", sock_path);
ret = lttcomm_create_unix_sock(sock_path);
if (ret < 0) {
if (getuid() == 0) {
gid_t gid;
- ret = utils_get_group_id(the_config.tracing_group_name.value,
- true, &gid);
+ ret = utils_get_group_id(the_config.tracing_group_name.value, true, &gid);
if (ret) {
/* Default to root group. */
gid = 0;
}
}
- DBG("Notification channel UNIX socket created (fd = %i)",
- fd);
+ DBG("Notification channel UNIX socket created (fd = %i)", fd);
free(sock_path);
return fd;
error:
return ret;
}
-static
-int init_poll_set(struct lttng_poll_event *poll_set,
- struct notification_thread_handle *handle,
- int notification_channel_socket)
+static int init_poll_set(struct lttng_poll_event *poll_set,
+ struct notification_thread_handle *handle,
+ int notification_channel_socket)
{
int ret;
ERR("Failed to add notification command queue event fd to pollset");
goto error;
}
- ret = lttng_poll_add(poll_set,
- handle->channel_monitoring_pipes.ust32_consumer, LPOLLIN);
+ ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.ust32_consumer, LPOLLIN);
if (ret < 0) {
ERR("Failed to add ust-32 channel monitoring pipe fd to pollset");
goto error;
}
- ret = lttng_poll_add(poll_set,
- handle->channel_monitoring_pipes.ust64_consumer, LPOLLIN);
+ ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.ust64_consumer, LPOLLIN);
if (ret < 0) {
ERR("Failed to add ust-64 channel monitoring pipe fd to pollset");
goto error;
if (handle->channel_monitoring_pipes.kernel_consumer < 0) {
goto end;
}
- ret = lttng_poll_add(poll_set,
- handle->channel_monitoring_pipes.kernel_consumer, LPOLLIN);
+ ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.kernel_consumer, LPOLLIN);
if (ret < 0) {
ERR("Failed to add kernel channel monitoring pipe fd to pollset");
goto error;
return ret;
}
-static
-void fini_thread_state(struct notification_thread_state *state)
+static void fini_thread_state(struct notification_thread_state *state)
{
int ret;
LTTNG_ASSERT(!ret);
}
if (state->notification_trigger_clients_ht) {
- ret = cds_lfht_destroy(state->notification_trigger_clients_ht,
- NULL);
+ ret = cds_lfht_destroy(state->notification_trigger_clients_ht, NULL);
LTTNG_ASSERT(!ret);
}
if (state->channels_ht) {
LTTNG_ASSERT(!ret);
}
if (state->notification_channel_socket >= 0) {
- notification_channel_socket_destroy(
- state->notification_channel_socket);
+ notification_channel_socket_destroy(state->notification_channel_socket);
}
LTTNG_ASSERT(cds_list_empty(&state->tracer_event_sources_list));
lttng_poll_clean(&state->events);
}
-static
-void mark_thread_as_ready(struct notification_thread_handle *handle)
+static void mark_thread_as_ready(struct notification_thread_handle *handle)
{
DBG("Marking notification thread as ready");
sem_post(&handle->ready);
}
-static
-void wait_until_thread_is_ready(struct notification_thread_handle *handle)
+static void wait_until_thread_is_ready(struct notification_thread_handle *handle)
{
DBG("Waiting for notification thread to be ready");
sem_wait(&handle->ready);
DBG("Notification thread is ready");
}
-static
-int init_thread_state(struct notification_thread_handle *handle,
- struct notification_thread_state *state)
+static int init_thread_state(struct notification_thread_handle *handle,
+ struct notification_thread_state *state)
{
int ret;
}
state->notification_channel_socket = ret;
- ret = init_poll_set(&state->events, handle,
- state->notification_channel_socket);
+ ret = init_poll_set(&state->events, handle, state->notification_channel_socket);
if (ret) {
goto end;
}
goto error;
}
- state->client_socket_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->client_socket_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->client_socket_ht) {
goto error;
}
- state->client_id_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->client_id_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->client_id_ht) {
goto error;
}
- state->channel_triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->channel_triggers_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->channel_triggers_ht) {
goto error;
}
- state->session_triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->session_triggers_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->session_triggers_ht) {
goto error;
}
- state->channel_state_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->channel_state_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->channel_state_ht) {
goto error;
}
- state->notification_trigger_clients_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->notification_trigger_clients_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->notification_trigger_clients_ht) {
goto error;
}
- state->channels_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->channels_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->channels_ht) {
goto error;
}
- state->sessions_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->sessions_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->sessions_ht) {
goto error;
}
- state->triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->triggers_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->triggers_ht) {
goto error;
}
- state->triggers_by_name_uid_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->triggers_by_name_uid_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->triggers_by_name_uid_ht) {
goto error;
}
- state->trigger_tokens_ht = cds_lfht_new(DEFAULT_HT_SIZE,
- 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ state->trigger_tokens_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!state->trigger_tokens_ht) {
goto error;
}
return -1;
}
-static
-int handle_channel_monitoring_pipe(int fd, uint32_t revents,
- struct notification_thread_handle *handle,
- struct notification_thread_state *state)
+static int handle_channel_monitoring_pipe(int fd,
+ uint32_t revents,
+ struct notification_thread_handle *handle,
+ struct notification_thread_state *state)
{
int ret = 0;
enum lttng_domain_type domain;
if (fd == handle->channel_monitoring_pipes.ust32_consumer ||
- fd == handle->channel_monitoring_pipes.ust64_consumer) {
+ fd == handle->channel_monitoring_pipes.ust64_consumer) {
domain = LTTNG_DOMAIN_UST;
} else if (fd == handle->channel_monitoring_pipes.kernel_consumer) {
domain = LTTNG_DOMAIN_KERNEL;
goto end;
}
- ret = handle_notification_thread_channel_sample(
- state, fd, domain);
+ ret = handle_notification_thread_channel_sample(state, fd, domain);
if (ret) {
ERR("Consumer sample handling error occurred");
ret = -1;
}
static int handle_event_notification_pipe(int event_source_fd,
- enum lttng_domain_type domain,
- uint32_t revents,
- struct notification_thread_state *state)
+ enum lttng_domain_type domain,
+ uint32_t revents,
+ struct notification_thread_state *state)
{
int ret = 0;
if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
- ret = handle_notification_thread_tracer_event_source_died(
- state, event_source_fd);
+ ret = handle_notification_thread_tracer_event_source_died(state, event_source_fd);
if (ret) {
ERR("Failed to remove event notification pipe from poll set: fd = %d",
- event_source_fd);
+ event_source_fd);
}
goto end;
}
goto end;
}
- ret = handle_notification_thread_event_notification(
- state, event_source_fd, domain);
+ ret = handle_notification_thread_event_notification(state, event_source_fd, domain);
if (ret) {
- ERR("Event notification handling error occurred for fd: %d",
- event_source_fd);
+ ERR("Event notification handling error occurred for fd: %d", event_source_fd);
ret = -1;
goto end;
}
* Return the event source domain type via parameter.
*/
static bool fd_is_event_notification_source(const struct notification_thread_state *state,
- int fd,
- enum lttng_domain_type *domain)
+ int fd,
+ enum lttng_domain_type *domain)
{
struct notification_event_tracer_event_source_element *source_element;
LTTNG_ASSERT(domain);
- cds_list_for_each_entry(source_element,
- &state->tracer_event_sources_list, node) {
+ cds_list_for_each_entry (source_element, &state->tracer_event_sources_list, node) {
if (source_element->fd != fd) {
continue;
}
* This thread services notification channel clients and commands received
* from various lttng-sessiond components over a command queue.
*/
-static
-void *thread_notification(void *data)
+static void *thread_notification(void *data)
{
int ret;
struct notification_thread_handle *handle = (notification_thread_handle *) data;
if (fd == state.notification_channel_socket) {
if (revents & LPOLLIN) {
- ret = handle_notification_thread_client_connect(
- &state);
+ ret = handle_notification_thread_client_connect(&state);
if (ret < 0) {
goto error;
}
- } else if (revents &
- (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
+ } else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
ERR("Notification socket poll error");
goto error;
} else {
- ERR("Unexpected poll events %u for notification socket %i", revents, fd);
+ ERR("Unexpected poll events %u for notification socket %i",
+ revents,
+ fd);
goto error;
}
} else if (fd == handle->cmd_queue.event_fd) {
- ret = handle_notification_thread_command(handle,
- &state);
+ ret = handle_notification_thread_command(handle, &state);
if (ret < 0) {
DBG("Error encountered while servicing command queue");
goto error;
goto exit;
}
} else if (fd == handle->channel_monitoring_pipes.ust32_consumer ||
- fd == handle->channel_monitoring_pipes.ust64_consumer ||
- fd == handle->channel_monitoring_pipes.kernel_consumer) {
- ret = handle_channel_monitoring_pipe(fd,
- revents, handle, &state);
+ fd == handle->channel_monitoring_pipes.ust64_consumer ||
+ fd == handle->channel_monitoring_pipes.kernel_consumer) {
+ ret = handle_channel_monitoring_pipe(fd, revents, handle, &state);
if (ret) {
goto error;
}
* receive the notifications to which
* it was subscribing or unsubscribing.
*/
- ret = handle_notification_thread_client_disconnect(
- fd, &state);
+ ret = handle_notification_thread_client_disconnect(fd,
+ &state);
if (ret) {
goto error;
}
} else {
if (revents & LPOLLIN) {
- ret = handle_notification_thread_client_in(
- &state, fd);
+ ret = handle_notification_thread_client_in(&state,
+ fd);
if (ret) {
goto error;
}
}
if (revents & LPOLLOUT) {
- ret = handle_notification_thread_client_out(
- &state, fd);
+ ret = handle_notification_thread_client_out(&state,
+ fd);
if (ret) {
goto error;
}
return NULL;
}
-static
-bool shutdown_notification_thread(void *thread_data)
+static bool shutdown_notification_thread(void *thread_data)
{
struct notification_thread_handle *handle = (notification_thread_handle *) thread_data;
return true;
}
-struct lttng_thread *launch_notification_thread(
- struct notification_thread_handle *handle)
+struct lttng_thread *launch_notification_thread(struct notification_thread_handle *handle)
{
struct lttng_thread *thread;
- thread = lttng_thread_create("Notification",
- thread_notification,
- shutdown_notification_thread,
- NULL,
- handle);
+ thread = lttng_thread_create(
+ "Notification", thread_notification, shutdown_notification_thread, NULL, handle);
if (!thread) {
goto error;
}
#define _LGPL_SOURCE
-#include <common/common.hpp>
-#include <common/utils.hpp>
-
#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
#include "lttng-sessiond.hpp"
#include "notify-apps.hpp"
-#include "health-sessiond.hpp"
#include "testpoint.hpp"
-#include "utils.hpp"
#include "thread.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/utils.hpp>
namespace {
struct thread_notifiers {
rcu_register_thread();
rcu_thread_online();
- health_register(the_health_sessiond,
- HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY);
+ health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_APP_MANAGE_NOTIFY);
if (testpoint(sessiond_thread_app_manage_notify)) {
goto error_testpoint;
}
/* Add notify pipe to the pollset. */
- ret = lttng_poll_add(&events, notifiers->apps_cmd_notify_pipe_read_fd,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(
+ &events, notifiers->apps_cmd_notify_pipe_read_fd, LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
goto error;
}
DBG3("[ust-thread] Manage notify polling");
/* Inifinite blocking call, waiting for transmission */
-restart:
+ restart:
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
DBG3("[ust-thread] Manage notify return from poll on %d fds",
- LTTNG_POLL_GETNB(&events));
+ LTTNG_POLL_GETNB(&events));
health_poll_exit();
if (ret < 0) {
/*
if (revents & LPOLLIN) {
/* Get socket from dispatch thread. */
- size_ret = lttng_read(notifiers->apps_cmd_notify_pipe_read_fd,
- &sock, sizeof(sock));
+ size_ret =
+ lttng_read(notifiers->apps_cmd_notify_pipe_read_fd,
+ &sock,
+ sizeof(sock));
if (size_ret < sizeof(sock)) {
PERROR("read apps notify pipe");
goto error;
ret = lttng_poll_add(&events, sock, LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
/*
- * It's possible we've reached the max poll fd allowed.
- * Let's close the socket but continue normal execution.
+ * It's possible we've reached the max poll fd
+ * allowed. Let's close the socket but continue
+ * normal execution.
*/
ret = close(sock);
if (ret) {
ERR("Apps notify command pipe error");
goto error;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
} else {
goto error;
}
- /* The socket is closed after a grace period here. */
+ /* The socket is closed after a grace period here.
+ */
ust_app_notify_sock_unregister(pollfd);
}
} else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
/* The socket is closed after a grace period here. */
ust_app_notify_sock_unregister(pollfd);
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto error;
}
health_code_update();
notifiers->quit_pipe = quit_pipe;
thread = lttng_thread_create("Application notification",
- thread_application_notification,
- shutdown_application_notification_thread,
- cleanup_application_notification_thread,
- notifiers);
+ thread_application_notification,
+ shutdown_application_notification_thread,
+ cleanup_application_notification_thread,
+ notifiers);
if (!thread) {
goto error;
}
*
*/
-#include <signal.h>
#include "lttng-sessiond.hpp"
+#include <signal.h>
+
/* Notify parents that we are ready for cmd and health check */
void sessiond_signal_parents(void)
{
*
*/
-#include <stddef.h>
-#include <stdlib.h>
-#include <urcu.h>
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "register.hpp"
+#include "testpoint.hpp"
+#include "thread.hpp"
+#include "utils.hpp"
+
#include <common/futex.hpp>
#include <common/macros.hpp>
#include <common/shm.hpp>
#include <common/utils.hpp>
-#include <sys/stat.h>
-#include "register.hpp"
-#include "lttng-sessiond.hpp"
-#include "testpoint.hpp"
-#include "health-sessiond.hpp"
-#include "fd-limit.hpp"
-#include "utils.hpp"
-#include "thread.hpp"
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <urcu.h>
namespace {
struct thread_state {
int apps_sock;
/* Create the application unix socket */
- apps_sock = lttcomm_create_unix_sock(
- the_config.apps_unix_sock_path.value);
+ apps_sock = lttcomm_create_unix_sock(the_config.apps_unix_sock_path.value);
if (apps_sock < 0) {
- ERR("Create unix sock failed: %s",
- the_config.apps_unix_sock_path.value);
+ ERR("Create unix sock failed: %s", the_config.apps_unix_sock_path.value);
ret = -1;
goto end;
}
ret = utils_set_fd_cloexec(apps_sock);
if (ret < 0) {
ERR("Unable to set CLOEXEC flag to the app Unix socket (fd: %d). "
- "Continuing but note that the consumer daemon will have a "
- "reference to this socket on exec()", apps_sock);
+ "Continuing but note that the consumer daemon will have a "
+ "reference to this socket on exec()",
+ apps_sock);
}
/* File permission MUST be 666 */
ret = chmod(the_config.apps_unix_sock_path.value,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
- S_IWOTH);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (ret < 0) {
- PERROR("Set file permissions failed on %s",
- the_config.apps_unix_sock_path.value);
+ PERROR("Set file permissions failed on %s", the_config.apps_unix_sock_path.value);
goto error_close_socket;
}
DBG("Notifying applications of session daemon state: %d", active);
/* See shm.c for this call implying mmap, shm and futex calls */
- wait_shm_mmap = shm_ust_get_mmap(
- the_config.wait_shm_path.value, is_root);
+ wait_shm_mmap = shm_ust_get_mmap(the_config.wait_shm_path.value, is_root);
if (wait_shm_mmap == NULL) {
goto error;
}
const bool is_root = (getuid() == 0);
struct thread_state *thread_state = (struct thread_state *) data;
const int application_socket = thread_state->application_socket;
- const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(
- thread_state->quit_pipe);
+ const auto thread_quit_pipe_fd = lttng_pipe_get_readfd(thread_state->quit_pipe);
DBG("[thread] Manage application registration started");
* parameter.
*/
if (the_config.app_socket_timeout >= 0) {
- (void) lttcomm_setsockopt_rcv_timeout(sock,
- the_config.app_socket_timeout * 1000);
- (void) lttcomm_setsockopt_snd_timeout(sock,
- the_config.app_socket_timeout * 1000);
+ (void) lttcomm_setsockopt_rcv_timeout(
+ sock, the_config.app_socket_timeout * 1000);
+ (void) lttcomm_setsockopt_snd_timeout(
+ sock, the_config.app_socket_timeout * 1000);
}
/*
sock = -1;
DBG("UST registration received with pid:%d ppid:%d uid:%d"
- " gid:%d sock:%d name:%s (version %d.%d)",
- ust_cmd->reg_msg.pid, ust_cmd->reg_msg.ppid,
- ust_cmd->reg_msg.uid, ust_cmd->reg_msg.gid,
- ust_cmd->sock, ust_cmd->reg_msg.name,
- ust_cmd->reg_msg.major, ust_cmd->reg_msg.minor);
+ " gid:%d sock:%d name:%s (version %d.%d)",
+ ust_cmd->reg_msg.pid,
+ ust_cmd->reg_msg.ppid,
+ ust_cmd->reg_msg.uid,
+ ust_cmd->reg_msg.gid,
+ ust_cmd->sock,
+ ust_cmd->reg_msg.name,
+ ust_cmd->reg_msg.major,
+ ust_cmd->reg_msg.minor);
/*
* Lock free enqueue the registration request. The red pill
*/
cds_wfcq_head_ptr_t head;
head.h = &thread_state->ust_cmd_queue->head;
- cds_wfcq_enqueue(head,
- &thread_state->ust_cmd_queue->tail,
- &ust_cmd->node);
+ cds_wfcq_enqueue(
+ head, &thread_state->ust_cmd_queue->tail, &ust_cmd->node);
/*
* Wake the registration queue futex. Implicit memory
return notify_thread_pipe(write_fd) == 1;
}
-struct lttng_thread *launch_application_registration_thread(
- struct ust_cmd_queue *cmd_queue)
+struct lttng_thread *launch_application_registration_thread(struct ust_cmd_queue *cmd_queue)
{
int ret;
struct lttng_pipe *quit_pipe;
sem_init(&thread_state->ready, 0, 0);
thread = lttng_thread_create("UST application registration",
- thread_application_registration,
- shutdown_application_registration_thread,
- cleanup_application_registration_thread,
- thread_state);
+ thread_application_registration,
+ shutdown_application_registration_thread,
+ cleanup_application_registration_thread,
+ thread_state);
if (!thread) {
goto error;
}
ret = notify_ust_apps(1, is_root);
if (ret < 0) {
ERR("Failed to notify applications or create the wait shared memory.\n"
- "Execution continues but there might be problems for already\n"
- "running applications that wishes to register.");
+ "Execution continues but there might be problems for already\n"
+ "running applications that wishes to register.");
}
return thread;
*/
#define _LGPL_SOURCE
-#include <lttng/trigger/trigger.h>
-#include <common/error.hpp>
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "session.hpp"
+#include "utils.hpp"
+
+#include <common/align.hpp>
#include <common/config/session-config.hpp>
+#include <common/credentials.hpp>
#include <common/defaults.hpp>
-#include <common/utils.hpp>
+#include <common/error.hpp>
#include <common/futex.hpp>
-#include <common/align.hpp>
-#include <common/time.hpp>
#include <common/hashtable/utils.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
-#include <common/credentials.hpp>
-#include <sys/stat.h>
-#include <time.h>
-#include <signal.h>
-#include <inttypes.h>
+#include <common/time.hpp>
+#include <common/utils.hpp>
+#include <lttng/action/action-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
#include <lttng/notification/channel-internal.hpp>
#include <lttng/rotate-internal.hpp>
-#include <lttng/condition/condition-internal.hpp>
-#include <lttng/action/action-internal.hpp>
-
-#include "session.hpp"
-#include "rotate.hpp"
-#include "rotation-thread.hpp"
-#include "lttng-sessiond.hpp"
-#include "health-sessiond.hpp"
-#include "cmd.hpp"
-#include "utils.hpp"
-#include "notification-thread-commands.hpp"
+#include <lttng/trigger/trigger.h>
+#include <inttypes.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <time.h>
#include <urcu.h>
#include <urcu/list.h>
#include <urcu/rculfhash.h>
-int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64_t size,
- struct notification_thread_handle *notification_thread_handle)
+int subscribe_session_consumed_size_rotation(
+ struct ltt_session *session,
+ uint64_t size,
+ struct notification_thread_handle *notification_thread_handle)
{
int ret;
enum lttng_condition_status condition_status;
goto end;
}
- condition_status = lttng_condition_session_consumed_size_set_threshold(
- rotate_condition, size);
+ condition_status =
+ lttng_condition_session_consumed_size_set_threshold(rotate_condition, size);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ERR("Could not set session consumed size condition threshold (size = %" PRIu64 ")",
- size);
+ size);
ret = -1;
goto end;
}
- condition_status =
- lttng_condition_session_consumed_size_set_session_name(
- rotate_condition, session->name);
+ condition_status = lttng_condition_session_consumed_size_set_session_name(rotate_condition,
+ session->name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ERR("Could not set session consumed size condition session name (name = %s)",
- session->name);
+ session->name);
ret = -1;
goto end;
}
}
LTTNG_ASSERT(!session->rotate_trigger);
- session->rotate_trigger = lttng_trigger_create(rotate_condition,
- notify_action);
+ session->rotate_trigger = lttng_trigger_create(rotate_condition, notify_action);
if (!session->rotate_trigger) {
ERR("Could not create size-based rotation trigger");
ret = -1;
/* Ensure this trigger is not visible to external users. */
lttng_trigger_set_hidden(session->rotate_trigger);
- lttng_trigger_set_credentials(
- session->rotate_trigger, &session_creds);
+ lttng_trigger_set_credentials(session->rotate_trigger, &session_creds);
- nc_status = lttng_notification_channel_subscribe(
- rotate_notification_channel, rotate_condition);
+ nc_status =
+ lttng_notification_channel_subscribe(rotate_notification_channel, rotate_condition);
if (nc_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
ERR("Could not subscribe to session consumed size notification");
ret = -1;
}
ret = notification_thread_command_register_trigger(
- notification_thread_handle, session->rotate_trigger,
- true);
+ notification_thread_handle, session->rotate_trigger, true);
if (ret < 0 && ret != -LTTNG_ERR_TRIGGER_EXISTS) {
ERR("Register trigger, %s", lttng_strerror(ret));
ret = -1;
return ret;
}
-int unsubscribe_session_consumed_size_rotation(struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle)
+int unsubscribe_session_consumed_size_rotation(
+ struct ltt_session *session, struct notification_thread_handle *notification_thread_handle)
{
int ret = 0;
enum lttng_notification_channel_status status;
LTTNG_ASSERT(session->rotate_trigger);
status = lttng_notification_channel_unsubscribe(
- rotate_notification_channel,
- lttng_trigger_get_const_condition(session->rotate_trigger));
+ rotate_notification_channel,
+ lttng_trigger_get_const_condition(session->rotate_trigger));
if (status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
ERR("Session unsubscribe error: %d", (int) status);
ret = -1;
goto end;
}
- ret = notification_thread_command_unregister_trigger(
- notification_thread_handle, session->rotate_trigger);
+ ret = notification_thread_command_unregister_trigger(notification_thread_handle,
+ session->rotate_trigger);
if (ret != LTTNG_OK) {
ERR("Session unregister trigger error: %d", ret);
goto end;
*/
#define _LGPL_SOURCE
-#include <lttng/trigger/trigger.h>
-#include <common/error.hpp>
+#include "cmd.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "rotate.hpp"
+#include "rotation-thread.hpp"
+#include "session.hpp"
+#include "thread.hpp"
+#include "timer.hpp"
+#include "utils.hpp"
+
+#include <common/align.hpp>
#include <common/config/session-config.hpp>
#include <common/defaults.hpp>
-#include <common/utils.hpp>
+#include <common/error.hpp>
#include <common/futex.hpp>
-#include <common/align.hpp>
-#include <common/time.hpp>
#include <common/hashtable/utils.hpp>
-#include <sys/stat.h>
-#include <time.h>
-#include <signal.h>
-#include <inttypes.h>
-
#include <common/kernel-ctl/kernel-ctl.hpp>
-#include <lttng/notification/channel-internal.hpp>
-#include <lttng/rotate-internal.hpp>
-#include <lttng/location-internal.hpp>
+#include <common/time.hpp>
+#include <common/utils.hpp>
+
#include <lttng/condition/condition-internal.hpp>
+#include <lttng/location-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
#include <lttng/notification/notification-internal.hpp>
+#include <lttng/rotate-internal.hpp>
+#include <lttng/trigger/trigger.h>
-#include "rotation-thread.hpp"
-#include "lttng-sessiond.hpp"
-#include "health-sessiond.hpp"
-#include "rotate.hpp"
-#include "cmd.hpp"
-#include "session.hpp"
-#include "timer.hpp"
-#include "notification-thread-commands.hpp"
-#include "utils.hpp"
-#include "thread.hpp"
-
+#include <inttypes.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <time.h>
#include <urcu.h>
#include <urcu/list.h>
};
} /* namespace */
-static
-const char *get_job_type_str(enum rotation_thread_job_type job_type)
+static const char *get_job_type_str(enum rotation_thread_job_type job_type)
{
switch (job_type) {
case ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION:
return queue;
}
-void rotation_thread_timer_queue_destroy(
- struct rotation_thread_timer_queue *queue)
+void rotation_thread_timer_queue_destroy(struct rotation_thread_timer_queue *queue)
{
if (!queue) {
return;
/*
* Destroy the thread data previously created by the init function.
*/
-void rotation_thread_handle_destroy(
- struct rotation_thread_handle *handle)
+void rotation_thread_handle_destroy(struct rotation_thread_handle *handle)
{
lttng_pipe_destroy(handle->quit_pipe);
free(handle);
}
-struct rotation_thread_handle *rotation_thread_handle_create(
- struct rotation_thread_timer_queue *rotation_timer_queue,
- struct notification_thread_handle *notification_thread_handle)
+struct rotation_thread_handle *
+rotation_thread_handle_create(struct rotation_thread_timer_queue *rotation_timer_queue,
+ struct notification_thread_handle *notification_thread_handle)
{
struct rotation_thread_handle *handle;
* Called with the rotation_thread_timer_queue lock held.
* Return true if the same timer job already exists in the queue, false if not.
*/
-static
-bool timer_job_exists(const struct rotation_thread_timer_queue *queue,
- enum rotation_thread_job_type job_type,
- struct ltt_session *session)
+static bool timer_job_exists(const struct rotation_thread_timer_queue *queue,
+ enum rotation_thread_job_type job_type,
+ struct ltt_session *session)
{
bool exists = false;
struct rotation_thread_job *job;
- cds_list_for_each_entry(job, &queue->list, head) {
+ cds_list_for_each_entry (job, &queue->list, head) {
if (job->session == session && job->type == job_type) {
exists = true;
goto end;
}
void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue,
- enum rotation_thread_job_type job_type,
- struct ltt_session *session)
+ enum rotation_thread_job_type job_type,
+ struct ltt_session *session)
{
int ret;
const char dummy = '!';
job = zmalloc<rotation_thread_job>();
if (!job) {
PERROR("Failed to allocate rotation thread job of type \"%s\" for session \"%s\"",
- job_type_str, session->name);
+ job_type_str,
+ session->name);
goto end;
}
/* No reason for this to fail as the caller must hold a reference. */
job->type = job_type;
cds_list_add_tail(&job->head, &queue->list);
- ret = lttng_write(lttng_pipe_get_writefd(queue->event_pipe), &dummy,
- sizeof(dummy));
+ ret = lttng_write(lttng_pipe_get_writefd(queue->event_pipe), &dummy, sizeof(dummy));
if (ret < 0) {
/*
* We do not want to block in the timer handler, the job has
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
/*
* Not an error, but would be surprising and indicate
* that the rotation thread can't keep up with the
goto end;
}
PERROR("Failed to wake-up the rotation thread after pushing a job of type \"%s\" for session \"%s\"",
- job_type_str, session->name);
+ job_type_str,
+ session->name);
goto end;
}
pthread_mutex_unlock(&queue->lock);
}
-static
-int init_poll_set(struct lttng_poll_event *poll_set,
- struct rotation_thread_handle *handle)
+static int init_poll_set(struct lttng_poll_event *poll_set, struct rotation_thread_handle *handle)
{
int ret;
goto error;
}
- ret = lttng_poll_add(poll_set,
- lttng_pipe_get_readfd(handle->quit_pipe), LPOLLIN);
+ ret = lttng_poll_add(poll_set, lttng_pipe_get_readfd(handle->quit_pipe), LPOLLIN);
if (ret < 0) {
ERR("Failed to add quit pipe read fd to poll set");
goto error;
}
- ret = lttng_poll_add(poll_set,
- lttng_pipe_get_readfd(handle->rotation_timer_queue->event_pipe),
- LPOLLIN);
+ ret = lttng_poll_add(
+ poll_set, lttng_pipe_get_readfd(handle->rotation_timer_queue->event_pipe), LPOLLIN);
if (ret < 0) {
ERR("Failed to add rotate_pending fd to poll set");
goto error;
return ret;
}
-static
-void fini_thread_state(struct rotation_thread *state)
+static void fini_thread_state(struct rotation_thread *state)
{
lttng_poll_clean(&state->events);
if (rotate_notification_channel) {
}
}
-static
-int init_thread_state(struct rotation_thread_handle *handle,
- struct rotation_thread *state)
+static int init_thread_state(struct rotation_thread_handle *handle, struct rotation_thread *state)
{
int ret;
goto end;
}
- rotate_notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ rotate_notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
if (!rotate_notification_channel) {
ERR("Could not create notification channel");
ret = -1;
goto end;
}
- ret = lttng_poll_add(&state->events, rotate_notification_channel->socket,
- LPOLLIN);
+ ret = lttng_poll_add(&state->events, rotate_notification_channel->socket, LPOLLIN);
if (ret < 0) {
ERR("Failed to add notification fd to pollset");
goto end;
return ret;
}
-static
-void check_session_rotation_pending_on_consumers(struct ltt_session *session,
- bool *_rotation_completed)
+static void check_session_rotation_pending_on_consumers(struct ltt_session *session,
+ bool *_rotation_completed)
{
int ret = 0;
struct consumer_socket *socket;
if (!session->ust_session) {
goto skip_ust;
}
- cds_lfht_for_each_entry(session->ust_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->consumer->socks->ht, &iter, socket, node.node) {
relayd_id = session->ust_session->consumer->type == CONSUMER_DST_LOCAL ?
- -1ULL :
- session->ust_session->consumer->net_seq_index;
+ -1ULL :
+ session->ust_session->consumer->net_seq_index;
pthread_mutex_lock(socket->lock);
ret = consumer_trace_chunk_exists(socket,
- relayd_id,
- session->id, session->chunk_being_archived,
- &exists_status);
+ relayd_id,
+ session->id,
+ session->chunk_being_archived,
+ &exists_status);
if (ret) {
pthread_mutex_unlock(socket->lock);
ERR("Error occurred while checking rotation status on consumer daemon");
if (!session->kernel_session) {
goto skip_kernel;
}
- cds_lfht_for_each_entry(session->kernel_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->kernel_session->consumer->socks->ht, &iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
relayd_id = session->kernel_session->consumer->type == CONSUMER_DST_LOCAL ?
- -1ULL :
- session->kernel_session->consumer->net_seq_index;
+ -1ULL :
+ session->kernel_session->consumer->net_seq_index;
ret = consumer_trace_chunk_exists(socket,
- relayd_id,
- session->id, session->chunk_being_archived,
- &exists_status);
+ relayd_id,
+ session->id,
+ session->chunk_being_archived,
+ &exists_status);
if (ret) {
pthread_mutex_unlock(socket->lock);
ERR("Error occurred while checking rotation status on consumer daemon");
if (!chunk_exists_on_peer) {
uint64_t chunk_being_archived_id;
- chunk_status = lttng_trace_chunk_get_id(
- session->chunk_being_archived,
- &chunk_being_archived_id);
+ chunk_status = lttng_trace_chunk_get_id(session->chunk_being_archived,
+ &chunk_being_archived_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
- DBG("Rotation of trace archive %" PRIu64 " of session \"%s\" is complete on all consumers",
- chunk_being_archived_id,
- session->name);
+ DBG("Rotation of trace archive %" PRIu64
+ " of session \"%s\" is complete on all consumers",
+ chunk_being_archived_id,
+ session->name);
}
*_rotation_completed = !chunk_exists_on_peer;
if (ret) {
- ret = session_reset_rotation_state(session,
- LTTNG_ROTATION_STATE_ERROR);
+ ret = session_reset_rotation_state(session, LTTNG_ROTATION_STATE_ERROR);
if (ret) {
- ERR("Failed to reset rotation state of session \"%s\"",
- session->name);
+ ERR("Failed to reset rotation state of session \"%s\"", session->name);
}
}
}
* Should only return non-zero in the event of a fatal error. Doing so will
* shutdown the thread.
*/
-static
-int check_session_rotation_pending(struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle)
+static int
+check_session_rotation_pending(struct ltt_session *session,
+ struct notification_thread_handle *notification_thread_handle)
{
int ret;
struct lttng_trace_archive_location *location;
goto end;
}
- chunk_status = lttng_trace_chunk_get_id(session->chunk_being_archived,
- &chunk_being_archived_id);
+ chunk_status =
+ lttng_trace_chunk_get_id(session->chunk_being_archived, &chunk_being_archived_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
DBG("Checking for pending rotation on session \"%s\", trace archive %" PRIu64,
- session->name, chunk_being_archived_id);
+ session->name,
+ chunk_being_archived_id);
/*
* The rotation-pending check timer of a session is launched in
goto check_ongoing_rotation;
}
- check_session_rotation_pending_on_consumers(session,
- &rotation_completed);
- if (!rotation_completed ||
- session->rotation_state == LTTNG_ROTATION_STATE_ERROR) {
+ check_session_rotation_pending_on_consumers(session, &rotation_completed);
+ if (!rotation_completed || session->rotation_state == LTTNG_ROTATION_STATE_ERROR) {
goto check_ongoing_rotation;
}
* Now we can clear the "ONGOING" state in the session. New
* rotations can start now.
*/
- chunk_status = lttng_trace_chunk_get_name(session->chunk_being_archived,
- &archived_chunk_name, NULL);
+ chunk_status = lttng_trace_chunk_get_name(
+ session->chunk_being_archived, &archived_chunk_name, NULL);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
free(session->last_archived_chunk_name);
session->last_archived_chunk_name = strdup(archived_chunk_name);
if (!session->quiet_rotation) {
location = session_get_trace_archive_location(session);
ret = notification_thread_command_session_rotation_completed(
- notification_thread_handle,
- session->id,
- session->last_archived_chunk_id.value,
- location);
+ notification_thread_handle,
+ session->id,
+ session->last_archived_chunk_id.value,
+ location);
lttng_trace_archive_location_put(location);
if (ret != LTTNG_OK) {
ERR("Failed to notify notification thread of completed rotation for session %s",
- session->name);
+ session->name);
}
}
ret = 0;
check_ongoing_rotation:
if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) {
- chunk_status = lttng_trace_chunk_get_id(
- session->chunk_being_archived,
- &chunk_being_archived_id);
+ chunk_status = lttng_trace_chunk_get_id(session->chunk_being_archived,
+ &chunk_being_archived_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
DBG("Rotation of trace archive %" PRIu64 " is still pending for session %s",
- chunk_being_archived_id, session->name);
+ chunk_being_archived_id,
+ session->name);
ret = timer_session_rotation_pending_check_start(session,
- DEFAULT_ROTATE_PENDING_TIMER);
+ DEFAULT_ROTATE_PENDING_TIMER);
if (ret) {
ERR("Failed to re-enable rotation pending timer");
ret = -1;
}
/* Call with the session and session_list locks held. */
-static
-int launch_session_rotation(struct ltt_session *session)
+static int launch_session_rotation(struct ltt_session *session)
{
int ret;
struct lttng_rotate_session_return rotation_return;
- DBG("Launching scheduled time-based rotation on session \"%s\"",
- session->name);
+ DBG("Launching scheduled time-based rotation on session \"%s\"", session->name);
- ret = cmd_rotate_session(session, &rotation_return, false,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ ret = cmd_rotate_session(
+ session, &rotation_return, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret == LTTNG_OK) {
DBG("Scheduled time-based rotation successfully launched on session \"%s\"",
- session->name);
+ session->name);
} else {
/* Don't consider errors as fatal. */
DBG("Scheduled time-based rotation aborted for session %s: %s",
- session->name, lttng_strerror(ret));
+ session->name,
+ lttng_strerror(ret));
}
return 0;
}
-static
-int run_job(struct rotation_thread_job *job, struct ltt_session *session,
- struct notification_thread_handle *notification_thread_handle)
+static int run_job(struct rotation_thread_job *job,
+ struct ltt_session *session,
+ struct notification_thread_handle *notification_thread_handle)
{
int ret;
ret = launch_session_rotation(session);
break;
case ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION:
- ret = check_session_rotation_pending(session,
- notification_thread_handle);
+ ret = check_session_rotation_pending(session, notification_thread_handle);
break;
default:
abort();
return ret;
}
-static
-int handle_job_queue(struct rotation_thread_handle *handle,
- struct rotation_thread *state __attribute__((unused)),
- struct rotation_thread_timer_queue *queue)
+static int handle_job_queue(struct rotation_thread_handle *handle,
+ struct rotation_thread *state __attribute__((unused)),
+ struct rotation_thread_timer_queue *queue)
{
int ret = 0;
pthread_mutex_unlock(&queue->lock);
break;
}
- job = cds_list_first_entry(&queue->list,
- typeof(*job), head);
+ job = cds_list_first_entry(&queue->list, typeof(*job), head);
cds_list_del(&job->head);
pthread_mutex_unlock(&queue->lock);
session_lock_list();
session = job->session;
if (!session) {
- DBG("Session \"%s\" not found",
- session->name != NULL ? session->name : "");
+ DBG("Session \"%s\" not found", session->name != NULL ? session->name : "");
/*
* This is a non-fatal error, and we cannot report it to
* the user (timer), so just print the error and
return ret;
}
-static
-int handle_condition(const struct lttng_notification *notification,
- struct notification_thread_handle *notification_thread_handle)
+static int handle_condition(const struct lttng_notification *notification,
+ struct notification_thread_handle *notification_thread_handle)
{
int ret = 0;
const char *condition_session_name = NULL;
uint64_t consumed;
struct ltt_session *session;
const struct lttng_condition *condition =
- lttng_notification_get_const_condition(notification);
+ lttng_notification_get_const_condition(notification);
const struct lttng_evaluation *evaluation =
- lttng_notification_get_const_evaluation(notification);
+ lttng_notification_get_const_evaluation(notification);
condition_type = lttng_condition_get_type(condition);
/* Fetch info to test */
condition_status = lttng_condition_session_consumed_size_get_session_name(
- condition, &condition_session_name);
+ condition, &condition_session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ERR("Session name could not be fetched");
ret = -1;
goto end;
}
- evaluation_status = lttng_evaluation_session_consumed_size_get_consumed_size(evaluation,
- &consumed);
+ evaluation_status =
+ lttng_evaluation_session_consumed_size_get_consumed_size(evaluation, &consumed);
if (evaluation_status != LTTNG_EVALUATION_STATUS_OK) {
ERR("Failed to get evaluation");
ret = -1;
session = session_find_by_name(condition_session_name);
if (!session) {
DBG("Failed to find session while handling notification: notification type = %s, session name = `%s`",
- lttng_condition_type_str(condition_type),
- condition_session_name);
+ lttng_condition_type_str(condition_type),
+ condition_session_name);
/*
* Not a fatal error: a session can be destroyed before we get
* the chance to handle the notification.
session_lock(session);
if (!lttng_trigger_is_equal(session->rotate_trigger,
- lttng_notification_get_const_trigger(notification))) {
+ lttng_notification_get_const_trigger(notification))) {
/* Notification does not originate from our rotation trigger. */
ret = 0;
goto end_unlock;
}
- ret = unsubscribe_session_consumed_size_rotation(session,
- notification_thread_handle);
+ ret = unsubscribe_session_consumed_size_rotation(session, notification_thread_handle);
if (ret) {
goto end_unlock;
}
ret = cmd_rotate_session(
- session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
+ session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
switch (ret) {
case LTTNG_OK:
break;
}
ret = subscribe_session_consumed_size_rotation(
- session, consumed + session->rotate_size, notification_thread_handle);
+ session, consumed + session->rotate_size, notification_thread_handle);
if (ret) {
ERR("Failed to subscribe to session consumed size condition");
goto end_unlock;
return ret;
}
-static
-int handle_notification_channel(int fd __attribute__((unused)),
- struct rotation_thread_handle *handle,
- struct rotation_thread *state __attribute__((unused)))
+static int handle_notification_channel(int fd __attribute__((unused)),
+ struct rotation_thread_handle *handle,
+ struct rotation_thread *state __attribute__((unused)))
{
int ret;
bool notification_pending;
struct lttng_notification *notification = NULL;
enum lttng_notification_channel_status status;
- status = lttng_notification_channel_has_pending_notification(
- rotate_notification_channel, ¬ification_pending);
+ status = lttng_notification_channel_has_pending_notification(rotate_notification_channel,
+ ¬ification_pending);
if (status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
ERR("Error occurred while checking for pending notification");
ret = -1;
}
/* Receive the next notification. */
- status = lttng_notification_channel_get_next_notification(
- rotate_notification_channel,
- ¬ification);
+ status = lttng_notification_channel_get_next_notification(rotate_notification_channel,
+ ¬ification);
switch (status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK:
case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED:
/* Not an error, we will wait for the next one */
ret = 0;
- goto end;;
+ goto end;
+ ;
case LTTNG_NOTIFICATION_CHANNEL_STATUS_CLOSED:
ERR("Notification channel was closed");
ret = -1;
goto end;
}
- ret = handle_condition(notification,
- handle->notification_thread_handle);
+ ret = handle_condition(notification, handle->notification_thread_handle);
end:
lttng_notification_destroy(notification);
return ret;
}
-static
-void *thread_rotation(void *data)
+static void *thread_rotation(void *data)
{
int ret;
struct rotation_thread_handle *handle = (rotation_thread_handle *) data;
goto end;
}
- queue_pipe_fd = lttng_pipe_get_readfd(
- handle->rotation_timer_queue->event_pipe);
-
+ queue_pipe_fd = lttng_pipe_get_readfd(handle->rotation_timer_queue->event_pipe);
ret = init_thread_state(handle, &thread);
if (ret) {
int fd = LTTNG_POLL_GETFD(&thread.events, i);
uint32_t revents = LTTNG_POLL_GETEV(&thread.events, i);
- DBG("Handling fd (%i) activity (%u)",
- fd, revents);
+ DBG("Handling fd (%i) activity (%u)", fd, revents);
if (revents & LPOLLERR) {
ERR("Polling returned an error on fd %i", fd);
}
if (fd == rotate_notification_channel->socket) {
- ret = handle_notification_channel(fd, handle,
- &thread);
+ ret = handle_notification_channel(fd, handle, &thread);
if (ret) {
ERR("Error occurred while handling activity on notification channel socket");
goto error;
* flushed and all references held in the queue
* are released.
*/
- ret = handle_job_queue(handle, &thread,
- handle->rotation_timer_queue);
+ ret = handle_job_queue(
+ handle, &thread, handle->rotation_timer_queue);
if (ret) {
ERR("Failed to handle rotation timer pipe event");
goto error;
ret = lttng_read(fd, &buf, 1);
if (ret != 1) {
- ERR("Failed to read from wakeup pipe (fd = %i)", fd);
+ ERR("Failed to read from wakeup pipe (fd = %i)",
+ fd);
goto error;
}
} else {
return NULL;
}
-static
-bool shutdown_rotation_thread(void *thread_data)
+static bool shutdown_rotation_thread(void *thread_data)
{
struct rotation_thread_handle *handle = (rotation_thread_handle *) thread_data;
const int write_fd = lttng_pipe_get_writefd(handle->quit_pipe);
{
struct lttng_thread *thread;
- thread = lttng_thread_create("Rotation",
- thread_rotation,
- shutdown_rotation_thread,
- NULL,
- handle);
+ thread = lttng_thread_create(
+ "Rotation", thread_rotation, shutdown_rotation_thread, NULL, handle);
if (!thread) {
goto error;
}
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <string.h>
-#include <urcu/uatomic.h>
-#include <unistd.h>
+#include "agent.hpp"
+#include "kernel.hpp"
+#include "lttng-syscall.hpp"
+#include "save.hpp"
+#include "session.hpp"
+#include "trace-ust.hpp"
+#include <common/config/session-config.hpp>
#include <common/defaults.hpp>
#include <common/error.hpp>
-#include <common/config/session-config.hpp>
-#include <common/utils.hpp>
#include <common/runas.hpp>
+#include <common/utils.hpp>
+
#include <lttng/save-internal.hpp>
-#include "kernel.hpp"
-#include "save.hpp"
-#include "session.hpp"
-#include "lttng-syscall.hpp"
-#include "trace-ust.hpp"
-#include "agent.hpp"
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <urcu/uatomic.h>
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_channel_attributes(struct config_writer *writer,
- struct lttng_channel_attr *attr)
+static int save_kernel_channel_attributes(struct config_writer *writer,
+ struct lttng_channel_attr *attr)
{
int ret;
ret = config_writer_write_element_string(writer,
- config_element_overwrite_mode,
- attr->overwrite ? config_overwrite_mode_overwrite :
- config_overwrite_mode_discard);
+ config_element_overwrite_mode,
+ attr->overwrite ? config_overwrite_mode_overwrite :
+ config_overwrite_mode_discard);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_subbuf_size, attr->subbuf_size);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_subbuf_size, attr->subbuf_size);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_num_subbuf,
- attr->num_subbuf);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_num_subbuf, attr->num_subbuf);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_switch_timer_interval,
- attr->switch_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_switch_timer_interval, attr->switch_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_read_timer_interval,
- attr->read_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_read_timer_interval, attr->read_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
ret = config_writer_write_element_string(writer,
- config_element_output_type,
- attr->output == LTTNG_EVENT_SPLICE ?
- config_output_type_splice : config_output_type_mmap);
+ config_element_output_type,
+ attr->output == LTTNG_EVENT_SPLICE ?
+ config_output_type_splice :
+ config_output_type_mmap);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_tracefile_size, attr->tracefile_size);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_size, attr->tracefile_size);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_tracefile_count,
- attr->tracefile_count);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_count, attr->tracefile_count);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_live_timer_interval,
- attr->live_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_live_timer_interval, attr->live_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
struct lttng_channel_extended *ext = NULL;
ext = (struct lttng_channel_extended *) attr->extended.ptr;
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_monitor_timer_interval,
- ext->monitor_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_monitor_timer_interval, ext->monitor_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_signed_int(writer,
- config_element_blocking_timeout,
- ext->blocking_timeout);
+ ret = config_writer_write_element_signed_int(
+ writer, config_element_blocking_timeout, ext->blocking_timeout);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_channel_attributes(struct config_writer *writer,
- struct lttng_ust_abi_channel_attr *attr)
+static int save_ust_channel_attributes(struct config_writer *writer,
+ struct lttng_ust_abi_channel_attr *attr)
{
int ret;
struct ltt_ust_channel *channel = NULL;
ret = config_writer_write_element_string(writer,
- config_element_overwrite_mode,
- attr->overwrite ? config_overwrite_mode_overwrite :
- config_overwrite_mode_discard);
+ config_element_overwrite_mode,
+ attr->overwrite ? config_overwrite_mode_overwrite :
+ config_overwrite_mode_discard);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_subbuf_size, attr->subbuf_size);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_subbuf_size, attr->subbuf_size);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_num_subbuf,
- attr->num_subbuf);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_num_subbuf, attr->num_subbuf);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_switch_timer_interval,
- attr->switch_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_switch_timer_interval, attr->switch_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_read_timer_interval,
- attr->read_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_read_timer_interval, attr->read_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
ret = config_writer_write_element_string(writer,
- config_element_output_type,
- attr->output == LTTNG_UST_ABI_MMAP ?
- config_output_type_mmap : config_output_type_splice);
+ config_element_output_type,
+ attr->output == LTTNG_UST_ABI_MMAP ?
+ config_output_type_mmap :
+ config_output_type_splice);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_signed_int(writer,
- config_element_blocking_timeout,
- attr->u.s.blocking_timeout);
+ ret = config_writer_write_element_signed_int(
+ writer, config_element_blocking_timeout, attr->u.s.blocking_timeout);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
* lttng_ust_channel_attr
*/
channel = lttng::utils::container_of(attr, <t_ust_channel::attr);
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_monitor_timer_interval,
- channel->monitor_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_monitor_timer_interval, channel->monitor_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
return ret;
}
-static
-const char *get_kernel_instrumentation_string(
- enum lttng_kernel_abi_instrumentation instrumentation)
+static const char *
+get_kernel_instrumentation_string(enum lttng_kernel_abi_instrumentation instrumentation)
{
const char *instrumentation_string;
return instrumentation_string;
}
-static
-const char *get_kernel_context_type_string(
- enum lttng_kernel_abi_context_type context_type)
+static const char *get_kernel_context_type_string(enum lttng_kernel_abi_context_type context_type)
{
const char *context_type_string;
return context_type_string;
}
-static
-const char *get_ust_context_type_string(
- enum lttng_ust_abi_context_type context_type)
+static const char *get_ust_context_type_string(enum lttng_ust_abi_context_type context_type)
{
const char *context_type_string;
return context_type_string;
}
-static
-const char *get_buffer_type_string(
- enum lttng_buffer_type buffer_type)
+static const char *get_buffer_type_string(enum lttng_buffer_type buffer_type)
{
const char *buffer_type_string;
return buffer_type_string;
}
-static
-const char *get_loglevel_type_string(
- enum lttng_ust_abi_loglevel_type loglevel_type)
+static const char *get_loglevel_type_string(enum lttng_ust_abi_loglevel_type loglevel_type)
{
const char *loglevel_type_string;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_function_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_function_event(struct config_writer *writer, struct ltt_kernel_event *event)
{
int ret;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_name,
- event->event->u.ftrace.symbol_name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, event->event->u.ftrace.symbol_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
return ret;
}
-static
-int save_kernel_kprobe_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_kprobe_event(struct config_writer *writer, struct ltt_kernel_event *event)
{
int ret;
const char *symbol_name;
}
if (addr) {
- ret = config_writer_write_element_unsigned_int( writer,
- config_element_address, addr);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_address, addr);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
} else if (symbol_name) {
- ret = config_writer_write_element_string(writer,
- config_element_symbol_name, symbol_name);
+ ret = config_writer_write_element_string(
+ writer, config_element_symbol_name, symbol_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* If the offset is non-zero, write it.*/
if (offset) {
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_offset, offset);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_offset, offset);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
-
ret = config_writer_close_element(writer);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
* Save the userspace probe tracepoint event associated with the event to the
* config writer.
*/
-static
-int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer,
+ struct ltt_kernel_event *event)
{
int ret = 0;
const char *probe_name, *provider_name, *binary_path;
/* Get the binary path, probe name and provider name. */
binary_path =
- lttng_userspace_probe_location_tracepoint_get_binary_path(
- userspace_probe_location);
+ lttng_userspace_probe_location_tracepoint_get_binary_path(userspace_probe_location);
if (!binary_path) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
probe_name =
- lttng_userspace_probe_location_tracepoint_get_probe_name(
- userspace_probe_location);
+ lttng_userspace_probe_location_tracepoint_get_probe_name(userspace_probe_location);
if (!probe_name) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- provider_name =
- lttng_userspace_probe_location_tracepoint_get_provider_name(
- userspace_probe_location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
+ userspace_probe_location);
if (!provider_name) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Open a userspace probe tracepoint attribute. */
- ret = config_writer_open_element(writer, config_element_userspace_probe_tracepoint_attributes);
+ ret = config_writer_open_element(writer,
+ config_element_userspace_probe_tracepoint_attributes);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_tracepoint_sdt);
+ ret = config_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_tracepoint_sdt);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Write the binary path, provider name and the probe name. */
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = config_writer_write_element_string(
+ writer, config_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_tracepoint_location_provider_name,
- provider_name);
+ ret = config_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_tracepoint_location_provider_name,
+ provider_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_tracepoint_location_probe_name,
- probe_name);
+ ret = config_writer_write_element_string(
+ writer, config_element_userspace_probe_tracepoint_location_probe_name, probe_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
* Save the userspace probe function event associated with the event to the
* config writer.
*/
-static
-int save_kernel_userspace_probe_function_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_function_event(struct config_writer *writer,
+ struct ltt_kernel_event *event)
{
int ret = 0;
const char *function_name, *binary_path;
}
/* Get lookup method and lookup method type. */
- lookup_method = lttng_userspace_probe_location_get_lookup_method(
- userspace_probe_location);
+ lookup_method = lttng_userspace_probe_location_get_lookup_method(userspace_probe_location);
if (!lookup_method) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
/* Get the binary path and the function name. */
binary_path =
- lttng_userspace_probe_location_function_get_binary_path(
- userspace_probe_location);
+ lttng_userspace_probe_location_function_get_binary_path(userspace_probe_location);
if (!binary_path) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
function_name =
- lttng_userspace_probe_location_function_get_function_name(
- userspace_probe_location);
+ lttng_userspace_probe_location_function_get_function_name(userspace_probe_location);
if (!function_name) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
/* Open a userspace probe function attribute. */
ret = config_writer_open_element(writer,
- config_element_userspace_probe_function_attributes);
+ config_element_userspace_probe_function_attributes);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
lookup_type = lttng_userspace_probe_location_lookup_method_get_type(lookup_method);
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_function_elf);
+ ret = config_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_function_elf);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_function_default);
+ ret = config_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_function_default);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Write the binary path and the function name. */
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = config_writer_write_element_string(
+ writer, config_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_userspace_probe_function_location_function_name,
- function_name);
+ ret = config_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_function_location_function_name,
+ function_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
return ret;
}
-static
-int save_kernel_userspace_probe_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_userspace_probe_event(struct config_writer *writer,
+ struct ltt_kernel_event *event)
{
int ret;
struct lttng_userspace_probe_location *userspace_probe_location;
goto end;
}
- switch(lttng_userspace_probe_location_get_type(userspace_probe_location)) {
+ switch (lttng_userspace_probe_location_get_type(userspace_probe_location)) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
{
ret = save_kernel_userspace_probe_function_event(writer, event);
return ret;
}
-static
-int save_kernel_event(struct config_writer *writer,
- struct ltt_kernel_event *event)
+static int save_kernel_event(struct config_writer *writer, struct ltt_kernel_event *event)
{
int ret;
const char *instrumentation_type;
}
if (event->event->name[0]) {
- ret = config_writer_write_element_string(writer,
- config_element_name, event->event->name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, event->event->name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
}
- ret = config_writer_write_element_bool(writer, config_element_enabled,
- event->enabled);
+ ret = config_writer_write_element_bool(writer, config_element_enabled, event->enabled);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- instrumentation_type = get_kernel_instrumentation_string(
- event->event->instrumentation);
+ instrumentation_type = get_kernel_instrumentation_string(event->event->instrumentation);
if (!instrumentation_type) {
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_type,
- instrumentation_type);
+ ret = config_writer_write_element_string(writer, config_element_type, instrumentation_type);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
if (event->filter_expression) {
- ret = config_writer_write_element_string(writer,
- config_element_filter,
- event->filter_expression);
+ ret = config_writer_write_element_string(
+ writer, config_element_filter, event->filter_expression);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
if (event->event->instrumentation == LTTNG_KERNEL_ABI_FUNCTION ||
- event->event->instrumentation == LTTNG_KERNEL_ABI_KPROBE ||
- event->event->instrumentation == LTTNG_KERNEL_ABI_UPROBE ||
- event->event->instrumentation == LTTNG_KERNEL_ABI_KRETPROBE) {
-
- ret = config_writer_open_element(writer,
- config_element_attributes);
+ event->event->instrumentation == LTTNG_KERNEL_ABI_KPROBE ||
+ event->event->instrumentation == LTTNG_KERNEL_ABI_UPROBE ||
+ event->event->instrumentation == LTTNG_KERNEL_ABI_KRETPROBE) {
+ ret = config_writer_open_element(writer, config_element_attributes);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_events(struct config_writer *writer,
- struct ltt_kernel_channel *kchan)
+static int save_kernel_events(struct config_writer *writer, struct ltt_kernel_channel *kchan)
{
int ret;
struct ltt_kernel_event *event;
goto end;
}
- cds_list_for_each_entry(event, &kchan->events_list.head, list) {
+ cds_list_for_each_entry (event, &kchan->events_list.head, list) {
ret = save_kernel_event(writer, event);
if (ret != LTTNG_OK) {
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_event(struct config_writer *writer,
- struct ltt_ust_event *event)
+static int save_ust_event(struct config_writer *writer, struct ltt_ust_event *event)
{
int ret;
const char *loglevel_type_string;
}
if (event->attr.name[0]) {
- ret = config_writer_write_element_string(writer,
- config_element_name, event->attr.name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, event->attr.name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
}
- ret = config_writer_write_element_bool(writer, config_element_enabled,
- event->enabled);
+ ret = config_writer_write_element_bool(writer, config_element_enabled, event->enabled);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_type,
- config_event_type_tracepoint);
+ ret = config_writer_write_element_string(
+ writer, config_element_type, config_event_type_tracepoint);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- loglevel_type_string = get_loglevel_type_string(
- (lttng_ust_abi_loglevel_type) event->attr.loglevel_type);
+ loglevel_type_string =
+ get_loglevel_type_string((lttng_ust_abi_loglevel_type) event->attr.loglevel_type);
if (!loglevel_type_string) {
ERR("Unsupported UST loglevel type.");
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_loglevel_type, loglevel_type_string);
+ ret = config_writer_write_element_string(
+ writer, config_element_loglevel_type, loglevel_type_string);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
/* The log level is irrelevant if no "filtering" is enabled */
if (event->attr.loglevel_type != LTTNG_UST_ABI_LOGLEVEL_ALL) {
- ret = config_writer_write_element_signed_int(writer,
- config_element_loglevel, event->attr.loglevel);
+ ret = config_writer_write_element_signed_int(
+ writer, config_element_loglevel, event->attr.loglevel);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
if (event->filter_expression) {
- ret = config_writer_write_element_string(writer,
- config_element_filter, event->filter_expression);
+ ret = config_writer_write_element_string(
+ writer, config_element_filter, event->filter_expression);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
if (event->exclusion && event->exclusion->count) {
uint32_t i;
- ret = config_writer_open_element(writer,
- config_element_exclusions);
+ ret = config_writer_open_element(writer, config_element_exclusions);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
for (i = 0; i < event->exclusion->count; i++) {
- ret = config_writer_write_element_string(writer,
+ ret = config_writer_write_element_string(
+ writer,
config_element_exclusion,
- LTTNG_EVENT_EXCLUSION_NAME_AT(
- event->exclusion, i));
+ LTTNG_EVENT_EXCLUSION_NAME_AT(event->exclusion, i));
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_events(struct config_writer *writer,
- struct lttng_ht *events)
+static int save_ust_events(struct config_writer *writer, struct lttng_ht *events)
{
int ret;
struct ltt_ust_event *event;
}
rcu_read_lock();
- cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) {
event = lttng::utils::container_of(node, <t_ust_event::node);
if (event->internal) {
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
- struct agent_event *agent_event)
+static int init_ust_event_from_agent_event(struct ltt_ust_event *ust_event,
+ struct agent_event *agent_event)
{
int ret;
enum lttng_ust_abi_loglevel_type ust_loglevel_type;
ust_event->enabled = AGENT_EVENT_IS_ENABLED(agent_event);
ust_event->attr.instrumentation = LTTNG_UST_ABI_TRACEPOINT;
- if (lttng_strncpy(ust_event->attr.name, agent_event->name,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (lttng_strncpy(ust_event->attr.name, agent_event->name, LTTNG_SYMBOL_NAME_LEN)) {
ret = LTTNG_ERR_INVALID;
goto end;
}
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_agent_events(struct config_writer *writer,
- struct agent *agent)
+static int save_agent_events(struct config_writer *writer, struct agent *agent)
{
int ret;
struct lttng_ht_iter iter;
}
rcu_read_lock();
- cds_lfht_for_each_entry(agent->events->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (agent->events->ht, &iter.iter, node, node) {
struct agent_event *agent_event;
struct ltt_ust_event fake_event;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_context(struct config_writer *writer,
- struct lttng_kernel_abi_context *ctx)
+static int save_kernel_context(struct config_writer *writer, struct lttng_kernel_abi_context *ctx)
{
int ret = LTTNG_OK;
}
if (ctx->ctx == LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER) {
- ret = config_writer_open_element(writer,
- config_element_context_perf);
+ ret = config_writer_open_element(writer, config_element_context_perf);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_type, ctx->u.perf_counter.type);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_type, ctx->u.perf_counter.type);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_config, ctx->u.perf_counter.config);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_config, ctx->u.perf_counter.config);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_name, ctx->u.perf_counter.name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, ctx->u.perf_counter.name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
} else {
- const char *context_type_string =
- get_kernel_context_type_string(ctx->ctx);
+ const char *context_type_string = get_kernel_context_type_string(ctx->ctx);
if (!context_type_string) {
ERR("Unsupported kernel context type.");
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_type, context_type_string);
+ ret = config_writer_write_element_string(
+ writer, config_element_type, context_type_string);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_contexts(struct config_writer *writer,
- struct ltt_kernel_channel *kchan)
+static int save_kernel_contexts(struct config_writer *writer, struct ltt_kernel_channel *kchan)
{
int ret;
struct ltt_kernel_context *ctx;
goto end;
}
- cds_list_for_each_entry(ctx, &kchan->ctx_list, list) {
+ cds_list_for_each_entry (ctx, &kchan->ctx_list, list) {
ret = save_kernel_context(writer, &ctx->ctx);
if (ret != LTTNG_OK) {
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_perf_thread_counter(struct config_writer *writer,
- struct ltt_ust_context *ctx)
+static int save_ust_context_perf_thread_counter(struct config_writer *writer,
+ struct ltt_ust_context *ctx)
{
int ret;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_type, ctx->ctx.u.perf_counter.type);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_type, ctx->ctx.u.perf_counter.type);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_config, ctx->ctx.u.perf_counter.config);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_config, ctx->ctx.u.perf_counter.config);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_name,
- ctx->ctx.u.perf_counter.name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, ctx->ctx.u.perf_counter.name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_app_ctx(struct config_writer *writer,
- struct ltt_ust_context *ctx)
+static int save_ust_context_app_ctx(struct config_writer *writer, struct ltt_ust_context *ctx)
{
int ret;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_context_app_provider_name,
- ctx->ctx.u.app_ctx.provider_name);
+ ret = config_writer_write_element_string(
+ writer, config_element_context_app_provider_name, ctx->ctx.u.app_ctx.provider_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_context_app_ctx_name,
- ctx->ctx.u.app_ctx.ctx_name);
+ ret = config_writer_write_element_string(
+ writer, config_element_context_app_ctx_name, ctx->ctx.u.app_ctx.ctx_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context_generic(struct config_writer *writer,
- struct ltt_ust_context *ctx)
+static int save_ust_context_generic(struct config_writer *writer, struct ltt_ust_context *ctx)
{
int ret;
const char *context_type_string;
LTTNG_ASSERT(ctx);
/* Save context as event_context_type_type */
- context_type_string = get_ust_context_type_string(
- ctx->ctx.ctx);
+ context_type_string = get_ust_context_type_string(ctx->ctx.ctx);
if (!context_type_string) {
ERR("Unsupported UST context type.");
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_type, context_type_string);
+ ret = config_writer_write_element_string(writer, config_element_type, context_type_string);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_context(struct config_writer *writer,
- struct cds_list_head *ctx_list)
+static int save_ust_context(struct config_writer *writer, struct cds_list_head *ctx_list)
{
int ret;
struct ltt_ust_context *ctx;
goto end;
}
- cds_list_for_each_entry(ctx, ctx_list, list) {
- ret = config_writer_open_element(writer,
- config_element_context);
+ cds_list_for_each_entry (ctx, ctx_list, list) {
+ ret = config_writer_open_element(writer, config_element_context);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_channel(struct config_writer *writer,
- struct ltt_kernel_channel *kchan)
+static int save_kernel_channel(struct config_writer *writer, struct ltt_kernel_channel *kchan)
{
int ret;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_name,
- kchan->channel->name);
+ ret = config_writer_write_element_string(writer, config_element_name, kchan->channel->name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_bool(writer, config_element_enabled,
- kchan->channel->enabled);
+ ret = config_writer_write_element_bool(
+ writer, config_element_enabled, kchan->channel->enabled);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_channel(struct config_writer *writer,
- struct ltt_ust_channel *ust_chan,
- struct ltt_ust_session *session)
+static int save_ust_channel(struct config_writer *writer,
+ struct ltt_ust_channel *ust_chan,
+ struct ltt_ust_session *session)
{
int ret;
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_name,
- ust_chan->name);
+ ret = config_writer_write_element_string(writer, config_element_name, ust_chan->name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_bool(writer, config_element_enabled,
- ust_chan->enabled);
+ ret = config_writer_write_element_bool(writer, config_element_enabled, ust_chan->enabled);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_tracefile_size, ust_chan->tracefile_size);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_size, ust_chan->tracefile_size);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_tracefile_count, ust_chan->tracefile_count);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_count, ust_chan->tracefile_count);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_live_timer_interval,
- session->live_timer_interval);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_live_timer_interval, session->live_timer_interval);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_kernel_session(struct config_writer *writer,
- struct ltt_session *session)
+static int save_kernel_session(struct config_writer *writer, struct ltt_session *session)
{
int ret;
struct ltt_kernel_channel *kchan;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(session);
- ret = config_writer_write_element_string(writer, config_element_type,
- config_domain_type_kernel);
+ ret = config_writer_write_element_string(
+ writer, config_element_type, config_domain_type_kernel);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_buffer_type, config_buffer_type_global);
+ ret = config_writer_write_element_string(
+ writer, config_element_buffer_type, config_buffer_type_global);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = config_writer_open_element(writer,
- config_element_channels);
+ ret = config_writer_open_element(writer, config_element_channels);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- cds_list_for_each_entry(kchan, &session->kernel_session->channel_list.head,
- list) {
+ cds_list_for_each_entry (kchan, &session->kernel_session->channel_list.head, list) {
ret = save_kernel_channel(writer, kchan);
if (ret != LTTNG_OK) {
goto end;
return ret;
}
-static
-const char *get_config_domain_str(enum lttng_domain_type domain)
+static const char *get_config_domain_str(enum lttng_domain_type domain)
{
const char *str_dom;
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
static int save_process_attr_tracker(struct config_writer *writer,
- struct ltt_session *sess,
- int domain,
- enum lttng_process_attr process_attr)
+ struct ltt_session *sess,
+ int domain,
+ enum lttng_process_attr process_attr)
{
int ret = LTTNG_OK;
const char *element_id_tracker, *element_target_id, *element_id;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
{
- tracker = kernel_get_process_attr_tracker(
- sess->kernel_session, process_attr);
+ tracker = kernel_get_process_attr_tracker(sess->kernel_session, process_attr);
LTTNG_ASSERT(tracker);
break;
}
case LTTNG_DOMAIN_UST:
{
- tracker = trace_ust_get_process_attr_tracker(
- sess->ust_session, process_attr);
+ tracker = trace_ust_get_process_attr_tracker(sess->ust_session, process_attr);
LTTNG_ASSERT(tracker);
break;
}
goto end;
}
- ret = config_writer_open_element(
- writer, config_element_process_attr_values);
+ ret = config_writer_open_element(writer, config_element_process_attr_values);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
if (tracking_policy == LTTNG_TRACKING_POLICY_INCLUDE_SET) {
unsigned int i, count;
enum process_attr_tracker_status status =
- process_attr_tracker_get_inclusion_set(
- tracker, &values);
+ process_attr_tracker_get_inclusion_set(tracker, &values);
if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
ret = LTTNG_ERR_NOMEM;
unsigned int integral_value = UINT_MAX;
const char *name = NULL;
const struct process_attr_value *value =
- lttng_process_attr_tracker_values_get_at_index(
- values, i);
+ lttng_process_attr_tracker_values_get_at_index(values, i);
LTTNG_ASSERT(value);
- ret = config_writer_open_element(
- writer, element_target_id);
+ ret = config_writer_open_element(writer, element_target_id);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
switch (value->type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
- integral_value =
- (unsigned int) value->value.pid;
+ integral_value = (unsigned int) value->value.pid;
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
- integral_value =
- (unsigned int) value->value.uid;
+ integral_value = (unsigned int) value->value.uid;
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
- integral_value =
- (unsigned int) value->value.gid;
+ integral_value = (unsigned int) value->value.gid;
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
name = value->value.user_name;
}
if (name) {
- ret = config_writer_write_element_string(writer,
- config_element_name, name);
+ ret = config_writer_write_element_string(
+ writer, config_element_name, name);
} else {
ret = config_writer_write_element_unsigned_int(
- writer, element_id,
- integral_value);
+ writer, element_id, integral_value);
}
if (ret) {
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static int save_process_attr_trackers(struct config_writer *writer,
- struct ltt_session *sess,
- int domain)
+static int
+save_process_attr_trackers(struct config_writer *writer, struct ltt_session *sess, int domain)
{
int ret;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_PROCESS_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_PROCESS_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_USER_ID);
+ ret = save_process_attr_tracker(writer, sess, domain, LTTNG_PROCESS_ATTR_USER_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_GROUP_ID);
+ ret = save_process_attr_tracker(writer, sess, domain, LTTNG_PROCESS_ATTR_GROUP_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
if (ret != LTTNG_OK) {
goto end;
}
break;
case LTTNG_DOMAIN_UST:
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
if (ret != LTTNG_OK) {
goto end;
}
- ret = save_process_attr_tracker(writer, sess, domain,
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ ret = save_process_attr_tracker(
+ writer, sess, domain, LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
if (ret != LTTNG_OK) {
goto end;
}
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_ust_domain(struct config_writer *writer,
- struct ltt_session *session, enum lttng_domain_type domain)
+static int save_ust_domain(struct config_writer *writer,
+ struct ltt_session *session,
+ enum lttng_domain_type domain)
{
int ret;
struct ltt_ust_channel *ust_chan;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(session);
- ret = config_writer_open_element(writer,
- config_element_domain);
+ ret = config_writer_open_element(writer, config_element_domain);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_type, config_domain_name);
+ ret = config_writer_write_element_string(writer, config_element_type, config_domain_name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- buffer_type_string = get_buffer_type_string(
- session->ust_session->buffer_type);
+ buffer_type_string = get_buffer_type_string(session->ust_session->buffer_type);
if (!buffer_type_string) {
ERR("Unsupported buffer type.");
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = config_writer_write_element_string(writer,
- config_element_buffer_type, buffer_type_string);
+ ret = config_writer_write_element_string(
+ writer, config_element_buffer_type, buffer_type_string);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
rcu_read_lock();
- cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
- &iter.iter, node, node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->domain_global.channels->ht, &iter.iter, node, node) {
ust_chan = lttng::utils::container_of(node, <t_ust_channel::node);
if (domain == ust_chan->domain) {
ret = save_ust_channel(writer, ust_chan, session->ust_session);
}
if (domain == LTTNG_DOMAIN_UST) {
- ret = config_writer_open_element(
- writer, config_element_process_attr_trackers);
+ ret = config_writer_open_element(writer, config_element_process_attr_trackers);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = save_process_attr_trackers(
- writer, session, LTTNG_DOMAIN_UST);
+ ret = save_process_attr_trackers(writer, session, LTTNG_DOMAIN_UST);
if (ret != LTTNG_OK) {
goto end;
}
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_domains(struct config_writer *writer, struct ltt_session *session)
+static int save_domains(struct config_writer *writer, struct ltt_session *session)
{
int ret = LTTNG_OK;
}
if (session->kernel_session) {
- ret = config_writer_open_element(writer,
- config_element_domain);
+ ret = config_writer_open_element(writer, config_element_domain);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
- ret = config_writer_open_element(
- writer, config_element_process_attr_trackers);
+ ret = config_writer_open_element(writer, config_element_process_attr_trackers);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- ret = save_process_attr_trackers(
- writer, session, LTTNG_DOMAIN_KERNEL);
+ ret = save_process_attr_trackers(writer, session, LTTNG_DOMAIN_KERNEL);
if (ret != LTTNG_OK) {
goto end;
}
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_consumer_output(struct config_writer *writer,
- struct consumer_output *output)
+static int save_consumer_output(struct config_writer *writer, struct consumer_output *output)
{
int ret;
goto end;
}
- ret = config_writer_write_element_bool(writer, config_element_enabled,
- output->enabled);
+ ret = config_writer_write_element_bool(writer, config_element_enabled, output->enabled);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
switch (output->type) {
case CONSUMER_DST_LOCAL:
- ret = config_writer_write_element_string(writer,
- config_element_path, output->dst.session_root_path);
+ ret = config_writer_write_element_string(
+ writer, config_element_path, output->dst.session_root_path);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end_net_output;
}
- if (output->dst.net.control_isset &&
- output->dst.net.data_isset) {
+ if (output->dst.net.control_isset && output->dst.net.data_isset) {
ret = uri_to_str_url(&output->dst.net.control, uri, PATH_MAX);
if (ret < 0) {
ret = LTTNG_ERR_INVALID;
goto end_net_output;
}
- ret = config_writer_write_element_string(writer,
- config_element_control_uri, uri);
+ ret = config_writer_write_element_string(
+ writer, config_element_control_uri, uri);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end_net_output;
goto end_net_output;
}
- ret = config_writer_write_element_string(writer,
- config_element_data_uri, uri);
+ ret = config_writer_write_element_string(
+ writer, config_element_data_uri, uri);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end_net_output;
}
ret = LTTNG_OK;
-end_net_output:
+ end_net_output:
free(uri);
if (ret != LTTNG_OK) {
goto end;
}
} else {
- ret = !output->dst.net.control_isset ?
- LTTNG_ERR_URL_CTRL_MISS :
- LTTNG_ERR_URL_DATA_MISS;
+ ret = !output->dst.net.control_isset ? LTTNG_ERR_URL_CTRL_MISS :
+ LTTNG_ERR_URL_DATA_MISS;
free(uri);
goto end;
}
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_snapshot_outputs(struct config_writer *writer,
- struct snapshot *snapshot)
+static int save_snapshot_outputs(struct config_writer *writer, struct snapshot *snapshot)
{
int ret;
struct lttng_ht_iter iter;
}
rcu_read_lock();
- cds_lfht_for_each_entry(snapshot->output_ht->ht, &iter.iter, output,
- node.node) {
- ret = config_writer_open_element(writer,
- config_element_output);
+ cds_lfht_for_each_entry (snapshot->output_ht->ht, &iter.iter, output, node.node) {
+ ret = config_writer_open_element(writer, config_element_output);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end_unlock;
}
- ret = config_writer_write_element_string(writer,
- config_element_name, output->name);
+ ret = config_writer_write_element_string(writer, config_element_name, output->name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end_unlock;
}
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_max_size, output->max_size);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_max_size, output->max_size);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end_unlock;
}
/* Return LTTNG_OK on success else a LTTNG_ERR* code. */
-static
-int save_session_output(struct config_writer *writer,
- struct ltt_session *session)
+static int save_session_output(struct config_writer *writer, struct ltt_session *session)
{
int ret;
LTTNG_ASSERT(session);
if ((session->snapshot_mode && session->snapshot.nb_output == 0) ||
- (!session->snapshot_mode && !session->consumer)) {
+ (!session->snapshot_mode && !session->consumer)) {
/* Session is in no output mode */
ret = LTTNG_OK;
goto end;
return ret;
}
-static
-int save_session_rotation_schedule(struct config_writer *writer,
- enum lttng_rotation_schedule_type type, uint64_t value)
+static int save_session_rotation_schedule(struct config_writer *writer,
+ enum lttng_rotation_schedule_type type,
+ uint64_t value)
{
int ret = 0;
const char *element_name;
switch (type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
element_name = config_element_rotation_schedule_periodic;
- value_name = config_element_rotation_schedule_periodic_time_us;
+ value_name = config_element_rotation_schedule_periodic_time_us;
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
element_name = config_element_rotation_schedule_size_threshold;
- value_name = config_element_rotation_schedule_size_threshold_bytes;
+ value_name = config_element_rotation_schedule_size_threshold_bytes;
break;
default:
ret = -1;
goto end;
}
- ret = config_writer_write_element_unsigned_int(writer,
- value_name, value);
+ ret = config_writer_write_element_unsigned_int(writer, value_name, value);
if (ret) {
goto end;
}
return ret;
}
-static
-int save_session_rotation_schedules(struct config_writer *writer,
- struct ltt_session *session)
+static int save_session_rotation_schedules(struct config_writer *writer,
+ struct ltt_session *session)
{
int ret;
- ret = config_writer_open_element(writer,
- config_element_rotation_schedules);
+ ret = config_writer_open_element(writer, config_element_rotation_schedules);
if (ret) {
goto end;
}
if (session->rotate_timer_period) {
ret = save_session_rotation_schedule(writer,
- LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
- session->rotate_timer_period);
+ LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
+ session->rotate_timer_period);
if (ret) {
goto close_schedules;
}
}
if (session->rotate_size) {
- ret = save_session_rotation_schedule(writer,
- LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD,
- session->rotate_size);
+ ret = save_session_rotation_schedule(
+ writer, LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD, session->rotate_size);
if (ret) {
goto close_schedules;
}
*
* Return LTTNG_OK on success else a LTTNG_ERR* code.
*/
-static
-int save_session(struct ltt_session *session,
- struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
+static int save_session(struct ltt_session *session,
+ struct lttng_save_session_attr *attr,
+ lttng_sock_cred *creds)
{
int ret, fd = -1;
char config_file_path[LTTNG_PATH_MAX];
session_name_len = strlen(session->name);
memset(config_file_path, 0, sizeof(config_file_path));
- if (!session_access_ok(session,
- LTTNG_SOCK_GET_UID_CRED(creds)) || session->destroyed) {
+ if (!session_access_ok(session, LTTNG_SOCK_GET_UID_CRED(creds)) || session->destroyed) {
ret = LTTNG_ERR_EPERM;
goto end;
}
strncpy(config_file_path, provided_path, sizeof(config_file_path));
} else {
ssize_t ret_len;
- char *home_dir = utils_get_user_home_dir(
- LTTNG_SOCK_GET_UID_CRED(creds));
+ char *home_dir = utils_get_user_home_dir(LTTNG_SOCK_GET_UID_CRED(creds));
if (!home_dir) {
ret = LTTNG_ERR_SET_URL;
goto end;
}
- ret_len = snprintf(config_file_path, sizeof(config_file_path),
- DEFAULT_SESSION_HOME_CONFIGPATH, home_dir);
+ ret_len = snprintf(config_file_path,
+ sizeof(config_file_path),
+ DEFAULT_SESSION_HOME_CONFIGPATH,
+ home_dir);
free(home_dir);
if (ret_len < 0) {
PERROR("snprintf save session");
* Check the path fits in the config file path dst including the '/'
* followed by trailing .lttng extension and the NULL terminated string.
*/
- if ((len + session_name_len + 2 +
- sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION))
- > sizeof(config_file_path)) {
+ if ((len + session_name_len + 2 + sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION)) >
+ sizeof(config_file_path)) {
ret = LTTNG_ERR_SET_URL;
goto end;
}
- ret = run_as_mkdir_recursive(config_file_path, S_IRWXU | S_IRWXG,
- LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
+ ret = run_as_mkdir_recursive(config_file_path,
+ S_IRWXU | S_IRWXG,
+ LTTNG_SOCK_GET_UID_CRED(creds),
+ LTTNG_SOCK_GET_GID_CRED(creds));
if (ret) {
ret = LTTNG_ERR_SET_URL;
goto end;
file_open_flags |= O_EXCL;
}
- fd = run_as_open(config_file_path, file_open_flags,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
- LTTNG_SOCK_GET_UID_CRED(creds), LTTNG_SOCK_GET_GID_CRED(creds));
+ fd = run_as_open(config_file_path,
+ file_open_flags,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
+ LTTNG_SOCK_GET_UID_CRED(creds),
+ LTTNG_SOCK_GET_GID_CRED(creds));
if (fd < 0) {
PERROR("Could not create configuration file");
switch (errno) {
goto end;
}
- ret = config_writer_write_element_string(writer, config_element_name,
- session->name);
+ ret = config_writer_write_element_string(writer, config_element_name, session->name);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
if (session->shm_path[0] != '\0') {
- ret = config_writer_write_element_string(writer,
- config_element_shared_memory_path,
- session->shm_path);
+ ret = config_writer_write_element_string(
+ writer, config_element_shared_memory_path, session->shm_path);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
goto end;
}
- ret = config_writer_write_element_bool(writer, config_element_started,
- session->active);
+ ret = config_writer_write_element_bool(writer, config_element_started, session->active);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
- if (session->snapshot_mode || session->live_timer ||
- session->rotate_timer_period || session->rotate_size) {
+ if (session->snapshot_mode || session->live_timer || session->rotate_timer_period ||
+ session->rotate_size) {
ret = config_writer_open_element(writer, config_element_attributes);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
}
if (session->snapshot_mode) {
- ret = config_writer_write_element_bool(writer,
- config_element_snapshot_mode, 1);
+ ret = config_writer_write_element_bool(
+ writer, config_element_snapshot_mode, 1);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
} else if (session->live_timer) {
- ret = config_writer_write_element_unsigned_int(writer,
- config_element_live_timer_interval, session->live_timer);
+ ret = config_writer_write_element_unsigned_int(
+ writer, config_element_live_timer_interval, session->live_timer);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
}
if (session->rotate_timer_period || session->rotate_size) {
- ret = save_session_rotation_schedules(writer,
- session);
+ ret = save_session_rotation_schedules(writer, session);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
return ret;
}
-int cmd_save_sessions(struct lttng_save_session_attr *attr,
- lttng_sock_cred *creds)
+int cmd_save_sessions(struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
{
int ret;
const char *session_name;
} else {
struct ltt_session_list *list = session_get_list();
- cds_list_for_each_entry(session, &list->head, list) {
+ cds_list_for_each_entry (session, &list->head, list) {
if (!session_get(session)) {
continue;
}
*/
#define _LGPL_SOURCE
+#include "cmd.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "session.hpp"
+#include "timer.hpp"
+#include "trace-ust.hpp"
+#include "utils.hpp"
+
+#include <common/common.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/urcu.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/location-internal.hpp>
+
#include <dirent.h>
#include <inttypes.h>
#include <limits.h>
#include <sys/types.h>
#include <urcu.h>
-#include <common/common.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/trace-chunk.hpp>
-#include <common/urcu.hpp>
-#include <common/utils.hpp>
-
-#include "lttng-sessiond.hpp"
-#include <lttng/location-internal.hpp>
-
-#include "cmd.hpp"
-#include "kernel.hpp"
-#include "session.hpp"
-#include "timer.hpp"
-#include "trace-ust.hpp"
-#include "utils.hpp"
-
namespace {
struct ltt_session_destroy_notifier_element {
ltt_session_destroy_notifier notifier;
{
pthread_mutex_lock(&the_session_list.lock);
while (!cds_list_empty(&the_session_list.head)) {
- pthread_cond_wait(&the_session_list.removal_cond,
- &the_session_list.lock);
+ pthread_cond_wait(&the_session_list.removal_cond, &the_session_list.lock);
}
pthread_mutex_unlock(&the_session_list.lock);
}
*
* The caller must hold the session lock.
*/
-enum consumer_dst_type session_get_consumer_destination_type(
- const struct ltt_session *session)
+enum consumer_dst_type session_get_consumer_destination_type(const struct ltt_session *session)
{
/*
* The output information is duplicated in both of those session types.
* Hence, it doesn't matter from which it is retrieved. However, it is
* possible for only one of them to be set.
*/
- return session->kernel_session ?
- session->kernel_session->consumer->type :
- session->ust_session->consumer->type;
+ return session->kernel_session ? session->kernel_session->consumer->type :
+ session->ust_session->consumer->type;
}
/*
const char *hostname = NULL;
const struct consumer_output *output;
- output = session->kernel_session ?
- session->kernel_session->consumer :
- session->ust_session->consumer;
+ output = session->kernel_session ? session->kernel_session->consumer :
+ session->ust_session->consumer;
/*
* hostname is assumed to be the same for both control and data
* The caller must hold the session lock.
*/
void session_get_net_consumer_ports(const struct ltt_session *session,
- uint16_t *control_port, uint16_t *data_port)
+ uint16_t *control_port,
+ uint16_t *data_port)
{
const struct consumer_output *output;
- output = session->kernel_session ?
- session->kernel_session->consumer :
- session->ust_session->consumer;
+ output = session->kernel_session ? session->kernel_session->consumer :
+ session->ust_session->consumer;
*control_port = output->dst.net.control.port;
*data_port = output->dst.net.data.port;
}
*
* The caller must hold the session lock.
*/
-struct lttng_trace_archive_location *session_get_trace_archive_location(
- const struct ltt_session *session)
+struct lttng_trace_archive_location *
+session_get_trace_archive_location(const struct ltt_session *session)
{
int ret;
struct lttng_trace_archive_location *location = NULL;
char *chunk_path = NULL;
if (session->rotation_state != LTTNG_ROTATION_STATE_COMPLETED ||
- !session->last_archived_chunk_name) {
+ !session->last_archived_chunk_name) {
goto end;
}
switch (session_get_consumer_destination_type(session)) {
case CONSUMER_DST_LOCAL:
ret = asprintf(&chunk_path,
- "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
- session_get_base_path(session),
- session->last_archived_chunk_name);
+ "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
+ session_get_base_path(session),
+ session->last_archived_chunk_name);
if (ret == -1) {
goto end;
}
- location = lttng_trace_archive_location_local_create(
- chunk_path);
+ location = lttng_trace_archive_location_local_create(chunk_path);
break;
case CONSUMER_DST_NET:
{
uint16_t control_port, data_port;
hostname = session_get_net_consumer_hostname(session);
- session_get_net_consumer_ports(session,
- &control_port,
- &data_port);
+ session_get_net_consumer_ports(session, &control_port, &data_port);
location = lttng_trace_archive_location_relay_create(
- hostname,
- LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP,
- control_port, data_port, session->last_chunk_path);
+ hostname,
+ LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP,
+ control_port,
+ data_port,
+ session->last_chunk_path);
break;
}
default:
pthread_mutex_unlock(&session->lock);
}
-static
-int _session_set_trace_chunk_no_lock_check(struct ltt_session *session,
- struct lttng_trace_chunk *new_trace_chunk,
- struct lttng_trace_chunk **_current_trace_chunk)
+static int _session_set_trace_chunk_no_lock_check(struct ltt_session *session,
+ struct lttng_trace_chunk *new_trace_chunk,
+ struct lttng_trace_chunk **_current_trace_chunk)
{
int ret = 0;
unsigned int i, refs_to_acquire = 0, refs_acquired = 0, refs_to_release = 0;
current_trace_chunk = session->current_trace_chunk;
session->current_trace_chunk = NULL;
if (session->ust_session) {
- lttng_trace_chunk_put(
- session->ust_session->current_trace_chunk);
+ lttng_trace_chunk_put(session->ust_session->current_trace_chunk);
session->ust_session->current_trace_chunk = NULL;
}
if (session->kernel_session) {
- lttng_trace_chunk_put(
- session->kernel_session->current_trace_chunk);
+ lttng_trace_chunk_put(session->kernel_session->current_trace_chunk);
session->kernel_session->current_trace_chunk = NULL;
}
if (!new_trace_chunk) {
refs_to_acquire += !!session->ust_session;
refs_to_acquire += !!session->kernel_session;
- for (refs_acquired = 0; refs_acquired < refs_to_acquire;
- refs_acquired++) {
+ for (refs_acquired = 0; refs_acquired < refs_to_acquire; refs_acquired++) {
if (!lttng_trace_chunk_get(new_trace_chunk)) {
ERR("Failed to acquire reference to new trace chunk of session \"%s\"",
- session->name);
+ session->name);
goto error;
}
}
if (session->ust_session) {
- const uint64_t relayd_id =
- session->ust_session->consumer->net_seq_index;
- const bool is_local_trace =
- session->ust_session->consumer->type ==
- CONSUMER_DST_LOCAL;
+ const uint64_t relayd_id = session->ust_session->consumer->net_seq_index;
+ const bool is_local_trace = session->ust_session->consumer->type ==
+ CONSUMER_DST_LOCAL;
session->ust_session->current_trace_chunk = new_trace_chunk;
if (is_local_trace) {
enum lttng_error_code ret_error_code;
- ret_error_code = ust_app_create_channel_subdirectories(
- session->ust_session);
+ ret_error_code =
+ ust_app_create_channel_subdirectories(session->ust_session);
if (ret_error_code != LTTNG_OK) {
goto error;
}
}
- cds_lfht_for_each_entry(
- session->ust_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->consumer->socks->ht, &iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = consumer_create_trace_chunk(socket,
- relayd_id,
- session->id, new_trace_chunk,
- DEFAULT_UST_TRACE_DIR);
+ relayd_id,
+ session->id,
+ new_trace_chunk,
+ DEFAULT_UST_TRACE_DIR);
pthread_mutex_unlock(socket->lock);
if (ret) {
goto error;
}
}
if (session->kernel_session) {
- const uint64_t relayd_id =
- session->kernel_session->consumer->net_seq_index;
- const bool is_local_trace =
- session->kernel_session->consumer->type ==
- CONSUMER_DST_LOCAL;
+ const uint64_t relayd_id = session->kernel_session->consumer->net_seq_index;
+ const bool is_local_trace = session->kernel_session->consumer->type ==
+ CONSUMER_DST_LOCAL;
session->kernel_session->current_trace_chunk = new_trace_chunk;
if (is_local_trace) {
enum lttng_error_code ret_error_code;
- ret_error_code = kernel_create_channel_subdirectories(
- session->kernel_session);
+ ret_error_code =
+ kernel_create_channel_subdirectories(session->kernel_session);
if (ret_error_code != LTTNG_OK) {
goto error;
}
}
- cds_lfht_for_each_entry(
- session->kernel_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->kernel_session->consumer->socks->ht, &iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = consumer_create_trace_chunk(socket,
- relayd_id,
- session->id, new_trace_chunk,
- DEFAULT_KERNEL_TRACE_DIR);
+ relayd_id,
+ session->id,
+ new_trace_chunk,
+ DEFAULT_KERNEL_TRACE_DIR);
pthread_mutex_unlock(socket->lock);
if (ret) {
goto error;
goto end_no_move;
}
-struct lttng_trace_chunk *session_create_new_trace_chunk(
- const struct ltt_session *session,
- const struct consumer_output *consumer_output_override,
- const char *session_base_path_override,
- const char *chunk_name_override)
+struct lttng_trace_chunk *
+session_create_new_trace_chunk(const struct ltt_session *session,
+ const struct consumer_output *consumer_output_override,
+ const char *session_base_path_override,
+ const char *chunk_name_override)
{
int ret;
struct lttng_trace_chunk *trace_chunk = NULL;
output = consumer_output_override;
} else {
LTTNG_ASSERT(session->ust_session || session->kernel_session);
- output = session->ust_session ?
- session->ust_session->consumer :
- session->kernel_session->consumer;
+ output = session->ust_session ? session->ust_session->consumer :
+ session->kernel_session->consumer;
}
is_local_trace = output->type == CONSUMER_DST_LOCAL;
- base_path = session_base_path_override ? :
- consumer_output_get_base_path(output);
+ base_path = session_base_path_override ?: consumer_output_get_base_path(output);
if (chunk_creation_ts == (time_t) -1) {
PERROR("Failed to sample time while creation session \"%s\" trace chunk",
- session->name);
+ session->name);
goto error;
}
- next_chunk_id = session->most_recent_chunk_id.is_set ?
- session->most_recent_chunk_id.value + 1 : 0;
+ next_chunk_id =
+ session->most_recent_chunk_id.is_set ? session->most_recent_chunk_id.value + 1 : 0;
if (session->current_trace_chunk &&
- !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
+ !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
chunk_status = lttng_trace_chunk_rename_path(session->current_trace_chunk,
- DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
+ DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
new_path = DEFAULT_CHUNK_TMP_NEW_DIRECTORY;
}
- trace_chunk = lttng_trace_chunk_create(next_chunk_id,
- chunk_creation_ts, new_path);
+ trace_chunk = lttng_trace_chunk_create(next_chunk_id, chunk_creation_ts, new_path);
if (!trace_chunk) {
goto error;
}
if (chunk_name_override) {
- chunk_status = lttng_trace_chunk_override_name(trace_chunk,
- chunk_name_override);
+ chunk_status = lttng_trace_chunk_override_name(trace_chunk, chunk_name_override);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
goto end;
}
- chunk_status = lttng_trace_chunk_set_credentials(trace_chunk,
- &session_credentials);
+ chunk_status = lttng_trace_chunk_set_credentials(trace_chunk, &session_credentials);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
- DBG("Creating base output directory of session \"%s\" at %s",
- session->name, base_path);
- ret = utils_mkdir_recursive(base_path, S_IRWXU | S_IRWXG,
- session->uid, session->gid);
+ DBG("Creating base output directory of session \"%s\" at %s", session->name, base_path);
+ ret = utils_mkdir_recursive(base_path, S_IRWXU | S_IRWXG, session->uid, session->gid);
if (ret) {
goto error;
}
if (!session_output_directory) {
goto error;
}
- chunk_status = lttng_trace_chunk_set_as_owner(trace_chunk,
- session_output_directory);
+ chunk_status = lttng_trace_chunk_set_as_owner(trace_chunk, session_output_directory);
lttng_directory_handle_put(session_output_directory);
session_output_directory = NULL;
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
}
int session_close_trace_chunk(struct ltt_session *session,
- struct lttng_trace_chunk *trace_chunk,
- enum lttng_trace_chunk_command_type close_command,
- char *closed_trace_chunk_path)
+ struct lttng_trace_chunk *trace_chunk,
+ enum lttng_trace_chunk_command_type close_command,
+ char *closed_trace_chunk_path)
{
int ret = 0;
bool error_occurred = false;
const time_t chunk_close_timestamp = time(NULL);
const char *new_path;
- chunk_status = lttng_trace_chunk_set_close_command(
- trace_chunk, close_command);
+ chunk_status = lttng_trace_chunk_set_close_command(trace_chunk, close_command);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
if (chunk_close_timestamp == (time_t) -1) {
ERR("Failed to sample the close timestamp of the current trace chunk of session \"%s\"",
- session->name);
+ session->name);
ret = -1;
goto end;
}
new_path = NULL;
}
if (session->current_trace_chunk &&
- !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
+ !lttng_trace_chunk_get_name_overridden(session->current_trace_chunk)) {
/* Rename new chunk path. */
- chunk_status = lttng_trace_chunk_rename_path(session->current_trace_chunk,
- new_path);
+ chunk_status =
+ lttng_trace_chunk_rename_path(session->current_trace_chunk, new_path);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
}
}
if (!lttng_trace_chunk_get_name_overridden(trace_chunk) &&
- close_command == LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION) {
+ close_command == LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION) {
const char *old_path;
if (!session->rotated) {
old_path = NULL;
}
/* We need to move back the .tmp_old_chunk to its rightful place. */
- chunk_status = lttng_trace_chunk_rename_path(trace_chunk,
- old_path);
+ chunk_status = lttng_trace_chunk_rename_path(trace_chunk, old_path);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
if (close_command == LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED) {
session->rotated = true;
}
- chunk_status = lttng_trace_chunk_set_close_timestamp(trace_chunk,
- chunk_close_timestamp);
+ chunk_status = lttng_trace_chunk_set_close_timestamp(trace_chunk, chunk_close_timestamp);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to set the close timestamp of the current trace chunk of session \"%s\"",
- session->name);
+ session->name);
ret = -1;
goto end;
}
if (session->ust_session) {
- const uint64_t relayd_id =
- session->ust_session->consumer->net_seq_index;
+ const uint64_t relayd_id = session->ust_session->consumer->net_seq_index;
- cds_lfht_for_each_entry(
- session->ust_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->ust_session->consumer->socks->ht, &iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = consumer_close_trace_chunk(socket,
- relayd_id,
- session->id,
- trace_chunk, closed_trace_chunk_path);
+ relayd_id,
+ session->id,
+ trace_chunk,
+ closed_trace_chunk_path);
pthread_mutex_unlock(socket->lock);
if (ret) {
ERR("Failed to close trace chunk on user space consumer");
}
}
if (session->kernel_session) {
- const uint64_t relayd_id =
- session->kernel_session->consumer->net_seq_index;
+ const uint64_t relayd_id = session->kernel_session->consumer->net_seq_index;
- cds_lfht_for_each_entry(
- session->kernel_session->consumer->socks->ht,
- &iter, socket, node.node) {
+ cds_lfht_for_each_entry (
+ session->kernel_session->consumer->socks->ht, &iter, socket, node.node) {
pthread_mutex_lock(socket->lock);
ret = consumer_close_trace_chunk(socket,
- relayd_id,
- session->id,
- trace_chunk, closed_trace_chunk_path);
+ relayd_id,
+ session->id,
+ trace_chunk,
+ closed_trace_chunk_path);
pthread_mutex_unlock(socket->lock);
if (ret) {
ERR("Failed to close trace chunk on kernel consumer");
* daemon as the same "offset" in a metadata stream will no longer point
* to the same content.
*/
-static
-enum lttng_error_code session_kernel_open_packets(struct ltt_session *session)
+static enum lttng_error_code session_kernel_open_packets(struct ltt_session *session)
{
enum lttng_error_code ret = LTTNG_OK;
struct consumer_socket *socket;
node = cds_lfht_iter_get_node(&iter.iter);
socket = caa_container_of(node, typeof(*socket), node.node);
- cds_list_for_each_entry(chan,
- &session->kernel_session->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &session->kernel_session->channel_list.head, list) {
int open_ret;
DBG("Open packet of kernel channel: channel key = %" PRIu64
- ", session name = %s, session_id = %" PRIu64,
- chan->key, session->name, session->id);
+ ", session name = %s, session_id = %" PRIu64,
+ chan->key,
+ session->name,
+ session->id);
open_ret = consumer_open_channel_packets(socket, chan->key);
if (open_ret < 0) {
enum lttng_error_code ret = LTTNG_OK;
DBG("Opening packets of session channels: session name = %s, session id = %" PRIu64,
- session->name, session->id);
+ session->name,
+ session->id);
if (session->ust_session) {
ret = ust_app_open_packets(session);
* Must be called with the session lock held.
*/
int session_set_trace_chunk(struct ltt_session *session,
- struct lttng_trace_chunk *new_trace_chunk,
- struct lttng_trace_chunk **current_trace_chunk)
+ struct lttng_trace_chunk *new_trace_chunk,
+ struct lttng_trace_chunk **current_trace_chunk)
{
ASSERT_LOCKED(session->lock);
- return _session_set_trace_chunk_no_lock_check(session, new_trace_chunk,
- current_trace_chunk);
+ return _session_set_trace_chunk_no_lock_check(
+ session, new_trace_chunk, current_trace_chunk);
}
-static
-void session_notify_destruction(const struct ltt_session *session)
+static void session_notify_destruction(const struct ltt_session *session)
{
size_t i;
- const size_t count = lttng_dynamic_array_get_count(
- &session->destroy_notifiers);
+ const size_t count = lttng_dynamic_array_get_count(&session->destroy_notifiers);
for (i = 0; i < count; i++) {
const struct ltt_session_destroy_notifier_element *element =
(ltt_session_destroy_notifier_element *) lttng_dynamic_array_get_element(
- &session->destroy_notifiers, i);
+ &session->destroy_notifiers, i);
element->notifier(session, element->user_data);
}
void session_notify_clear(struct ltt_session *session)
{
size_t i;
- const size_t count = lttng_dynamic_array_get_count(
- &session->clear_notifiers);
+ const size_t count = lttng_dynamic_array_get_count(&session->clear_notifiers);
for (i = 0; i < count; i++) {
const struct ltt_session_clear_notifier_element *element =
(ltt_session_clear_notifier_element *) lttng_dynamic_array_get_element(
- &session->clear_notifiers, i);
+ &session->clear_notifiers, i);
element->notifier(session, element->user_data);
}
lttng_dynamic_array_clear(&session->clear_notifiers);
}
-static
-void session_release(struct urcu_ref *ref)
+static void session_release(struct urcu_ref *ref)
{
int ret;
struct ltt_ust_session *usess;
}
int session_add_destroy_notifier(struct ltt_session *session,
- ltt_session_destroy_notifier notifier, void *user_data)
+ ltt_session_destroy_notifier notifier,
+ void *user_data)
{
- const struct ltt_session_destroy_notifier_element element = {
- .notifier = notifier,
- .user_data = user_data
- };
+ const struct ltt_session_destroy_notifier_element element = { .notifier = notifier,
+ .user_data = user_data };
- return lttng_dynamic_array_add_element(&session->destroy_notifiers,
- &element);
+ return lttng_dynamic_array_add_element(&session->destroy_notifiers, &element);
}
int session_add_clear_notifier(struct ltt_session *session,
- ltt_session_clear_notifier notifier, void *user_data)
+ ltt_session_clear_notifier notifier,
+ void *user_data)
{
- const struct ltt_session_clear_notifier_element element = {
- .notifier = notifier,
- .user_data = user_data
- };
+ const struct ltt_session_clear_notifier_element element = { .notifier = notifier,
+ .user_data = user_data };
- return lttng_dynamic_array_add_element(&session->clear_notifiers,
- &element);
+ return lttng_dynamic_array_add_element(&session->clear_notifiers, &element);
}
/*
DBG2("Trying to find session by name %s", name);
- cds_list_for_each_entry(iter, &the_session_list.head, list) {
- if (!strncmp(iter->name, name, NAME_MAX) &&
- !iter->destroyed) {
+ cds_list_for_each_entry (iter, &the_session_list.head, list) {
+ if (!strncmp(iter->name, name, NAME_MAX) && !iter->destroyed) {
goto found;
}
}
* Create a new session and add it to the session list.
* Session list lock must be held by the caller.
*/
-enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid,
- struct ltt_session **out_session)
+enum lttng_error_code
+session_create(const char *name, uid_t uid, gid_t gid, struct ltt_session **out_session)
{
int ret;
enum lttng_error_code ret_code;
}
lttng_dynamic_array_init(&new_session->destroy_notifiers,
- sizeof(struct ltt_session_destroy_notifier_element),
- NULL);
+ sizeof(struct ltt_session_destroy_notifier_element),
+ NULL);
lttng_dynamic_array_init(&new_session->clear_notifiers,
- sizeof(struct ltt_session_clear_notifier_element),
- NULL);
+ sizeof(struct ltt_session_clear_notifier_element),
+ NULL);
urcu_ref_init(&new_session->ref);
pthread_mutex_init(&new_session->lock, NULL);
if (i == 0) {
ret = snprintf(new_session->name,
- sizeof(new_session->name),
- "%s-%s",
- DEFAULT_SESSION_NAME,
- datetime);
+ sizeof(new_session->name),
+ "%s-%s",
+ DEFAULT_SESSION_NAME,
+ datetime);
} else {
ret = snprintf(new_session->name,
- sizeof(new_session->name),
- "%s%d-%s",
- DEFAULT_SESSION_NAME, i,
- datetime);
+ sizeof(new_session->name),
+ "%s%d-%s",
+ DEFAULT_SESSION_NAME,
+ i,
+ datetime);
}
new_session->name_contains_creation_time = true;
if (ret == -1 || ret >= sizeof(new_session->name)) {
goto error;
}
- clashing_session =
- session_find_by_name(new_session->name);
+ clashing_session = session_find_by_name(new_session->name);
session_put(clashing_session);
if (!clashing_session) {
found_name = true;
if (errno == ENAMETOOLONG) {
new_session->hostname[sizeof(new_session->hostname) - 1] = '\0';
ERR("Hostname exceeds the maximal permitted length and has been truncated to %s",
- new_session->hostname);
+ new_session->hostname);
} else {
ret_code = LTTNG_ERR_SESSION_FAIL;
goto error;
* set it up and, if valid, assign it to the session.
*/
DBG("Tracing session %s created with ID %" PRIu64 " by uid = %d, gid = %d",
- new_session->name, new_session->id, new_session->uid,
- new_session->gid);
+ new_session->name,
+ new_session->id,
+ new_session->uid,
+ new_session->gid);
ret_code = LTTNG_OK;
end:
if (new_session) {
*
* Must be called with the session and session_list locks held.
*/
-int session_reset_rotation_state(struct ltt_session *session,
- enum lttng_rotation_state result)
+int session_reset_rotation_state(struct ltt_session *session, enum lttng_rotation_state result)
{
int ret = 0;
uint64_t chunk_id;
enum lttng_trace_chunk_status chunk_status;
- chunk_status = lttng_trace_chunk_get_id(
- session->chunk_being_archived,
- &chunk_id);
+ chunk_status = lttng_trace_chunk_get_id(session->chunk_being_archived, &chunk_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
- LTTNG_OPTIONAL_SET(&session->last_archived_chunk_id,
- chunk_id);
+ LTTNG_OPTIONAL_SET(&session->last_archived_chunk_id, chunk_id);
lttng_trace_chunk_put(session->chunk_being_archived);
session->chunk_being_archived = NULL;
/*
return nullptr;
}
- return {session, session_put};
+ return { session, session_put };
}
*
*/
-#include "version.hpp"
-#include "sessiond-config.hpp"
#include "lttng-ust-ctl.hpp"
+#include "sessiond-config.hpp"
+#include "version.hpp"
+
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
#include <common/defaults.hpp>
-#include <limits.h>
-#include <ctype.h>
#include <common/error.hpp>
-#include <common/utils.hpp>
#include <common/path.hpp>
-#include <common/compat/errno.hpp>
-#include <common/compat/getenv.hpp>
+#include <common/utils.hpp>
-static
-struct sessiond_config sessiond_config_build_defaults = {
- .verbose = 0,
- .verbose_consumer = 0,
- .agent_tcp_port = { .begin = DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN, .end = DEFAULT_AGENT_TCP_PORT_RANGE_END },
+#include <ctype.h>
+#include <limits.h>
- .event_notifier_buffer_size_kernel = DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
- .event_notifier_buffer_size_userspace = DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
- .app_socket_timeout = DEFAULT_APP_SOCKET_RW_TIMEOUT,
+static struct sessiond_config sessiond_config_build_defaults = {
+ .verbose = 0,
+ .verbose_consumer = 0,
+ .agent_tcp_port = { .begin = DEFAULT_AGENT_TCP_PORT_RANGE_BEGIN,
+ .end = DEFAULT_AGENT_TCP_PORT_RANGE_END },
- .quiet = false,
+ .event_notifier_buffer_size_kernel = DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
+ .event_notifier_buffer_size_userspace = DEFAULT_EVENT_NOTIFIER_ERROR_COUNT_MAP_SIZE,
+ .app_socket_timeout = DEFAULT_APP_SOCKET_RW_TIMEOUT,
+ .quiet = false,
- .no_kernel = false,
- .background = false,
- .daemonize = false,
- .sig_parent = false,
+ .no_kernel = false,
+ .background = false,
+ .daemonize = false,
+ .sig_parent = false,
.tracing_group_name = { (char *) DEFAULT_TRACING_GROUP, false },
.kconsumerd_cmd_unix_sock_path = { nullptr, false },
};
-static
-void config_string_fini(struct config_string *str)
+static void config_string_fini(struct config_string *str)
{
config_string_set(str, NULL);
}
-static
-void config_string_set_static(struct config_string *config_str,
- const char *value)
+static void config_string_set_static(struct config_string *config_str, const char *value)
{
config_string_set(config_str, (char *) value);
config_str->should_free = false;
errno = 0;
int_val = strtoul(env_value, &endptr, 0);
- if (errno != 0 || int_val > INT_MAX ||
- (int_val < 0 && int_val != -1)) {
+ if (errno != 0 || int_val > INT_MAX || (int_val < 0 && int_val != -1)) {
ERR("Invalid value \"%s\" used for \"%s\" environment variable",
- env_value, DEFAULT_APP_SOCKET_TIMEOUT_ENV);
+ env_value,
+ DEFAULT_APP_SOCKET_TIMEOUT_ENV);
ret = -1;
goto end;
}
env_value = lttng_secure_getenv("LTTNG_CONSUMERD32_BIN");
if (env_value) {
- config_string_set_static(&config->consumerd32_bin_path,
- env_value);
+ config_string_set_static(&config->consumerd32_bin_path, env_value);
}
env_value = lttng_secure_getenv("LTTNG_CONSUMERD64_BIN");
if (env_value) {
- config_string_set_static(&config->consumerd64_bin_path,
- env_value);
+ config_string_set_static(&config->consumerd64_bin_path, env_value);
}
env_value = lttng_secure_getenv("LTTNG_CONSUMERD32_LIBDIR");
if (env_value) {
- config_string_set_static(&config->consumerd32_lib_dir,
- env_value);
+ config_string_set_static(&config->consumerd32_lib_dir, env_value);
}
env_value = lttng_secure_getenv("LTTNG_CONSUMERD64_LIBDIR");
if (env_value) {
- config_string_set_static(&config->consumerd64_lib_dir,
- env_value);
+ config_string_set_static(&config->consumerd64_lib_dir, env_value);
}
env_value = lttng_secure_getenv("LTTNG_UST_CLOCK_PLUGIN");
if (env_value) {
- config_string_set_static(&config->lttng_ust_clock_plugin,
- env_value);
+ config_string_set_static(&config->lttng_ust_clock_plugin, env_value);
}
env_value = lttng_secure_getenv(DEFAULT_LTTNG_KMOD_PROBES);
if (env_value) {
- config_string_set_static(&config->kmod_probes_list,
- env_value);
+ config_string_set_static(&config->kmod_probes_list, env_value);
}
env_value = lttng_secure_getenv(DEFAULT_LTTNG_EXTRA_KMOD_PROBES);
if (env_value) {
- config_string_set_static(&config->kmod_extra_probes_list,
- env_value);
+ config_string_set_static(&config->kmod_extra_probes_list, env_value);
}
end:
return ret;
}
-static
-int config_set_paths_root(struct sessiond_config *config)
+static int config_set_paths_root(struct sessiond_config *config)
{
int ret = 0;
goto end;
}
- config_string_set_static(&config->apps_unix_sock_path,
- DEFAULT_GLOBAL_APPS_UNIX_SOCK);
- config_string_set_static(&config->client_unix_sock_path,
- DEFAULT_GLOBAL_CLIENT_UNIX_SOCK);
- config_string_set_static(&config->wait_shm_path,
- DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH);
- config_string_set_static(&config->health_unix_sock_path,
- DEFAULT_GLOBAL_HEALTH_UNIX_SOCK);
+ config_string_set_static(&config->apps_unix_sock_path, DEFAULT_GLOBAL_APPS_UNIX_SOCK);
+ config_string_set_static(&config->client_unix_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK);
+ config_string_set_static(&config->wait_shm_path, DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH);
+ config_string_set_static(&config->health_unix_sock_path, DEFAULT_GLOBAL_HEALTH_UNIX_SOCK);
end:
return ret;
}
-static
-int config_set_paths_non_root(struct sessiond_config *config)
+static int config_set_paths_non_root(struct sessiond_config *config)
{
int ret = 0;
const char *home_path = utils_get_home_dir();
}
/* 32 bits consumerd path setup */
- ret = asprintf(&str, DEFAULT_USTCONSUMERD32_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD32_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 32-bit consumer path");
goto error;
config_string_set(&config->consumerd32_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 32-bit consumer error socket path");
goto error;
config_string_set(&config->consumerd32_err_unix_sock_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 32-bit consumer command socket path");
goto error;
str = NULL;
/* 64 bits consumerd path setup */
- ret = asprintf(&str, DEFAULT_USTCONSUMERD64_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD64_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 64-bit consumer path");
goto error;
config_string_set(&config->consumerd64_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 64-bit consumer error socket path");
goto error;
config_string_set(&config->consumerd64_err_unix_sock_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set 64-bit consumer command socket path");
goto error;
str = NULL;
/* kconsumerd consumerd path setup */
- ret = asprintf(&str, DEFAULT_KCONSUMERD_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_KCONSUMERD_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set kernel consumer path");
goto error;
config_string_set(&config->kconsumerd_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_KCONSUMERD_ERR_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set kernel consumer error socket path");
goto error;
config_string_set(&config->kconsumerd_err_unix_sock_path, str);
str = NULL;
- ret = asprintf(&str, DEFAULT_KCONSUMERD_CMD_SOCK_PATH,
- config->rundir.value);
+ ret = asprintf(&str, DEFAULT_KCONSUMERD_CMD_SOCK_PATH, config->rundir.value);
if (ret < 0) {
ERR("Failed to set kernel consumer command socket path");
goto error;
config_string_set(&config->kconsumerd_cmd_unix_sock_path, str);
str = NULL;
- ret = asprintf(&str, "%s/%s", config->rundir.value,
- DEFAULT_LTTNG_SESSIOND_PIDFILE);
+ ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_PIDFILE);
if (ret < 0) {
ERR("Failed to set PID file path");
goto error;
config_string_set(&config->pid_file_path, str);
str = NULL;
- ret = asprintf(&str, "%s/%s", config->rundir.value,
- DEFAULT_LTTNG_SESSIOND_LOCKFILE);
+ ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_LOCKFILE);
if (ret < 0) {
ERR("Failed to set lock file path");
goto error;
config_string_set(&config->lock_file_path, str);
str = NULL;
- ret = asprintf(&str, "%s/%s", config->rundir.value,
- DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
+ ret = asprintf(&str, "%s/%s", config->rundir.value, DEFAULT_LTTNG_SESSIOND_AGENTPORT_FILE);
if (ret < 0) {
ERR("Failed to set agent port file path");
goto error;
*/
#if (CAA_BITS_PER_LONG == 32)
config_string_set_static(&config->consumerd32_bin_path,
- INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE);
- config_string_set_static(&config->consumerd32_lib_dir,
- INSTALL_LIB_PATH);
+ INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE);
+ config_string_set_static(&config->consumerd32_lib_dir, INSTALL_LIB_PATH);
#elif (CAA_BITS_PER_LONG == 64)
config_string_set_static(&config->consumerd64_bin_path,
- INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE);
- config_string_set_static(&config->consumerd64_lib_dir,
- INSTALL_LIB_PATH);
+ INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE);
+ config_string_set_static(&config->consumerd64_lib_dir, INSTALL_LIB_PATH);
#else
#error "Unknown bitness"
#endif
config_string_fini(&config->kconsumerd_cmd_unix_sock_path);
}
-static
-int resolve_path(struct config_string *path)
+static int resolve_path(struct config_string *path)
{
int ret = 0;
char *absolute_path;
return ret;
}
-#define RESOLVE_CHECK(path_config_str) \
- if (resolve_path(path_config_str)) \
- return -1
+#define RESOLVE_CHECK(path_config_str) \
+ if (resolve_path(path_config_str)) \
+ return -1
int sessiond_config_resolve_paths(struct sessiond_config *config)
{
DBG_NO_LOC("\tagent_tcp_port: %i", config->agent_tcp_port.begin);
} else {
DBG_NO_LOC("\tagent_tcp_port: [%i, %i]",
- config->agent_tcp_port.begin,
- config->agent_tcp_port.end);
+ config->agent_tcp_port.begin,
+ config->agent_tcp_port.end);
}
DBG_NO_LOC("\tapplication socket timeout: %i", config->app_socket_timeout);
DBG_NO_LOC("\tno-kernel: %s", config->no_kernel ? "True" : "False");
DBG_NO_LOC("\tbackground: %s", config->background ? "True" : "False");
DBG_NO_LOC("\tdaemonize: %s", config->daemonize ? "True" : "False");
DBG_NO_LOC("\tsignal parent on start: %s", config->sig_parent ? "True" : "False");
- DBG_NO_LOC("\ttracing group name: %s", config->tracing_group_name.value ? : "Unknown");
- DBG_NO_LOC("\tkmod_probe_list: %s", config->kmod_probes_list.value ? : "None");
- DBG_NO_LOC("\tkmod_extra_probe_list: %s", config->kmod_extra_probes_list.value ? : "None");
- DBG_NO_LOC("\trundir: %s", config->rundir.value ? : "Unknown");
- DBG_NO_LOC("\tapplication socket path: %s", config->apps_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tclient socket path: %s", config->client_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\twait shm path: %s", config->wait_shm_path.value ? : "Unknown");
- DBG_NO_LOC("\thealth socket path: %s", config->health_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tLTTNG_UST_CLOCK_PLUGIN: %s", config->lttng_ust_clock_plugin.value ? : "None");
- DBG_NO_LOC("\tpid file path: %s", config->pid_file_path.value ? : "Unknown");
- DBG_NO_LOC("\tlock file path: %s", config->lock_file_path.value ? : "Unknown");
- DBG_NO_LOC("\tsession load path: %s", config->load_session_path.value ? : "None");
- DBG_NO_LOC("\tagent port file path: %s", config->agent_port_file_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd32 path: %s", config->consumerd32_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd32 bin path: %s", config->consumerd32_bin_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd32 lib dir: %s", config->consumerd32_lib_dir.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd32 err unix sock path:%s", config->consumerd32_err_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd32 cmd unix sock path:%s", config->consumerd32_cmd_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd64 path: %s", config->consumerd64_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd64 bin path: %s", config->consumerd64_bin_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd64 lib dir: %s", config->consumerd64_lib_dir.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd64 err unix sock path:%s", config->consumerd64_err_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tconsumerd64 cmd unix sock path:%s", config->consumerd64_cmd_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tkconsumerd path: %s", config->kconsumerd_path.value ? : "Unknown");
- DBG_NO_LOC("\tkconsumerd err unix sock path: %s", config->kconsumerd_err_unix_sock_path.value ? : "Unknown");
- DBG_NO_LOC("\tkconsumerd cmd unix sock path: %s", config->kconsumerd_cmd_unix_sock_path.value ? : "Unknown");
+ DBG_NO_LOC("\ttracing group name: %s",
+ config->tracing_group_name.value ?: "Unknown");
+ DBG_NO_LOC("\tkmod_probe_list: %s", config->kmod_probes_list.value ?: "None");
+ DBG_NO_LOC("\tkmod_extra_probe_list: %s",
+ config->kmod_extra_probes_list.value ?: "None");
+ DBG_NO_LOC("\trundir: %s", config->rundir.value ?: "Unknown");
+ DBG_NO_LOC("\tapplication socket path: %s",
+ config->apps_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tclient socket path: %s",
+ config->client_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\twait shm path: %s", config->wait_shm_path.value ?: "Unknown");
+ DBG_NO_LOC("\thealth socket path: %s",
+ config->health_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tLTTNG_UST_CLOCK_PLUGIN: %s",
+ config->lttng_ust_clock_plugin.value ?: "None");
+ DBG_NO_LOC("\tpid file path: %s", config->pid_file_path.value ?: "Unknown");
+ DBG_NO_LOC("\tlock file path: %s",
+ config->lock_file_path.value ?: "Unknown");
+ DBG_NO_LOC("\tsession load path: %s",
+ config->load_session_path.value ?: "None");
+ DBG_NO_LOC("\tagent port file path: %s",
+ config->agent_port_file_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd32 path: %s",
+ config->consumerd32_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd32 bin path: %s",
+ config->consumerd32_bin_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd32 lib dir: %s",
+ config->consumerd32_lib_dir.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd32 err unix sock path:%s",
+ config->consumerd32_err_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd32 cmd unix sock path:%s",
+ config->consumerd32_cmd_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd64 path: %s",
+ config->consumerd64_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd64 bin path: %s",
+ config->consumerd64_bin_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd64 lib dir: %s",
+ config->consumerd64_lib_dir.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd64 err unix sock path:%s",
+ config->consumerd64_err_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tconsumerd64 cmd unix sock path:%s",
+ config->consumerd64_cmd_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tkconsumerd path: %s",
+ config->kconsumerd_path.value ?: "Unknown");
+ DBG_NO_LOC("\tkconsumerd err unix sock path: %s",
+ config->kconsumerd_err_unix_sock_path.value ?: "Unknown");
+ DBG_NO_LOC("\tkconsumerd cmd unix sock path: %s",
+ config->kconsumerd_cmd_unix_sock_path.value ?: "Unknown");
}
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <string.h>
-#include <urcu/uatomic.h>
+#include "snapshot.hpp"
+#include "utils.hpp"
#include <common/defaults.hpp>
-#include "snapshot.hpp"
-#include "utils.hpp"
+#include <inttypes.h>
+#include <string.h>
+#include <urcu/uatomic.h>
/*
* Return the atomically incremented value of next_output_id.
* Return 0 on success or else a negative value.
*/
static int output_init(const struct ltt_session *session,
- uint64_t max_size, const char *name,
- struct lttng_uri *uris, size_t nb_uri,
- struct consumer_output *consumer, struct snapshot_output *output,
- struct snapshot *snapshot)
+ uint64_t max_size,
+ const char *name,
+ struct lttng_uri *uris,
+ size_t nb_uri,
+ struct consumer_output *consumer,
+ struct snapshot_output *output,
+ struct snapshot *snapshot)
{
int ret = 0, i;
}
} else {
/* Set default name. */
- ret = snprintf(output->name, sizeof(output->name), "%s-%" PRIu32,
- DEFAULT_SNAPSHOT_NAME, output->id);
+ ret = snprintf(output->name,
+ sizeof(output->name),
+ "%s-%" PRIu32,
+ DEFAULT_SNAPSHOT_NAME,
+ output->id);
if (ret < 0) {
ret = -ENOMEM;
goto error;
}
if (uris[0].dtype == LTTNG_DST_PATH) {
- memset(output->consumer->dst.session_root_path, 0,
- sizeof(output->consumer->dst.session_root_path));
+ memset(output->consumer->dst.session_root_path,
+ 0,
+ sizeof(output->consumer->dst.session_root_path));
if (lttng_strncpy(output->consumer->dst.session_root_path,
- uris[0].dst.path,
- sizeof(output->consumer->dst.session_root_path))) {
+ uris[0].dst.path,
+ sizeof(output->consumer->dst.session_root_path))) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
goto error;
}
- for (i = 0; i < nb_uri; i ++) {
+ for (i = 0; i < nb_uri; i++) {
/* Network URIs */
- ret = consumer_set_network_uri(session, output->consumer,
- &uris[i]);
+ ret = consumer_set_network_uri(session, output->consumer, &uris[i]);
if (ret < 0) {
goto error;
}
* Return 0 on success or else a negative value.
*/
int snapshot_output_init_with_uri(const struct ltt_session *session,
- uint64_t max_size, const char *name,
- struct lttng_uri *uris, size_t nb_uri,
- struct consumer_output *consumer, struct snapshot_output *output,
- struct snapshot *snapshot)
+ uint64_t max_size,
+ const char *name,
+ struct lttng_uri *uris,
+ size_t nb_uri,
+ struct consumer_output *consumer,
+ struct snapshot_output *output,
+ struct snapshot *snapshot)
{
- return output_init(session, max_size, name, uris, nb_uri, consumer,
- output, snapshot);
+ return output_init(session, max_size, name, uris, nb_uri, consumer, output, snapshot);
}
/*
* Return 0 on success or else a negative value.
*/
int snapshot_output_init(const struct ltt_session *session,
- uint64_t max_size, const char *name,
- const char *ctrl_url, const char *data_url,
- struct consumer_output *consumer, struct snapshot_output *output,
- struct snapshot *snapshot)
+ uint64_t max_size,
+ const char *name,
+ const char *ctrl_url,
+ const char *data_url,
+ struct consumer_output *consumer,
+ struct snapshot_output *output,
+ struct snapshot *snapshot)
{
int ret = 0, nb_uri;
struct lttng_uri *uris = NULL;
goto error;
}
- ret = output_init(session, max_size, name, uris, nb_uri, consumer,
- output, snapshot);
+ ret = output_init(session, max_size, name, uris, nb_uri, consumer, output, snapshot);
error:
free(uris);
/*
* Delete output from the snapshot object.
*/
-void snapshot_delete_output(struct snapshot *snapshot,
- struct snapshot_output *output)
+void snapshot_delete_output(struct snapshot *snapshot, struct snapshot_output *output)
{
int ret;
struct lttng_ht_iter iter;
/*
* Add output object to the snapshot.
*/
-void snapshot_add_output(struct snapshot *snapshot,
- struct snapshot_output *output)
+void snapshot_add_output(struct snapshot *snapshot, struct snapshot_output *output)
{
LTTNG_ASSERT(snapshot);
LTTNG_ASSERT(snapshot->output_ht);
*
* Return the reference on success or else NULL.
*/
-struct snapshot_output *snapshot_find_output_by_name(const char *name,
- struct snapshot *snapshot)
+struct snapshot_output *snapshot_find_output_by_name(const char *name, struct snapshot *snapshot)
{
struct lttng_ht_iter iter;
struct snapshot_output *output = NULL;
LTTNG_ASSERT(name);
ASSERT_RCU_READ_LOCKED();
- cds_lfht_for_each_entry(snapshot->output_ht->ht, &iter.iter, output,
- node.node) {
+ cds_lfht_for_each_entry (snapshot->output_ht->ht, &iter.iter, output, node.node) {
if (!strncmp(output->name, name, strlen(name))) {
return output;
}
*
* Return the reference on success or else NULL.
*/
-struct snapshot_output *snapshot_find_output_by_id(uint32_t id,
- struct snapshot *snapshot)
+struct snapshot_output *snapshot_find_output_by_id(uint32_t id, struct snapshot *snapshot)
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
LTTNG_ASSERT(snapshot);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(snapshot->output_ht, (void *)((unsigned long) id), &iter);
+ lttng_ht_lookup(snapshot->output_ht, (void *) ((unsigned long) id), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (!node) {
DBG3("Snapshot output not found with id %" PRId32, id);
}
rcu_read_lock();
- cds_lfht_for_each_entry(obj->output_ht->ht, &iter.iter, output,
- node.node) {
+ cds_lfht_for_each_entry (obj->output_ht->ht, &iter.iter, output, node.node) {
snapshot_delete_output(obj, output);
snapshot_output_destroy(output);
}
namespace lst = lttng::sessiond::trace;
-lttng::sessiond::trace::stream_class::stream_class(unsigned int in_id,
- enum header_type in_header_type,
- nonstd::optional<std::string> in_default_clock_class_name) :
- id{in_id},
- header_type_{in_header_type},
- default_clock_class_name{std::move(in_default_clock_class_name)}
+lttng::sessiond::trace::stream_class::stream_class(
+ unsigned int in_id,
+ enum header_type in_header_type,
+ nonstd::optional<std::string> in_default_clock_class_name) :
+ id{ in_id },
+ header_type_{ in_header_type },
+ default_clock_class_name{ std::move(in_default_clock_class_name) }
{
}
#include "lttng-sessiond.hpp"
#include "utils.hpp"
+
#include <common/utils.hpp>
+
#include <pthread.h>
/*
*/
#include "thread.hpp"
+
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+
+#include <pthread.h>
#include <urcu/list.h>
#include <urcu/ref.h>
-#include <pthread.h>
-#include <common/macros.hpp>
-#include <common/error.hpp>
-#include <common/defaults.hpp>
namespace {
struct thread_list {
void *data;
};
-static
-void lttng_thread_destroy(struct lttng_thread *thread)
+static void lttng_thread_destroy(struct lttng_thread *thread)
{
if (thread->cleanup) {
thread->cleanup(thread->data);
free(thread);
}
-static
-void lttng_thread_release(struct urcu_ref *ref)
+static void lttng_thread_release(struct urcu_ref *ref)
{
lttng_thread_destroy(lttng::utils::container_of(ref, <tng_thread::ref));
}
-static
-void *launch_thread(void *data)
+static void *launch_thread(void *data)
{
void *ret;
struct lttng_thread *thread = (struct lttng_thread *) data;
}
struct lttng_thread *lttng_thread_create(const char *name,
- lttng_thread_entry_point entry,
- lttng_thread_shutdown_cb shutdown,
- lttng_thread_cleanup_cb cleanup,
- void *thread_data)
+ lttng_thread_entry_point entry,
+ lttng_thread_shutdown_cb shutdown,
+ lttng_thread_cleanup_cb cleanup,
+ void *thread_data)
{
int ret;
struct lttng_thread *thread;
cds_list_add(&thread->node, &thread_list.head);
(void) lttng_thread_get(thread);
- ret = pthread_create(&thread->thread, default_pthread_attr(),
- launch_thread, thread);
+ ret = pthread_create(&thread->thread, default_pthread_attr(), launch_thread, thread);
if (ret) {
PERROR("Failed to create \"%s\" thread", thread->name);
goto error_pthread_create;
return thread->name;
}
-static
-bool _lttng_thread_shutdown(struct lttng_thread *thread)
+static bool _lttng_thread_shutdown(struct lttng_thread *thread)
{
int ret;
void *status;
struct lttng_thread *thread, *tmp;
pthread_mutex_lock(&thread_list.lock);
- cds_list_for_each_entry_safe(thread, tmp, &thread_list.head, node) {
+ cds_list_for_each_entry_safe (thread, tmp, &thread_list.head, node) {
bool result;
const long ref = uatomic_read(&thread->ref.refcount);
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <signal.h>
-
-#include "timer.hpp"
#include "health-sessiond.hpp"
#include "rotation-thread.hpp"
#include "thread.hpp"
+#include "timer.hpp"
+
+#include <inttypes.h>
+#include <signal.h>
-#define LTTNG_SESSIOND_SIG_QS SIGRTMIN + 10
-#define LTTNG_SESSIOND_SIG_EXIT SIGRTMIN + 11
-#define LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK SIGRTMIN + 12
-#define LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION SIGRTMIN + 13
+#define LTTNG_SESSIOND_SIG_QS SIGRTMIN + 10
+#define LTTNG_SESSIOND_SIG_EXIT SIGRTMIN + 11
+#define LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK SIGRTMIN + 12
+#define LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION SIGRTMIN + 13
-#define UINT_TO_PTR(value) \
- ({ \
- LTTNG_ASSERT(value <= UINTPTR_MAX); \
- (void *) (uintptr_t) value; \
+#define UINT_TO_PTR(value) \
+ ({ \
+ LTTNG_ASSERT(value <= UINTPTR_MAX); \
+ (void *) (uintptr_t) value; \
})
#define PTR_TO_UINT(ptr) ((uintptr_t) ptr)
/*
* Set custom signal mask to current thread.
*/
-static
-void setmask(sigset_t *mask)
+static void setmask(sigset_t *mask)
{
int ret;
* returns, it means that no timer signr is currently pending or being handled
* by the timer thread. This cannot be called from the timer thread.
*/
-static
-void timer_signal_thread_qs(unsigned int signr)
+static void timer_signal_thread_qs(unsigned int signr)
{
sigset_t pending_set;
int ret;
* Returns a negative value on error, 0 if a timer was created, and
* a positive value if no timer was created (not an error).
*/
-static
-int timer_start(timer_t *timer_id, struct ltt_session *session,
- unsigned int timer_interval_us, int signal, bool one_shot)
+static int timer_start(timer_t *timer_id,
+ struct ltt_session *session,
+ unsigned int timer_interval_us,
+ int signal,
+ bool one_shot)
{
int ret = 0, delete_ret;
struct sigevent sev = {};
return ret;
}
-static
-int timer_stop(timer_t *timer_id, int signal)
+static int timer_stop(timer_t *timer_id, int signal)
{
int ret = 0;
}
int timer_session_rotation_pending_check_start(struct ltt_session *session,
- unsigned int interval_us)
+ unsigned int interval_us)
{
int ret;
ret = -1;
goto end;
}
- DBG("Enabling session rotation pending check timer on session %" PRIu64,
- session->id);
+ DBG("Enabling session rotation pending check timer on session %" PRIu64, session->id);
/*
* We arm this timer in a one-shot mode so we don't have to disable it
* explicitly (which could deadlock if the timer thread is blocked
* no need to go through the whole signal teardown scheme everytime.
*/
ret = timer_start(&session->rotation_pending_check_timer,
- session, interval_us,
- LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK,
- /* one-shot */ true);
+ session,
+ interval_us,
+ LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK,
+ /* one-shot */ true);
if (ret == 0) {
session->rotation_pending_check_timer_enabled = true;
}
LTTNG_ASSERT(session);
LTTNG_ASSERT(session->rotation_pending_check_timer_enabled);
- DBG("Disabling session rotation pending check timer on session %" PRIu64,
- session->id);
+ DBG("Disabling session rotation pending check timer on session %" PRIu64, session->id);
ret = timer_stop(&session->rotation_pending_check_timer,
- LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK);
+ LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK);
if (ret == -1) {
ERR("Failed to stop rotate_pending_check timer");
} else {
* Call with session and session_list locks held.
*/
int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
- unsigned int interval_us)
+ unsigned int interval_us)
{
int ret;
ret = -1;
goto end;
}
- DBG("Enabling scheduled rotation timer on session \"%s\" (%ui %s)", session->name,
- interval_us, USEC_UNIT);
- ret = timer_start(&session->rotation_schedule_timer, session,
- interval_us, LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION,
- /* one-shot */ false);
+ DBG("Enabling scheduled rotation timer on session \"%s\" (%ui %s)",
+ session->name,
+ interval_us,
+ USEC_UNIT);
+ ret = timer_start(&session->rotation_schedule_timer,
+ session,
+ interval_us,
+ LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION,
+ /* one-shot */ false);
if (ret < 0) {
goto end;
}
}
DBG("Disabling scheduled rotation timer on session %s", session->name);
- ret = timer_stop(&session->rotation_schedule_timer,
- LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION);
+ ret = timer_stop(&session->rotation_schedule_timer, LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION);
if (ret < 0) {
- ERR("Failed to stop scheduled rotation timer of session \"%s\"",
- session->name);
+ ERR("Failed to stop scheduled rotation timer of session \"%s\"", session->name);
goto end;
}
/*
* This thread is the sighandler for the timer signals.
*/
-static
-void *thread_timer(void *data)
+static void *thread_timer(void *data)
{
int signr;
sigset_t mask;
goto end;
} else if (signr == LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK) {
struct ltt_session *session =
- (struct ltt_session *) info.si_value.sival_ptr;
+ (struct ltt_session *) info.si_value.sival_ptr;
rotation_thread_enqueue_job(ctx->rotation_thread_job_queue,
- ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION,
- session);
+ ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION,
+ session);
} else if (signr == LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION) {
rotation_thread_enqueue_job(ctx->rotation_thread_job_queue,
- ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
- (struct ltt_session *) info.si_value.sival_ptr);
+ ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION,
+ (struct ltt_session *) info.si_value.sival_ptr);
/*
* The scheduled periodic rotation timer is not in
* "one-shot" mode. The reference to the session is not
return NULL;
}
-static
-bool shutdown_timer_thread(void *data __attribute__((unused)))
+static bool shutdown_timer_thread(void *data __attribute__((unused)))
{
return kill(getpid(), LTTNG_SESSIOND_SIG_EXIT) == 0;
}
-bool launch_timer_thread(
- struct timer_thread_parameters *timer_thread_parameters)
+bool launch_timer_thread(struct timer_thread_parameters *timer_thread_parameters)
{
struct lttng_thread *thread;
- thread = lttng_thread_create("Timer",
- thread_timer,
- shutdown_timer_thread,
- NULL,
- timer_thread_parameters);
+ thread = lttng_thread_create(
+ "Timer", thread_timer, shutdown_timer_thread, NULL, timer_thread_parameters);
if (!thread) {
goto error;
}
namespace lst = lttng::sessiond::trace;
-lttng::sessiond::trace::trace_class::trace_class(
- const struct abi& in_abi,
- const lttng_uuid& in_trace_uuid) :
- abi{in_abi},
- uuid{in_trace_uuid}
+lttng::sessiond::trace::trace_class::trace_class(const struct abi& in_abi,
+ const lttng_uuid& in_trace_uuid) :
+ abi{ in_abi }, uuid{ in_trace_uuid }
{
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include "consumer.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "trace-kernel.hpp"
+
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/macros.hpp>
+#include <common/trace-chunk.hpp>
-#include <lttng/event.h>
-#include <lttng/lttng-error.h>
-#include <lttng/kernel-probe.h>
-#include <lttng/userspace-probe.h>
-#include <lttng/userspace-probe-internal.hpp>
-#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/event-rule-internal.hpp>
-#include <lttng/event-rule/kernel-kprobe.h>
+#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/kernel-kprobe-internal.hpp>
-#include <lttng/event-rule/kernel-syscall.h>
+#include <lttng/event-rule/kernel-kprobe.h>
#include <lttng/event-rule/kernel-syscall-internal.hpp>
-#include <lttng/event-rule/kernel-tracepoint.h>
+#include <lttng/event-rule/kernel-syscall.h>
#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
-#include <lttng/event-rule/kernel-uprobe.h>
+#include <lttng/event-rule/kernel-tracepoint.h>
#include <lttng/event-rule/kernel-uprobe-internal.hpp>
-#include <common/common.hpp>
-#include <common/defaults.hpp>
-#include <common/trace-chunk.hpp>
-#include <common/macros.hpp>
+#include <lttng/event-rule/kernel-uprobe.h>
+#include <lttng/event.h>
+#include <lttng/kernel-probe.h>
+#include <lttng/lttng-error.h>
+#include <lttng/userspace-probe-internal.hpp>
+#include <lttng/userspace-probe.h>
-#include "consumer.hpp"
-#include "trace-kernel.hpp"
-#include "lttng-sessiond.hpp"
-#include "notification-thread-commands.hpp"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
/*
* Find the channel name for the given kernel session.
*/
-struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
- const char *name, struct ltt_kernel_session *session)
+struct ltt_kernel_channel *trace_kernel_get_channel_by_name(const char *name,
+ struct ltt_kernel_session *session)
{
struct ltt_kernel_channel *chan;
DBG("Trying to find channel %s", name);
- cds_list_for_each_entry(chan, &session->channel_list.head, list) {
+ cds_list_for_each_entry (chan, &session->channel_list.head, list) {
if (strcmp(name, chan->channel->name) == 0) {
DBG("Found channel by name %s", name);
return chan;
/*
* Find the event for the given channel.
*/
-struct ltt_kernel_event *trace_kernel_find_event(
- char *name, struct ltt_kernel_channel *channel,
- enum lttng_event_type type,
- struct lttng_bytecode *filter)
+struct ltt_kernel_event *trace_kernel_find_event(char *name,
+ struct ltt_kernel_channel *channel,
+ enum lttng_event_type type,
+ struct lttng_bytecode *filter)
{
struct ltt_kernel_event *ev;
int found = 0;
LTTNG_ASSERT(name);
LTTNG_ASSERT(channel);
- cds_list_for_each_entry(ev, &channel->events_list.head, list) {
+ cds_list_for_each_entry (ev, &channel->events_list.head, list) {
if (type != LTTNG_EVENT_ALL && ev->type != type) {
continue;
}
}
if (ev->filter && filter) {
if (ev->filter->len != filter->len ||
- memcmp(ev->filter->data, filter->data,
- filter->len) != 0) {
+ memcmp(ev->filter->data, filter->data, filter->len) != 0) {
continue;
}
}
break;
}
if (found) {
- DBG("Found event %s for channel %s", name,
- channel->channel->name);
+ DBG("Found event %s for channel %s", name, channel->channel->name);
return ev;
} else {
return NULL;
/*
* Find the event name for the given channel.
*/
-struct ltt_kernel_event *trace_kernel_get_event_by_name(
- char *name, struct ltt_kernel_channel *channel,
- enum lttng_event_type type)
+struct ltt_kernel_event *trace_kernel_get_event_by_name(char *name,
+ struct ltt_kernel_channel *channel,
+ enum lttng_event_type type)
{
struct ltt_kernel_event *ev;
int found = 0;
LTTNG_ASSERT(name);
LTTNG_ASSERT(channel);
- cds_list_for_each_entry(ev, &channel->events_list.head, list) {
+ cds_list_for_each_entry (ev, &channel->events_list.head, list) {
if (type != LTTNG_EVENT_ALL && ev->type != type) {
continue;
}
break;
}
if (found) {
- DBG("Found event %s for channel %s", name,
- channel->channel->name);
+ DBG("Found event %s for channel %s", name, channel->channel->name);
return ev;
} else {
return NULL;
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_channel *trace_kernel_create_channel(
- struct lttng_channel *chan)
+struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan)
{
struct ltt_kernel_channel *lkc;
struct lttng_channel_extended *extended = NULL;
* default channel name is requested.
*/
if (chan->name[0] == '\0') {
- strncpy(lkc->channel->name, DEFAULT_CHANNEL_NAME,
- sizeof(lkc->channel->name));
+ strncpy(lkc->channel->name, DEFAULT_CHANNEL_NAME, sizeof(lkc->channel->name));
}
lkc->channel->name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
*
* Return the allocated object or NULL on error.
*/
-struct ltt_kernel_context *trace_kernel_create_context(
- struct lttng_kernel_abi_context *ctx)
+struct ltt_kernel_context *trace_kernel_create_context(struct lttng_kernel_abi_context *ctx)
{
struct ltt_kernel_context *kctx;
*
* Return the allocated object or NULL on error.
*/
-struct ltt_kernel_context *trace_kernel_copy_context(
- struct ltt_kernel_context *kctx)
+struct ltt_kernel_context *trace_kernel_copy_context(struct ltt_kernel_context *kctx)
{
struct ltt_kernel_context *kctx_copy;
*
* Return pointer to structure or NULL.
*/
-enum lttng_error_code trace_kernel_create_event(
- struct lttng_event *ev, char *filter_expression,
- struct lttng_bytecode *filter,
- struct ltt_kernel_event **kernel_event)
+enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct ltt_kernel_event **kernel_event)
{
enum lttng_error_code ret;
struct lttng_kernel_abi_event *attr;
attr->u.kprobe.addr = ev->attr.probe.addr;
attr->u.kprobe.offset = ev->attr.probe.offset;
strncpy(attr->u.kprobe.symbol_name,
- ev->attr.probe.symbol_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
+ ev->attr.probe.symbol_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN);
attr->u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
break;
case LTTNG_EVENT_USERSPACE_PROBE:
{
- const struct lttng_userspace_probe_location* location = NULL;
+ const struct lttng_userspace_probe_location *location = NULL;
const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
location = lttng_event_get_userspace_probe_location(ev);
*/
attr->instrumentation = LTTNG_KERNEL_ABI_UPROBE;
- lookup = lttng_userspace_probe_location_get_lookup_method(
- location);
+ lookup = lttng_userspace_probe_location_get_lookup_method(location);
if (!lookup) {
ret = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto error;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
/* Get the file descriptor on the target binary. */
attr->u.uprobe.fd =
- lttng_userspace_probe_location_function_get_binary_fd(location);
+ lttng_userspace_probe_location_function_get_binary_fd(location);
/*
* Save a reference to the probe location used during
* the listing of events.
*/
- userspace_probe_location =
- lttng_userspace_probe_location_copy(location);
+ userspace_probe_location = lttng_userspace_probe_location_copy(location);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
/* Get the file descriptor on the target binary. */
attr->u.uprobe.fd =
- lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
+ lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
/*
* Save a reference to the probe location used during the listing of
* events.
*/
- userspace_probe_location =
- lttng_userspace_probe_location_copy(location);
+ userspace_probe_location = lttng_userspace_probe_location_copy(location);
break;
default:
DBG("Unsupported lookup method type");
attr->u.kretprobe.addr = ev->attr.probe.addr;
attr->u.kretprobe.offset = ev->attr.probe.offset;
strncpy(attr->u.kretprobe.symbol_name,
- ev->attr.probe.symbol_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
+ ev->attr.probe.symbol_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN);
attr->u.kretprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
break;
case LTTNG_EVENT_FUNCTION_ENTRY:
attr->instrumentation = LTTNG_KERNEL_ABI_FUNCTION;
strncpy(attr->u.ftrace.symbol_name,
- ev->attr.ftrace.symbol_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
+ ev->attr.ftrace.symbol_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN);
attr->u.ftrace.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
break;
case LTTNG_EVENT_TRACEPOINT:
*
* Return pointer to structure or NULL.
*/
-enum lttng_error_code trace_kernel_create_event_notifier_rule(
- struct lttng_trigger *trigger,
- uint64_t token,
- uint64_t error_counter_index,
- struct ltt_kernel_event_notifier_rule **event_notifier_rule)
+enum lttng_error_code
+trace_kernel_create_event_notifier_rule(struct lttng_trigger *trigger,
+ uint64_t token,
+ uint64_t error_counter_index,
+ struct ltt_kernel_event_notifier_rule **event_notifier_rule)
{
enum lttng_error_code ret = LTTNG_OK;
enum lttng_condition_type condition_type;
condition_type = lttng_condition_get_type(condition);
LTTNG_ASSERT(condition_type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(event_rule);
event_rule_type = lttng_event_rule_get_type(event_rule);
LTTNG_ASSERT(event_rule_type != LTTNG_EVENT_RULE_TYPE_UNKNOWN);
- local_kernel_token_event_rule =
- zmalloc<ltt_kernel_event_notifier_rule>();
+ local_kernel_token_event_rule = zmalloc<ltt_kernel_event_notifier_rule>();
if (local_kernel_token_event_rule == NULL) {
PERROR("Failed to allocate ltt_kernel_token_event_rule structure");
ret = LTTNG_ERR_NOMEM;
local_kernel_token_event_rule->trigger = trigger;
/* The event rule still owns the filter and bytecode. */
- local_kernel_token_event_rule->filter =
- lttng_event_rule_get_filter_bytecode(event_rule);
+ local_kernel_token_event_rule->filter = lttng_event_rule_get_filter_bytecode(event_rule);
DBG3("Created kernel event notifier rule: token = %" PRIu64,
- local_kernel_token_event_rule->token);
+ local_kernel_token_event_rule->token);
error:
*event_notifier_rule = local_kernel_token_event_rule;
return ret;
* Initialize a kernel trigger from an event rule.
*/
enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
- const struct lttng_event_rule *rule,
- struct lttng_kernel_abi_event_notifier *kernel_event_notifier)
+ const struct lttng_event_rule *rule,
+ struct lttng_kernel_abi_event_notifier *kernel_event_notifier)
{
enum lttng_error_code ret_code;
const char *name;
switch (lttng_kernel_probe_location_get_type(location)) {
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS:
{
- k_status = lttng_kernel_probe_location_address_get_address(
- location, &address);
+ k_status =
+ lttng_kernel_probe_location_address_get_address(location, &address);
LTTNG_ASSERT(k_status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
break;
}
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET:
{
- k_status = lttng_kernel_probe_location_symbol_get_offset(
- location, &offset);
+ k_status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
LTTNG_ASSERT(k_status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
- symbol_name = lttng_kernel_probe_location_symbol_get_name(
- location);
+ symbol_name = lttng_kernel_probe_location_symbol_get_name(location);
break;
}
default:
kernel_event_notifier->event.u.kprobe.offset = offset;
if (symbol_name) {
strncpy_ret = lttng_strncpy(
- kernel_event_notifier->event.u.kprobe.symbol_name,
- symbol_name,
- sizeof(kernel_event_notifier->event.u.kprobe.symbol_name));
+ kernel_event_notifier->event.u.kprobe.symbol_name,
+ symbol_name,
+ sizeof(kernel_event_notifier->event.u.kprobe.symbol_name));
if (strncpy_ret) {
ret_code = LTTNG_ERR_INVALID;
}
}
- kernel_event_notifier->event.u.kprobe.symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ kernel_event_notifier->event.u.kprobe
+ .symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
status = lttng_event_rule_kernel_kprobe_get_event_name(rule, &name);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
}
case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
{
- const struct lttng_userspace_probe_location* location = NULL;
+ const struct lttng_userspace_probe_location *location = NULL;
const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
enum lttng_event_rule_status status;
kernel_event_notifier->event.instrumentation = LTTNG_KERNEL_ABI_UPROBE;
- lookup = lttng_userspace_probe_location_get_lookup_method(
- location);
+ lookup = lttng_userspace_probe_location_get_lookup_method(location);
if (!lookup) {
ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto error;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
/* Get the file descriptor on the target binary. */
kernel_event_notifier->event.u.uprobe.fd =
- lttng_userspace_probe_location_function_get_binary_fd(location);
+ lttng_userspace_probe_location_function_get_binary_fd(location);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
/* Get the file descriptor on the target binary. */
kernel_event_notifier->event.u.uprobe.fd =
- lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
+ lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
break;
default:
abort();
}
- status = lttng_event_rule_kernel_uprobe_get_event_name(
- rule, &name);
+ status = lttng_event_rule_kernel_uprobe_get_event_name(rule, &name);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
ret_code = LTTNG_OK;
break;
case LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT:
{
const enum lttng_event_rule_status status =
- lttng_event_rule_kernel_tracepoint_get_name_pattern(
- rule, &name);
+ lttng_event_rule_kernel_tracepoint_get_name_pattern(rule, &name);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
- kernel_event_notifier->event.instrumentation =
- LTTNG_KERNEL_ABI_TRACEPOINT;
+ kernel_event_notifier->event.instrumentation = LTTNG_KERNEL_ABI_TRACEPOINT;
ret_code = LTTNG_OK;
break;
case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
{
const enum lttng_event_rule_status status =
- lttng_event_rule_kernel_syscall_get_name_pattern(
- rule, &name);
- const enum lttng_event_rule_kernel_syscall_emission_site
- emission_site =
+ lttng_event_rule_kernel_syscall_get_name_pattern(rule, &name);
+ const enum lttng_event_rule_kernel_syscall_emission_site emission_site =
lttng_event_rule_kernel_syscall_get_emission_site(rule);
enum lttng_kernel_abi_syscall_entryexit entryexit;
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
- LTTNG_ASSERT(emission_site != LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_UNKNOWN);
+ LTTNG_ASSERT(emission_site !=
+ LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_UNKNOWN);
- switch(emission_site) {
+ switch (emission_site) {
case LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY:
entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
break;
break;
}
- kernel_event_notifier->event.instrumentation =
- LTTNG_KERNEL_ABI_SYSCALL;
- kernel_event_notifier->event.u.syscall.abi =
- LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL;
- kernel_event_notifier->event.u.syscall.entryexit =
- entryexit;
- kernel_event_notifier->event.u.syscall.match =
- LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME;
+ kernel_event_notifier->event.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ kernel_event_notifier->event.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL;
+ kernel_event_notifier->event.u.syscall.entryexit = entryexit;
+ kernel_event_notifier->event.u.syscall.match = LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME;
ret_code = LTTNG_OK;
break;
}
break;
}
- strncpy_ret = lttng_strncpy(kernel_event_notifier->event.name, name,
- LTTNG_KERNEL_ABI_SYM_NAME_LEN);
+ strncpy_ret = lttng_strncpy(
+ kernel_event_notifier->event.name, name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
if (strncpy_ret) {
ret_code = LTTNG_ERR_INVALID;
goto error;
goto error;
}
- ret = lttng_strncpy(
- chan->name, DEFAULT_METADATA_NAME, sizeof(chan->name));
+ ret = lttng_strncpy(chan->name, DEFAULT_METADATA_NAME, sizeof(chan->name));
if (ret) {
- ERR("Failed to initialize metadata channel name to `%s`",
- DEFAULT_METADATA_NAME);
+ ERR("Failed to initialize metadata channel name to `%s`", DEFAULT_METADATA_NAME);
goto error;
}
chan->attr.subbuf_size = default_get_metadata_subbuf_size();
chan->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM;
chan->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER;
- chan->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;;
-
+ chan->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;
+ ;
/*
* The metadata channel of kernel sessions must use the "mmap"
*
* Return pointer to structure or NULL.
*/
-struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
- unsigned int count)
+struct ltt_kernel_stream *trace_kernel_create_stream(const char *name, unsigned int count)
{
int ret;
struct ltt_kernel_stream *lks;
*/
static void free_token_event_rule_rcu(struct rcu_head *rcu_node)
{
- struct ltt_kernel_event_notifier_rule *rule = caa_container_of(rcu_node,
- struct ltt_kernel_event_notifier_rule, rcu_node);
+ struct ltt_kernel_event_notifier_rule *rule =
+ caa_container_of(rcu_node, struct ltt_kernel_event_notifier_rule, rcu_node);
free(rule);
}
-void trace_kernel_destroy_event_notifier_rule(
- struct ltt_kernel_event_notifier_rule *event)
+void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *event)
{
LTTNG_ASSERT(event);
if (event->fd >= 0) {
const int ret = close(event->fd);
- DBG("Closing kernel event notifier rule file descriptor: fd = %d",
- event->fd);
+ DBG("Closing kernel event notifier rule file descriptor: fd = %d", event->fd);
if (ret) {
PERROR("Failed to close kernel event notifier file descriptor: fd = %d",
- event->fd);
+ event->fd);
}
} else {
DBG("Destroying kernel event notifier rule (no associated file descriptor)");
}
/* For each stream in the channel list */
- cds_list_for_each_entry_safe(stream, stmp, &channel->stream_list.head, list) {
+ cds_list_for_each_entry_safe (stream, stmp, &channel->stream_list.head, list) {
trace_kernel_destroy_stream(stream);
}
/* For each event in the channel list */
- cds_list_for_each_entry_safe(event, etmp, &channel->events_list.head, list) {
+ cds_list_for_each_entry_safe (event, etmp, &channel->events_list.head, list) {
trace_kernel_destroy_event(event);
}
/* For each context in the channel list */
- cds_list_for_each_entry_safe(ctx, ctmp, &channel->ctx_list, list) {
+ cds_list_for_each_entry_safe (ctx, ctmp, &channel->ctx_list, list) {
trace_kernel_destroy_context(ctx);
}
/* Remove from channel list */
cds_list_del(&channel->list);
- if (the_notification_thread_handle &&
- channel->published_to_notification_thread) {
+ if (the_notification_thread_handle && channel->published_to_notification_thread) {
status = notification_thread_command_remove_channel(
- the_notification_thread_handle, channel->key,
- LTTNG_DOMAIN_KERNEL);
+ the_notification_thread_handle, channel->key, LTTNG_DOMAIN_KERNEL);
LTTNG_ASSERT(status == LTTNG_OK);
}
free(channel->channel->attr.extended.ptr);
trace_kernel_destroy_metadata(session->metadata);
}
- cds_list_for_each_entry_safe(channel, ctmp, &session->channel_list.head, list) {
+ cds_list_for_each_entry_safe (channel, ctmp, &session->channel_list.head, list) {
trace_kernel_destroy_channel(channel);
}
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
+#include "agent.hpp"
+#include "buffer-registry.hpp"
+#include "trace-ust.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/defaults.hpp>
#include <common/trace-chunk.hpp>
#include <common/utils.hpp>
-#include "buffer-registry.hpp"
-#include "trace-ust.hpp"
-#include "utils.hpp"
-#include "ust-app.hpp"
-#include "agent.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
namespace lsu = lttng::sessiond::ust;
*
* Matches by name only. Used by the disable command.
*/
-int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
- const void *_key)
+int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, const void *_key)
{
struct ltt_ust_event *event;
const char *name;
/* Event loglevel value and type. */
ll_match = loglevels_match(event->attr.loglevel_type,
- ev_loglevel_value, key->loglevel_type,
- key->loglevel_value, LTTNG_UST_ABI_LOGLEVEL_ALL);
+ ev_loglevel_value,
+ key->loglevel_type,
+ key->loglevel_value,
+ LTTNG_UST_ABI_LOGLEVEL_ALL);
if (!ll_match) {
goto no_match;
if (key->filter && event->filter) {
/* Both filters exists, check length followed by the bytecode. */
if (event->filter->len != key->filter->len ||
- memcmp(event->filter->data, key->filter->data,
- event->filter->len) != 0) {
+ memcmp(event->filter->data, key->filter->data, event->filter->len) != 0) {
goto no_match;
}
}
/* Compare names individually. */
for (i = 0; i < event->exclusion->count; ++i) {
size_t j;
- bool found = false;
- const char *name_ev =
- LTTNG_EVENT_EXCLUSION_NAME_AT(
- event->exclusion, i);
+ bool found = false;
+ const char *name_ev = LTTNG_EVENT_EXCLUSION_NAME_AT(event->exclusion, i);
/*
* Compare this exclusion name to all the key's
*/
for (j = 0; j < key->exclusion->count; ++j) {
const char *name_key =
- LTTNG_EVENT_EXCLUSION_NAME_AT(
- key->exclusion, j);
+ LTTNG_EVENT_EXCLUSION_NAME_AT(key->exclusion, j);
- if (!strncmp(name_ev, name_key,
- LTTNG_SYMBOL_NAME_LEN)) {
+ if (!strncmp(name_ev, name_key, LTTNG_SYMBOL_NAME_LEN)) {
/* Names match! */
found = true;
break;
* Find the channel in the hashtable and return channel pointer. RCU read side
* lock MUST be acquired before calling this.
*/
-struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
- const char *name)
+struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, const char *name)
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
if (name[0] == '\0')
name = DEFAULT_CHANNEL_NAME;
- lttng_ht_lookup(ht, (void *)name, &iter);
+ lttng_ht_lookup(ht, (void *) name, &iter);
node = lttng_ht_iter_get_node_str(&iter);
if (node == NULL) {
goto error;
* MUST be acquired before calling this.
*/
struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
- char *name, struct lttng_bytecode *filter,
- enum lttng_ust_abi_loglevel_type loglevel_type, int loglevel_value,
- struct lttng_event_exclusion *exclusion)
+ char *name,
+ struct lttng_bytecode *filter,
+ enum lttng_ust_abi_loglevel_type loglevel_type,
+ int loglevel_value,
+ struct lttng_event_exclusion *exclusion)
{
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
key.loglevel_value = loglevel_value;
key.exclusion = exclusion;
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
- trace_ust_ht_match_event, &key, &iter.iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) name, lttng_ht_seed),
+ trace_ust_ht_match_event,
+ &key,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (node == NULL) {
goto error;
* once the agent is no longer in scope or being used.
*/
struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
- enum lttng_domain_type domain_type)
+ enum lttng_domain_type domain_type)
{
struct agent *agt = NULL;
struct lttng_ht_node_u64 *node;
* Return pointer to structure or NULL.
*/
struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan,
- enum lttng_domain_type domain)
+ enum lttng_domain_type domain)
{
struct ltt_ust_channel *luc;
luc->attr.switch_timer_interval = chan->attr.switch_timer_interval;
luc->attr.read_timer_interval = chan->attr.read_timer_interval;
luc->attr.output = (enum lttng_ust_abi_output) chan->attr.output;
- luc->monitor_timer_interval = ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->monitor_timer_interval;
- luc->attr.u.s.blocking_timeout = ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->blocking_timeout;
+ luc->monitor_timer_interval =
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval;
+ luc->attr.u.s.blocking_timeout =
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->blocking_timeout;
/* Translate to UST output enum */
switch (luc->attr.output) {
for (i = 0; i < exclusion->count; ++i) {
size_t j;
- const char *name_a =
- LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, i);
+ const char *name_a = LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, i);
for (j = 0; j < i; ++j) {
- const char *name_b =
- LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, j);
+ const char *name_b = LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, j);
if (!strncmp(name_a, name_b, LTTNG_SYMBOL_NAME_LEN)) {
/* Match! */
* Return an lttng_error_code
*/
enum lttng_error_code trace_ust_create_event(struct lttng_event *ev,
- char *filter_expression,
- struct lttng_bytecode *filter,
- struct lttng_event_exclusion *exclusion,
- bool internal_event,
- struct ltt_ust_event **ust_event)
+ char *filter_expression,
+ struct lttng_bytecode *filter,
+ struct lttng_event_exclusion *exclusion,
+ bool internal_event,
+ struct ltt_ust_event **ust_event)
{
struct ltt_ust_event *local_ust_event;
enum lttng_error_code ret = LTTNG_OK;
switch (ev->loglevel_type) {
case LTTNG_EVENT_LOGLEVEL_ALL:
local_ust_event->attr.loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
- local_ust_event->attr.loglevel = -1; /* Force to -1 */
+ local_ust_event->attr.loglevel = -1; /* Force to -1 */
break;
case LTTNG_EVENT_LOGLEVEL_RANGE:
local_ust_event->attr.loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE;
lttng_ht_node_init_str(&local_ust_event->node, local_ust_event->attr.name);
DBG2("Trace UST event %s, loglevel (%d,%d) created",
- local_ust_event->attr.name, local_ust_event->attr.loglevel_type,
- local_ust_event->attr.loglevel);
+ local_ust_event->attr.name,
+ local_ust_event->attr.loglevel_type,
+ local_ust_event->attr.loglevel);
*ust_event = local_ust_event;
return ret;
}
-static
-int trace_ust_context_type_event_to_ust(
- enum lttng_event_context_type type)
+static int trace_ust_context_type_event_to_ust(enum lttng_event_context_type type)
{
int utype;
* Return 1 if contexts match, 0 otherwise.
*/
int trace_ust_match_context(const struct ltt_ust_context *uctx,
- const struct lttng_event_context *ctx)
+ const struct lttng_event_context *ctx)
{
int utype;
}
switch (utype) {
case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER:
- if (uctx->ctx.u.perf_counter.type
- != ctx->u.perf_counter.type) {
+ if (uctx->ctx.u.perf_counter.type != ctx->u.perf_counter.type) {
return 0;
}
- if (uctx->ctx.u.perf_counter.config
- != ctx->u.perf_counter.config) {
+ if (uctx->ctx.u.perf_counter.config != ctx->u.perf_counter.config) {
return 0;
}
if (strncmp(uctx->ctx.u.perf_counter.name,
- ctx->u.perf_counter.name,
- LTTNG_UST_ABI_SYM_NAME_LEN)) {
+ ctx->u.perf_counter.name,
+ LTTNG_UST_ABI_SYM_NAME_LEN)) {
return 0;
}
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
LTTNG_ASSERT(uctx->ctx.u.app_ctx.provider_name);
LTTNG_ASSERT(uctx->ctx.u.app_ctx.ctx_name);
- if (strcmp(uctx->ctx.u.app_ctx.provider_name,
- ctx->u.app_ctx.provider_name) ||
- strcmp(uctx->ctx.u.app_ctx.ctx_name,
- ctx->u.app_ctx.ctx_name)) {
+ if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) ||
+ strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name)) {
return 0;
}
default:
break;
-
}
return 1;
}
*
* Return pointer to structure or NULL.
*/
-struct ltt_ust_context *trace_ust_create_context(
- const struct lttng_event_context *ctx)
+struct ltt_ust_context *trace_ust_create_context(const struct lttng_event_context *ctx)
{
struct ltt_ust_context *uctx = NULL;
int utype;
case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER:
uctx->ctx.u.perf_counter.type = ctx->u.perf_counter.type;
uctx->ctx.u.perf_counter.config = ctx->u.perf_counter.config;
- strncpy(uctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name,
- LTTNG_UST_ABI_SYM_NAME_LEN);
+ strncpy(uctx->ctx.u.perf_counter.name,
+ ctx->u.perf_counter.name,
+ LTTNG_UST_ABI_SYM_NAME_LEN);
uctx->ctx.u.perf_counter.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
static void destroy_id_tracker_node_rcu(struct rcu_head *head)
{
- struct ust_id_tracker_node *tracker_node = caa_container_of(
- head, struct ust_id_tracker_node, node.head);
+ struct ust_id_tracker_node *tracker_node =
+ caa_container_of(head, struct ust_id_tracker_node, node.head);
free(tracker_node);
}
return;
}
rcu_read_lock();
- cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node,
- node.node) {
+ cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) {
int ret = lttng_ht_del(id_tracker->ht, &iter);
LTTNG_ASSERT(!ret);
id_tracker->ht = NULL;
}
-static struct ust_id_tracker_node *id_tracker_lookup(
- struct ust_id_tracker *id_tracker,
- int id,
- struct lttng_ht_iter *iter)
+static struct ust_id_tracker_node *
+id_tracker_lookup(struct ust_id_tracker *id_tracker, int id, struct lttng_ht_iter *iter)
{
unsigned long _id = (unsigned long) id;
struct lttng_ht_node_ulong *node;
}
static struct ust_id_tracker *get_id_tracker(struct ltt_ust_session *session,
- enum lttng_process_attr process_attr)
+ enum lttng_process_attr process_attr)
{
switch (process_attr) {
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
}
}
-static struct process_attr_tracker *_trace_ust_get_process_attr_tracker(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr)
+static struct process_attr_tracker *
+_trace_ust_get_process_attr_tracker(struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr)
{
switch (process_attr) {
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
}
}
-const struct process_attr_tracker *trace_ust_get_process_attr_tracker(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr)
+const struct process_attr_tracker *
+trace_ust_get_process_attr_tracker(struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr)
{
- return (const struct process_attr_tracker *)
- _trace_ust_get_process_attr_tracker(
- session, process_attr);
+ return (const struct process_attr_tracker *) _trace_ust_get_process_attr_tracker(
+ session, process_attr);
}
/*
* The session lock is held when calling this function.
*/
int trace_ust_id_tracker_lookup(enum lttng_process_attr process_attr,
- struct ltt_ust_session *session,
- int id)
+ struct ltt_ust_session *session,
+ int id)
{
struct lttng_ht_iter iter;
struct ust_id_tracker *id_tracker;
/*
* Called with the session lock held.
*/
-enum lttng_error_code trace_ust_process_attr_tracker_set_tracking_policy(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- enum lttng_tracking_policy policy)
+enum lttng_error_code
+trace_ust_process_attr_tracker_set_tracking_policy(struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ enum lttng_tracking_policy policy)
{
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
- struct ust_id_tracker *id_tracker =
- get_id_tracker(session, process_attr);
+ struct ust_id_tracker *id_tracker = get_id_tracker(session, process_attr);
struct process_attr_tracker *tracker =
- _trace_ust_get_process_attr_tracker(
- session, process_attr);
+ _trace_ust_get_process_attr_tracker(session, process_attr);
bool should_update_apps = false;
enum lttng_tracking_policy previous_policy;
}
/* Called with the session lock held. */
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_add_value(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_add_value(struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
enum lttng_error_code ret_code = LTTNG_OK;
bool should_update_apps = false;
- struct ust_id_tracker *id_tracker =
- get_id_tracker(session, process_attr);
+ struct ust_id_tracker *id_tracker = get_id_tracker(session, process_attr);
struct process_attr_tracker *tracker;
int integral_value;
enum process_attr_tracker_status status;
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME) {
uid_t uid;
- ret_code = utils_user_id_from_name(
- value->value.user_name, &uid);
+ ret_code = utils_user_id_from_name(value->value.user_name, &uid);
if (ret_code != LTTNG_OK) {
goto end;
}
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME) {
gid_t gid;
- ret_code = utils_group_id_from_name(
- value->value.group_name, &gid);
+ ret_code = utils_group_id_from_name(value->value.group_name, &gid);
if (ret_code != LTTNG_OK) {
goto end;
}
}
DBG("User space track %s %d for session id %" PRIu64,
- lttng_process_attr_to_string(process_attr),
- integral_value, session->id);
+ lttng_process_attr_to_string(process_attr),
+ integral_value,
+ session->id);
ret_code = (lttng_error_code) id_tracker_add_id(id_tracker, integral_value);
if (ret_code != LTTNG_OK) {
}
/* Called with the session lock held. */
-enum lttng_error_code trace_ust_process_attr_tracker_inclusion_set_remove_value(
- struct ltt_ust_session *session,
- enum lttng_process_attr process_attr,
- const struct process_attr_value *value)
+enum lttng_error_code
+trace_ust_process_attr_tracker_inclusion_set_remove_value(struct ltt_ust_session *session,
+ enum lttng_process_attr process_attr,
+ const struct process_attr_value *value)
{
enum lttng_error_code ret_code = LTTNG_OK;
bool should_update_apps = false;
- struct ust_id_tracker *id_tracker =
- get_id_tracker(session, process_attr);
+ struct ust_id_tracker *id_tracker = get_id_tracker(session, process_attr);
struct process_attr_tracker *tracker;
int integral_value;
enum process_attr_tracker_status status;
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME) {
uid_t uid;
- ret_code = utils_user_id_from_name(
- value->value.user_name, &uid);
+ ret_code = utils_user_id_from_name(value->value.user_name, &uid);
if (ret_code != LTTNG_OK) {
goto end;
}
if (value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME) {
gid_t gid;
- ret_code = utils_group_id_from_name(
- value->value.group_name, &gid);
+ ret_code = utils_group_id_from_name(value->value.group_name, &gid);
if (ret_code != LTTNG_OK) {
goto end;
}
goto end;
}
- status = process_attr_tracker_inclusion_set_remove_value(
- tracker, value);
+ status = process_attr_tracker_inclusion_set_remove_value(tracker, value);
if (status != PROCESS_ATTR_TRACKER_STATUS_OK) {
switch (status) {
case PROCESS_ATTR_TRACKER_STATUS_MISSING:
}
DBG("User space untrack %s %d for session id %" PRIu64,
- lttng_process_attr_to_string(process_attr),
- integral_value, session->id);
+ lttng_process_attr_to_string(process_attr),
+ integral_value,
+ session->id);
ret_code = (lttng_error_code) id_tracker_del_id(id_tracker, integral_value);
if (ret_code != LTTNG_OK) {
{
struct lttng_ht_node_ulong *node =
lttng::utils::container_of(head, <tng_ht_node_ulong::head);
- struct ltt_ust_context *ctx =
- lttng::utils::container_of(node, <t_ust_context::node);
+ struct ltt_ust_context *ctx = lttng::utils::container_of(node, <t_ust_context::node);
trace_ust_destroy_context(ctx);
}
LTTNG_ASSERT(ht);
rcu_read_lock();
- cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) {
/* Remove from ordered list. */
ctx = lttng::utils::container_of(node, <t_ust_context::node);
cds_list_del(&ctx->list);
*/
static void destroy_event_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_str *node =
- lttng::utils::container_of(head, <tng_ht_node_str::head);
- struct ltt_ust_event *event =
- lttng::utils::container_of(node, <t_ust_event::node);
+ struct lttng_ht_node_str *node = lttng::utils::container_of(head, <tng_ht_node_str::head);
+ struct ltt_ust_event *event = lttng::utils::container_of(node, <t_ust_event::node);
trace_ust_destroy_event(event);
}
LTTNG_ASSERT(events);
rcu_read_lock();
- cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) {
ret = lttng_ht_del(events, &iter);
LTTNG_ASSERT(!ret);
call_rcu(&node->head, destroy_event_rcu);
*/
static void destroy_channel_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_str *node =
- lttng::utils::container_of(head, <tng_ht_node_str::head);
- struct ltt_ust_channel *channel =
- lttng::utils::container_of(node, <t_ust_channel::node);
+ struct lttng_ht_node_str *node = lttng::utils::container_of(head, <tng_ht_node_str::head);
+ struct ltt_ust_channel *channel = lttng::utils::container_of(node, <t_ust_channel::node);
_trace_ust_destroy_channel(channel);
}
/*
* Remove an UST channel from a channel HT.
*/
-void trace_ust_delete_channel(struct lttng_ht *ht,
- struct ltt_ust_channel *channel)
+void trace_ust_delete_channel(struct lttng_ht *ht, struct ltt_ust_channel *channel)
{
int ret;
struct lttng_ht_iter iter;
struct buffer_reg_session *session_reg = NULL;
rcu_read_lock();
- cds_list_for_each_entry(uid_reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (uid_reg, &usess->buffer_reg_uid_list, lnode) {
lsu::registry_session *registry;
session_reg = uid_reg->registry;
LTTNG_ASSERT(channels);
rcu_read_lock();
- cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
+ cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) {
struct ltt_ust_channel *chan =
lttng::utils::container_of(node, <t_ust_channel::node);
destroy_domain_global(&session->domain_global);
rcu_read_lock();
- cds_lfht_for_each_entry(session->agents->ht, &iter.iter, agt, node.node) {
+ cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) {
int ret = lttng_ht_del(session->agents, &iter);
LTTNG_ASSERT(!ret);
lttng_ht_destroy(session->agents);
/* Cleanup UID buffer registry object(s). */
- cds_list_for_each_entry_safe(reg, sreg, &session->buffer_reg_uid_list,
- lnode) {
+ cds_list_for_each_entry_safe (reg, sreg, &session->buffer_reg_uid_list, lnode) {
cds_list_del(®->lnode);
buffer_reg_uid_remove(reg);
buffer_reg_uid_destroy(reg, session->consumer);
*
*/
-#include "lttng/tracker.h"
#include "common/dynamic-array.hpp"
#include "common/macros.hpp"
+#include "lttng/tracker.h"
#define _LGPL_SOURCE
-#include <grp.h>
-#include <pwd.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <urcu.h>
-#include <urcu/list.h>
-#include <urcu/rculfhash.h>
-
#include "tracker.hpp"
+
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/hashtable/utils.hpp>
#include <common/tracker.hpp>
+
#include <lttng/lttng-error.h>
+#include <grp.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <urcu.h>
+#include <urcu/list.h>
+#include <urcu/rculfhash.h>
+
struct process_attr_tracker {
enum lttng_tracking_policy policy;
struct cds_lfht *inclusion_set_ht;
static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head)
{
- struct process_attr_tracker_value_node *node = lttng::utils::container_of(
- rcu_head, &process_attr_tracker_value_node::rcu_head);
+ struct process_attr_tracker_value_node *node =
+ lttng::utils::container_of(rcu_head, &process_attr_tracker_value_node::rcu_head);
free(node);
}
return NULL;
}
- (void) process_attr_tracker_set_tracking_policy(
- tracker, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
+ (void) process_attr_tracker_set_tracking_policy(tracker, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
- tracker->inclusion_set_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ tracker->inclusion_set_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!tracker->inclusion_set_ht) {
goto error;
}
return NULL;
}
-static void process_attr_tracker_remove_value_node(
- struct process_attr_tracker *tracker,
- struct process_attr_tracker_value_node *value_node)
+static void
+process_attr_tracker_remove_value_node(struct process_attr_tracker *tracker,
+ struct process_attr_tracker_value_node *value_node)
{
- cds_lfht_del(tracker->inclusion_set_ht,
- &value_node->inclusion_set_ht_node);
+ cds_lfht_del(tracker->inclusion_set_ht, &value_node->inclusion_set_ht_node);
process_attr_value_destroy(value_node->value);
- call_rcu(&value_node->rcu_head,
- process_attr_tracker_value_node_rcu_free);
+ call_rcu(&value_node->rcu_head, process_attr_tracker_value_node_rcu_free);
}
-static void process_attr_tracker_clear_inclusion_set(
- struct process_attr_tracker *tracker)
+static void process_attr_tracker_clear_inclusion_set(struct process_attr_tracker *tracker)
{
int ret;
struct lttng_ht_iter iter;
}
rcu_read_lock();
- cds_lfht_for_each_entry (tracker->inclusion_set_ht, &iter.iter,
- value_node, inclusion_set_ht_node) {
+ cds_lfht_for_each_entry (
+ tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) {
process_attr_tracker_remove_value_node(tracker, value_node);
}
rcu_read_unlock();
tracker->inclusion_set_ht = NULL;
}
-static int process_attr_tracker_create_inclusion_set(
- struct process_attr_tracker *tracker)
+static int process_attr_tracker_create_inclusion_set(struct process_attr_tracker *tracker)
{
LTTNG_ASSERT(!tracker->inclusion_set_ht);
- tracker->inclusion_set_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ tracker->inclusion_set_ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
return tracker->inclusion_set_ht ? 0 : -1;
}
free(tracker);
}
-enum lttng_tracking_policy process_attr_tracker_get_tracking_policy(
- const struct process_attr_tracker *tracker)
+enum lttng_tracking_policy
+process_attr_tracker_get_tracking_policy(const struct process_attr_tracker *tracker)
{
return tracker->policy;
}
-int process_attr_tracker_set_tracking_policy(
- struct process_attr_tracker *tracker,
- enum lttng_tracking_policy tracking_policy)
+int process_attr_tracker_set_tracking_policy(struct process_attr_tracker *tracker,
+ enum lttng_tracking_policy tracking_policy)
{
int ret = 0;
return ret;
}
-static int match_inclusion_set_value(
- struct cds_lfht_node *node, const void *key)
+static int match_inclusion_set_value(struct cds_lfht_node *node, const void *key)
{
const struct process_attr_value *value_key = (process_attr_value *) key;
- const struct process_attr_tracker_value_node *value_node =
- caa_container_of(node,
- struct process_attr_tracker_value_node,
- inclusion_set_ht_node);
+ const struct process_attr_tracker_value_node *value_node = caa_container_of(
+ node, struct process_attr_tracker_value_node, inclusion_set_ht_node);
return process_attr_tracker_value_equal(value_node->value, value_key);
}
-static struct process_attr_tracker_value_node *process_attr_tracker_lookup(
- const struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+static struct process_attr_tracker_value_node *
+process_attr_tracker_lookup(const struct process_attr_tracker *tracker,
+ const struct process_attr_value *value)
{
struct cds_lfht_iter iter;
struct cds_lfht_node *node;
rcu_read_lock();
cds_lfht_lookup(tracker->inclusion_set_ht,
process_attr_value_hash(value),
- match_inclusion_set_value, value, &iter);
+ match_inclusion_set_value,
+ value,
+ &iter);
node = cds_lfht_iter_get_node(&iter);
rcu_read_unlock();
- return node ? lttng::utils::container_of(node,
- &process_attr_tracker_value_node::inclusion_set_ht_node) :
- NULL;
+ return node ? lttng::utils::container_of(
+ node, &process_attr_tracker_value_node::inclusion_set_ht_node) :
+ NULL;
}
/* Protected by session mutex held by caller. */
-enum process_attr_tracker_status process_attr_tracker_inclusion_set_add_value(
- struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+enum process_attr_tracker_status
+process_attr_tracker_inclusion_set_add_value(struct process_attr_tracker *tracker,
+ const struct process_attr_value *value)
{
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
struct process_attr_value *value_copy = NULL;
struct process_attr_tracker_value_node *value_node = NULL;
value_node->value = value_copy;
cds_lfht_add(tracker->inclusion_set_ht,
- process_attr_value_hash(value_copy),
- &value_node->inclusion_set_ht_node);
+ process_attr_value_hash(value_copy),
+ &value_node->inclusion_set_ht_node);
value_copy = NULL;
value_node = NULL;
end:
/* Protected by session mutex held by caller. */
enum process_attr_tracker_status
-process_attr_tracker_inclusion_set_remove_value(
- struct process_attr_tracker *tracker,
- const struct process_attr_value *value)
+process_attr_tracker_inclusion_set_remove_value(struct process_attr_tracker *tracker,
+ const struct process_attr_value *value)
{
struct process_attr_tracker_value_node *value_node;
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
rcu_read_lock();
if (tracker->policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
return status;
}
-enum process_attr_tracker_status process_attr_tracker_get_inclusion_set(
- const struct process_attr_tracker *tracker,
- struct lttng_process_attr_values **_values)
+enum process_attr_tracker_status
+process_attr_tracker_get_inclusion_set(const struct process_attr_tracker *tracker,
+ struct lttng_process_attr_values **_values)
{
struct lttng_ht_iter iter;
struct process_attr_tracker_value_node *value_node;
- enum process_attr_tracker_status status =
- PROCESS_ATTR_TRACKER_STATUS_OK;
+ enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
struct lttng_process_attr_values *values;
struct process_attr_value *new_value = NULL;
}
rcu_read_lock();
- cds_lfht_for_each_entry (tracker->inclusion_set_ht, &iter.iter,
- value_node, inclusion_set_ht_node) {
+ cds_lfht_for_each_entry (
+ tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) {
int ret;
new_value = process_attr_value_copy(value_node->value);
goto error_unlock;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &values->array, new_value);
+ ret = lttng_dynamic_pointer_array_add_pointer(&values->array, new_value);
if (ret) {
status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
goto error_unlock;
*/
#include "event-notifier-error-accounting.hpp"
+
+#include <lttng/action/action-internal.hpp>
#include <lttng/error-query-internal.hpp>
#include <lttng/trigger/trigger-internal.hpp>
-#include <lttng/action/action-internal.hpp>
-enum lttng_trigger_status lttng_trigger_add_error_results(
- const struct lttng_trigger *trigger __attribute__((unused)),
- struct lttng_error_query_results *results __attribute__((unused)))
+enum lttng_trigger_status lttng_trigger_add_error_results(const struct lttng_trigger *trigger
+ __attribute__((unused)),
+ struct lttng_error_query_results *results
+ __attribute__((unused)))
{
return LTTNG_TRIGGER_STATUS_OK;
}
-enum lttng_trigger_status lttng_trigger_condition_add_error_results(
- const struct lttng_trigger *trigger,
- struct lttng_error_query_results *results)
+enum lttng_trigger_status
+lttng_trigger_condition_add_error_results(const struct lttng_trigger *trigger,
+ struct lttng_error_query_results *results)
{
enum lttng_trigger_status status;
uint64_t discarded_tracer_messages_count;
uid_t trigger_owner;
status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
- status = lttng_trigger_get_owner_uid(trigger,
- &trigger_owner);
+ trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
+ status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
LTTNG_ASSERT(status == LTTNG_TRIGGER_STATUS_OK);
/*
}
error_accounting_status = event_notifier_error_accounting_get_count(
- trigger, &discarded_tracer_messages_count);
+ trigger, &discarded_tracer_messages_count);
if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
ERR("Failed to retrieve tracer discarded messages count for trigger: trigger name = '%s', trigger owner uid = %d",
- trigger_name, (int) trigger_owner);
+ trigger_name,
+ (int) trigger_owner);
status = LTTNG_TRIGGER_STATUS_ERROR;
goto end;
}
discarded_tracer_messages_counter = lttng_error_query_result_counter_create(
- "discarded tracer messages",
- "Count of messages discarded by the tracer due to a communication error with the session daemon",
- discarded_tracer_messages_count);
+ "discarded tracer messages",
+ "Count of messages discarded by the tracer due to a communication error with the session daemon",
+ discarded_tracer_messages_count);
if (!discarded_tracer_messages_counter) {
status = LTTNG_TRIGGER_STATUS_ERROR;
goto end;
}
- if (lttng_error_query_results_add_result(
- results, discarded_tracer_messages_counter)) {
+ if (lttng_error_query_results_add_result(results, discarded_tracer_messages_counter)) {
status = LTTNG_TRIGGER_STATUS_ERROR;
goto end;
}
return status;
}
-enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
- struct lttng_trigger *trigger,
- struct lttng_error_query_results *results)
+enum lttng_trigger_status
+lttng_trigger_add_action_error_query_results(struct lttng_trigger *trigger,
+ struct lttng_error_query_results *results)
{
enum lttng_trigger_status status;
const char *trigger_name;
enum lttng_action_status action_status;
status = lttng_trigger_get_name(trigger, &trigger_name);
- trigger_name = status == LTTNG_TRIGGER_STATUS_OK ?
- trigger_name : "(anonymous)";
- status = lttng_trigger_get_owner_uid(trigger,
- &trigger_owner);
+ trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
+ status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
LTTNG_ASSERT(status == LTTNG_TRIGGER_STATUS_OK);
- action_status = lttng_action_add_error_query_results(
- lttng_trigger_get_action(trigger), results);
+ action_status =
+ lttng_action_add_error_query_results(lttng_trigger_get_action(trigger), results);
switch (action_status) {
case LTTNG_ACTION_STATUS_OK:
break;
*
*/
-#include "tsdl-trace-class-visitor.hpp"
#include "clock-class.hpp"
+#include "tsdl-trace-class-visitor.hpp"
#include <common/exception.hpp>
#include <common/format.hpp>
#include <common/make-unique.hpp>
-#include <common/uuid.hpp>
#include <common/scope-exit.hpp>
+#include <common/uuid.hpp>
#include <vendor/optional.hpp>
* Although the CTF v1.8 specification recommends ignoring any leading underscore, Some readers,
* such as Babeltrace 1.x, expect special identifiers without a prepended underscore.
*/
-const std::unordered_set<std::string> safe_tsdl_identifiers = {
- "stream_id",
- "packet_size",
- "content_size",
- "id",
- "v",
- "timestamp",
- "events_discarded",
- "packet_seq_num",
- "timestamp_begin",
- "timestamp_end",
- "cpu_id",
- "magic",
- "uuid",
- "stream_instance_id"
-};
+const std::unordered_set<std::string> safe_tsdl_identifiers = { "stream_id",
+ "packet_size",
+ "content_size",
+ "id",
+ "v",
+ "timestamp",
+ "events_discarded",
+ "packet_seq_num",
+ "timestamp_begin",
+ "timestamp_end",
+ "cpu_id",
+ "magic",
+ "uuid",
+ "stream_instance_id" };
/*
* A previous implementation always prepended '_' to the identifiers in order to
new_identifier = "_";
/* Replace illegal characters by '_'. */
- std::locale c_locale{"C"};
+ std::locale c_locale{ "C" };
for (const auto current_char : original_identifier) {
if (!std::isalnum(current_char, c_locale) && current_char != '_') {
new_identifier += '_';
using type_lookup_function = std::function<const lst::type&(const lst::field_location&)>;
variant_tsdl_keyword_sanitizer(tsdl::details::type_overrider& type_overrides,
- type_lookup_function lookup_type) :
- _type_overrides{type_overrides}, _lookup_type(lookup_type)
+ type_lookup_function lookup_type) :
+ _type_overrides{ type_overrides }, _lookup_type(lookup_type)
{
}
{
}
- virtual void visit(const lst::floating_point_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::floating_point_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::signed_enumeration_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::signed_enumeration_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::unsigned_enumeration_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::unsigned_enumeration_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::static_length_array_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::static_length_array_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::dynamic_length_array_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::dynamic_length_array_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::static_length_blob_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::static_length_blob_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::dynamic_length_blob_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::dynamic_length_blob_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::null_terminated_string_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::null_terminated_string_type& type
+ __attribute__((unused))) override final
{
}
}
/*
- * Create a new enumeration type replacing any mapping that match, by name, the elements in `unsafe_names_found`
- * with a TSDL-safe version. Currently, unsafe identifiers are made safe by adding
- * a leading underscore.
+ * Create a new enumeration type replacing any mapping that match, by name, the elements in
+ * `unsafe_names_found` with a TSDL-safe version. Currently, unsafe identifiers are made
+ * safe by adding a leading underscore.
*/
template <typename MappingIntegerType>
lst::type::cuptr _create_sanitized_selector(
- const lst::typed_enumeration_type<MappingIntegerType>& original_selector,
- const unsafe_names& unsafe_names_found)
+ const lst::typed_enumeration_type<MappingIntegerType>& original_selector,
+ const unsafe_names& unsafe_names_found)
{
- auto new_mappings = std::make_shared<typename lst::typed_enumeration_type<
- MappingIntegerType>::mappings>();
+ auto new_mappings = std::make_shared<
+ typename lst::typed_enumeration_type<MappingIntegerType>::mappings>();
for (const auto& mapping : *original_selector.mappings_) {
if (unsafe_names_found.find(mapping.name.c_str()) ==
- unsafe_names_found.end()) {
+ unsafe_names_found.end()) {
/* Mapping is safe, simply copy it. */
new_mappings->emplace_back(mapping);
} else {
/* Unsafe mapping, rename it and keep the rest of its attributes. */
- new_mappings->emplace_back(
- fmt::format("_{}", mapping.name), mapping.range);
+ new_mappings->emplace_back(fmt::format("_{}", mapping.name),
+ mapping.range);
}
}
return lttng::make_unique<lst::typed_enumeration_type<MappingIntegerType>>(
- original_selector.alignment, original_selector.byte_order,
- original_selector.size, original_selector.base_, new_mappings);
+ original_selector.alignment,
+ original_selector.byte_order,
+ original_selector.size,
+ original_selector.base_,
+ new_mappings);
}
template <typename MappingIntegerType>
const typename lst::typed_enumeration_type<MappingIntegerType>::mapping&
_find_enumeration_mapping_by_range(
- const typename lst::typed_enumeration_type<MappingIntegerType>&
- enumeration_type,
- const typename lst::typed_enumeration_type<
- MappingIntegerType>::mapping::range_t& target_mapping_range)
+ const typename lst::typed_enumeration_type<MappingIntegerType>& enumeration_type,
+ const typename lst::typed_enumeration_type<MappingIntegerType>::mapping::range_t&
+ target_mapping_range)
{
for (const auto& mapping : *enumeration_type.mappings_) {
if (mapping.range == target_mapping_range) {
}
LTTNG_THROW_ERROR(fmt::format(
- "Failed to find mapping by range in enumeration while sanitizing a variant: target_mapping_range={}",
- target_mapping_range));
+ "Failed to find mapping by range in enumeration while sanitizing a variant: target_mapping_range={}",
+ target_mapping_range));
}
/*
* to produce a TSDL-safe version of the variant.
*/
template <typename MappingIntegerType>
- lst::type::cuptr _create_sanitized_variant(
- const lst::variant_type<MappingIntegerType>& original_variant)
+ lst::type::cuptr
+ _create_sanitized_variant(const lst::variant_type<MappingIntegerType>& original_variant)
{
typename lst::variant_type<MappingIntegerType>::choices new_choices;
- const auto& sanitized_selector = static_cast<
- const lst::typed_enumeration_type<MappingIntegerType>&>(
- _type_overrides.type(_lookup_type(
- original_variant.selector_field_location)));
+ const auto& sanitized_selector =
+ static_cast<const lst::typed_enumeration_type<MappingIntegerType>&>(
+ _type_overrides.type(
+ _lookup_type(original_variant.selector_field_location)));
/* Visit variant choices to sanitize them as needed. */
for (const auto& choice : original_variant.choices_) {
for (const auto& choice : original_variant.choices_) {
const auto& sanitized_choice_type = _type_overrides.type(*choice.second);
- new_choices.emplace_back(
- _find_enumeration_mapping_by_range(
- sanitized_selector, choice.first.range),
- sanitized_choice_type.copy());
+ new_choices.emplace_back(_find_enumeration_mapping_by_range(
+ sanitized_selector, choice.first.range),
+ sanitized_choice_type.copy());
}
return lttng::make_unique<lst::variant_type<MappingIntegerType>>(
- original_variant.alignment,
- original_variant.selector_field_location,
- std::move(new_choices));
+ original_variant.alignment,
+ original_variant.selector_field_location,
+ std::move(new_choices));
}
template <typename MappingIntegerType>
{
unsafe_names unsafe_names_found;
static const std::unordered_set<std::string> tsdl_protected_keywords = {
- "align",
- "callsite",
- "const",
- "char",
- "clock",
- "double",
- "enum",
- "env",
- "event",
- "floating_point",
- "float",
- "integer",
- "int",
- "long",
- "short",
- "signed",
- "stream",
- "string",
- "struct",
- "trace",
- "typealias",
- "typedef",
- "unsigned",
- "variant",
- "void",
- "_Bool",
- "_Complex",
- "_Imaginary",
+ "align", "callsite", "const", "char", "clock", "double",
+ "enum", "env", "event", "floating_point", "float", "integer",
+ "int", "long", "short", "signed", "stream", "string",
+ "struct", "trace", "typealias", "typedef", "unsigned", "variant",
+ "void", "_Bool", "_Complex", "_Imaginary",
};
for (const auto& choice : type.choices_) {
- if (tsdl_protected_keywords.find(choice.first.name) != tsdl_protected_keywords.cend()) {
- /* Choice name is illegal, we have to rename it and its matching mapping. */
+ if (tsdl_protected_keywords.find(choice.first.name) !=
+ tsdl_protected_keywords.cend()) {
+ /* Choice name is illegal, we have to rename it and its matching
+ * mapping. */
unsafe_names_found.insert(choice.first.name.c_str());
}
}
const auto& overriden_selector_type = _type_overrides.type(original_selector_type);
auto sanitized_selector_type = _create_sanitized_selector(
- static_cast<const lst::typed_enumeration_type<MappingIntegerType>&>(
- overriden_selector_type), unsafe_names_found);
+ static_cast<const lst::typed_enumeration_type<MappingIntegerType>&>(
+ overriden_selector_type),
+ unsafe_names_found);
_type_overrides.publish(original_selector_type, std::move(sanitized_selector_type));
auto sanitized_variant_type = _create_sanitized_variant(
- static_cast<const lst::variant_type<MappingIntegerType>&>(type));
+ static_cast<const lst::variant_type<MappingIntegerType>&>(type));
_type_overrides.publish(type, std::move(sanitized_variant_type));
}
- virtual void visit(const lst::variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+ virtual void visit(const lst::variant_type<
+ lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type)
+ override final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+ virtual void visit(const lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type)
+ override final
{
visit_variant(type);
}
- virtual void visit(const lst::static_length_string_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::static_length_string_type& type
+ __attribute__((unused))) override final
{
}
- virtual void visit(const lst::dynamic_length_string_type& type __attribute__((unused))) override final
+ virtual void visit(const lst::dynamic_length_string_type& type
+ __attribute__((unused))) override final
{
}
public lttng::sessiond::trace::type_visitor {
public:
tsdl_field_visitor(const lst::abi& abi,
- unsigned int indentation_level,
- const tsdl::details::type_overrider& type_overrides,
- const nonstd::optional<std::string>& in_default_clock_class_name =
- nonstd::nullopt) :
- _indentation_level{indentation_level},
- _trace_abi{abi},
- _bypass_identifier_escape{false},
- _default_clock_class_name{in_default_clock_class_name ?
- in_default_clock_class_name->c_str() :
- nullptr},
- _type_overrides{type_overrides}
+ unsigned int indentation_level,
+ const tsdl::details::type_overrider& type_overrides,
+ const nonstd::optional<std::string>& in_default_clock_class_name =
+ nonstd::nullopt) :
+ _indentation_level{ indentation_level },
+ _trace_abi{ abi },
+ _bypass_identifier_escape{ false },
+ _default_clock_class_name{ in_default_clock_class_name ?
+ in_default_clock_class_name->c_str() :
+ nullptr },
+ _type_overrides{ type_overrides }
{
}
* constraint. The name of this structure is generated using the field's name.
*/
_current_field_name.push(_bypass_identifier_escape ?
- field.name : escape_tsdl_identifier(field.name));
+ field.name :
+ escape_tsdl_identifier(field.name));
_type_overrides.type(field.get_type()).accept(*this);
_description += " ";
_description += _current_field_name.top();
/* Mandatory properties (no defaults). */
_description += fmt::format("size = {size}; align = {alignment};",
- fmt::arg("size", type.size),
- fmt::arg("alignment", type.alignment));
+ fmt::arg("size", type.size),
+ fmt::arg("alignment", type.alignment));
/* Defaults to unsigned. */
if (type.signedness_ == lst::integer_type::signedness::SIGNED) {
break;
default:
LTTNG_THROW_ERROR(fmt::format(
- "Unexpected base encountered while serializing integer type to TSDL: base = {}",
- (int) type.base_));
+ "Unexpected base encountered while serializing integer type to TSDL: base = {}",
+ (int) type.base_));
}
_description += fmt::format(" base = {};", base);
/* Defaults to the trace's native byte order. */
if (type.byte_order != _trace_abi.byte_order) {
- const auto byte_order_str = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le";
+ const auto byte_order_str =
+ type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le";
_description += fmt::format(" byte_order = {};", byte_order_str);
}
break;
default:
LTTNG_THROW_ERROR(fmt::format(
- "Unexpected encoding encountered while serializing integer type to TSDL: encoding = {}",
- (int) *_current_integer_encoding_override));
+ "Unexpected encoding encountered while serializing integer type to TSDL: encoding = {}",
+ (int) *_current_integer_encoding_override));
}
_description += fmt::format(" encoding = {};", encoding_str);
_current_integer_encoding_override.reset();
}
- if (std::find(type.roles_.begin(), type.roles_.end(),
- lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP) !=
- type.roles_.end() ||
- std::find(type.roles_.begin(), type.roles_.end(),
- lst::integer_type::role::
- PACKET_END_DEFAULT_CLOCK_TIMESTAMP) !=
- type.roles_.end()) {
+ if (std::find(type.roles_.begin(),
+ type.roles_.end(),
+ lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP) !=
+ type.roles_.end() ||
+ std::find(type.roles_.begin(),
+ type.roles_.end(),
+ lst::integer_type::role::PACKET_END_DEFAULT_CLOCK_TIMESTAMP) !=
+ type.roles_.end()) {
LTTNG_ASSERT(_default_clock_class_name);
- _description += fmt::format(
- " map = clock.{}.value;", _default_clock_class_name);
+ _description +=
+ fmt::format(" map = clock.{}.value;", _default_clock_class_name);
}
_description += " }";
virtual void visit(const lst::floating_point_type& type) override final
{
_description += fmt::format(
- "floating_point {{ align = {alignment}; mant_dig = {mantissa_digits}; exp_dig = {exponent_digits};",
- fmt::arg("alignment", type.alignment),
- fmt::arg("mantissa_digits", type.mantissa_digits),
- fmt::arg("exponent_digits", type.exponent_digits));
+ "floating_point {{ align = {alignment}; mant_dig = {mantissa_digits}; exp_dig = {exponent_digits};",
+ fmt::arg("alignment", type.alignment),
+ fmt::arg("mantissa_digits", type.mantissa_digits),
+ fmt::arg("exponent_digits", type.exponent_digits));
/* Defaults to the trace's native byte order. */
if (type.byte_order != _trace_abi.byte_order) {
- const auto byte_order_str = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le";
+ const auto byte_order_str =
+ type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le";
_description += fmt::format(" byte_order = {};", byte_order_str);
}
_description.resize(_description.size() + mappings_indentation_level, '\t');
if (mapping.range.begin == mapping.range.end) {
- _description += fmt::format(
- "\"{mapping_name}\" = {mapping_value}",
- fmt::arg("mapping_name", mapping.name),
- fmt::arg("mapping_value", mapping.range.begin));
+ _description +=
+ fmt::format("\"{mapping_name}\" = {mapping_value}",
+ fmt::arg("mapping_name", mapping.name),
+ fmt::arg("mapping_value", mapping.range.begin));
} else {
_description += fmt::format(
- "\"{mapping_name}\" = {mapping_range_begin} ... {mapping_range_end}",
- fmt::arg("mapping_name", mapping.name),
- fmt::arg("mapping_range_begin",
- mapping.range.begin),
- fmt::arg("mapping_range_end", mapping.range.end));
+ "\"{mapping_name}\" = {mapping_range_begin} ... {mapping_range_end}",
+ fmt::arg("mapping_name", mapping.name),
+ fmt::arg("mapping_range_begin", mapping.range.begin),
+ fmt::arg("mapping_range_end", mapping.range.end));
}
first_mapping = false;
if (type.alignment != 0) {
LTTNG_ASSERT(_current_field_name.size() > 0);
_description += fmt::format(
- "struct {{ }} align({alignment}) {field_name}_padding;\n",
- fmt::arg("alignment", type.alignment),
- fmt::arg("field_name", _current_field_name.top()));
+ "struct {{ }} align({alignment}) {field_name}_padding;\n",
+ fmt::arg("alignment", type.alignment),
+ fmt::arg("field_name", _current_field_name.top()));
_description.resize(_description.size() + _indentation_level, '\t');
}
*/
LTTNG_ASSERT(_current_field_name.size() > 0);
_description += fmt::format(
- "struct {{ }} align({alignment}) {field_name}_padding;\n",
- fmt::arg("alignment", type.alignment),
- fmt::arg("field_name", _current_field_name.top()));
+ "struct {{ }} align({alignment}) {field_name}_padding;\n",
+ fmt::arg("alignment", type.alignment),
+ fmt::arg("field_name", _current_field_name.top()));
_description.resize(_description.size() + _indentation_level, '\t');
}
type.element_type->accept(*this);
- _type_suffixes.emplace(fmt::format("[{}]",
- _bypass_identifier_escape ?
- *(type.length_field_location.elements_.end() - 1) :
- escape_tsdl_identifier(*(type.length_field_location.elements_.end() - 1))));
+ _type_suffixes.emplace(fmt::format(
+ "[{}]",
+ _bypass_identifier_escape ?
+ *(type.length_field_location.elements_.end() - 1) :
+ escape_tsdl_identifier(
+ *(type.length_field_location.elements_.end() - 1))));
}
virtual void visit(const lst::static_length_blob_type& type) override final
{
- /* This type doesn't exist in CTF 1.x, express it as a static length array of uint8_t. */
- std::unique_ptr<const lst::type> uint8_element = lttng::make_unique<lst::integer_type>(8,
- _trace_abi.byte_order, 8, lst::integer_type::signedness::UNSIGNED,
+ /* This type doesn't exist in CTF 1.x, express it as a static length array of
+ * uint8_t. */
+ std::unique_ptr<const lst::type> uint8_element =
+ lttng::make_unique<lst::integer_type>(
+ 8,
+ _trace_abi.byte_order,
+ 8,
+ lst::integer_type::signedness::UNSIGNED,
lst::integer_type::base::HEXADECIMAL);
const auto array = lttng::make_unique<lst::static_length_array_type>(
- type.alignment, std::move(uint8_element), type.length_bytes);
+ type.alignment, std::move(uint8_element), type.length_bytes);
visit(*array);
}
virtual void visit(const lst::dynamic_length_blob_type& type) override final
{
- /* This type doesn't exist in CTF 1.x, express it as a dynamic length array of uint8_t. */
- std::unique_ptr<const lst::type> uint8_element = lttng::make_unique<lst::integer_type>(0,
- _trace_abi.byte_order, 8, lst::integer_type::signedness::UNSIGNED,
+ /* This type doesn't exist in CTF 1.x, express it as a dynamic length array of
+ * uint8_t. */
+ std::unique_ptr<const lst::type> uint8_element =
+ lttng::make_unique<lst::integer_type>(
+ 0,
+ _trace_abi.byte_order,
+ 8,
+ lst::integer_type::signedness::UNSIGNED,
lst::integer_type::base::HEXADECIMAL);
const auto array = lttng::make_unique<lst::dynamic_length_array_type>(
- type.alignment, std::move(uint8_element), type.length_field_location);
+ type.alignment, std::move(uint8_element), type.length_field_location);
visit(*array);
}
if (type.alignment != 0) {
LTTNG_ASSERT(_current_field_name.size() > 0);
_description += fmt::format(
- "struct {{ }} align({alignment}) {field_name}_padding;\n",
- fmt::arg("alignment", type.alignment),
- fmt::arg("field_name", _current_field_name.top()));
+ "struct {{ }} align({alignment}) {field_name}_padding;\n",
+ fmt::arg("alignment", type.alignment),
+ fmt::arg("field_name", _current_field_name.top()));
_description.resize(_description.size() + _indentation_level, '\t');
}
_indentation_level++;
- _description += fmt::format("variant <{}> {{\n",
- _bypass_identifier_escape ?
- *(type.selector_field_location.elements_.end() - 1) :
- escape_tsdl_identifier(*(type.selector_field_location.elements_.end() - 1)));
+ _description += fmt::format(
+ "variant <{}> {{\n",
+ _bypass_identifier_escape ?
+ *(type.selector_field_location.elements_.end() - 1) :
+ escape_tsdl_identifier(
+ *(type.selector_field_location.elements_.end() - 1)));
/*
* The CTF 1.8 specification only recommends that implementations ignore
_description += "}";
}
- virtual void visit(const lst::variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+ virtual void visit(const lst::variant_type<
+ lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type)
+ override final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+ virtual void visit(const lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type)
+ override final
{
visit_variant(type);
}
lst::type::cuptr create_character_type(enum lst::string_type::encoding encoding)
{
_current_integer_encoding_override = encoding;
- return lttng::make_unique<lst::integer_type>(8, _trace_abi.byte_order, 8,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL);
+ return lttng::make_unique<lst::integer_type>(
+ 8,
+ _trace_abi.byte_order,
+ 8,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL);
}
virtual void visit(const lst::static_length_string_type& type) override final
* an encoding specified.
*/
const auto char_array = lttng::make_unique<lst::static_length_array_type>(
- type.alignment, create_character_type(type.encoding_), type.length);
+ type.alignment, create_character_type(type.encoding_), type.length);
visit(*char_array);
}
* an encoding specified.
*/
const auto char_sequence = lttng::make_unique<lst::dynamic_length_array_type>(
- type.alignment, create_character_type(type.encoding_),
- type.length_field_location);
+ type.alignment,
+ create_character_type(type.encoding_),
+ type.length_field_location);
visit(*char_sequence);
}
class tsdl_trace_environment_visitor : public lst::trace_class_environment_visitor {
public:
- tsdl_trace_environment_visitor() : _environment{"env {\n"}
+ tsdl_trace_environment_visitor() : _environment{ "env {\n" }
{
}
virtual void visit(const lst::environment_field<const char *>& field) override
{
- _environment += fmt::format(" {} = \"{}\";\n", field.name,
- escape_tsdl_env_string_value(field.value));
+ _environment += fmt::format(
+ " {} = \"{}\";\n", field.name, escape_tsdl_env_string_value(field.value));
}
/* Only call once. */
};
} /* namespace */
-tsdl::trace_class_visitor::trace_class_visitor(const lst::abi& trace_abi,
- tsdl::append_metadata_fragment_function append_metadata_fragment) :
- _trace_abi{trace_abi},
- _append_metadata_fragment(append_metadata_fragment)
+tsdl::trace_class_visitor::trace_class_visitor(
+ const lst::abi& trace_abi,
+ tsdl::append_metadata_fragment_function append_metadata_fragment) :
+ _trace_abi{ trace_abi }, _append_metadata_fragment(append_metadata_fragment)
{
}
LTTNG_ASSERT(!_current_trace_class || _current_trace_class == &trace_class);
_current_trace_class = &trace_class;
- tsdl_field_visitor packet_header_visitor{trace_class.abi, 1, _sanitized_types_overrides};
+ tsdl_field_visitor packet_header_visitor{ trace_class.abi, 1, _sanitized_types_overrides };
trace_class.packet_header()->accept(packet_header_visitor);
/* Declare type aliases, trace class, and packet header. */
auto trace_class_tsdl = fmt::format(
- "/* CTF {ctf_major}.{ctf_minor} */\n\n"
- "trace {{\n"
- " major = {ctf_major};\n"
- " minor = {ctf_minor};\n"
- " uuid = \"{uuid}\";\n"
- " byte_order = {byte_order};\n"
- " packet.header := {packet_header_layout};\n"
- "}};\n\n",
- fmt::arg("ctf_major", ctf_spec_major),
- fmt::arg("ctf_minor", ctf_spec_minor),
- fmt::arg("uint8_t_alignment", trace_class.abi.uint8_t_alignment),
- fmt::arg("uint16_t_alignment", trace_class.abi.uint16_t_alignment),
- fmt::arg("uint32_t_alignment", trace_class.abi.uint32_t_alignment),
- fmt::arg("uint64_t_alignment", trace_class.abi.uint64_t_alignment),
- fmt::arg("long_alignment", trace_class.abi.long_alignment),
- fmt::arg("long_size", trace_class.abi.long_alignment),
- fmt::arg("bits_per_long", trace_class.abi.bits_per_long),
- fmt::arg("uuid", lttng::utils::uuid_to_str(trace_class.uuid)),
- fmt::arg("byte_order",
- trace_class.abi.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le"),
- fmt::arg("packet_header_layout", packet_header_visitor.move_description()));
+ "/* CTF {ctf_major}.{ctf_minor} */\n\n"
+ "trace {{\n"
+ " major = {ctf_major};\n"
+ " minor = {ctf_minor};\n"
+ " uuid = \"{uuid}\";\n"
+ " byte_order = {byte_order};\n"
+ " packet.header := {packet_header_layout};\n"
+ "}};\n\n",
+ fmt::arg("ctf_major", ctf_spec_major),
+ fmt::arg("ctf_minor", ctf_spec_minor),
+ fmt::arg("uint8_t_alignment", trace_class.abi.uint8_t_alignment),
+ fmt::arg("uint16_t_alignment", trace_class.abi.uint16_t_alignment),
+ fmt::arg("uint32_t_alignment", trace_class.abi.uint32_t_alignment),
+ fmt::arg("uint64_t_alignment", trace_class.abi.uint64_t_alignment),
+ fmt::arg("long_alignment", trace_class.abi.long_alignment),
+ fmt::arg("long_size", trace_class.abi.long_alignment),
+ fmt::arg("bits_per_long", trace_class.abi.bits_per_long),
+ fmt::arg("uuid", lttng::utils::uuid_to_str(trace_class.uuid)),
+ fmt::arg("byte_order",
+ trace_class.abi.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le"),
+ fmt::arg("packet_header_layout", packet_header_visitor.move_description()));
/* Declare trace scope and type aliases. */
append_metadata_fragment(trace_class_tsdl);
void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::clock_class& clock_class)
{
auto uuid_str = clock_class.uuid ?
- fmt::format(" uuid = \"{}\";\n",
- lttng::utils::uuid_to_str(*clock_class.uuid)) :
- "";
+ fmt::format(" uuid = \"{}\";\n", lttng::utils::uuid_to_str(*clock_class.uuid)) :
+ "";
/* Assumes a single clock that maps to specific stream class fields/roles. */
- auto clock_class_str = fmt::format(
- "clock {{\n"
- " name = \"{name}\";\n"
- /* Optional uuid. */
- "{uuid}"
- " description = \"{description}\";\n"
- " freq = {frequency};\n"
- " offset = {offset};\n"
- "}};\n"
- "\n",
- fmt::arg("name", clock_class.name),
- fmt::arg("uuid", uuid_str),
- fmt::arg("description", clock_class.description),
- fmt::arg("frequency", clock_class.frequency),
- fmt::arg("offset", clock_class.offset));
+ auto clock_class_str = fmt::format("clock {{\n"
+ " name = \"{name}\";\n"
+ /* Optional uuid. */
+ "{uuid}"
+ " description = \"{description}\";\n"
+ " freq = {frequency};\n"
+ " offset = {offset};\n"
+ "}};\n"
+ "\n",
+ fmt::arg("name", clock_class.name),
+ fmt::arg("uuid", uuid_str),
+ fmt::arg("description", clock_class.description),
+ fmt::arg("frequency", clock_class.frequency),
+ fmt::arg("offset", clock_class.offset));
append_metadata_fragment(clock_class_str);
}
void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class& stream_class)
{
_current_stream_class = &stream_class;
- const auto clear_stream_class_on_exit = lttng::make_scope_exit(
- [this]() noexcept { _current_stream_class = nullptr; });
+ const auto clear_stream_class_on_exit =
+ lttng::make_scope_exit([this]() noexcept { _current_stream_class = nullptr; });
auto stream_class_str = fmt::format("stream {{\n"
- " id = {};\n", stream_class.id);
- variant_tsdl_keyword_sanitizer variant_sanitizer(_sanitized_types_overrides,
- [this](const lttng::sessiond::trace::field_location& location)
- -> const lst::type& {
- return _lookup_field_type(location);
- });
+ " id = {};\n",
+ stream_class.id);
+ variant_tsdl_keyword_sanitizer variant_sanitizer(
+ _sanitized_types_overrides,
+ [this](const lttng::sessiond::trace::field_location& location) -> const lst::type& {
+ return _lookup_field_type(location);
+ });
const auto *event_header = stream_class.event_header();
if (event_header) {
- tsdl_field_visitor event_header_visitor{_trace_abi, 1, _sanitized_types_overrides,
- stream_class.default_clock_class_name};
+ tsdl_field_visitor event_header_visitor{ _trace_abi,
+ 1,
+ _sanitized_types_overrides,
+ stream_class.default_clock_class_name };
event_header->accept(variant_sanitizer);
event_header->accept(event_header_visitor);
stream_class_str += fmt::format(" event.header := {};\n",
- event_header_visitor.move_description());
+ event_header_visitor.move_description());
}
const auto *packet_context = stream_class.packet_context();
if (packet_context) {
- tsdl_field_visitor packet_context_visitor{_trace_abi, 1, _sanitized_types_overrides,
- stream_class.default_clock_class_name};
+ tsdl_field_visitor packet_context_visitor{ _trace_abi,
+ 1,
+ _sanitized_types_overrides,
+ stream_class.default_clock_class_name };
packet_context->accept(variant_sanitizer);
packet_context->accept(packet_context_visitor);
stream_class_str += fmt::format(" packet.context := {};\n",
- packet_context_visitor.move_description());
+ packet_context_visitor.move_description());
}
const auto *event_context = stream_class.event_context();
if (event_context) {
- tsdl_field_visitor event_context_visitor{_trace_abi, 1, _sanitized_types_overrides};
+ tsdl_field_visitor event_context_visitor{ _trace_abi,
+ 1,
+ _sanitized_types_overrides };
event_context->accept(variant_sanitizer);
event_context->accept(event_context_visitor);
stream_class_str += fmt::format(" event.context := {};\n",
- event_context_visitor.move_description());
+ event_context_visitor.move_description());
}
stream_class_str += "};\n\n";
void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::event_class& event_class)
{
_current_event_class = &event_class;
- const auto clear_event_class_on_exit = lttng::make_scope_exit(
- [this]() noexcept { _current_event_class = nullptr; });
+ const auto clear_event_class_on_exit =
+ lttng::make_scope_exit([this]() noexcept { _current_event_class = nullptr; });
auto event_class_str = fmt::format("event {{\n"
" name = \"{name}\";\n"
" id = {id};\n"
" stream_id = {stream_class_id};\n"
" loglevel = {log_level};\n",
- fmt::arg("name", event_class.name),
- fmt::arg("id", event_class.id),
- fmt::arg("stream_class_id", event_class.stream_class_id),
- fmt::arg("log_level", event_class.log_level));
+ fmt::arg("name", event_class.name),
+ fmt::arg("id", event_class.id),
+ fmt::arg("stream_class_id", event_class.stream_class_id),
+ fmt::arg("log_level", event_class.log_level));
if (event_class.model_emf_uri) {
- event_class_str += fmt::format(
- " model.emf.uri = \"{}\";\n", *event_class.model_emf_uri);
+ event_class_str +=
+ fmt::format(" model.emf.uri = \"{}\";\n", *event_class.model_emf_uri);
}
- tsdl_field_visitor payload_visitor{_trace_abi, 1, _sanitized_types_overrides};
- variant_tsdl_keyword_sanitizer variant_sanitizer(_sanitized_types_overrides,
- [this](const lttng::sessiond::trace::field_location& location)
- -> const lst::type& {
- return _lookup_field_type(location);
- });
+ tsdl_field_visitor payload_visitor{ _trace_abi, 1, _sanitized_types_overrides };
+ variant_tsdl_keyword_sanitizer variant_sanitizer(
+ _sanitized_types_overrides,
+ [this](const lttng::sessiond::trace::field_location& location) -> const lst::type& {
+ return _lookup_field_type(location);
+ });
event_class.payload->accept(variant_sanitizer);
event_class.payload->accept(payload_visitor);
- event_class_str += fmt::format(
- " fields := {};\n}};\n\n", payload_visitor.move_description());
+ event_class_str +=
+ fmt::format(" fields := {};\n}};\n\n", payload_visitor.move_description());
append_metadata_fragment(event_class_str);
}
-void tsdl::details::type_overrider::publish(
- const lttng::sessiond::trace::type& original_type,
- lttng::sessiond::trace::type::cuptr new_type_override)
+void tsdl::details::type_overrider::publish(const lttng::sessiond::trace::type& original_type,
+ lttng::sessiond::trace::type::cuptr new_type_override)
{
auto current_override = _overriden_types.find(&original_type);
if (current_override != _overriden_types.end()) {
current_override->second = std::move(new_type_override);
} else {
- _overriden_types.insert(std::make_pair(&original_type, std::move(new_type_override)));
+ _overriden_types.insert(
+ std::make_pair(&original_type, std::move(new_type_override)));
}
}
-const lst::type& tsdl::details::type_overrider::type(
- const lttng::sessiond::trace::type& original) const noexcept
+const lst::type&
+tsdl::details::type_overrider::type(const lttng::sessiond::trace::type& original) const noexcept
{
const auto result = _overriden_types.find(&original);
}
namespace {
-const lttng::sessiond::trace::type& lookup_type_from_root_type(
- const lttng::sessiond::trace::type& root_type,
- const lttng::sessiond::trace::field_location& field_location)
+const lttng::sessiond::trace::type&
+lookup_type_from_root_type(const lttng::sessiond::trace::type& root_type,
+ const lttng::sessiond::trace::field_location& field_location)
{
const auto *type = &root_type;
*/
if (!struct_type) {
LTTNG_THROW_ERROR(fmt::format(
- "Encountered a type that is not a structure while traversing field location: field-location=`{}`",
- field_location));
+ "Encountered a type that is not a structure while traversing field location: field-location=`{}`",
+ field_location));
}
- const auto field_found_it = std::find_if(struct_type->fields_.cbegin(),
- struct_type->fields_.cend(),
- [&location_element](const lst::field::cuptr& struct_field) {
- return struct_field->name == location_element;
- });
+ const auto field_found_it =
+ std::find_if(struct_type->fields_.cbegin(),
+ struct_type->fields_.cend(),
+ [&location_element](const lst::field::cuptr& struct_field) {
+ return struct_field->name == location_element;
+ });
if (field_found_it == struct_type->fields_.cend()) {
LTTNG_THROW_ERROR(fmt::format(
- "Failed to find field using field location: field-name:=`{field_name}`, field-location=`{field_location}`",
- fmt::arg("field_location", field_location),
- fmt::arg("field_name", location_element)));
+ "Failed to find field using field location: field-name:=`{field_name}`, field-location=`{field_location}`",
+ fmt::arg("field_location", field_location),
+ fmt::arg("field_name", location_element)));
}
type = &(*field_found_it)->get_type();
* as found in the trace hierarchy.
*/
const lttng::sessiond::trace::type& lttng::sessiond::tsdl::trace_class_visitor::_lookup_field_type(
- const lttng::sessiond::trace::field_location& location) const
+ const lttng::sessiond::trace::field_location& location) const
{
/* Validate the look-up is happening in a valid visit context. */
switch (location.root_) {
case lst::field_location::root::EVENT_RECORD_PAYLOAD:
if (!_current_event_class) {
LTTNG_THROW_ERROR(
- "Field type look-up failure: no current event class in visitor's context");
+ "Field type look-up failure: no current event class in visitor's context");
}
/* fall through. */
case lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT:
case lst::field_location::root::PACKET_CONTEXT:
if (!_current_stream_class) {
LTTNG_THROW_ERROR(
- "Field type look-up failure: no current stream class in visitor's context");
+ "Field type look-up failure: no current stream class in visitor's context");
}
/* fall through. */
case lst::field_location::root::PACKET_HEADER:
if (!_current_trace_class) {
LTTNG_THROW_ERROR(
- "Field type look-up failure: no current trace class in visitor's context");
+ "Field type look-up failure: no current trace class in visitor's context");
}
break;
case lst::field_location::root::EVENT_RECORD_SPECIFIC_CONTEXT:
LTTNG_THROW_UNSUPPORTED_ERROR(
- "Field type look-up failure: event-record specific contexts are not supported");
+ "Field type look-up failure: event-record specific contexts are not supported");
default:
LTTNG_THROW_UNSUPPORTED_ERROR(
- "Field type look-up failure: unknown field location root");
+ "Field type look-up failure: unknown field location root");
}
switch (location.root_) {
case lst::field_location::root::PACKET_HEADER:
- return lookup_type_from_root_type(
- *_current_trace_class->packet_header(), location);
+ return lookup_type_from_root_type(*_current_trace_class->packet_header(), location);
case lst::field_location::root::PACKET_CONTEXT:
- return lookup_type_from_root_type(
- *_current_stream_class->packet_context(), location);
+ return lookup_type_from_root_type(*_current_stream_class->packet_context(),
+ location);
case lst::field_location::root::EVENT_RECORD_HEADER:
- return lookup_type_from_root_type(
- *_current_stream_class->event_header(), location);
+ return lookup_type_from_root_type(*_current_stream_class->event_header(), location);
case lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT:
- return lookup_type_from_root_type(
- *_current_stream_class->event_context(), location);
+ return lookup_type_from_root_type(*_current_stream_class->event_context(),
+ location);
case lst::field_location::root::EVENT_RECORD_PAYLOAD:
- return lookup_type_from_root_type(
- *_current_event_class->payload, location);
+ return lookup_type_from_root_type(*_current_event_class->payload, location);
case lst::field_location::root::EVENT_RECORD_SPECIFIC_CONTEXT:
default:
/* Unreachable as it was checked before. */
struct lttng_ht *ust_app_ht_by_sock;
struct lttng_ht *ust_app_ht_by_notify_sock;
-static
-int ust_app_flush_app_session(struct ust_app *app, struct ust_app_session *ua_sess);
+static int ust_app_flush_app_session(struct ust_app *app, struct ust_app_session *ua_sess);
/* Next available channel key. Access under next_channel_key_lock. */
static uint64_t _next_channel_key;
* A registry per UID object MUST exists before calling this function or else
* it LTTNG_ASSERT() if not found. RCU read side lock must be acquired.
*/
-static lsu::registry_session *get_session_registry(
- const struct ust_app_session *ua_sess)
+static lsu::registry_session *get_session_registry(const struct ust_app_session *ua_sess)
{
lsu::registry_session *registry = NULL;
}
case LTTNG_BUFFER_PER_UID:
{
- struct buffer_reg_uid *reg_uid = buffer_reg_uid_find(
- ua_sess->tracing_id, ua_sess->bits_per_long,
- lttng_credentials_get_uid(&ua_sess->real_credentials));
+ struct buffer_reg_uid *reg_uid =
+ buffer_reg_uid_find(ua_sess->tracing_id,
+ ua_sess->bits_per_long,
+ lttng_credentials_get_uid(&ua_sess->real_credentials));
if (!reg_uid) {
goto error;
}
return registry;
}
-lsu::registry_session::locked_ptr
-get_locked_session_registry(const struct ust_app_session *ua_sess)
+lsu::registry_session::locked_ptr get_locked_session_registry(const struct ust_app_session *ua_sess)
{
auto session = get_session_registry(ua_sess);
if (session) {
pthread_mutex_lock(&session->_lock);
}
- return lsu::registry_session::locked_ptr{session};
+ return lsu::registry_session::locked_ptr{ session };
}
} /* namespace */
return ret;
}
-static void copy_channel_attr_to_ustctl(
- struct lttng_ust_ctl_consumer_channel_attr *attr,
- struct lttng_ust_abi_channel_attr *uattr)
+static void copy_channel_attr_to_ustctl(struct lttng_ust_ctl_consumer_channel_attr *attr,
+ struct lttng_ust_abi_channel_attr *uattr)
{
/* Copy event attributes since the layout is different. */
attr->subbuf_size = uattr->subbuf_size;
/* Event loglevel. */
if (ev_loglevel_value != key->loglevel_type) {
- if (event->attr.loglevel_type == LTTNG_UST_ABI_LOGLEVEL_ALL
- && key->loglevel_type == 0 &&
- ev_loglevel_value == -1) {
+ if (event->attr.loglevel_type == LTTNG_UST_ABI_LOGLEVEL_ALL &&
+ key->loglevel_type == 0 && ev_loglevel_value == -1) {
/*
* Match is accepted. This is because on event creation, the
* loglevel is set to -1 if the event loglevel type is ALL so 0 and
if (key->filter && event->filter) {
/* Both filters exists, check length followed by the bytecode. */
if (event->filter->len != key->filter->len ||
- memcmp(event->filter->data, key->filter->data,
- event->filter->len) != 0) {
+ memcmp(event->filter->data, key->filter->data, event->filter->len) != 0) {
goto no_match;
}
}
if (key->exclusion && event->exclusion) {
/* Both exclusions exists, check count followed by the names. */
if (event->exclusion->count != key->exclusion->count ||
- memcmp(event->exclusion->names, key->exclusion->names,
- event->exclusion->count * LTTNG_UST_ABI_SYM_NAME_LEN) != 0) {
+ memcmp(event->exclusion->names,
+ key->exclusion->names,
+ event->exclusion->count * LTTNG_UST_ABI_SYM_NAME_LEN) != 0) {
goto no_match;
}
}
-
/* Match. */
return 1;
* Unique add of an ust app event in the given ht. This uses the custom
* ht_match_ust_app_event match function and the event name as hash.
*/
-static void add_unique_ust_app_event(struct ust_app_channel *ua_chan,
- struct ust_app_event *event)
+static void add_unique_ust_app_event(struct ust_app_channel *ua_chan, struct ust_app_event *event)
{
struct cds_lfht_node *node_ptr;
struct ust_app_ht_key key;
key.exclusion = event->exclusion;
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct(event->node.key, lttng_ht_seed),
- ht_match_ust_app_event, &key, &event->node.node);
+ ht->hash_fct(event->node.key, lttng_ht_seed),
+ ht_match_ust_app_event,
+ &key,
+ &event->node.node);
LTTNG_ASSERT(node_ptr == &event->node.node);
}
* Delete ust context safely. RCU read lock must be held before calling
* this function.
*/
-static
-void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx,
- struct ust_app *app)
+static void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx, struct ust_app *app)
{
int ret;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app release ctx failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app release ctx failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app release ctx obj handle %d failed with ret %d: pid = %d, sock = %d",
- ua_ctx->obj->handle, ret,
- app->pid, app->sock);
+ ua_ctx->obj->handle,
+ ret,
+ app->pid,
+ app->sock);
}
}
free(ua_ctx->obj);
* Delete ust app event safely. RCU read lock must be held before calling
* this function.
*/
-static
-void delete_ust_app_event(int sock, struct ust_app_event *ua_event,
- struct ust_app *app)
+static void delete_ust_app_event(int sock, struct ust_app_event *ua_event, struct ust_app *app)
{
int ret;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app release event failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app release event failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app release event obj failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
free(ua_event->obj);
* Delayed reclaim of a ust_app_event_notifier_rule object. This MUST be called
* through a call_rcu().
*/
-static
-void free_ust_app_event_notifier_rule_rcu(struct rcu_head *head)
+static void free_ust_app_event_notifier_rule_rcu(struct rcu_head *head)
{
- struct ust_app_event_notifier_rule *obj = lttng::utils::container_of(
- head, &ust_app_event_notifier_rule::rcu_head);
+ struct ust_app_event_notifier_rule *obj =
+ lttng::utils::container_of(head, &ust_app_event_notifier_rule::rcu_head);
free(obj);
}
/*
* Delete ust app event notifier rule safely.
*/
-static void delete_ust_app_event_notifier_rule(int sock,
- struct ust_app_event_notifier_rule *ua_event_notifier_rule,
- struct ust_app *app)
+static void delete_ust_app_event_notifier_rule(
+ int sock, struct ust_app_event_notifier_rule *ua_event_notifier_rule, struct ust_app *app)
{
int ret;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app release event notifier failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app release event notifier failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app release event notifier failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
}
lttng_trigger_put(ua_event_notifier_rule->trigger);
- call_rcu(&ua_event_notifier_rule->rcu_head,
- free_ust_app_event_notifier_rule_rcu);
+ call_rcu(&ua_event_notifier_rule->rcu_head, free_ust_app_event_notifier_rule_rcu);
}
/*
*
* Return 0 on success or else a negative value.
*/
-static int release_ust_app_stream(int sock, struct ust_app_stream *stream,
- struct ust_app *app)
+static int release_ust_app_stream(int sock, struct ust_app_stream *stream, struct ust_app *app)
{
int ret = 0;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app release stream failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app release stream failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app release stream obj failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
lttng_fd_put(LTTNG_FD_APPS, 2);
* Delete ust app stream safely. RCU read lock must be held before calling
* this function.
*/
-static
-void delete_ust_app_stream(int sock, struct ust_app_stream *stream,
- struct ust_app *app)
+static void delete_ust_app_stream(int sock, struct ust_app_stream *stream, struct ust_app *app)
{
LTTNG_ASSERT(stream);
ASSERT_RCU_READ_LOCKED();
free(stream);
}
-static
-void delete_ust_app_channel_rcu(struct rcu_head *head)
+static void delete_ust_app_channel_rcu(struct rcu_head *head)
{
struct ust_app_channel *ua_chan =
lttng::utils::container_of(head, &ust_app_channel::rcu_head);
*
* The session list lock must be held by the caller.
*/
-static
-void save_per_pid_lost_discarded_counters(struct ust_app_channel *ua_chan)
+static void save_per_pid_lost_discarded_counters(struct ust_app_channel *ua_chan)
{
uint64_t discarded = 0, lost = 0;
struct ltt_session *session;
if (ua_chan->attr.overwrite) {
consumer_get_lost_packets(ua_chan->session->tracing_id,
- ua_chan->key, session->ust_session->consumer,
- &lost);
+ ua_chan->key,
+ session->ust_session->consumer,
+ &lost);
} else {
consumer_get_discarded_events(ua_chan->session->tracing_id,
- ua_chan->key, session->ust_session->consumer,
- &discarded);
+ ua_chan->key,
+ session->ust_session->consumer,
+ &discarded);
}
- uchan = trace_ust_find_channel_by_name(
- session->ust_session->domain_global.channels,
- ua_chan->name);
+ uchan = trace_ust_find_channel_by_name(session->ust_session->domain_global.channels,
+ ua_chan->name);
if (!uchan) {
ERR("Missing UST channel to store discarded counters");
goto end;
* The session list lock must be held by the caller.
*/
static void delete_ust_app_channel(int sock,
- struct ust_app_channel *ua_chan,
- struct ust_app *app,
- const lsu::registry_session::locked_ptr& locked_registry)
+ struct ust_app_channel *ua_chan,
+ struct ust_app *app,
+ const lsu::registry_session::locked_ptr& locked_registry)
{
int ret;
struct lttng_ht_iter iter;
DBG3("UST app deleting channel %s", ua_chan->name);
/* Wipe stream */
- cds_list_for_each_entry_safe(stream, stmp, &ua_chan->streams.head, list) {
+ cds_list_for_each_entry_safe (stream, stmp, &ua_chan->streams.head, list) {
cds_list_del(&stream->list);
delete_ust_app_stream(sock, stream, app);
}
/* Wipe context */
- cds_lfht_for_each_entry(ua_chan->ctx->ht, &iter.iter, ua_ctx, node.node) {
+ cds_lfht_for_each_entry (ua_chan->ctx->ht, &iter.iter, ua_ctx, node.node) {
cds_list_del(&ua_ctx->list);
ret = lttng_ht_del(ua_chan->ctx, &iter);
LTTNG_ASSERT(!ret);
}
/* Wipe events */
- cds_lfht_for_each_entry(ua_chan->events->ht, &iter.iter, ua_event,
- node.node) {
+ cds_lfht_for_each_entry (ua_chan->events->ht, &iter.iter, ua_event, node.node) {
ret = lttng_ht_del(ua_chan->events, &iter);
LTTNG_ASSERT(!ret);
delete_ust_app_event(sock, ua_event, app);
if (locked_registry) {
try {
locked_registry->remove_channel(ua_chan->key, sock >= 0);
- } catch (const std::exception &ex) {
+ } catch (const std::exception& ex) {
DBG("Could not find channel for removal: %s", ex.what());
}
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app channel %s release failed. Application is dead: pid = %d, sock = %d",
- ua_chan->name, app->pid,
- app->sock);
+ ua_chan->name,
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app channel %s release failed. Communication time out: pid = %d, sock = %d",
- ua_chan->name, app->pid,
- app->sock);
+ ua_chan->name,
+ app->pid,
+ app->sock);
} else {
ERR("UST app channel %s release failed with ret %d: pid = %d, sock = %d",
- ua_chan->name, ret, app->pid,
- app->sock);
+ ua_chan->name,
+ ret,
+ app->pid,
+ app->sock);
}
}
lttng_fd_put(LTTNG_FD_APPS, 1);
* terminated concurrently).
*/
ssize_t ust_app_push_metadata(const lsu::registry_session::locked_ptr& locked_registry,
- struct consumer_socket *socket,
- int send_zero_data)
+ struct consumer_socket *socket,
+ int send_zero_data)
{
int ret;
char *metadata_str = NULL;
metadata_version = locked_registry->_metadata_version;
if (len == 0) {
DBG3("No metadata to push for metadata key %" PRIu64,
- locked_registry->_metadata_key);
+ locked_registry->_metadata_key);
ret_val = len;
if (send_zero_data) {
DBG("No metadata to push");
* daemon. Those push and pull schemes are performed on two
* different bidirectionnal communication sockets.
*/
- ret = consumer_push_metadata(socket, metadata_key,
- metadata_str, len, offset, metadata_version);
+ ret = consumer_push_metadata(
+ socket, metadata_key, metadata_str, len, offset, metadata_version);
pthread_mutex_lock(&locked_registry->_lock);
if (ret < 0) {
/*
* send.
*/
locked_registry->_metadata_len_sent =
- std::max(locked_registry->_metadata_len_sent,
- new_metadata_len_sent);
+ std::max(locked_registry->_metadata_len_sent, new_metadata_len_sent);
}
free(metadata_str);
return len;
* terminated concurrently).
*/
static int push_metadata(const lsu::registry_session::locked_ptr& locked_registry,
- struct consumer_output *consumer)
+ struct consumer_output *consumer)
{
int ret_val;
ssize_t ret;
}
/* Get consumer socket to use to push the metadata.*/
- socket = consumer_find_socket_by_bitness(locked_registry->abi.bits_per_long,
- consumer);
+ socket = consumer_find_socket_by_bitness(locked_registry->abi.bits_per_long, consumer);
if (!socket) {
ret_val = -1;
goto error;
*
* Return 0 on success else a negative value.
*/
-static int close_metadata(uint64_t metadata_key, unsigned int consumer_bitness,
- struct consumer_output *consumer)
+static int close_metadata(uint64_t metadata_key,
+ unsigned int consumer_bitness,
+ struct consumer_output *consumer)
{
int ret;
struct consumer_socket *socket;
LTTNG_ASSERT(consumer);
/* Get consumer socket to use to push the metadata. */
- socket = consumer_find_socket_by_bitness(consumer_bitness,
- consumer);
+ socket = consumer_find_socket_by_bitness(consumer_bitness, consumer);
if (!socket) {
ret = -1;
goto end;
return ret;
}
-static
-void delete_ust_app_session_rcu(struct rcu_head *head)
+static void delete_ust_app_session_rcu(struct rcu_head *head)
{
struct ust_app_session *ua_sess =
lttng::utils::container_of(head, &ust_app_session::rcu_head);
*
* The session list lock must be held by the caller.
*/
-static
-void delete_ust_app_session(int sock, struct ust_app_session *ua_sess,
- struct ust_app *app)
+static void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, struct ust_app *app)
{
int ret;
struct lttng_ht_iter iter;
(void) push_metadata(locked_registry, ua_sess->consumer);
}
- cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
- node.node) {
+ cds_lfht_for_each_entry (ua_sess->channels->ht, &iter.iter, ua_chan, node.node) {
ret = lttng_ht_del(ua_sess->channels, &iter);
LTTNG_ASSERT(!ret);
delete_ust_app_channel(sock, ua_chan, app, locked_registry);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app release session handle failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app release session handle failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app release session handle failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
* Delete a traceable application structure from the global list. Never call
* this function outside of a call_rcu call.
*/
-static
-void delete_ust_app(struct ust_app *app)
+static void delete_ust_app(struct ust_app *app)
{
int ret, sock;
struct ust_app_session *ua_sess, *tmp_ua_sess;
app->sock = -1;
/* Wipe sessions */
- cds_list_for_each_entry_safe(ua_sess, tmp_ua_sess, &app->teardown_head,
- teardown_node) {
+ cds_list_for_each_entry_safe (ua_sess, tmp_ua_sess, &app->teardown_head, teardown_node) {
/* Free every object in the session and the session. */
rcu_read_lock();
delete_ust_app_session(sock, ua_sess, app);
/* Remove the event notifier rules associated with this app. */
rcu_read_lock();
cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht,
- &iter.iter, event_notifier_rule, node.node) {
+ &iter.iter,
+ event_notifier_rule,
+ node.node) {
ret = lttng_ht_del(app->token_to_event_notifier_rule_ht, &iter);
LTTNG_ASSERT(!ret);
- delete_ust_app_event_notifier_rule(
- app->sock, event_notifier_rule, app);
+ delete_ust_app_event_notifier_rule(app->sock, event_notifier_rule, app);
}
rcu_read_unlock();
enum lttng_error_code ret_code;
enum event_notifier_error_accounting_status status;
- const int event_notifier_read_fd = lttng_pipe_get_readfd(
- app->event_notifier_group.event_pipe);
+ const int event_notifier_read_fd =
+ lttng_pipe_get_readfd(app->event_notifier_group.event_pipe);
ret_code = notification_thread_command_remove_tracer_event_source(
- the_notification_thread_handle,
- event_notifier_read_fd);
+ the_notification_thread_handle, event_notifier_read_fd);
if (ret_code != LTTNG_OK) {
ERR("Failed to remove application tracer event source from notification thread");
}
free(app->event_notifier_group.object);
}
- event_notifier_write_fd_is_open = lttng_pipe_is_write_open(
- app->event_notifier_group.event_pipe);
+ event_notifier_write_fd_is_open =
+ lttng_pipe_is_write_open(app->event_notifier_group.event_pipe);
lttng_pipe_destroy(app->event_notifier_group.event_pipe);
/*
* Release the file descriptors reserved for the event notifier pipe.
/*
* URCU intermediate call to delete an UST app.
*/
-static
-void delete_ust_app_rcu(struct rcu_head *head)
+static void delete_ust_app_rcu(struct rcu_head *head)
{
struct lttng_ht_node_ulong *node =
lttng::utils::container_of(head, <tng_ht_node_ulong::head);
- struct ust_app *app =
- lttng::utils::container_of(node, &ust_app::pid_n);
+ struct ust_app *app = lttng::utils::container_of(node, &ust_app::pid_n);
DBG3("Call RCU deleting app PID %d", app->pid);
delete_ust_app(app);
*
* The session list lock must be held by the caller.
*/
-static void destroy_app_session(struct ust_app *app,
- struct ust_app_session *ua_sess)
+static void destroy_app_session(struct ust_app *app, struct ust_app_session *ua_sess)
{
int ret;
struct lttng_ht_iter iter;
/*
* Alloc new UST app session.
*/
-static
-struct ust_app_session *alloc_ust_app_session(void)
+static struct ust_app_session *alloc_ust_app_session(void)
{
struct ust_app_session *ua_sess;
/*
* Alloc new UST app channel.
*/
-static
-struct ust_app_channel *alloc_ust_app_channel(const char *name,
- struct ust_app_session *ua_sess,
- struct lttng_ust_abi_channel_attr *attr)
+static struct ust_app_channel *alloc_ust_app_channel(const char *name,
+ struct ust_app_session *ua_sess,
+ struct lttng_ust_abi_channel_attr *attr)
{
struct ust_app_channel *ua_chan;
/*
* Alloc new UST app event.
*/
-static
-struct ust_app_event *alloc_ust_app_event(char *name,
- struct lttng_ust_abi_event *attr)
+static struct ust_app_event *alloc_ust_app_event(char *name, struct lttng_ust_abi_event *attr)
{
struct ust_app_event *ua_event;
/*
* Allocate a new UST app event notifier rule.
*/
-static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
- struct lttng_trigger *trigger)
+static struct ust_app_event_notifier_rule *
+alloc_ust_app_event_notifier_rule(struct lttng_trigger *trigger)
{
- enum lttng_event_rule_generate_exclusions_status
- generate_exclusion_status;
+ enum lttng_event_rule_generate_exclusions_status generate_exclusion_status;
enum lttng_condition_status cond_status;
struct ust_app_event_notifier_rule *ua_event_notifier_rule;
struct lttng_condition *condition = NULL;
ua_event_notifier_rule->enabled = 1;
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);
+ lttng_ht_node_init_u64(&ua_event_notifier_rule->node, ua_event_notifier_rule->token);
condition = lttng_trigger_get_condition(trigger);
LTTNG_ASSERT(condition);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- cond_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ cond_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(cond_status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(event_rule);
ua_event_notifier_rule->error_counter_index =
- lttng_condition_event_rule_matches_get_error_counter_index(condition);
+ lttng_condition_event_rule_matches_get_error_counter_index(condition);
/* Acquire the event notifier's reference to the trigger. */
lttng_trigger_get(trigger);
ua_event_notifier_rule->trigger = trigger;
ua_event_notifier_rule->filter = lttng_event_rule_get_filter_bytecode(event_rule);
generate_exclusion_status = lttng_event_rule_generate_exclusions(
- event_rule, &ua_event_notifier_rule->exclusion);
+ event_rule, &ua_event_notifier_rule->exclusion);
switch (generate_exclusion_status) {
case LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK:
case LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE:
}
DBG3("UST app event notifier rule allocated: token = %" PRIu64,
- ua_event_notifier_rule->token);
+ ua_event_notifier_rule->token);
return ua_event_notifier_rule;
/*
* Alloc new UST app context.
*/
-static
-struct ust_app_ctx *alloc_ust_app_ctx(struct lttng_ust_context_attr *uctx)
+static struct ust_app_ctx *alloc_ust_app_ctx(struct lttng_ust_context_attr *uctx)
{
struct ust_app_ctx *ua_ctx;
*
* Return allocated filter or NULL on error.
*/
-static struct lttng_ust_abi_filter_bytecode *create_ust_filter_bytecode_from_bytecode(
- const struct lttng_bytecode *orig_f)
+static struct lttng_ust_abi_filter_bytecode *
+create_ust_filter_bytecode_from_bytecode(const struct lttng_bytecode *orig_f)
{
struct lttng_ust_abi_filter_bytecode *filter = NULL;
/* Copy filter bytecode. */
filter = zmalloc<lttng_ust_abi_filter_bytecode>(sizeof(*filter) + orig_f->len);
if (!filter) {
- PERROR("Failed to allocate lttng_ust_filter_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len);
+ PERROR("Failed to allocate lttng_ust_filter_bytecode: bytecode len = %" PRIu32
+ " bytes",
+ orig_f->len);
goto error;
}
- LTTNG_ASSERT(sizeof(struct lttng_bytecode) ==
- sizeof(struct lttng_ust_abi_filter_bytecode));
+ LTTNG_ASSERT(sizeof(struct lttng_bytecode) == sizeof(struct lttng_ust_abi_filter_bytecode));
memcpy(filter, orig_f, sizeof(*filter) + orig_f->len);
error:
return filter;
/* Copy capture bytecode. */
capture = zmalloc<lttng_ust_abi_capture_bytecode>(sizeof(*capture) + orig_f->len);
if (!capture) {
- PERROR("Failed to allocate lttng_ust_abi_capture_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len);
+ PERROR("Failed to allocate lttng_ust_abi_capture_bytecode: bytecode len = %" PRIu32
+ " bytes",
+ orig_f->len);
goto error;
}
LTTNG_ASSERT(sizeof(struct lttng_bytecode) ==
- sizeof(struct lttng_ust_abi_capture_bytecode));
+ sizeof(struct lttng_ust_abi_capture_bytecode));
memcpy(capture, orig_f, sizeof(*capture) + orig_f->len);
error:
return capture;
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(ust_app_ht_by_sock, (void *)((unsigned long) sock), &iter);
+ lttng_ht_lookup(ust_app_ht_by_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app find by sock %d not found", sock);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(ust_app_ht_by_notify_sock, (void *)((unsigned long) sock),
- &iter);
+ lttng_ht_lookup(ust_app_ht_by_notify_sock, (void *) ((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app find by notify sock %d not found", sock);
* Return an ust_app_event object or NULL on error.
*/
static struct ust_app_event *find_ust_app_event(struct lttng_ht *ht,
- const char *name, const struct lttng_bytecode *filter,
- int loglevel_value,
- const struct lttng_event_exclusion *exclusion)
+ const char *name,
+ const struct lttng_bytecode *filter,
+ int loglevel_value,
+ const struct lttng_event_exclusion *exclusion)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_str *node;
key.exclusion = exclusion;
/* Lookup using the event name as hash and a custom match fct. */
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
- ht_match_ust_app_event, &key, &iter.iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) name, lttng_ht_seed),
+ ht_match_ust_app_event,
+ &key,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (node == NULL) {
goto end;
* Must be called with the RCU read lock held.
* Return an ust_app_event_notifier_rule object or NULL on error.
*/
-static struct ust_app_event_notifier_rule *find_ust_app_event_notifier_rule(
- struct lttng_ht *ht, uint64_t token)
+static struct ust_app_event_notifier_rule *find_ust_app_event_notifier_rule(struct lttng_ht *ht,
+ uint64_t token)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
lttng_ht_lookup(ht, &token, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (node == NULL) {
- DBG2("UST app event notifier rule token not found: token = %" PRIu64,
- token);
+ DBG2("UST app event notifier rule token not found: token = %" PRIu64, token);
goto end;
}
- event_notifier_rule = lttng::utils::container_of(
- node, &ust_app_event_notifier_rule::node);
+ event_notifier_rule = lttng::utils::container_of(node, &ust_app_event_notifier_rule::node);
end:
return event_notifier_rule;
}
*
* Called with UST app session lock held.
*/
-static
-int create_ust_channel_context(struct ust_app_channel *ua_chan,
- struct ust_app_ctx *ua_ctx, struct ust_app *app)
+static int create_ust_channel_context(struct ust_app_channel *ua_chan,
+ struct ust_app_ctx *ua_ctx,
+ struct ust_app *app)
{
int ret;
health_code_update();
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_add_context(app->sock, &ua_ctx->ctx,
- ua_chan->obj, &ua_ctx->obj);
+ ret = lttng_ust_ctl_add_context(app->sock, &ua_ctx->ctx, ua_chan->obj, &ua_ctx->obj);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app create channel context failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app create channel context failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app create channel context failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
ua_ctx->handle = ua_ctx->obj->handle;
DBG2("UST app context handle %d created successfully for channel %s",
- ua_ctx->handle, ua_chan->name);
+ ua_ctx->handle,
+ ua_chan->name);
error:
health_code_update();
* Set the filter on the tracer.
*/
static int set_ust_object_filter(struct ust_app *app,
- const struct lttng_bytecode *bytecode,
- struct lttng_ust_abi_object_data *ust_object)
+ const struct lttng_bytecode *bytecode,
+ struct lttng_ust_abi_object_data *ust_object)
{
int ret;
struct lttng_ust_abi_filter_bytecode *ust_bytecode = NULL;
goto error;
}
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_set_filter(app->sock, ust_bytecode,
- ust_object);
+ ret = lttng_ust_ctl_set_filter(app->sock, ust_bytecode, ust_object);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app set filter failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app set filter failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app set filter failed with ret %d: pid = %d, sock = %d, object = %p",
- ret, app->pid, app->sock, ust_object);
+ ret,
+ app->pid,
+ app->sock,
+ ust_object);
}
goto error;
}
* the captured payloads.
*/
static int set_ust_capture(struct ust_app *app,
- const struct lttng_bytecode *bytecode,
- unsigned int capture_seqnum,
- struct lttng_ust_abi_object_data *ust_object)
+ const struct lttng_bytecode *bytecode,
+ unsigned int capture_seqnum,
+ struct lttng_ust_abi_object_data *ust_object)
{
int ret;
struct lttng_ust_abi_capture_bytecode *ust_bytecode = NULL;
ust_bytecode->seqnum = capture_seqnum;
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_set_capture(app->sock, ust_bytecode,
- ust_object);
+ ret = lttng_ust_ctl_set_capture(app->sock, ust_bytecode, ust_object);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app set capture failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
DBG3("UST app set capture failed. Communication timeout: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app event set capture failed with ret %d: pid = %d, sock = %d",
- ret, app->pid,
- app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
return ret;
}
-static
-struct lttng_ust_abi_event_exclusion *create_ust_exclusion_from_exclusion(
- const struct lttng_event_exclusion *exclusion)
+static struct lttng_ust_abi_event_exclusion *
+create_ust_exclusion_from_exclusion(const struct lttng_event_exclusion *exclusion)
{
struct lttng_ust_abi_event_exclusion *ust_exclusion = NULL;
size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) +
}
LTTNG_ASSERT(sizeof(struct lttng_event_exclusion) ==
- sizeof(struct lttng_ust_abi_event_exclusion));
+ sizeof(struct lttng_ust_abi_event_exclusion));
memcpy(ust_exclusion, exclusion, exclusion_alloc_size);
end:
return ust_exclusion;
* Set event exclusions on the tracer.
*/
static int set_ust_object_exclusions(struct ust_app *app,
- const struct lttng_event_exclusion *exclusions,
- struct lttng_ust_abi_object_data *ust_object)
+ const struct lttng_event_exclusion *exclusions,
+ struct lttng_ust_abi_object_data *ust_object)
{
int ret;
struct lttng_ust_abi_event_exclusion *ust_exclusions = NULL;
health_code_update();
- ust_exclusions = create_ust_exclusion_from_exclusion(
- exclusions);
+ ust_exclusions = create_ust_exclusion_from_exclusion(exclusions);
if (!ust_exclusions) {
ret = -LTTNG_ERR_NOMEM;
goto error;
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app event exclusion failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app event exclusion failed. Communication time out(pid: %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app event exclusions failed with ret %d: pid = %d, sock = %d, object = %p",
- ret, app->pid, app->sock, ust_object);
+ ret,
+ app->pid,
+ app->sock,
+ ust_object);
}
goto error;
}
/*
* Disable the specified event on to UST tracer for the UST session.
*/
-static int disable_ust_object(struct ust_app *app,
- struct lttng_ust_abi_object_data *object)
+static int disable_ust_object(struct ust_app *app, struct lttng_ust_abi_object_data *object)
{
int ret;
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app disable object failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app disable object failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app disable object failed with ret %d: pid = %d, sock = %d, object = %p",
- ret, app->pid, app->sock, object);
+ ret,
+ app->pid,
+ app->sock,
+ object);
}
goto error;
}
- DBG2("UST app object %p disabled successfully for app: pid = %d",
- object, app->pid);
+ DBG2("UST app object %p disabled successfully for app: pid = %d", object, app->pid);
error:
health_code_update();
* Disable the specified channel on to UST tracer for the UST session.
*/
static int disable_ust_channel(struct ust_app *app,
- struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan)
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app disable channel failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app disable channel failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app channel %s disable failed, session handle %d, with ret %d: pid = %d, sock = %d",
- ua_chan->name, ua_sess->handle, ret,
- app->pid, app->sock);
+ ua_chan->name,
+ ua_sess->handle,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
- DBG2("UST app channel %s disabled successfully for app: pid = %d",
- ua_chan->name, app->pid);
+ DBG2("UST app channel %s disabled successfully for app: pid = %d", ua_chan->name, app->pid);
error:
health_code_update();
* Enable the specified channel on to UST tracer for the UST session.
*/
static int enable_ust_channel(struct ust_app *app,
- struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan)
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app channel %s enable failed. Application is dead: pid = %d, sock = %d",
- ua_chan->name, app->pid, app->sock);
+ ua_chan->name,
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app channel %s enable failed. Communication time out: pid = %d, sock = %d",
- ua_chan->name, app->pid, app->sock);
+ ua_chan->name,
+ app->pid,
+ app->sock);
} else {
ERR("UST app channel %s enable failed, session handle %d, with ret %d: pid = %d, sock = %d",
- ua_chan->name, ua_sess->handle, ret,
- app->pid, app->sock);
+ ua_chan->name,
+ ua_sess->handle,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
ua_chan->enabled = 1;
- DBG2("UST app channel %s enabled successfully for app: pid = %d",
- ua_chan->name, app->pid);
+ DBG2("UST app channel %s enabled successfully for app: pid = %d", ua_chan->name, app->pid);
error:
health_code_update();
/*
* Enable the specified event on to UST tracer for the UST session.
*/
-static int enable_ust_object(
- struct ust_app *app, struct lttng_ust_abi_object_data *ust_object)
+static int enable_ust_object(struct ust_app *app, struct lttng_ust_abi_object_data *ust_object)
{
int ret;
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app enable object failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app enable object failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app enable object failed with ret %d: pid = %d, sock = %d, object = %p",
- ret, app->pid, app->sock, ust_object);
+ ret,
+ app->pid,
+ app->sock,
+ ust_object);
}
goto error;
}
- DBG2("UST app object %p enabled successfully for app: pid = %d",
- ust_object, app->pid);
+ DBG2("UST app object %p enabled successfully for app: pid = %d", ust_object, app->pid);
error:
health_code_update();
* Return 0 on success. On error, a negative value is returned.
*/
static int send_channel_pid_to_ust(struct ust_app *app,
- struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan)
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
struct ust_app_stream *stream, *stmp;
health_code_update();
- DBG("UST app sending channel %s to UST app sock %d", ua_chan->name,
- app->sock);
+ DBG("UST app sending channel %s to UST app sock %d", ua_chan->name, app->sock);
/* Send channel to the application. */
ret = ust_consumer_send_channel_to_ust(app, ua_sess, ua_chan);
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
- ret = -ENOTCONN; /* Caused by app exiting. */
+ ret = -ENOTCONN; /* Caused by app exiting. */
goto error;
} else if (ret == -EAGAIN) {
/* Caused by timeout. */
- WARN("Communication with application %d timed out on send_channel for channel \"%s\" of session \"%" PRIu64 "\".",
- app->pid, ua_chan->name, ua_sess->tracing_id);
+ WARN("Communication with application %d timed out on send_channel for channel \"%s\" of session \"%" PRIu64
+ "\".",
+ app->pid,
+ ua_chan->name,
+ ua_sess->tracing_id);
/* Treat this the same way as an application that is exiting. */
ret = -ENOTCONN;
goto error;
health_code_update();
/* Send all streams to application. */
- cds_list_for_each_entry_safe(stream, stmp, &ua_chan->streams.head, list) {
+ cds_list_for_each_entry_safe (stream, stmp, &ua_chan->streams.head, list) {
ret = ust_consumer_send_stream_to_ust(app, ua_chan, stream);
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = -ENOTCONN; /* Caused by app exiting. */
goto error;
} else if (ret == -EAGAIN) {
/* Caused by timeout. */
- WARN("Communication with application %d timed out on send_stream for stream \"%s\" of channel \"%s\" of session \"%" PRIu64 "\".",
- app->pid, stream->name, ua_chan->name,
- ua_sess->tracing_id);
+ WARN("Communication with application %d timed out on send_stream for stream \"%s\" of channel \"%s\" of session \"%" PRIu64
+ "\".",
+ app->pid,
+ stream->name,
+ ua_chan->name,
+ ua_sess->tracing_id);
/*
* Treat this the same way as an application that is
* exiting.
*
* Should be called with session mutex held.
*/
-static
-int create_ust_event(struct ust_app *app,
- struct ust_app_channel *ua_chan, struct ust_app_event *ua_event)
+static int create_ust_event(struct ust_app *app,
+ struct ust_app_channel *ua_chan,
+ struct ust_app_event *ua_event)
{
int ret = 0;
/* Create UST event on tracer */
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
- &ua_event->obj);
+ ret = lttng_ust_ctl_create_event(app->sock, &ua_event->attr, ua_chan->obj, &ua_event->obj);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app create event failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app create event failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app create event '%s' failed with ret %d: pid = %d, sock = %d",
- ua_event->attr.name, ret, app->pid,
- app->sock);
+ ua_event->attr.name,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
ua_event->handle = ua_event->obj->handle;
DBG2("UST app event %s created successfully for pid:%d object = %p",
- ua_event->attr.name, app->pid, ua_event->obj);
+ ua_event->attr.name,
+ app->pid,
+ ua_event->obj);
health_code_update();
return ret;
}
-static int init_ust_event_notifier_from_event_rule(
- const struct lttng_event_rule *rule,
- struct lttng_ust_abi_event_notifier *event_notifier)
+static int
+init_ust_event_notifier_from_event_rule(const struct lttng_event_rule *rule,
+ struct lttng_ust_abi_event_notifier *event_notifier)
{
enum lttng_event_rule_status status;
enum lttng_ust_abi_loglevel_type ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
int loglevel = -1, ret = 0;
const char *pattern;
-
memset(event_notifier, 0, sizeof(*event_notifier));
if (lttng_event_rule_targets_agent_domain(rule)) {
* attached later on.
* Set the default values for the agent event.
*/
- pattern = event_get_default_agent_ust_name(
- lttng_event_rule_get_domain_type(rule));
+ pattern = event_get_default_agent_ust_name(lttng_event_rule_get_domain_type(rule));
loglevel = 0;
ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
} else {
const struct lttng_log_level_rule *log_level_rule;
LTTNG_ASSERT(lttng_event_rule_get_type(rule) ==
- LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT);
+ LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT);
status = lttng_event_rule_user_tracepoint_get_name_pattern(rule, &pattern);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
abort();
}
- status = lttng_event_rule_user_tracepoint_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_user_tracepoint_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
} else if (status == LTTNG_EVENT_RULE_STATUS_OK) {
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE;
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &loglevel);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule,
+ &loglevel);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE;
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &loglevel);
+ log_level_rule, &loglevel);
break;
default:
abort();
}
event_notifier->event.instrumentation = LTTNG_UST_ABI_TRACEPOINT;
- ret = lttng_strncpy(event_notifier->event.name, pattern,
- sizeof(event_notifier->event.name));
+ ret = lttng_strncpy(
+ event_notifier->event.name, pattern, sizeof(event_notifier->event.name));
if (ret) {
- ERR("Failed to copy event rule pattern to notifier: pattern = '%s' ",
- pattern);
+ ERR("Failed to copy event rule pattern to notifier: pattern = '%s' ", pattern);
goto end;
}
* given application.
*/
static int create_ust_event_notifier(struct ust_app *app,
- struct ust_app_event_notifier_rule *ua_event_notifier_rule)
+ struct ust_app_event_notifier_rule *ua_event_notifier_rule)
{
int ret = 0;
enum lttng_condition_status condition_status;
health_code_update();
LTTNG_ASSERT(app->event_notifier_group.object);
- condition = lttng_trigger_get_const_condition(
- ua_event_notifier_rule->trigger);
+ condition = lttng_trigger_get_const_condition(ua_event_notifier_rule->trigger);
LTTNG_ASSERT(condition);
LTTNG_ASSERT(lttng_condition_get_type(condition) ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(event_rule);
event_rule_type = lttng_event_rule_get_type(event_rule);
LTTNG_ASSERT(event_rule_type == LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT ||
- event_rule_type == LTTNG_EVENT_RULE_TYPE_JUL_LOGGING ||
- event_rule_type ==
- LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING ||
- event_rule_type ==
- LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING);
+ event_rule_type == LTTNG_EVENT_RULE_TYPE_JUL_LOGGING ||
+ event_rule_type == LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING ||
+ event_rule_type == LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING);
init_ust_event_notifier_from_event_rule(event_rule, &event_notifier);
event_notifier.event.token = ua_event_notifier_rule->token;
/* Create UST event notifier against the tracer. */
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_create_event_notifier(app->sock, &event_notifier,
- app->event_notifier_group.object,
- &ua_event_notifier_rule->obj);
+ ret = lttng_ust_ctl_create_event_notifier(app->sock,
+ &event_notifier,
+ app->event_notifier_group.object,
+ &ua_event_notifier_rule->obj);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app create event notifier failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app create event notifier failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app create event notifier '%s' failed with ret %d: pid = %d, sock = %d",
- event_notifier.event.name, ret, app->pid,
- app->sock);
+ event_notifier.event.name,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
ua_event_notifier_rule->handle = ua_event_notifier_rule->obj->handle;
DBG2("UST app event notifier %s created successfully: app = '%s': pid = %d, object = %p",
- event_notifier.event.name, app->name, app->pid,
- ua_event_notifier_rule->obj);
+ event_notifier.event.name,
+ app->name,
+ app->pid,
+ ua_event_notifier_rule->obj);
health_code_update();
/* Set filter if one is present. */
if (ua_event_notifier_rule->filter) {
- ret = set_ust_object_filter(app, ua_event_notifier_rule->filter,
- ua_event_notifier_rule->obj);
+ ret = set_ust_object_filter(
+ app, ua_event_notifier_rule->filter, ua_event_notifier_rule->obj);
if (ret < 0) {
goto error;
}
/* Set exclusions for the event. */
if (ua_event_notifier_rule->exclusion) {
- ret = set_ust_object_exclusions(app,
- ua_event_notifier_rule->exclusion,
- ua_event_notifier_rule->obj);
+ ret = set_ust_object_exclusions(
+ app, ua_event_notifier_rule->exclusion, ua_event_notifier_rule->obj);
if (ret < 0) {
goto error;
}
/* Set the capture bytecodes. */
cond_status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &capture_bytecode_count);
+ condition, &capture_bytecode_count);
LTTNG_ASSERT(cond_status == LTTNG_CONDITION_STATUS_OK);
for (i = 0; i < capture_bytecode_count; i++) {
const struct lttng_bytecode *capture_bytecode =
- lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_capture_bytecode_at_index(condition,
+ i);
- ret = set_ust_capture(app, capture_bytecode, i,
- ua_event_notifier_rule->obj);
+ ret = set_ust_capture(app, capture_bytecode, i, ua_event_notifier_rule->obj);
if (ret < 0) {
goto error;
}
/*
* Copy data between an UST app event and a LTT event.
*/
-static void shadow_copy_event(struct ust_app_event *ua_event,
- struct ltt_ust_event *uevent)
+static void shadow_copy_event(struct ust_app_event *ua_event, struct ltt_ust_event *uevent)
{
size_t exclusion_alloc_size;
/* Copy exclusion data */
if (uevent->exclusion) {
exclusion_alloc_size = sizeof(struct lttng_event_exclusion) +
- LTTNG_UST_ABI_SYM_NAME_LEN * uevent->exclusion->count;
+ LTTNG_UST_ABI_SYM_NAME_LEN * uevent->exclusion->count;
ua_event->exclusion = zmalloc<lttng_event_exclusion>(exclusion_alloc_size);
if (ua_event->exclusion == NULL) {
PERROR("malloc");
} else {
- memcpy(ua_event->exclusion, uevent->exclusion,
- exclusion_alloc_size);
+ memcpy(ua_event->exclusion, uevent->exclusion, exclusion_alloc_size);
}
}
}
/*
* Copy data between an UST app channel and a LTT channel.
*/
-static void shadow_copy_channel(struct ust_app_channel *ua_chan,
- struct ltt_ust_channel *uchan)
+static void shadow_copy_channel(struct ust_app_channel *ua_chan, struct ltt_ust_channel *uchan)
{
DBG2("UST app shadow copy of channel %s started", ua_chan->name);
* Copy data between a UST app session and a regular LTT session.
*/
static void shadow_copy_session(struct ust_app_session *ua_sess,
- struct ltt_ust_session *usess, struct ust_app *app)
+ struct ltt_ust_session *usess,
+ struct ust_app *app)
{
struct tm *timeinfo;
char datetime[16];
ua_sess->output_traces = usess->output_traces;
ua_sess->live_timer_interval = usess->live_timer_interval;
- copy_channel_attr_to_ustctl(&ua_sess->metadata_attr,
- &usess->metadata_attr);
+ copy_channel_attr_to_ustctl(&ua_sess->metadata_attr, &usess->metadata_attr);
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
- ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
- DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s", app->name, app->pid,
- datetime);
+ ret = snprintf(ua_sess->path,
+ sizeof(ua_sess->path),
+ DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s",
+ app->name,
+ app->pid,
+ datetime);
break;
case LTTNG_BUFFER_PER_UID:
- ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
- DEFAULT_UST_TRACE_UID_PATH,
- lttng_credentials_get_uid(&ua_sess->real_credentials),
- app->abi.bits_per_long);
+ ret = snprintf(ua_sess->path,
+ sizeof(ua_sess->path),
+ DEFAULT_UST_TRACE_UID_PATH,
+ lttng_credentials_get_uid(&ua_sess->real_credentials),
+ app->abi.bits_per_long);
break;
default:
abort();
goto error;
}
- strncpy(ua_sess->root_shm_path, usess->root_shm_path,
- sizeof(ua_sess->root_shm_path));
+ strncpy(ua_sess->root_shm_path, usess->root_shm_path, sizeof(ua_sess->root_shm_path));
ua_sess->root_shm_path[sizeof(ua_sess->root_shm_path) - 1] = '\0';
- strncpy(ua_sess->shm_path, usess->shm_path,
- sizeof(ua_sess->shm_path));
+ strncpy(ua_sess->shm_path, usess->shm_path, sizeof(ua_sess->shm_path));
ua_sess->shm_path[sizeof(ua_sess->shm_path) - 1] = '\0';
if (ua_sess->shm_path[0]) {
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
- ret = snprintf(tmp_shm_path, sizeof(tmp_shm_path),
- "/" DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s",
- app->name, app->pid, datetime);
+ ret = snprintf(tmp_shm_path,
+ sizeof(tmp_shm_path),
+ "/" DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s",
+ app->name,
+ app->pid,
+ datetime);
break;
case LTTNG_BUFFER_PER_UID:
- ret = snprintf(tmp_shm_path, sizeof(tmp_shm_path),
- "/" DEFAULT_UST_TRACE_UID_PATH,
- app->uid, app->abi.bits_per_long);
+ ret = snprintf(tmp_shm_path,
+ sizeof(tmp_shm_path),
+ "/" DEFAULT_UST_TRACE_UID_PATH,
+ app->uid,
+ app->abi.bits_per_long);
break;
default:
abort();
abort();
goto error;
}
- strncat(ua_sess->shm_path, tmp_shm_path,
+ strncat(ua_sess->shm_path,
+ tmp_shm_path,
sizeof(ua_sess->shm_path) - strlen(ua_sess->shm_path) - 1);
ua_sess->shm_path[sizeof(ua_sess->shm_path) - 1] = '\0';
}
/*
* Lookup sesison wrapper.
*/
-static
-void __lookup_session_by_app(const struct ltt_ust_session *usess,
- struct ust_app *app, struct lttng_ht_iter *iter)
+static void __lookup_session_by_app(const struct ltt_ust_session *usess,
+ struct ust_app *app,
+ struct lttng_ht_iter *iter)
{
/* Get right UST app session from app */
lttng_ht_lookup(app->sessions, &usess->id, iter);
* Return ust app session from the app session hashtable using the UST session
* id.
*/
-static struct ust_app_session *lookup_session_by_app(
- const struct ltt_ust_session *usess, struct ust_app *app)
+static struct ust_app_session *lookup_session_by_app(const struct ltt_ust_session *usess,
+ struct ust_app *app)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
* Return 0 on success or else a negative value.
*/
static int setup_buffer_reg_pid(struct ust_app_session *ua_sess,
- struct ust_app *app, struct buffer_reg_pid **regp)
+ struct ust_app *app,
+ struct buffer_reg_pid **regp)
{
int ret = 0;
struct buffer_reg_pid *reg_pid;
* This is the create channel path meaning that if there is NO
* registry available, we have to create one for this session.
*/
- ret = buffer_reg_pid_create(ua_sess->id, ®_pid,
- ua_sess->root_shm_path, ua_sess->shm_path);
+ ret = buffer_reg_pid_create(
+ ua_sess->id, ®_pid, ua_sess->root_shm_path, ua_sess->shm_path);
if (ret < 0) {
goto error;
}
}
/* Initialize registry. */
- reg_pid->registry->reg.ust = ust_registry_session_per_pid_create(app, app->abi,
- app->version.major, app->version.minor, reg_pid->root_shm_path,
- reg_pid->shm_path,
- lttng_credentials_get_uid(&ua_sess->effective_credentials),
- lttng_credentials_get_gid(&ua_sess->effective_credentials),
- ua_sess->tracing_id);
+ reg_pid->registry->reg.ust = ust_registry_session_per_pid_create(
+ app,
+ app->abi,
+ app->version.major,
+ app->version.minor,
+ reg_pid->root_shm_path,
+ reg_pid->shm_path,
+ lttng_credentials_get_uid(&ua_sess->effective_credentials),
+ lttng_credentials_get_gid(&ua_sess->effective_credentials),
+ ua_sess->tracing_id);
if (!reg_pid->registry->reg.ust) {
/*
* reg_pid->registry->reg.ust is NULL upon error, so we need to
* Return 0 on success or else a negative value.
*/
static int setup_buffer_reg_uid(struct ltt_ust_session *usess,
- struct ust_app_session *ua_sess,
- struct ust_app *app, struct buffer_reg_uid **regp)
+ struct ust_app_session *ua_sess,
+ struct ust_app *app,
+ struct buffer_reg_uid **regp)
{
int ret = 0;
struct buffer_reg_uid *reg_uid;
* This is the create channel path meaning that if there is NO
* registry available, we have to create one for this session.
*/
- ret = buffer_reg_uid_create(usess->id, app->abi.bits_per_long, app->uid,
- LTTNG_DOMAIN_UST, ®_uid, ua_sess->root_shm_path,
- ua_sess->shm_path);
+ ret = buffer_reg_uid_create(usess->id,
+ app->abi.bits_per_long,
+ app->uid,
+ LTTNG_DOMAIN_UST,
+ ®_uid,
+ ua_sess->root_shm_path,
+ ua_sess->shm_path);
if (ret < 0) {
goto error;
}
/* Initialize registry. */
reg_uid->registry->reg.ust = ust_registry_session_per_uid_create(app->abi,
- app->version.major, app->version.minor, reg_uid->root_shm_path,
- reg_uid->shm_path, usess->uid, usess->gid, ua_sess->tracing_id, app->uid);
+ app->version.major,
+ app->version.minor,
+ reg_uid->root_shm_path,
+ reg_uid->shm_path,
+ usess->uid,
+ usess->gid,
+ ua_sess->tracing_id,
+ app->uid);
if (!reg_uid->registry->reg.ust) {
/*
* reg_uid->registry->reg.ust is NULL upon error, so we need to
* -ENOTCONN which is the default code if the lttng_ust_ctl_create_session fails.
*/
static int find_or_create_ust_app_session(struct ltt_ust_session *usess,
- struct ust_app *app, struct ust_app_session **ua_sess_ptr,
- int *is_created)
+ struct ust_app *app,
+ struct ust_app_session **ua_sess_ptr,
+ int *is_created)
{
int ret, created = 0;
struct ust_app_session *ua_sess;
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
DBG2("UST app pid: %d session id %" PRIu64 " not found, creating it",
- app->pid, usess->id);
+ app->pid,
+ usess->id);
ua_sess = alloc_ust_app_session();
if (ua_sess == NULL) {
/* Only malloc can failed so something is really wrong */
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG("UST app creating session failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
ret = 0;
} else if (ret == -EAGAIN) {
DBG("UST app creating session failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
ret = 0;
} else {
ERR("UST app creating session failed with ret %d: pid = %d, sock =%d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
delete_ust_app_session(-1, ua_sess, app);
if (ret != -ENOMEM) {
ua_sess->handle = ret;
/* Add ust app session to app's HT */
- lttng_ht_node_init_u64(&ua_sess->node,
- ua_sess->tracing_id);
+ lttng_ht_node_init_u64(&ua_sess->node, ua_sess->tracing_id);
lttng_ht_add_unique_u64(app->sessions, &ua_sess->node);
lttng_ht_node_init_ulong(&ua_sess->ust_objd_node, ua_sess->handle);
- lttng_ht_add_unique_ulong(app->ust_sessions_objd,
- &ua_sess->ust_objd_node);
+ lttng_ht_add_unique_ulong(app->ust_sessions_objd, &ua_sess->ust_objd_node);
DBG2("UST app session created successfully with handle %d", ret);
}
goto no_match;
}
- switch(key->ctx) {
+ switch (key->ctx) {
case LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER:
if (strncmp(key->u.perf_counter.name,
- ctx->ctx.u.perf_counter.name,
- sizeof(key->u.perf_counter.name))) {
+ ctx->ctx.u.perf_counter.name,
+ sizeof(key->u.perf_counter.name))) {
goto no_match;
}
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
- if (strcmp(key->u.app_ctx.provider_name,
- ctx->ctx.u.app_ctx.provider_name) ||
- strcmp(key->u.app_ctx.ctx_name,
- ctx->ctx.u.app_ctx.ctx_name)) {
+ if (strcmp(key->u.app_ctx.provider_name, ctx->ctx.u.app_ctx.provider_name) ||
+ strcmp(key->u.app_ctx.ctx_name, ctx->ctx.u.app_ctx.ctx_name)) {
goto no_match;
}
break;
* Must be called while holding RCU read side lock.
* Return an ust_app_ctx object or NULL on error.
*/
-static
-struct ust_app_ctx *find_ust_app_context(struct lttng_ht *ht,
- struct lttng_ust_context_attr *uctx)
+static struct ust_app_ctx *find_ust_app_context(struct lttng_ht *ht,
+ struct lttng_ust_context_attr *uctx)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *node;
ASSERT_RCU_READ_LOCKED();
/* Lookup using the lttng_ust_context_type and a custom match fct. */
- cds_lfht_lookup(ht->ht, ht->hash_fct((void *) uctx->ctx, lttng_ht_seed),
- ht_match_ust_app_ctx, uctx, &iter.iter);
+ cds_lfht_lookup(ht->ht,
+ ht->hash_fct((void *) uctx->ctx, lttng_ht_seed),
+ ht_match_ust_app_ctx,
+ uctx,
+ &iter.iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (!node) {
goto end;
*
* Called with UST app session lock held and a RCU read side lock.
*/
-static
-int create_ust_app_channel_context(struct ust_app_channel *ua_chan,
- struct lttng_ust_context_attr *uctx,
- struct ust_app *app)
+static int create_ust_app_channel_context(struct ust_app_channel *ua_chan,
+ struct lttng_ust_context_attr *uctx,
+ struct ust_app *app)
{
int ret = 0;
struct ust_app_ctx *ua_ctx;
*
* Called with UST app session lock held.
*/
-static
-int enable_ust_app_event(struct ust_app_event *ua_event,
- struct ust_app *app)
+static int enable_ust_app_event(struct ust_app_event *ua_event, struct ust_app *app)
{
int ret;
/*
* Disable on the tracer side a ust app event for the session and channel.
*/
-static int disable_ust_app_event(struct ust_app_event *ua_event,
- struct ust_app *app)
+static int disable_ust_app_event(struct ust_app_event *ua_event, struct ust_app *app)
{
int ret;
/*
* Lookup ust app channel for session and disable it on the tracer side.
*/
-static
-int disable_ust_app_channel(struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan, struct ust_app *app)
+static int disable_ust_app_channel(struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan,
+ struct ust_app *app)
{
int ret;
* MUST be called with a RCU read side lock acquired.
*/
static int enable_ust_app_channel(struct ust_app_session *ua_sess,
- struct ltt_ust_channel *uchan, struct ust_app *app)
+ struct ltt_ust_channel *uchan,
+ struct ust_app *app)
{
int ret = 0;
struct lttng_ht_iter iter;
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
if (ua_chan_node == NULL) {
DBG2("Unable to find channel %s in ust session id %" PRIu64,
- uchan->name, ua_sess->tracing_id);
+ uchan->name,
+ ua_sess->tracing_id);
goto error;
}
* Return 0 on success or else a negative value.
*/
static int do_consumer_create_channel(struct ltt_ust_session *usess,
- struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan,
- int bitness, lsu::registry_session *registry)
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan,
+ int bitness,
+ lsu::registry_session *registry)
{
int ret;
unsigned int nb_fd = 0;
* Ask consumer to create channel. The consumer will return the number of
* stream we have to expect.
*/
- ret = ust_consumer_ask_channel(ua_sess, ua_chan, usess->consumer, socket,
- registry, usess->current_trace_chunk);
+ ret = ust_consumer_ask_channel(
+ ua_sess, ua_chan, usess->consumer, socket, registry, usess->current_trace_chunk);
if (ret < 0) {
goto error_ask;
}
* Return 0 on success or else a negative value.
*/
static int duplicate_stream_object(struct buffer_reg_stream *reg_stream,
- struct ust_app_stream *stream)
+ struct ust_app_stream *stream)
{
int ret;
}
/* Duplicate object for stream once the original is in the registry. */
- ret = lttng_ust_ctl_duplicate_ust_object_data(&stream->obj,
- reg_stream->obj.ust);
+ ret = lttng_ust_ctl_duplicate_ust_object_data(&stream->obj, reg_stream->obj.ust);
if (ret < 0) {
ERR("Duplicate stream obj from %p to %p failed with ret %d",
- reg_stream->obj.ust, stream->obj, ret);
+ reg_stream->obj.ust,
+ stream->obj,
+ ret);
lttng_fd_put(LTTNG_FD_APPS, 2);
goto error;
}
* Return 0 on success or else a negative value.
*/
static int duplicate_channel_object(struct buffer_reg_channel *buf_reg_chan,
- struct ust_app_channel *ua_chan)
+ struct ust_app_channel *ua_chan)
{
int ret;
ret = lttng_ust_ctl_duplicate_ust_object_data(&ua_chan->obj, buf_reg_chan->obj.ust);
if (ret < 0) {
ERR("Duplicate channel obj from %p to %p failed with ret: %d",
- buf_reg_chan->obj.ust, ua_chan->obj, ret);
+ buf_reg_chan->obj.ust,
+ ua_chan->obj,
+ ret);
goto error;
}
ua_chan->handle = ua_chan->obj->handle;
* Return 0 on success or else a negative value.
*/
static int setup_buffer_reg_streams(struct buffer_reg_channel *buf_reg_chan,
- struct ust_app_channel *ua_chan,
- struct ust_app *app)
+ struct ust_app_channel *ua_chan,
+ struct ust_app *app)
{
int ret = 0;
struct ust_app_stream *stream, *stmp;
DBG2("UST app setup buffer registry stream");
/* Send all streams to application. */
- cds_list_for_each_entry_safe(stream, stmp, &ua_chan->streams.head, list) {
+ cds_list_for_each_entry_safe (stream, stmp, &ua_chan->streams.head, list) {
struct buffer_reg_stream *reg_stream;
ret = buffer_reg_stream_create(®_stream);
* Return 0 on success else a negative value.
*/
static int create_buffer_reg_channel(struct buffer_reg_session *reg_sess,
- struct ust_app_channel *ua_chan, struct buffer_reg_channel **regp)
+ struct ust_app_channel *ua_chan,
+ struct buffer_reg_channel **regp)
{
int ret;
struct buffer_reg_channel *buf_reg_chan = NULL;
try {
reg_sess->reg.ust->add_channel(ua_chan->tracing_channel_id);
} catch (const std::exception& ex) {
- ERR("Failed to add a channel registry to userspace registry session: %s", ex.what());
+ ERR("Failed to add a channel registry to userspace registry session: %s",
+ ex.what());
ret = -1;
goto error;
}
* Return 0 on success else a negative value.
*/
static int setup_buffer_reg_channel(struct buffer_reg_session *reg_sess,
- struct ust_app_channel *ua_chan, struct buffer_reg_channel *buf_reg_chan,
- struct ust_app *app)
+ struct ust_app_channel *ua_chan,
+ struct buffer_reg_channel *buf_reg_chan,
+ struct ust_app *app)
{
int ret;
* Return 0 on success else a negative value.
*/
static int send_channel_uid_to_ust(struct buffer_reg_channel *buf_reg_chan,
- struct ust_app *app, struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan)
+ struct ust_app *app,
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
struct buffer_reg_stream *reg_stream;
/* Send channel to the application. */
ret = ust_consumer_send_channel_to_ust(app, ua_sess, ua_chan);
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
- ret = -ENOTCONN; /* Caused by app exiting. */
+ ret = -ENOTCONN; /* Caused by app exiting. */
goto error;
} else if (ret == -EAGAIN) {
/* Caused by timeout. */
- WARN("Communication with application %d timed out on send_channel for channel \"%s\" of session \"%" PRIu64 "\".",
- app->pid, ua_chan->name, ua_sess->tracing_id);
+ WARN("Communication with application %d timed out on send_channel for channel \"%s\" of session \"%" PRIu64
+ "\".",
+ app->pid,
+ ua_chan->name,
+ ua_sess->tracing_id);
/* Treat this the same way as an application that is exiting. */
ret = -ENOTCONN;
goto error;
/* Send all streams to application. */
pthread_mutex_lock(&buf_reg_chan->stream_list_lock);
- cds_list_for_each_entry(reg_stream, &buf_reg_chan->streams, lnode) {
+ cds_list_for_each_entry (reg_stream, &buf_reg_chan->streams, lnode) {
struct ust_app_stream stream = {};
ret = duplicate_stream_object(reg_stream, &stream);
* Treat this the same way as an application
* that is exiting.
*/
- WARN("Communication with application %d timed out on send_stream for stream of channel \"%s\" of session \"%" PRIu64 "\".",
- app->pid,
- ua_chan->name,
- ua_sess->tracing_id);
+ WARN("Communication with application %d timed out on send_stream for stream of channel \"%s\" of session \"%" PRIu64
+ "\".",
+ app->pid,
+ ua_chan->name,
+ ua_sess->tracing_id);
ret = -ENOTCONN;
}
(void) release_ust_app_stream(-1, &stream, app);
* Return 0 on success else a negative value.
*/
static int create_channel_per_uid(struct ust_app *app,
- struct ltt_ust_session *usess, struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan)
+ struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
struct buffer_reg_uid *reg_uid;
*/
LTTNG_ASSERT(reg_uid);
- buf_reg_chan = buffer_reg_channel_find(ua_chan->tracing_channel_id,
- reg_uid);
+ buf_reg_chan = buffer_reg_channel_find(ua_chan->tracing_channel_id, reg_uid);
if (buf_reg_chan) {
goto send_channel;
}
/* Create the buffer registry channel object. */
ret = create_buffer_reg_channel(reg_uid->registry, ua_chan, &buf_reg_chan);
if (ret < 0) {
- ERR("Error creating the UST channel \"%s\" registry instance",
- ua_chan->name);
+ ERR("Error creating the UST channel \"%s\" registry instance", ua_chan->name);
goto error;
}
* Create the buffers on the consumer side. This call populates the
* ust app channel object with all streams and data object.
*/
- ret = do_consumer_create_channel(usess, ua_sess, ua_chan,
- app->abi.bits_per_long, reg_uid->registry->reg.ust);
+ ret = do_consumer_create_channel(
+ usess, ua_sess, ua_chan, app->abi.bits_per_long, reg_uid->registry->reg.ust);
if (ret < 0) {
- ERR("Error creating UST channel \"%s\" on the consumer daemon",
- ua_chan->name);
+ ERR("Error creating UST channel \"%s\" on the consumer daemon", ua_chan->name);
/*
* Let's remove the previously created buffer registry channel so
auto locked_registry = reg_uid->registry->reg.ust->lock();
try {
locked_registry->remove_channel(ua_chan->tracing_channel_id, false);
- } catch (const std::exception &ex) {
+ } catch (const std::exception& ex) {
DBG("Could not find channel for removal: %s", ex.what());
}
buffer_reg_channel_remove(reg_uid->registry, buf_reg_chan);
/*
* Setup the streams and add it to the session registry.
*/
- ret = setup_buffer_reg_channel(reg_uid->registry,
- ua_chan, buf_reg_chan, app);
+ ret = setup_buffer_reg_channel(reg_uid->registry, ua_chan, buf_reg_chan, app);
if (ret < 0) {
ERR("Error setting up UST channel \"%s\"", ua_chan->name);
goto error;
/* Notify the notification subsystem of the channel's creation. */
notification_ret = notification_thread_command_add_channel(
- the_notification_thread_handle, session->id,
- ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST,
- ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
+ the_notification_thread_handle,
+ session->id,
+ ua_chan->name,
+ ua_chan->key,
+ LTTNG_DOMAIN_UST,
+ ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
if (notification_ret != LTTNG_OK) {
- ret = - (int) notification_ret;
+ ret = -(int) notification_ret;
ERR("Failed to add channel to notification thread");
goto error;
}
* Return 0 on success else a negative value.
*/
static int create_channel_per_pid(struct ust_app *app,
- struct ltt_ust_session *usess, struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan)
+ struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
lsu::registry_session *registry;
try {
registry->add_channel(ua_chan->key);
} catch (const std::exception& ex) {
- ERR("Error creating the UST channel \"%s\" registry instance: %s", ua_chan->name,
- ex.what());
+ ERR("Error creating the UST channel \"%s\" registry instance: %s",
+ ua_chan->name,
+ ex.what());
ret = -1;
goto error;
}
ASSERT_SESSION_LIST_LOCKED();
/* Create and get channel on the consumer side. */
- ret = do_consumer_create_channel(usess, ua_sess, ua_chan,
- app->abi.bits_per_long, registry);
+ ret = do_consumer_create_channel(usess, ua_sess, ua_chan, app->abi.bits_per_long, registry);
if (ret < 0) {
- ERR("Error creating UST channel \"%s\" on the consumer daemon",
- ua_chan->name);
+ ERR("Error creating UST channel \"%s\" on the consumer daemon", ua_chan->name);
goto error_remove_from_registry;
}
ust_reg_chan._consumer_key = ua_chan->key;
}
- cmd_ret = notification_thread_command_add_channel(
- the_notification_thread_handle, session->id,
- ua_chan->name, ua_chan->key, LTTNG_DOMAIN_UST,
- ua_chan->attr.subbuf_size * ua_chan->attr.num_subbuf);
+ cmd_ret = notification_thread_command_add_channel(the_notification_thread_handle,
+ session->id,
+ ua_chan->name,
+ ua_chan->key,
+ LTTNG_DOMAIN_UST,
+ ua_chan->attr.subbuf_size *
+ ua_chan->attr.num_subbuf);
if (cmd_ret != LTTNG_OK) {
- ret = - (int) cmd_ret;
+ ret = -(int) cmd_ret;
ERR("Failed to add channel to notification thread");
goto error_remove_from_registry;
}
* the application exited concurrently.
*/
static int ust_app_channel_send(struct ust_app *app,
- struct ltt_ust_session *usess, struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan)
+ struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan)
{
int ret;
* Return 0 on success or else a negative value.
*/
static int ust_app_channel_allocate(struct ust_app_session *ua_sess,
- struct ltt_ust_channel *uchan,
- enum lttng_ust_abi_chan_type type,
- struct ltt_ust_session *usess __attribute__((unused)),
- struct ust_app_channel **ua_chanp)
+ struct ltt_ust_channel *uchan,
+ enum lttng_ust_abi_chan_type type,
+ struct ltt_ust_session *usess __attribute__((unused)),
+ struct ust_app_channel **ua_chanp)
{
int ret = 0;
struct lttng_ht_iter iter;
ASSERT_RCU_READ_LOCKED();
/* Lookup channel in the ust app session */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
if (ua_chan_node != NULL) {
ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
* Must be called with the RCU read side lock held.
* Called with ust app session mutex held.
*/
-static
-int create_ust_app_event(struct ust_app_channel *ua_chan,
- struct ltt_ust_event *uevent,
- struct ust_app *app)
+static int create_ust_app_event(struct ust_app_channel *ua_chan,
+ struct ltt_ust_event *uevent,
+ struct ust_app *app)
{
int ret = 0;
struct ust_app_event *ua_event;
*/
if (ret == -LTTNG_UST_ERR_EXIST) {
ERR("Tracer for application reported that an event being created already existed: "
- "event_name = \"%s\", pid = %d, ppid = %d, uid = %d, gid = %d",
- uevent->attr.name,
- app->pid, app->ppid, app->uid,
- app->gid);
+ "event_name = \"%s\", pid = %d, ppid = %d, uid = %d, gid = %d",
+ uevent->attr.name,
+ app->pid,
+ app->ppid,
+ app->uid,
+ app->gid);
}
goto error;
}
add_unique_ust_app_event(ua_chan, ua_event);
- DBG2("UST app create event completed: app = '%s' pid = %d",
- app->name, app->pid);
+ DBG2("UST app create event completed: app = '%s' pid = %d", app->name, app->pid);
end:
return ret;
* Must be called with the RCU read side lock held.
* Called with ust app session mutex held.
*/
-static
-int create_ust_app_event_notifier_rule(struct lttng_trigger *trigger,
- struct ust_app *app)
+static int create_ust_app_event_notifier_rule(struct lttng_trigger *trigger, struct ust_app *app)
{
int ret = 0;
struct ust_app_event_notifier_rule *ua_event_notifier_rule;
*/
if (ret == -LTTNG_UST_ERR_EXIST) {
ERR("Tracer for application reported that an event notifier being created already exists: "
- "token = \"%" PRIu64 "\", pid = %d, ppid = %d, uid = %d, gid = %d",
- lttng_trigger_get_tracer_token(trigger),
- app->pid, app->ppid, app->uid,
- app->gid);
+ "token = \"%" PRIu64 "\", pid = %d, ppid = %d, uid = %d, gid = %d",
+ lttng_trigger_get_tracer_token(trigger),
+ app->pid,
+ app->ppid,
+ app->uid,
+ app->gid);
}
goto error;
}
lttng_ht_add_unique_u64(app->token_to_event_notifier_rule_ht,
- &ua_event_notifier_rule->node);
+ &ua_event_notifier_rule->node);
DBG2("UST app create token event rule completed: app = '%s', pid = %d, token = %" PRIu64,
- app->name, app->pid, lttng_trigger_get_tracer_token(trigger));
+ app->name,
+ app->pid,
+ lttng_trigger_get_tracer_token(trigger));
goto end;
* Called with UST app session lock held and RCU read side lock.
*/
static int create_ust_app_metadata(struct ust_app_session *ua_sess,
- struct ust_app *app, struct consumer_output *consumer)
+ struct ust_app *app,
+ struct consumer_output *consumer)
{
int ret = 0;
struct ust_app_channel *metadata;
* never added or monitored until we do a first push metadata to the
* consumer.
*/
- ret = ust_consumer_ask_channel(ua_sess, metadata, consumer, socket,
- locked_registry.get(), session->current_trace_chunk);
+ ret = ust_consumer_ask_channel(ua_sess,
+ metadata,
+ consumer,
+ socket,
+ locked_registry.get(),
+ session->current_trace_chunk);
if (ret < 0) {
/* Nullify the metadata key so we don't try to close it later on. */
locked_registry->_metadata_key = 0;
goto error_consumer;
}
- DBG2("UST metadata with key %" PRIu64 " created for app pid %d",
- metadata->key, app->pid);
+ DBG2("UST metadata with key %" PRIu64 " created for app pid %d", metadata->key, app->pid);
error_consumer:
lttng_fd_put(LTTNG_FD_APPS, 1);
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
- lttng_ht_lookup(ust_app_ht, (void *)((unsigned long) pid), &iter);
+ lttng_ht_lookup(ust_app_ht, (void *) ((unsigned long) pid), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app no found with pid %d", pid);
DBG3("UST app creating application for socket %d", sock);
- if ((msg->bits_per_long == 64 &&
- (uatomic_read(&the_ust_consumerd64_fd) ==
- -EINVAL)) ||
- (msg->bits_per_long == 32 &&
- (uatomic_read(&the_ust_consumerd32_fd) ==
- -EINVAL))) {
+ if ((msg->bits_per_long == 64 && (uatomic_read(&the_ust_consumerd64_fd) == -EINVAL)) ||
+ (msg->bits_per_long == 32 && (uatomic_read(&the_ust_consumerd32_fd) == -EINVAL))) {
ERR("Registration failed: application \"%s\" (pid: %d) has "
- "%d-bit long, but no consumerd for this size is available.\n",
- msg->name, msg->pid, msg->bits_per_long);
+ "%d-bit long, but no consumerd for this size is available.\n",
+ msg->name,
+ msg->pid,
+ msg->bits_per_long);
goto error;
}
ret = lttng_fd_get(LTTNG_FD_APPS, 2);
if (ret) {
ERR("Failed to reserve two file descriptors for the event source pipe while creating a new application instance: app = '%s', pid = %d",
- msg->name, (int) msg->pid);
+ msg->name,
+ (int) msg->pid);
goto error;
}
event_notifier_event_source_pipe = lttng_pipe_open(FD_CLOEXEC);
if (!event_notifier_event_source_pipe) {
PERROR("Failed to open application event source pipe: '%s' (pid = %d)",
- msg->name, msg->pid);
+ msg->name,
+ msg->pid);
goto error;
}
.uint32_t_alignment = msg->uint32_t_alignment,
.uint64_t_alignment = msg->uint64_t_alignment,
.byte_order = msg->byte_order == LITTLE_ENDIAN ?
- lttng::sessiond::trace::byte_order::LITTLE_ENDIAN_ :
- lttng::sessiond::trace::byte_order::BIG_ENDIAN_,
+ lttng::sessiond::trace::byte_order::LITTLE_ENDIAN_ :
+ lttng::sessiond::trace::byte_order::BIG_ENDIAN_,
};
lta->v_major = msg->major;
lttng_ht_add_unique_ulong(ust_app_ht_by_notify_sock, &app->notify_sock_n);
DBG("App registered with pid:%d ppid:%d uid:%d gid:%d sock =%d name:%s "
- "notify_sock =%d (version %d.%d)", app->pid, app->ppid, app->uid,
- app->gid, app->sock, app->name, app->notify_sock, app->v_major,
- app->v_minor);
+ "notify_sock =%d (version %d.%d)",
+ app->pid,
+ app->ppid,
+ app->uid,
+ app->gid,
+ app->sock,
+ app->name,
+ app->notify_sock,
+ app->v_major,
+ app->v_minor);
rcu_read_unlock();
}
if (ret < 0) {
if (ret == -LTTNG_UST_ERR_EXITING || ret == -EPIPE) {
DBG3("UST app version failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app version failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app version failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
}
/* Get the write side of the pipe. */
- event_pipe_write_fd = lttng_pipe_get_writefd(
- app->event_notifier_group.event_pipe);
+ event_pipe_write_fd = lttng_pipe_get_writefd(app->event_notifier_group.event_pipe);
pthread_mutex_lock(&app->sock_lock);
- ret = lttng_ust_ctl_create_event_notifier_group(app->sock,
- event_pipe_write_fd, &event_notifier_group);
+ ret = lttng_ust_ctl_create_event_notifier_group(
+ app->sock, event_pipe_write_fd, &event_notifier_group);
pthread_mutex_unlock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
ret = 0;
DBG3("UST app create event notifier group failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
ret = 0;
WARN("UST app create event notifier group failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app create event notifier group failed with ret %d: pid = %d, sock = %d, event_pipe_write_fd: %d",
- ret, app->pid, app->sock, event_pipe_write_fd);
+ ret,
+ app->pid,
+ app->sock,
+ event_pipe_write_fd);
}
goto error;
}
ret = lttng_pipe_write_close(app->event_notifier_group.event_pipe);
if (ret) {
ERR("Failed to close write end of the application's event source pipe: app = '%s' (pid = %d)",
- app->name, app->pid);
+ app->name,
+ app->pid);
goto error;
}
lttng_fd_put(LTTNG_FD_APPS, 1);
lttng_ret = notification_thread_command_add_tracer_event_source(
- the_notification_thread_handle,
- lttng_pipe_get_readfd(
- app->event_notifier_group.event_pipe),
- LTTNG_DOMAIN_UST);
+ the_notification_thread_handle,
+ lttng_pipe_get_readfd(app->event_notifier_group.event_pipe),
+ LTTNG_DOMAIN_UST);
if (lttng_ret != LTTNG_OK) {
ERR("Failed to add tracer event source to notification thread");
- ret = - 1;
+ ret = -1;
goto error;
}
/* Assign handle only when the complete setup is valid. */
app->event_notifier_group.object = event_notifier_group;
- event_notifier_error_accounting_status =
- event_notifier_error_accounting_register_app(app);
+ event_notifier_error_accounting_status = event_notifier_error_accounting_register_app(app);
switch (event_notifier_error_accounting_status) {
case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK:
break;
case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_UNSUPPORTED:
DBG3("Failed to setup event notifier error accounting (application does not support notifier error accounting): app socket fd = %d, app name = '%s', app pid = %d",
- app->sock, app->name, (int) app->pid);
+ app->sock,
+ app->name,
+ (int) app->pid);
ret = 0;
goto error_accounting;
case EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD:
DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d, app name = '%s', app pid = %d",
- app->sock, app->name, (int) app->pid);
+ app->sock,
+ app->name,
+ (int) app->pid);
ret = 0;
goto error_accounting;
default:
error_accounting:
lttng_ret = notification_thread_command_remove_tracer_event_source(
- the_notification_thread_handle,
- lttng_pipe_get_readfd(
- app->event_notifier_group.event_pipe));
+ the_notification_thread_handle,
+ lttng_pipe_get_readfd(app->event_notifier_group.event_pipe));
if (lttng_ret != LTTNG_OK) {
ERR("Failed to remove application tracer event source from notification thread");
}
rcu_read_lock();
/* Get the node reference for a call_rcu */
- lttng_ht_lookup(ust_app_ht_by_sock, (void *)((unsigned long) sock), &ust_app_sock_iter);
+ lttng_ht_lookup(ust_app_ht_by_sock, (void *) ((unsigned long) sock), &ust_app_sock_iter);
node = lttng_ht_iter_get_node_ulong(&ust_app_sock_iter);
LTTNG_ASSERT(node);
* ensuring proper behavior of data_pending check.
* Remove sessions so they are not visible during deletion.
*/
- cds_lfht_for_each_entry(lta->sessions->ht, &iter.iter, ua_sess,
- node.node) {
+ cds_lfht_for_each_entry (lta->sessions->ht, &iter.iter, ua_sess, node.node) {
ret = lttng_ht_del(lta->sessions, &iter);
if (ret) {
/* The session was already removed so scheduled for teardown. */
locked_registry->_metadata_closed = true;
}
- /* Release lock before communication, see comments in close_metadata(). */
+ /* Release lock before communication, see comments in
+ * close_metadata(). */
locked_registry.reset();
- (void) close_metadata(metadata_key, consumer_bitness, ua_sess->consumer);
+ (void) close_metadata(
+ metadata_key, consumer_bitness, ua_sess->consumer);
} else {
locked_registry.reset();
}
iter.iter.node = <a->pid_n.node;
ret = lttng_ht_del(ust_app_ht, &iter);
if (ret) {
- DBG3("Unregister app by PID %d failed. This can happen on pid reuse",
- lta->pid);
+ DBG3("Unregister app by PID %d failed. This can happen on pid reuse", lta->pid);
}
/* Free memory */
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ust_abi_tracepoint_iter uiter;
health_code_update();
if (handle < 0) {
if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) {
ERR("UST app list events getting handle failed for app pid %d",
- app->pid);
+ app->pid);
}
pthread_mutex_unlock(&app->sock_lock);
continue;
}
- while ((ret = lttng_ust_ctl_tracepoint_list_get(app->sock, handle,
- &uiter)) != -LTTNG_UST_ERR_NOENT) {
+ while ((ret = lttng_ust_ctl_tracepoint_list_get(app->sock, handle, &uiter)) !=
+ -LTTNG_UST_ERR_NOENT) {
/* Handle ustctl error. */
if (ret < 0) {
int release_ret;
if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
ERR("UST app tp list get failed for app %d with ret %d",
- app->sock, ret);
+ app->sock,
+ ret);
} else {
DBG3("UST app tp list get failed. Application is dead");
break;
}
free(tmp_event);
release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
- if (release_ret < 0 &&
- release_ret != -LTTNG_UST_ERR_EXITING &&
- release_ret != -EPIPE) {
- ERR("Error releasing app handle for app %d with ret %d", app->sock, release_ret);
+ if (release_ret < 0 && release_ret != -LTTNG_UST_ERR_EXITING &&
+ release_ret != -EPIPE) {
+ ERR("Error releasing app handle for app %d with ret %d",
+ app->sock,
+ release_ret);
}
pthread_mutex_unlock(&app->sock_lock);
goto rcu_error;
new_nbmem = nbmem << 1;
DBG2("Reallocating event list from %zu to %zu entries",
- nbmem, new_nbmem);
- new_tmp_event = (lttng_event *) realloc(tmp_event,
- new_nbmem * sizeof(struct lttng_event));
+ nbmem,
+ new_nbmem);
+ new_tmp_event = (lttng_event *) realloc(
+ tmp_event, new_nbmem * sizeof(struct lttng_event));
if (new_tmp_event == NULL) {
int release_ret;
PERROR("realloc ust app events");
free(tmp_event);
ret = -ENOMEM;
- release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
+ release_ret =
+ lttng_ust_ctl_release_handle(app->sock, handle);
if (release_ret < 0 &&
- release_ret != -LTTNG_UST_ERR_EXITING &&
- release_ret != -EPIPE) {
- ERR("Error releasing app handle for app %d with ret %d", app->sock, release_ret);
+ release_ret != -LTTNG_UST_ERR_EXITING &&
+ release_ret != -EPIPE) {
+ ERR("Error releasing app handle for app %d with ret %d",
+ app->sock,
+ release_ret);
}
pthread_mutex_unlock(&app->sock_lock);
goto rcu_error;
}
/* Zero the new memory */
- memset(new_tmp_event + nbmem, 0,
- (new_nbmem - nbmem) * sizeof(struct lttng_event));
+ memset(new_tmp_event + nbmem,
+ 0,
+ (new_nbmem - nbmem) * sizeof(struct lttng_event));
nbmem = new_nbmem;
tmp_event = new_tmp_event;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("Error releasing app handle. Application died: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("Error releasing app handle. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("Error releasing app handle with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
}
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ust_abi_field_iter uiter;
health_code_update();
if (handle < 0) {
if (handle != -EPIPE && handle != -LTTNG_UST_ERR_EXITING) {
ERR("UST app list field getting handle failed for app pid %d",
- app->pid);
+ app->pid);
}
pthread_mutex_unlock(&app->sock_lock);
continue;
}
- while ((ret = lttng_ust_ctl_tracepoint_field_list_get(app->sock, handle,
- &uiter)) != -LTTNG_UST_ERR_NOENT) {
+ while ((ret = lttng_ust_ctl_tracepoint_field_list_get(app->sock, handle, &uiter)) !=
+ -LTTNG_UST_ERR_NOENT) {
/* Handle ustctl error. */
if (ret < 0) {
int release_ret;
if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
ERR("UST app tp list field failed for app %d with ret %d",
- app->sock, ret);
+ app->sock,
+ ret);
} else {
DBG3("UST app tp list field failed. Application is dead");
break;
free(tmp_event);
release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
pthread_mutex_unlock(&app->sock_lock);
- if (release_ret < 0 &&
- release_ret != -LTTNG_UST_ERR_EXITING &&
- release_ret != -EPIPE) {
- ERR("Error releasing app handle for app %d with ret %d", app->sock, release_ret);
+ if (release_ret < 0 && release_ret != -LTTNG_UST_ERR_EXITING &&
+ release_ret != -EPIPE) {
+ ERR("Error releasing app handle for app %d with ret %d",
+ app->sock,
+ release_ret);
}
goto rcu_error;
}
new_nbmem = nbmem << 1;
DBG2("Reallocating event field list from %zu to %zu entries",
- nbmem, new_nbmem);
- new_tmp_event = (lttng_event_field *) realloc(tmp_event,
- new_nbmem * sizeof(struct lttng_event_field));
+ nbmem,
+ new_nbmem);
+ new_tmp_event = (lttng_event_field *) realloc(
+ tmp_event, new_nbmem * sizeof(struct lttng_event_field));
if (new_tmp_event == NULL) {
int release_ret;
PERROR("realloc ust app event fields");
free(tmp_event);
ret = -ENOMEM;
- release_ret = lttng_ust_ctl_release_handle(app->sock, handle);
+ release_ret =
+ lttng_ust_ctl_release_handle(app->sock, handle);
pthread_mutex_unlock(&app->sock_lock);
- if (release_ret &&
- release_ret != -LTTNG_UST_ERR_EXITING &&
- release_ret != -EPIPE) {
- ERR("Error releasing app handle for app %d with ret %d", app->sock, release_ret);
+ if (release_ret && release_ret != -LTTNG_UST_ERR_EXITING &&
+ release_ret != -EPIPE) {
+ ERR("Error releasing app handle for app %d with ret %d",
+ app->sock,
+ release_ret);
}
goto rcu_error;
}
/* Zero the new memory */
- memset(new_tmp_event + nbmem, 0,
- (new_nbmem - nbmem) * sizeof(struct lttng_event_field));
+ memset(new_tmp_event + nbmem,
+ 0,
+ (new_nbmem - nbmem) * sizeof(struct lttng_event_field));
nbmem = new_nbmem;
tmp_event = new_tmp_event;
}
- memcpy(tmp_event[count].field_name, uiter.field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
+ memcpy(tmp_event[count].field_name,
+ uiter.field_name,
+ LTTNG_UST_ABI_SYM_NAME_LEN);
/* Mapping between these enums matches 1 to 1. */
tmp_event[count].type = (enum lttng_event_field_type) uiter.type;
tmp_event[count].nowrite = uiter.nowrite;
- memcpy(tmp_event[count].event.name, uiter.event_name, LTTNG_UST_ABI_SYM_NAME_LEN);
+ memcpy(tmp_event[count].event.name,
+ uiter.event_name,
+ LTTNG_UST_ABI_SYM_NAME_LEN);
tmp_event[count].event.loglevel = uiter.loglevel;
tmp_event[count].event.type = LTTNG_EVENT_TRACEPOINT;
tmp_event[count].event.pid = app->pid;
}
ret = lttng_ust_ctl_release_handle(app->sock, handle);
pthread_mutex_unlock(&app->sock_lock);
- if (ret < 0 &&
- ret != -LTTNG_UST_ERR_EXITING &&
- ret != -EPIPE) {
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
ERR("Error releasing app handle for app %d with ret %d", app->sock, ret);
}
}
/* Cleanup notify socket hash table */
if (ust_app_ht_by_notify_sock) {
- cds_lfht_for_each_entry(ust_app_ht_by_notify_sock->ht, &iter.iter, app,
- notify_sock_n.node) {
+ cds_lfht_for_each_entry (
+ ust_app_ht_by_notify_sock->ht, &iter.iter, app, notify_sock_n.node) {
/*
* Assert that all notifiers are gone as all triggers
* are unregistered prior to this clean-up.
}
if (ust_app_ht) {
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = lttng_ht_del(ust_app_ht, &iter);
LTTNG_ASSERT(!ret);
call_rcu(&app->pid_n.head, delete_ust_app_rcu);
/* Cleanup socket hash table */
if (ust_app_ht_by_sock) {
- cds_lfht_for_each_entry(ust_app_ht_by_sock->ht, &iter.iter, app,
- sock_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht_by_sock->ht, &iter.iter, app, sock_n.node) {
ret = lttng_ht_del(ust_app_ht_by_sock, &iter);
LTTNG_ASSERT(!ret);
}
/*
* For a specific UST session, disable the channel for all registered apps.
*/
-int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
{
int ret = 0;
struct lttng_ht_iter iter;
LTTNG_ASSERT(usess->active);
DBG2("UST app disabling channel %s from global domain for session id %" PRIu64,
- uchan->name, usess->id);
+ uchan->name,
+ usess->id);
rcu_read_lock();
/* For every registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ht_iter uiter;
if (!app->compatible) {
/*
}
/* Get channel */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
/* If the session if found for the app, the channel must be there */
LTTNG_ASSERT(ua_chan_node);
/*
* For a specific UST session, enable the channel for all registered apps.
*/
-int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan)
+int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan)
{
int ret = 0;
struct lttng_ht_iter iter;
LTTNG_ASSERT(usess->active);
DBG2("UST app enabling channel %s to global domain for session id %" PRIu64,
- uchan->name, usess->id);
+ uchan->name,
+ usess->id);
rcu_read_lock();
/* For every registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
* Disable an event in a channel and for a specific session.
*/
int ust_app_disable_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
+ struct ltt_ust_channel *uchan,
+ struct ltt_ust_event *uevent)
{
int ret = 0;
struct lttng_ht_iter iter, uiter;
LTTNG_ASSERT(usess->active);
DBG("UST app disabling event %s for all apps in channel "
- "%s for session id %" PRIu64,
- uevent->attr.name, uchan->name, usess->id);
+ "%s for session id %" PRIu64,
+ uevent->attr.name,
+ uchan->name,
+ usess->id);
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
}
/* Lookup channel in the ust app session */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_chan_node == NULL) {
DBG2("Channel %s not found in session id %" PRIu64 " for app pid %d."
- "Skipping", uchan->name, usess->id, app->pid);
+ "Skipping",
+ uchan->name,
+ usess->id,
+ app->pid);
continue;
}
ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
- ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
- uevent->filter, uevent->attr.loglevel,
- uevent->exclusion);
+ ua_event = find_ust_app_event(ua_chan->events,
+ uevent->attr.name,
+ uevent->filter,
+ uevent->attr.loglevel,
+ uevent->exclusion);
if (ua_event == NULL) {
DBG2("Event %s not found in channel %s for app pid %d."
- "Skipping", uevent->attr.name, uchan->name, app->pid);
+ "Skipping",
+ uevent->attr.name,
+ uchan->name,
+ app->pid);
continue;
}
}
/* The ua_sess lock must be held by the caller. */
-static
-int ust_app_channel_create(struct ltt_ust_session *usess,
- struct ust_app_session *ua_sess,
- struct ltt_ust_channel *uchan, struct ust_app *app,
- struct ust_app_channel **_ua_chan)
+static int ust_app_channel_create(struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ltt_ust_channel *uchan,
+ struct ust_app *app,
+ struct ust_app_channel **_ua_chan)
{
int ret = 0;
struct ust_app_channel *ua_chan = NULL;
LTTNG_ASSERT(ua_sess);
ASSERT_LOCKED(ua_sess->lock);
- if (!strncmp(uchan->name, DEFAULT_METADATA_NAME,
- sizeof(uchan->name))) {
- copy_channel_attr_to_ustctl(&ua_sess->metadata_attr,
- &uchan->attr);
+ if (!strncmp(uchan->name, DEFAULT_METADATA_NAME, sizeof(uchan->name))) {
+ copy_channel_attr_to_ustctl(&ua_sess->metadata_attr, &uchan->attr);
ret = 0;
} else {
struct ltt_ust_context *uctx = NULL;
* Create channel onto application and synchronize its
* configuration.
*/
- ret = ust_app_channel_allocate(ua_sess, uchan,
- LTTNG_UST_ABI_CHAN_PER_CPU, usess,
- &ua_chan);
+ ret = ust_app_channel_allocate(
+ ua_sess, uchan, LTTNG_UST_ABI_CHAN_PER_CPU, usess, &ua_chan);
if (ret < 0) {
goto error;
}
- ret = ust_app_channel_send(app, usess,
- ua_sess, ua_chan);
+ ret = ust_app_channel_send(app, usess, ua_sess, ua_chan);
if (ret) {
goto error;
}
/* Add contexts. */
- cds_list_for_each_entry(uctx, &uchan->ctx_list, list) {
- ret = create_ust_app_channel_context(ua_chan,
- &uctx->ctx, app);
+ cds_list_for_each_entry (uctx, &uchan->ctx_list, list) {
+ ret = create_ust_app_channel_context(ua_chan, &uctx->ctx, app);
if (ret) {
goto error;
}
* or a timeout on it. We can't inform the caller that for a
* specific app, the session failed so lets continue here.
*/
- ret = 0; /* Not an error. */
+ ret = 0; /* Not an error. */
break;
case -ENOMEM:
default:
* Enable event for a specific session and channel on the tracer.
*/
int ust_app_enable_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
+ struct ltt_ust_channel *uchan,
+ struct ltt_ust_event *uevent)
{
int ret = 0;
struct lttng_ht_iter iter, uiter;
LTTNG_ASSERT(usess->active);
DBG("UST app enabling event %s for all apps for session id %" PRIu64,
- uevent->attr.name, usess->id);
+ uevent->attr.name,
+ usess->id);
/*
* NOTE: At this point, this function is called only if the session and
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
}
/* Lookup channel in the ust app session */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
/*
* It is possible that the channel cannot be found is
ua_chan = lttng::utils::container_of(ua_chan_node, &ust_app_channel::node);
/* Get event node */
- ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
- uevent->filter, uevent->attr.loglevel, uevent->exclusion);
+ ua_event = find_ust_app_event(ua_chan->events,
+ uevent->attr.name,
+ uevent->filter,
+ uevent->attr.loglevel,
+ uevent->exclusion);
if (ua_event == NULL) {
DBG3("UST app enable event %s not found for app PID %d."
- "Skipping app", uevent->attr.name, app->pid);
+ "Skipping app",
+ uevent->attr.name,
+ app->pid);
goto next_app;
}
* all registered apps.
*/
int ust_app_create_event_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
+ struct ltt_ust_channel *uchan,
+ struct ltt_ust_event *uevent)
{
int ret = 0;
struct lttng_ht_iter iter, uiter;
LTTNG_ASSERT(usess->active);
DBG("UST app creating event %s for all apps for session id %" PRIu64,
- uevent->attr.name, usess->id);
+ uevent->attr.name,
+ usess->id);
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
}
/* Lookup channel in the ust app session */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
/* If the channel is not found, there is a code flow error */
LTTNG_ASSERT(ua_chan_node);
break;
}
DBG2("UST app event %s already exist on app PID %d",
- uevent->attr.name, app->pid);
+ uevent->attr.name,
+ app->pid);
continue;
}
}
* Called with UST app session lock held.
*
*/
-static
-int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
+static int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
{
int ret = 0;
struct ust_app_session *ua_sess;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app start session failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
pthread_mutex_unlock(&ua_sess->lock);
goto end;
} else if (ret == -EAGAIN) {
WARN("UST app start session failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
pthread_mutex_unlock(&ua_sess->lock);
goto end;
} else {
ERR("UST app start session failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
goto error_unlock;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app wait quiescent failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app wait quiescent failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app wait quiescent failed with ret %d: pid %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
/*
* Stop tracing for a specific UST session and app.
*/
-static
-int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
+static int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app)
{
int ret = 0;
struct ust_app_session *ua_sess;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app stop session failed. Application is dead: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
goto end_unlock;
} else if (ret == -EAGAIN) {
WARN("UST app stop session failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
goto end_unlock;
} else {
ERR("UST app stop session failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
goto error_rcu_unlock;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app wait quiescent failed. Application is dead: pid= %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app wait quiescent failed. Communication time out: pid= %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app wait quiescent failed with ret %d: pid= %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
return -1;
}
-static
-int ust_app_flush_app_session(struct ust_app *app,
- struct ust_app_session *ua_sess)
+static int ust_app_flush_app_session(struct ust_app *app, struct ust_app_session *ua_sess)
{
int ret, retval = 0;
struct lttng_ht_iter iter;
health_code_update();
/* Flushing buffers */
- socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
- ua_sess->consumer);
+ socket = consumer_find_socket_by_bitness(app->abi.bits_per_long, ua_sess->consumer);
/* Flush buffers and push metadata. */
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
- cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
- node.node) {
+ cds_lfht_for_each_entry (ua_sess->channels->ht, &iter.iter, ua_chan, node.node) {
health_code_update();
ret = consumer_flush_channel(socket, ua_chan->key);
if (ret) {
* Flush buffers for all applications for a specific UST session.
* Called with UST session lock held.
*/
-static
-int ust_app_flush_session(struct ltt_ust_session *usess)
+static int ust_app_flush_session(struct ltt_ust_session *usess)
{
int ret = 0;
struct lttng_ht_iter iter;
/* Flush all per UID buffers associated to that session. */
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
lsu::registry_session *ust_session_reg;
struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
/* Get consumer socket to use to push the metadata.*/
socket = consumer_find_socket_by_bitness(reg->bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
/* Ignore request if no consumer is found for the session. */
continue;
}
- cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
- buf_reg_chan, node.node) {
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
/*
* The following call will print error values so the return
* code is of little importance because whatever happens, we
struct lttng_ht_iter iter;
struct ust_app *app;
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
continue;
return ret;
}
-static
-int ust_app_clear_quiescent_app_session(struct ust_app *app,
- struct ust_app_session *ua_sess)
+static int ust_app_clear_quiescent_app_session(struct ust_app *app, struct ust_app_session *ua_sess)
{
int ret = 0;
struct lttng_ht_iter iter;
health_code_update();
- socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
- ua_sess->consumer);
+ socket = consumer_find_socket_by_bitness(app->abi.bits_per_long, ua_sess->consumer);
if (!socket) {
- ERR("Failed to find consumer (%" PRIu32 ") socket",
- app->abi.bits_per_long);
+ ERR("Failed to find consumer (%" PRIu32 ") socket", app->abi.bits_per_long);
ret = -1;
goto end_unlock;
}
/* Clear quiescent state. */
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
- cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter,
- ua_chan, node.node) {
+ cds_lfht_for_each_entry (ua_sess->channels->ht, &iter.iter, ua_chan, node.node) {
health_code_update();
- ret = consumer_clear_quiescent_channel(socket,
- ua_chan->key);
+ ret = consumer_clear_quiescent_channel(socket, ua_chan->key);
if (ret) {
ERR("Error clearing quiescent state for consumer channel");
ret = -1;
* specific UST session.
* Called with UST session lock held.
*/
-static
-int ust_app_clear_quiescent_session(struct ltt_ust_session *usess)
+static int ust_app_clear_quiescent_session(struct ltt_ust_session *usess)
{
int ret = 0;
* Clear quiescent for all per UID buffers associated to
* that session.
*/
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct consumer_socket *socket;
struct buffer_reg_channel *buf_reg_chan;
/* Get associated consumer socket.*/
- socket = consumer_find_socket_by_bitness(
- reg->bits_per_long, usess->consumer);
+ socket = consumer_find_socket_by_bitness(reg->bits_per_long,
+ usess->consumer);
if (!socket) {
/*
* Ignore request if no consumer is found for
continue;
}
- cds_lfht_for_each_entry(reg->registry->channels->ht,
- &iter.iter, buf_reg_chan, node.node) {
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
/*
* The following call will print error values so
* the return code is of little importance
* all.
*/
(void) consumer_clear_quiescent_channel(socket,
- buf_reg_chan->consumer_key);
+ buf_reg_chan->consumer_key);
}
}
break;
struct lttng_ht_iter iter;
struct ust_app *app;
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app,
- pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
continue;
}
- (void) ust_app_clear_quiescent_app_session(app,
- ua_sess);
+ (void) ust_app_clear_quiescent_app_session(app, ua_sess);
}
break;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app wait quiescent failed. Application is dead: pid= %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app wait quiescent failed. Communication time out: pid= %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app wait quiescent failed with ret %d: pid= %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
}
end:
*/
(void) ust_app_clear_quiescent_session(usess);
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ust_app_global_update(usess, app);
}
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = ust_app_stop_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = destroy_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
}
/* The ua_sess lock must be held by the caller. */
-static
-int find_or_create_ust_app_channel(
- struct ltt_ust_session *usess,
- struct ust_app_session *ua_sess,
- struct ust_app *app,
- struct ltt_ust_channel *uchan,
- struct ust_app_channel **ua_chan)
+static int find_or_create_ust_app_channel(struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ust_app *app,
+ struct ltt_ust_channel *uchan,
+ struct ust_app_channel **ua_chan)
{
int ret = 0;
struct lttng_ht_iter iter;
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &iter);
ua_chan_node = lttng_ht_iter_get_node_str(&iter);
if (ua_chan_node) {
- *ua_chan = caa_container_of(ua_chan_node,
- struct ust_app_channel, node);
+ *ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
goto end;
}
return ret;
}
-static
-int ust_app_channel_synchronize_event(struct ust_app_channel *ua_chan,
- struct ltt_ust_event *uevent,
- struct ust_app *app)
+static int ust_app_channel_synchronize_event(struct ust_app_channel *ua_chan,
+ struct ltt_ust_event *uevent,
+ struct ust_app *app)
{
int ret = 0;
struct ust_app_event *ua_event = NULL;
- ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name,
- uevent->filter, uevent->attr.loglevel, uevent->exclusion);
+ ua_event = find_ust_app_event(ua_chan->events,
+ uevent->attr.name,
+ uevent->filter,
+ uevent->attr.loglevel,
+ uevent->exclusion);
if (!ua_event) {
ret = create_ust_app_event(ua_chan, uevent, app);
if (ret < 0) {
}
} else {
if (ua_event->enabled != uevent->enabled) {
- ret = uevent->enabled ?
- enable_ust_app_event(ua_event, app) :
- disable_ust_app_event(ua_event, app);
+ ret = uevent->enabled ? enable_ust_app_event(ua_event, app) :
+ disable_ust_app_event(ua_event, app);
}
}
}
/* Called with RCU read-side lock held. */
-static
-void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
+static void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
{
int ret = 0;
enum lttng_error_code ret_code;
/* Get all triggers using uid 0 (root) */
ret_code = notification_thread_command_list_triggers(
- the_notification_thread_handle, 0, &triggers);
+ the_notification_thread_handle, 0, &triggers);
if (ret_code != LTTNG_OK) {
goto end;
}
condition = lttng_trigger_get_condition(trigger);
if (lttng_condition_get_type(condition) !=
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) {
+ LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES) {
/* Does not apply */
continue;
}
- condition_status =
- lttng_condition_event_rule_matches_borrow_rule_mutable(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_borrow_rule_mutable(
+ condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
if (lttng_event_rule_get_domain_type(event_rule) == LTTNG_DOMAIN_KERNEL) {
* explicitly acquiring it here.
*/
looked_up_event_notifier_rule = find_ust_app_event_notifier_rule(
- app->token_to_event_notifier_rule_ht, token);
+ app->token_to_event_notifier_rule_ht, token);
if (!looked_up_event_notifier_rule) {
ret = create_ust_app_event_notifier_rule(trigger, app);
if (ret < 0) {
rcu_read_lock();
/* Remove all unknown event sources from the app. */
cds_lfht_for_each_entry (app->token_to_event_notifier_rule_ht->ht,
- &app_trigger_iter.iter, event_notifier_rule,
- node.node) {
+ &app_trigger_iter.iter,
+ event_notifier_rule,
+ node.node) {
const uint64_t app_token = event_notifier_rule->token;
bool found = false;
for (i = 0; i < count; i++) {
uint64_t notification_thread_token;
const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(
- triggers, i);
+ lttng_triggers_get_at_index(triggers, i);
LTTNG_ASSERT(trigger);
- notification_thread_token =
- lttng_trigger_get_tracer_token(trigger);
+ notification_thread_token = lttng_trigger_get_tracer_token(trigger);
if (notification_thread_token == app_token) {
found = true;
* This trigger was unregistered, disable it on the tracer's
* side.
*/
- ret = lttng_ht_del(app->token_to_event_notifier_rule_ht,
- &app_trigger_iter);
+ ret = lttng_ht_del(app->token_to_event_notifier_rule_ht, &app_trigger_iter);
LTTNG_ASSERT(ret == 0);
/* Callee logs errors. */
(void) disable_ust_object(app, event_notifier_rule->obj);
- delete_ust_app_event_notifier_rule(
- app->sock, event_notifier_rule, app);
+ delete_ust_app_event_notifier_rule(app->sock, event_notifier_rule, app);
}
rcu_read_unlock();
/*
* RCU read lock must be held by the caller.
*/
-static
-void ust_app_synchronize_all_channels(struct ltt_ust_session *usess,
- struct ust_app_session *ua_sess,
- struct ust_app *app)
+static void ust_app_synchronize_all_channels(struct ltt_ust_session *usess,
+ struct ust_app_session *ua_sess,
+ struct ust_app *app)
{
int ret = 0;
struct cds_lfht_iter uchan_iter;
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
- cds_lfht_for_each_entry(usess->domain_global.channels->ht, &uchan_iter,
- uchan, node.node) {
+ cds_lfht_for_each_entry (usess->domain_global.channels->ht, &uchan_iter, uchan, node.node) {
struct ust_app_channel *ua_chan;
struct cds_lfht_iter uevent_iter;
struct ltt_ust_event *uevent;
* allocated (if necessary) and sent to the application, and
* all enabled contexts will be added to the channel.
*/
- ret = find_or_create_ust_app_channel(usess, ua_sess,
- app, uchan, &ua_chan);
+ ret = find_or_create_ust_app_channel(usess, ua_sess, app, uchan, &ua_chan);
if (ret) {
/* Tracer is probably gone or ENOMEM. */
goto end;
continue;
}
- cds_lfht_for_each_entry(uchan->events->ht, &uevent_iter, uevent,
- node.node) {
- ret = ust_app_channel_synchronize_event(ua_chan,
- uevent, app);
+ cds_lfht_for_each_entry (uchan->events->ht, &uevent_iter, uevent, node.node) {
+ ret = ust_app_channel_synchronize_event(ua_chan, uevent, app);
if (ret) {
goto end;
}
}
if (ua_chan->enabled != uchan->enabled) {
- ret = uchan->enabled ?
- enable_ust_app_channel(ua_sess, uchan, app) :
- disable_ust_app_channel(ua_sess, ua_chan, app);
+ ret = uchan->enabled ? enable_ust_app_channel(ua_sess, uchan, app) :
+ disable_ust_app_channel(ua_sess, ua_chan, app);
if (ret) {
goto end;
}
* The caller must ensure that the application is compatible and is tracked
* by the process attribute trackers.
*/
-static
-void ust_app_synchronize(struct ltt_ust_session *usess,
- struct ust_app *app)
+static void ust_app_synchronize(struct ltt_ust_session *usess, struct ust_app *app)
{
int ret = 0;
struct ust_app_session *ua_sess = NULL;
ret = create_ust_app_metadata(ua_sess, app, usess->consumer);
if (ret < 0) {
ERR("Metadata creation failed for app sock %d for session id %" PRIu64,
- app->sock, usess->id);
+ app->sock,
+ usess->id);
}
rcu_read_unlock();
return;
}
-static
-void ust_app_global_destroy(struct ltt_ust_session *usess, struct ust_app *app)
+static void ust_app_global_destroy(struct ltt_ust_session *usess, struct ust_app *app)
{
struct ust_app_session *ua_sess;
LTTNG_ASSERT(usess->active);
ASSERT_RCU_READ_LOCKED();
- DBG2("UST app global update for app sock %d for session id %" PRIu64,
- app->sock, usess->id);
+ DBG2("UST app global update for app sock %d for session id %" PRIu64, app->sock, usess->id);
if (!app->compatible) {
return;
}
- if (trace_ust_id_tracker_lookup(LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID,
- usess, app->pid) &&
- trace_ust_id_tracker_lookup(
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID,
- usess, app->uid) &&
- trace_ust_id_tracker_lookup(
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID,
- usess, app->gid)) {
+ if (trace_ust_id_tracker_lookup(LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID, usess, app->pid) &&
+ trace_ust_id_tracker_lookup(LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID, usess, app->uid) &&
+ trace_ust_id_tracker_lookup(LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID, usess, app->gid)) {
/*
* Synchronize the application's internal tracing configuration
* and start tracing.
ASSERT_RCU_READ_LOCKED();
DBG2("UST application global event notifier rules update: app = '%s', pid = %d",
- app->name, app->pid);
+ app->name,
+ app->pid);
if (!app->compatible || !ust_app_supports_notifiers(app)) {
return;
if (app->event_notifier_group.object == NULL) {
WARN("UST app global update of event notifiers for app skipped since communication handle is null: app = '%s', pid = %d",
- app->name, app->pid);
+ app->name,
+ app->pid);
return;
}
struct ust_app *app;
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ust_app_global_update(usess, app);
}
rcu_read_unlock();
struct ust_app *app;
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ust_app_global_update_event_notifier_rules(app);
}
* Add context to a specific channel for global UST domain.
*/
int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx)
+ struct ltt_ust_channel *uchan,
+ struct ltt_ust_context *uctx)
{
int ret = 0;
struct lttng_ht_node_str *ua_chan_node;
LTTNG_ASSERT(usess->active);
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
}
/* Lookup channel in the ust app session */
- lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
+ lttng_ht_lookup(ua_sess->channels, (void *) uchan->name, &uiter);
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_chan_node == NULL) {
goto next_app;
}
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel,
- node);
+ ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
ret = create_ust_app_channel_context(ua_chan, &uctx->ctx, app);
if (ret < 0) {
goto next_app;
LTTNG_ASSERT(msg);
- ret = lttng_ust_ctl_recv_reg_msg(sock, &msg->type, &msg->major, &msg->minor,
- &pid, &ppid, &uid, &gid,
- &msg->bits_per_long,
- &msg->uint8_t_alignment,
- &msg->uint16_t_alignment,
- &msg->uint32_t_alignment,
- &msg->uint64_t_alignment,
- &msg->long_alignment,
- &msg->byte_order,
- msg->name);
+ ret = lttng_ust_ctl_recv_reg_msg(sock,
+ &msg->type,
+ &msg->major,
+ &msg->minor,
+ &pid,
+ &ppid,
+ &uid,
+ &gid,
+ &msg->bits_per_long,
+ &msg->uint8_t_alignment,
+ &msg->uint16_t_alignment,
+ &msg->uint32_t_alignment,
+ &msg->uint64_t_alignment,
+ &msg->long_alignment,
+ &msg->byte_order,
+ msg->name);
if (ret < 0) {
switch (-ret) {
case EPIPE:
break;
case LTTNG_UST_ERR_UNSUP_MAJOR:
ERR("UST app recv reg unsupported version %d.%d. Supporting %d.%d",
- msg->major, msg->minor, LTTNG_UST_ABI_MAJOR_VERSION,
- LTTNG_UST_ABI_MINOR_VERSION);
+ msg->major,
+ msg->minor,
+ LTTNG_UST_ABI_MAJOR_VERSION,
+ LTTNG_UST_ABI_MINOR_VERSION);
break;
default:
ERR("UST app recv reg message failed with ret %d", ret);
* Return a ust app session object using the application object and the
* session object descriptor has a key. If not found, NULL is returned.
* A RCU read side lock MUST be acquired when calling this function.
-*/
-static struct ust_app_session *find_session_by_objd(struct ust_app *app,
- int objd)
+ */
+static struct ust_app_session *find_session_by_objd(struct ust_app *app, int objd)
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(app->ust_sessions_objd, (void *)((unsigned long) objd), &iter);
+ lttng_ht_lookup(app->ust_sessions_objd, (void *) ((unsigned long) objd), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app session find by objd %d not found", objd);
* object descriptor has a key. If not found, NULL is returned. A RCU read side
* lock MUST be acquired before calling this function.
*/
-static struct ust_app_channel *find_channel_by_objd(struct ust_app *app,
- int objd)
+static struct ust_app_channel *find_channel_by_objd(struct ust_app *app, int objd)
{
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
LTTNG_ASSERT(app);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(app->ust_objd, (void *)((unsigned long) objd), &iter);
+ lttng_ht_lookup(app->ust_objd, (void *) ((unsigned long) objd), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app channel find by objd %d not found", objd);
* On success 0 is returned else a negative value.
*/
static int handle_app_register_channel_notification(int sock,
- int cobjd,
- struct lttng_ust_ctl_field *raw_context_fields,
- size_t context_field_count)
+ int cobjd,
+ struct lttng_ust_ctl_field *raw_context_fields,
+ size_t context_field_count)
{
int ret, ret_code = 0;
uint32_t chan_id;
struct ust_app *app;
struct ust_app_channel *ua_chan;
struct ust_app_session *ua_sess;
- auto ust_ctl_context_fields = lttng::make_unique_wrapper<lttng_ust_ctl_field, lttng::free>(
- raw_context_fields);
+ auto ust_ctl_context_fields =
+ lttng::make_unique_wrapper<lttng_ust_ctl_field, lttng::free>(raw_context_fields);
lttng::urcu::read_lock_guard read_lock_guard;
/* Lookup application. If not found, there is a code flow error. */
app = find_app_by_notify_sock(sock);
if (!app) {
- DBG("Application socket %d is being torn down. Abort event notify",
- sock);
+ DBG("Application socket %d is being torn down. Abort event notify", sock);
return -1;
}
*/
try {
auto app_context_fields = lsu::create_trace_fields_from_ust_ctl_fields(
- *locked_registry_session, ust_ctl_context_fields.get(),
- context_field_count,
- lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT,
- lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS);
+ *locked_registry_session,
+ ust_ctl_context_fields.get(),
+ context_field_count,
+ lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT,
+ lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS);
if (!ust_reg_chan.is_registered()) {
lst::type::cuptr event_context = app_context_fields.size() ?
- lttng::make_unique<lst::structure_type>(
- 0, std::move(app_context_fields)) :
- nullptr;
+ lttng::make_unique<lst::structure_type>(
+ 0, std::move(app_context_fields)) :
+ nullptr;
ust_reg_chan.event_context(std::move(event_context));
} else {
context_fields_match = app_context_fields.size() == 0;
} else {
const lst::structure_type app_event_context_struct(
- 0, std::move(app_context_fields));
+ 0, std::move(app_context_fields));
context_fields_match = *previous_event_context ==
- app_event_context_struct;
+ app_event_context_struct;
}
if (!context_fields_match) {
ERR("Registering application channel due to context field mismatch: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
ret_code = -EINVAL;
goto reply;
}
}
reply:
- DBG3("UST app replying to register channel key %" PRIu64
- " with id %u, ret = %d", chan_reg_key, chan_id,
- ret_code);
-
- ret = lttng_ust_ctl_reply_register_channel(sock, chan_id,
- ust_reg_chan.header_type_ == lst::stream_class::header_type::COMPACT ?
- LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT :
- LTTNG_UST_CTL_CHANNEL_HEADER_LARGE,
- ret_code);
+ DBG3("UST app replying to register channel key %" PRIu64 " with id %u, ret = %d",
+ chan_reg_key,
+ chan_id,
+ ret_code);
+
+ ret = lttng_ust_ctl_reply_register_channel(
+ sock,
+ chan_id,
+ ust_reg_chan.header_type_ == lst::stream_class::header_type::COMPACT ?
+ LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT :
+ LTTNG_UST_CTL_CHANNEL_HEADER_LARGE,
+ ret_code);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app reply channel failed. Application died: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app reply channel failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app reply channel failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
return ret;
*
* On success 0 is returned else a negative value.
*/
-static int add_event_ust_registry(int sock, int sobjd, int cobjd, const char *name,
- char *raw_signature, size_t nr_fields, struct lttng_ust_ctl_field *raw_fields,
- int loglevel_value, char *raw_model_emf_uri)
+static int add_event_ust_registry(int sock,
+ int sobjd,
+ int cobjd,
+ const char *name,
+ char *raw_signature,
+ size_t nr_fields,
+ struct lttng_ust_ctl_field *raw_fields,
+ int loglevel_value,
+ char *raw_model_emf_uri)
{
int ret, ret_code;
uint32_t event_id = 0;
/* Lookup application. If not found, there is a code flow error. */
app = find_app_by_notify_sock(sock);
if (!app) {
- DBG("Application socket %d is being torn down. Abort event notify",
- sock);
+ DBG("Application socket %d is being torn down. Abort event notify", sock);
return -1;
}
auto& channel = locked_registry->channel(chan_reg_key);
/* event_id is set on success. */
- channel.add_event(sobjd, cobjd, name, signature.get(),
- lsu::create_trace_fields_from_ust_ctl_fields(
- *locked_registry, fields.get(),
- nr_fields,
- lst::field_location::root::
- EVENT_RECORD_PAYLOAD,
- lsu::ctl_field_quirks::
- UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS),
- loglevel_value,
- model_emf_uri.get() ?
- nonstd::optional<std::string>(
- model_emf_uri.get()) :
- nonstd::nullopt,
- ua_sess->buffer_type, *app, event_id);
+ channel.add_event(
+ sobjd,
+ cobjd,
+ name,
+ signature.get(),
+ lsu::create_trace_fields_from_ust_ctl_fields(
+ *locked_registry,
+ fields.get(),
+ nr_fields,
+ lst::field_location::root::EVENT_RECORD_PAYLOAD,
+ lsu::ctl_field_quirks::
+ UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS),
+ loglevel_value,
+ model_emf_uri.get() ?
+ nonstd::optional<std::string>(model_emf_uri.get()) :
+ nonstd::nullopt,
+ ua_sess->buffer_type,
+ *app,
+ event_id);
ret_code = 0;
} catch (const std::exception& ex) {
- ERR("Failed to add event `%s` to registry session: %s", name,
- ex.what());
+ ERR("Failed to add event `%s` to registry session: %s",
+ name,
+ ex.what());
/* Inform the application of the error; don't return directly. */
ret_code = -EINVAL;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app reply event failed. Application died: pid = %d, sock = %d.",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app reply event failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app reply event failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
/*
* No need to wipe the create event since the application socket will
return ret;
}
- DBG3("UST registry event %s with id %" PRId32 " added successfully",
- name, event_id);
+ DBG3("UST registry event %s with id %" PRId32 " added successfully", name, event_id);
return ret;
}
*
* On success 0 is returned else a negative value.
*/
-static int add_enum_ust_registry(int sock, int sobjd, const char *name,
- struct lttng_ust_ctl_enum_entry *raw_entries, size_t nr_entries)
+static int add_enum_ust_registry(int sock,
+ int sobjd,
+ const char *name,
+ struct lttng_ust_ctl_enum_entry *raw_entries,
+ size_t nr_entries)
{
int ret = 0;
struct ust_app *app;
uint64_t enum_id = -1ULL;
lttng::urcu::read_lock_guard read_lock_guard;
auto entries = lttng::make_unique_wrapper<struct lttng_ust_ctl_enum_entry, lttng::free>(
- raw_entries);
+ raw_entries);
/* Lookup application. If not found, there is a code flow error. */
app = find_app_by_notify_sock(sock);
if (!app) {
/* Return an error since this is not an error */
- DBG("Application socket %d is being torn down. Aborting enum registration",
- sock);
+ DBG("Application socket %d is being torn down. Aborting enum registration", sock);
return -1;
}
int application_reply_code;
try {
locked_registry->create_or_find_enum(
- sobjd, name, entries.release(), nr_entries, &enum_id);
+ sobjd, name, entries.release(), nr_entries, &enum_id);
application_reply_code = 0;
} catch (const std::exception& ex) {
- ERR("%s: %s", fmt::format("Failed to create or find enumeration provided by application: app = {}, enumeration name = {}",
- *app, name).c_str(), ex.what());
+ ERR("%s: %s",
+ fmt::format(
+ "Failed to create or find enumeration provided by application: app = {}, enumeration name = {}",
+ *app,
+ name)
+ .c_str(),
+ ex.what());
application_reply_code = -1;
}
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app reply enum failed. Application died: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app reply enum failed. Communication time out: pid = %d, sock = %d",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app reply enum failed with ret %d: pid = %d, sock = %d",
- ret, app->pid, app->sock);
+ ret,
+ app->pid,
+ app->sock);
}
/*
* No need to wipe the create enum since the application socket will
ret = lttng_ust_ctl_recv_notify(sock, &cmd);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
- DBG3("UST app recv notify failed. Application died: sock = %d",
- sock);
+ DBG3("UST app recv notify failed. Application died: sock = %d", sock);
} else if (ret == -EAGAIN) {
- WARN("UST app recv notify failed. Communication time out: sock = %d",
- sock);
+ WARN("UST app recv notify failed. Communication time out: sock = %d", sock);
} else {
- ERR("UST app recv notify failed with ret %d: sock = %d",
- ret, sock);
+ ERR("UST app recv notify failed with ret %d: sock = %d", ret, sock);
}
goto error;
}
DBG2("UST app ustctl register event received");
- ret = lttng_ust_ctl_recv_register_event(sock, &sobjd, &cobjd, name, &loglevel_value,
- &sig, &nr_fields, &fields, &model_emf_uri);
+ ret = lttng_ust_ctl_recv_register_event(sock,
+ &sobjd,
+ &cobjd,
+ name,
+ &loglevel_value,
+ &sig,
+ &nr_fields,
+ &fields,
+ &model_emf_uri);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app recv event failed. Application died: sock = %d",
- sock);
+ sock);
} else if (ret == -EAGAIN) {
WARN("UST app recv event failed. Communication time out: sock = %d",
- sock);
+ sock);
} else {
- ERR("UST app recv event failed with ret %d: sock = %d",
- ret, sock);
+ ERR("UST app recv event failed with ret %d: sock = %d", ret, sock);
}
goto error;
}
lttng::urcu::read_lock_guard rcu_lock;
const struct ust_app *app = find_app_by_notify_sock(sock);
if (!app) {
- DBG("Application socket %d is being torn down. Abort event notify", sock);
+ DBG("Application socket %d is being torn down. Abort event notify",
+ sock);
ret = -1;
goto error;
}
if ((!fields && nr_fields > 0) || (fields && nr_fields == 0)) {
ERR("Invalid return value from lttng_ust_ctl_recv_register_event: fields = %p, nr_fields = %zu",
- fields, nr_fields);
+ fields,
+ nr_fields);
ret = -1;
free(fields);
goto error;
* code path loses the ownsership of these variables and transfer them
* to the this function.
*/
- ret = add_event_ust_registry(sock, sobjd, cobjd, name, sig, nr_fields,
- fields, loglevel_value, model_emf_uri);
+ ret = add_event_ust_registry(sock,
+ sobjd,
+ cobjd,
+ name,
+ sig,
+ nr_fields,
+ fields,
+ loglevel_value,
+ model_emf_uri);
if (ret < 0) {
goto error;
}
DBG2("UST app ustctl register channel received");
ret = lttng_ust_ctl_recv_register_channel(
- sock, &sobjd, &cobjd, &field_count, &context_fields);
+ sock, &sobjd, &cobjd, &field_count, &context_fields);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app recv channel failed. Application died: sock = %d",
- sock);
+ sock);
} else if (ret == -EAGAIN) {
WARN("UST app recv channel failed. Communication time out: sock = %d",
- sock);
+ sock);
} else {
- ERR("UST app recv channel failed with ret %d: sock = %d", ret,
- sock);
+ ERR("UST app recv channel failed with ret %d: sock = %d",
+ ret,
+ sock);
}
goto error;
}
* that if needed it will be freed. After this, it's invalid to access
* fields or clean them up.
*/
- ret = handle_app_register_channel_notification(sock, cobjd, context_fields, field_count);
+ ret = handle_app_register_channel_notification(
+ sock, cobjd, context_fields, field_count);
if (ret < 0) {
goto error;
}
DBG2("UST app ustctl register enum received");
- ret = lttng_ust_ctl_recv_register_enum(sock, &sobjd, name,
- &entries, &nr_entries);
+ ret = lttng_ust_ctl_recv_register_enum(sock, &sobjd, name, &entries, &nr_entries);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
- DBG3("UST app recv enum failed. Application died: sock = %d",
- sock);
+ DBG3("UST app recv enum failed. Application died: sock = %d", sock);
} else if (ret == -EAGAIN) {
WARN("UST app recv enum failed. Communication time out: sock = %d",
- sock);
+ sock);
} else {
- ERR("UST app recv enum failed with ret %d: sock = %d",
- ret, sock);
+ ERR("UST app recv enum failed with ret %d: sock = %d", ret, sock);
}
goto error;
}
/* Callee assumes ownership of entries. */
- ret = add_enum_ust_registry(sock, sobjd, name,
- entries, nr_entries);
+ ret = add_enum_ust_registry(sock, sobjd, name, entries, nr_entries);
if (ret < 0) {
goto error;
}
*
* Returns LTTNG_OK on success or a LTTNG_ERR error code.
*/
-enum lttng_error_code ust_app_snapshot_record(
- const struct ltt_ust_session *usess,
- const struct consumer_output *output,
- uint64_t nb_packets_per_stream)
+enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *usess,
+ const struct consumer_output *output,
+ uint64_t nb_packets_per_stream)
{
int ret = 0;
enum lttng_error_code status = LTTNG_OK;
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
char pathname[PATH_MAX];
/* Get consumer socket to use to push the metadata.*/
socket = consumer_find_socket_by_bitness(reg->bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
status = LTTNG_ERR_INVALID;
goto error;
}
memset(pathname, 0, sizeof(pathname));
- ret = snprintf(pathname, sizeof(pathname),
- DEFAULT_UST_TRACE_UID_PATH,
- reg->uid, reg->bits_per_long);
+ ret = snprintf(pathname,
+ sizeof(pathname),
+ DEFAULT_UST_TRACE_UID_PATH,
+ reg->uid,
+ reg->bits_per_long);
if (ret < 0) {
PERROR("snprintf snapshot path");
status = LTTNG_ERR_INVALID;
}
/* Free path allowed on previous iteration. */
free(trace_path);
- trace_path = setup_channel_trace_path(usess->consumer, pathname,
- &consumer_path_offset);
+ trace_path = setup_channel_trace_path(
+ usess->consumer, pathname, &consumer_path_offset);
if (!trace_path) {
status = LTTNG_ERR_INVALID;
goto error;
}
/* Add the UST default trace dir to path. */
- cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
- buf_reg_chan, node.node) {
- status = consumer_snapshot_channel(socket,
- buf_reg_chan->consumer_key,
- output, 0, &trace_path[consumer_path_offset],
- nb_packets_per_stream);
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ status =
+ consumer_snapshot_channel(socket,
+ buf_reg_chan->consumer_key,
+ output,
+ 0,
+ &trace_path[consumer_path_offset],
+ nb_packets_per_stream);
if (status != LTTNG_OK) {
goto error;
}
}
status = consumer_snapshot_channel(socket,
- reg->registry->reg.ust->_metadata_key, output, 1,
- &trace_path[consumer_path_offset], 0);
+ reg->registry->reg.ust->_metadata_key,
+ output,
+ 1,
+ &trace_path[consumer_path_offset],
+ 0);
if (status != LTTNG_OK) {
goto error;
}
}
case LTTNG_BUFFER_PER_PID:
{
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct consumer_socket *socket;
struct lttng_ht_iter chan_iter;
struct ust_app_channel *ua_chan;
}
/* Get the right consumer socket for the application. */
- socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
- output);
+ socket = consumer_find_socket_by_bitness(app->abi.bits_per_long, output);
if (!socket) {
status = LTTNG_ERR_INVALID;
goto error;
/* Add the UST default trace dir to path. */
memset(pathname, 0, sizeof(pathname));
- ret = snprintf(pathname, sizeof(pathname), "%s",
- ua_sess->path);
+ ret = snprintf(pathname, sizeof(pathname), "%s", ua_sess->path);
if (ret < 0) {
status = LTTNG_ERR_INVALID;
PERROR("snprintf snapshot path");
}
/* Free path allowed on previous iteration. */
free(trace_path);
- trace_path = setup_channel_trace_path(usess->consumer, pathname,
- &consumer_path_offset);
+ trace_path = setup_channel_trace_path(
+ usess->consumer, pathname, &consumer_path_offset);
if (!trace_path) {
status = LTTNG_ERR_INVALID;
goto error;
}
- cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
- ua_chan, node.node) {
- status = consumer_snapshot_channel(socket,
- ua_chan->key, output, 0,
- &trace_path[consumer_path_offset],
- nb_packets_per_stream);
+ cds_lfht_for_each_entry (
+ ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
+ status =
+ consumer_snapshot_channel(socket,
+ ua_chan->key,
+ output,
+ 0,
+ &trace_path[consumer_path_offset],
+ nb_packets_per_stream);
switch (status) {
case LTTNG_OK:
break;
continue;
}
status = consumer_snapshot_channel(socket,
- registry->_metadata_key, output, 1,
- &trace_path[consumer_path_offset], 0);
+ registry->_metadata_key,
+ output,
+ 1,
+ &trace_path[consumer_path_offset],
+ 0);
switch (status) {
case LTTNG_OK:
break;
/*
* Return the size taken by one more packet per stream.
*/
-uint64_t ust_app_get_size_one_more_packet_per_stream(
- const struct ltt_ust_session *usess, uint64_t cur_nr_packets)
+uint64_t ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_session *usess,
+ uint64_t cur_nr_packets)
{
uint64_t tot_size = 0;
struct ust_app *app;
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct buffer_reg_channel *buf_reg_chan;
rcu_read_lock();
- cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
- buf_reg_chan, node.node) {
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
if (cur_nr_packets >= buf_reg_chan->num_subbuf) {
/*
* Don't take channel into account if we
case LTTNG_BUFFER_PER_PID:
{
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct ust_app_channel *ua_chan;
struct ust_app_session *ua_sess;
struct lttng_ht_iter chan_iter;
continue;
}
- cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
- ua_chan, node.node) {
+ cds_lfht_for_each_entry (
+ ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
if (cur_nr_packets >= ua_chan->attr.num_subbuf) {
/*
* Don't take channel into account if we
}
int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
- struct cds_list_head *buffer_reg_uid_list,
- struct consumer_output *consumer, uint64_t uchan_id,
- int overwrite, uint64_t *discarded, uint64_t *lost)
+ struct cds_list_head *buffer_reg_uid_list,
+ struct consumer_output *consumer,
+ uint64_t uchan_id,
+ int overwrite,
+ uint64_t *discarded,
+ uint64_t *lost)
{
int ret;
uint64_t consumer_chan_key;
*lost = 0;
ret = buffer_reg_uid_consumer_channel_key(
- buffer_reg_uid_list, uchan_id, &consumer_chan_key);
+ buffer_reg_uid_list, uchan_id, &consumer_chan_key);
if (ret < 0) {
/* Not found */
ret = 0;
}
if (overwrite) {
- ret = consumer_get_lost_packets(ust_session_id,
- consumer_chan_key, consumer, lost);
+ ret = consumer_get_lost_packets(ust_session_id, consumer_chan_key, consumer, lost);
} else {
- ret = consumer_get_discarded_events(ust_session_id,
- consumer_chan_key, consumer, discarded);
+ ret = consumer_get_discarded_events(
+ ust_session_id, consumer_chan_key, consumer, discarded);
}
end:
}
int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan,
- struct consumer_output *consumer, int overwrite,
- uint64_t *discarded, uint64_t *lost)
+ struct ltt_ust_channel *uchan,
+ struct consumer_output *consumer,
+ int overwrite,
+ uint64_t *discarded,
+ uint64_t *lost)
{
int ret = 0;
struct lttng_ht_iter iter;
* Iterate over every registered applications. Sum counters for
* all applications containing requested session and channel.
*/
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ht_iter uiter;
ua_sess = lookup_session_by_app(usess, app);
if (overwrite) {
uint64_t _lost;
- ret = consumer_get_lost_packets(usess->id, ua_chan->key,
- consumer, &_lost);
+ ret = consumer_get_lost_packets(usess->id, ua_chan->key, consumer, &_lost);
if (ret < 0) {
break;
}
} else {
uint64_t _discarded;
- ret = consumer_get_discarded_events(usess->id,
- ua_chan->key, consumer, &_discarded);
+ ret = consumer_get_discarded_events(
+ usess->id, ua_chan->key, consumer, &_discarded);
if (ret < 0) {
break;
}
return ret;
}
-static
-int ust_app_regenerate_statedump(struct ltt_ust_session *usess,
- struct ust_app *app)
+static int ust_app_regenerate_statedump(struct ltt_ust_session *usess, struct ust_app *app)
{
int ret = 0;
struct ust_app_session *ua_sess;
rcu_read_lock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
continue;
}
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
/* Get consumer socket to use to push the metadata.*/
socket = consumer_find_socket_by_bitness(reg->bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
/* Rotate the data channels. */
- cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
- buf_reg_chan, node.node) {
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
ret = consumer_rotate_channel(socket,
- buf_reg_chan->consumer_key,
- usess->consumer,
- /* is_metadata_channel */ false);
+ buf_reg_chan->consumer_key,
+ usess->consumer,
+ /* is_metadata_channel */ false);
if (ret < 0) {
cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
ret = consumer_rotate_channel(socket,
- reg->registry->reg.ust->_metadata_key,
- usess->consumer,
- /* is_metadata_channel */ true);
+ reg->registry->reg.ust->_metadata_key,
+ usess->consumer,
+ /* is_metadata_channel */ true);
if (ret < 0) {
cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
case LTTNG_BUFFER_PER_PID:
{
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct consumer_socket *socket;
struct lttng_ht_iter chan_iter;
struct ust_app_channel *ua_chan;
/* Get the right consumer socket for the application. */
socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
/* Rotate the data channels. */
- cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
- ua_chan, node.node) {
+ cds_lfht_for_each_entry (
+ ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
ret = consumer_rotate_channel(socket,
- ua_chan->key,
- ua_sess->consumer,
- /* is_metadata_channel */ false);
+ ua_chan->key,
+ ua_sess->consumer,
+ /* is_metadata_channel */ false);
if (ret < 0) {
/* Per-PID buffer and application going away. */
if (ret == -LTTNG_ERR_CHAN_NOT_FOUND)
(void) push_metadata(locked_registry, usess->consumer);
}
ret = consumer_rotate_channel(socket,
- registry->_metadata_key,
- ua_sess->consumer,
- /* is_metadata_channel */ true);
+ registry->_metadata_key,
+ ua_sess->consumer,
+ /* is_metadata_channel */ true);
if (ret < 0) {
/* Per-PID buffer and application going away. */
if (ret == -LTTNG_ERR_CHAN_NOT_FOUND)
return cmd_ret;
}
-enum lttng_error_code ust_app_create_channel_subdirectories(
- const struct ltt_ust_session *usess)
+enum lttng_error_code ust_app_create_channel_subdirectories(const struct ltt_ust_session *usess)
{
enum lttng_error_code ret = LTTNG_OK;
struct lttng_ht_iter iter;
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
fmt_ret = asprintf(&pathname_index,
- DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH "/" DEFAULT_INDEX_DIR,
- reg->uid, reg->bits_per_long);
+ DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH
+ "/" DEFAULT_INDEX_DIR,
+ reg->uid,
+ reg->bits_per_long);
if (fmt_ret < 0) {
ERR("Failed to format channel index directory");
ret = LTTNG_ERR_CREATE_DIR_FAIL;
* of implicitly creating the channel's path.
*/
chunk_status = lttng_trace_chunk_create_subdirectory(
- usess->current_trace_chunk,
- pathname_index);
+ usess->current_trace_chunk, pathname_index);
free(pathname_index);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
/*
* Create the toplevel ust/ directory in case no apps are running.
*/
- chunk_status = lttng_trace_chunk_create_subdirectory(
- usess->current_trace_chunk,
- DEFAULT_UST_TRACE_DIR);
+ chunk_status = lttng_trace_chunk_create_subdirectory(usess->current_trace_chunk,
+ DEFAULT_UST_TRACE_DIR);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
goto error;
}
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app,
- pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct ust_app_session *ua_sess;
lsu::registry_session *registry;
}
fmt_ret = asprintf(&pathname_index,
- DEFAULT_UST_TRACE_DIR "/%s/" DEFAULT_INDEX_DIR,
- ua_sess->path);
+ DEFAULT_UST_TRACE_DIR "/%s/" DEFAULT_INDEX_DIR,
+ ua_sess->path);
if (fmt_ret < 0) {
ERR("Failed to format channel index directory");
ret = LTTNG_ERR_CREATE_DIR_FAIL;
* of implicitly creating the channel's path.
*/
chunk_status = lttng_trace_chunk_create_subdirectory(
- usess->current_trace_chunk,
- pathname_index);
+ usess->current_trace_chunk, pathname_index);
free(pathname_index);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = LTTNG_ERR_CREATE_DIR_FAIL;
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
/* Get consumer socket to use to push the metadata.*/
socket = consumer_find_socket_by_bitness(reg->bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
cmd_ret = LTTNG_ERR_INVALID;
goto error_socket;
}
/* Clear the data channels. */
- cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
- buf_reg_chan, node.node) {
- ret = consumer_clear_channel(socket,
- buf_reg_chan->consumer_key);
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ ret = consumer_clear_channel(socket, buf_reg_chan->consumer_key);
if (ret < 0) {
goto error;
}
* Metadata channel is not cleared per se but we still need to
* perform a rotation operation on it behind the scene.
*/
- ret = consumer_clear_channel(socket,
- reg->registry->reg.ust->_metadata_key);
+ ret = consumer_clear_channel(socket, reg->registry->reg.ust->_metadata_key);
if (ret < 0) {
goto error;
}
}
case LTTNG_BUFFER_PER_PID:
{
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct consumer_socket *socket;
struct lttng_ht_iter chan_iter;
struct ust_app_channel *ua_chan;
/* Get the right consumer socket for the application. */
socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
- usess->consumer);
+ usess->consumer);
if (!socket) {
cmd_ret = LTTNG_ERR_INVALID;
goto error_socket;
}
/* Clear the data channels. */
- cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
- ua_chan, node.node) {
+ cds_lfht_for_each_entry (
+ ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
ret = consumer_clear_channel(socket, ua_chan->key);
if (ret < 0) {
/* Per-PID buffer and application going away. */
{
struct buffer_reg_uid *reg;
- cds_list_for_each_entry (
- reg, &usess->buffer_reg_uid_list, lnode) {
+ cds_list_for_each_entry (reg, &usess->buffer_reg_uid_list, lnode) {
struct buffer_reg_channel *buf_reg_chan;
struct consumer_socket *socket;
- socket = consumer_find_socket_by_bitness(
- reg->bits_per_long, usess->consumer);
+ socket = consumer_find_socket_by_bitness(reg->bits_per_long,
+ usess->consumer);
if (!socket) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- cds_lfht_for_each_entry(reg->registry->channels->ht,
- &iter.iter, buf_reg_chan, node.node) {
- const int open_ret =
- consumer_open_channel_packets(
- socket,
- buf_reg_chan->consumer_key);
+ cds_lfht_for_each_entry (
+ reg->registry->channels->ht, &iter.iter, buf_reg_chan, node.node) {
+ const int open_ret = consumer_open_channel_packets(
+ socket, buf_reg_chan->consumer_key);
if (open_ret < 0) {
ret = LTTNG_ERR_UNK;
{
struct ust_app *app;
- cds_lfht_for_each_entry (
- ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+ cds_lfht_for_each_entry (ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct consumer_socket *socket;
struct lttng_ht_iter chan_iter;
struct ust_app_channel *ua_chan;
}
/* Get the right consumer socket for the application. */
- socket = consumer_find_socket_by_bitness(
- app->abi.bits_per_long, usess->consumer);
+ socket = consumer_find_socket_by_bitness(app->abi.bits_per_long,
+ usess->consumer);
if (!socket) {
ret = LTTNG_ERR_FATAL;
goto error;
continue;
}
- cds_lfht_for_each_entry(ua_sess->channels->ht,
- &chan_iter.iter, ua_chan, node.node) {
+ cds_lfht_for_each_entry (
+ ua_sess->channels->ht, &chan_iter.iter, ua_chan, node.node) {
const int open_ret =
- consumer_open_channel_packets(
- socket,
- ua_chan->key);
+ consumer_open_channel_packets(socket, ua_chan->key);
if (open_ret < 0) {
/*
* correctly match, making this quirk unnecessary.
*/
return v_major <= 9 ? lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS :
- lsu::ctl_field_quirks::NONE;
+ lsu::ctl_field_quirks::NONE;
}
\ No newline at end of file
#include "ust-clock-class.hpp"
-#include <common/time.hpp>
#include <common/exception.hpp>
+#include <common/time.hpp>
#include <lttng/ust-clock.h>
-#define CLOCK_OFFSET_SAMPLE_COUNT 10
+#define CLOCK_OFFSET_SAMPLE_COUNT 10
namespace lst = lttng::sessiond::trace;
LTTNG_THROW_ERROR("Failed to parse UUID from string");
}
- return nonstd::optional<lttng_uuid>{uuid};
+ return nonstd::optional<lttng_uuid>{ uuid };
}
const char *sample_clock_name()
const auto name = get_name_cb();
if (!name) {
- LTTNG_THROW_ERROR("Invalid clock name returned by LTTng-UST `lttng_ust_clock_name_function`");
+ LTTNG_THROW_ERROR(
+ "Invalid clock name returned by LTTng-UST `lttng_ust_clock_name_function`");
}
return name;
const auto description = get_description_cb();
if (!description) {
- LTTNG_THROW_ERROR("Invalid clock description returned by LTTng-UST `lttng_ust_clock_description_function`");
+ LTTNG_THROW_ERROR(
+ "Invalid clock description returned by LTTng-UST `lttng_ust_clock_description_function`");
}
return description;
*/
void measure_single_clock_offset(struct offset_sample *sample)
{
- lst::clock_class::cycles_t monotonic_avg, monotonic[2], measure_delta,
- realtime;
+ lst::clock_class::cycles_t monotonic_avg, monotonic[2], measure_delta, realtime;
const auto tcf = sample_clock_frequency();
struct timespec rts = { 0, 0 };
if (tcf == NSEC_PER_SEC) {
realtime += rts.tv_nsec;
} else {
- realtime += (lst::clock_class::cycles_t) rts.tv_nsec * tcf /
- NSEC_PER_SEC;
+ realtime += (lst::clock_class::cycles_t) rts.tv_nsec * tcf / NSEC_PER_SEC;
}
sample->offset = (lst::clock_class::scycles_t) realtime - monotonic_avg;
lttng::sessiond::ust::clock_class::clock_class() :
lst::clock_class(sample_clock_name(),
- sample_clock_description(),
- sample_clock_uuid(),
- measure_clock_offset(),
- sample_clock_frequency())
+ sample_clock_description(),
+ sample_clock_uuid(),
+ measure_clock_offset(),
+ sample_clock_frequency())
{
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
+#include "buffer-registry.hpp"
+#include "consumer.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "lttng-ust-error.hpp"
+#include "session.hpp"
+#include "ust-consumer.hpp"
-#include <common/compat/errno.hpp>
#include <common/common.hpp>
+#include <common/compat/errno.hpp>
#include <common/consumer/consumer.hpp>
#include <common/defaults.hpp>
-#include "consumer.hpp"
-#include "health-sessiond.hpp"
-#include "ust-consumer.hpp"
-#include "lttng-ust-error.hpp"
-#include "buffer-registry.hpp"
-#include "session.hpp"
-#include "lttng-sessiond.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
namespace lsu = lttng::sessiond::ust;
* Consumer socket lock MUST be acquired before calling this.
*/
static int ask_channel_creation(struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan,
- struct consumer_output *consumer,
- struct consumer_socket *socket,
- lsu::registry_session *registry,
- struct lttng_trace_chunk *trace_chunk)
+ struct ust_app_channel *ua_chan,
+ struct consumer_output *consumer,
+ struct consumer_socket *socket,
+ lsu::registry_session *registry,
+ struct lttng_trace_chunk *trace_chunk)
{
int ret, output;
uint32_t chan_id;
is_local_trace = consumer->net_seq_index == -1ULL;
/* Format the channel's path (relative to the current trace chunk). */
- pathname = setup_channel_trace_path(consumer, ua_sess->path,
- &consumer_path_offset);
+ pathname = setup_channel_trace_path(consumer, ua_sess->path, &consumer_path_offset);
if (!pathname) {
ret = -1;
goto error;
enum lttng_trace_chunk_status chunk_status;
char *pathname_index;
- ret = asprintf(&pathname_index, "%s/" DEFAULT_INDEX_DIR,
- pathname);
+ ret = asprintf(&pathname_index, "%s/" DEFAULT_INDEX_DIR, pathname);
if (ret < 0) {
ERR("Failed to format channel index directory");
ret = -1;
* Create the index subdirectory which will take care
* of implicitly creating the channel's path.
*/
- chunk_status = lttng_trace_chunk_create_subdirectory(
- trace_chunk, pathname_index);
+ chunk_status = lttng_trace_chunk_create_subdirectory(trace_chunk, pathname_index);
free(pathname_index);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
if (ua_sess->shm_path[0]) {
strncpy(shm_path, ua_sess->shm_path, sizeof(shm_path));
shm_path[sizeof(shm_path) - 1] = '\0';
- strncat(shm_path, "/",
- sizeof(shm_path) - strlen(shm_path) - 1);
- strncat(shm_path, ua_chan->name,
- sizeof(shm_path) - strlen(shm_path) - 1);
- strncat(shm_path, "_",
- sizeof(shm_path) - strlen(shm_path) - 1);
+ strncat(shm_path, "/", sizeof(shm_path) - strlen(shm_path) - 1);
+ strncat(shm_path, ua_chan->name, sizeof(shm_path) - strlen(shm_path) - 1);
+ strncat(shm_path, "_", sizeof(shm_path) - strlen(shm_path) - 1);
}
strncpy(root_shm_path, ua_sess->root_shm_path, sizeof(root_shm_path));
root_shm_path[sizeof(root_shm_path) - 1] = '\0';
}
consumer_init_ask_channel_comm_msg(&msg,
- ua_chan->attr.subbuf_size,
- ua_chan->attr.num_subbuf,
- ua_chan->attr.overwrite,
- ua_chan->attr.switch_timer_interval,
- ua_chan->attr.read_timer_interval,
- ua_sess->live_timer_interval,
- ua_sess->live_timer_interval != 0,
- ua_chan->monitor_timer_interval,
- output,
- (int) ua_chan->attr.type,
- ua_sess->tracing_id,
- &pathname[consumer_path_offset],
- ua_chan->name,
- consumer->net_seq_index,
- ua_chan->key,
- registry->uuid,
- chan_id,
- ua_chan->tracefile_size,
- ua_chan->tracefile_count,
- ua_sess->id,
- ua_sess->output_traces,
- lttng_credentials_get_uid(&ua_sess->real_credentials),
- ua_chan->attr.blocking_timeout,
- root_shm_path, shm_path,
- trace_chunk,
- &ua_sess->effective_credentials);
+ ua_chan->attr.subbuf_size,
+ ua_chan->attr.num_subbuf,
+ ua_chan->attr.overwrite,
+ ua_chan->attr.switch_timer_interval,
+ ua_chan->attr.read_timer_interval,
+ ua_sess->live_timer_interval,
+ ua_sess->live_timer_interval != 0,
+ ua_chan->monitor_timer_interval,
+ output,
+ (int) ua_chan->attr.type,
+ ua_sess->tracing_id,
+ &pathname[consumer_path_offset],
+ ua_chan->name,
+ consumer->net_seq_index,
+ ua_chan->key,
+ registry->uuid,
+ chan_id,
+ ua_chan->tracefile_size,
+ ua_chan->tracefile_count,
+ ua_sess->id,
+ ua_sess->output_traces,
+ lttng_credentials_get_uid(&ua_sess->real_credentials),
+ ua_chan->attr.blocking_timeout,
+ root_shm_path,
+ shm_path,
+ trace_chunk,
+ &ua_sess->effective_credentials);
health_code_update();
goto error;
}
- ret = consumer_recv_status_channel(socket, &key,
- &ua_chan->expected_stream_count);
+ ret = consumer_recv_status_channel(socket, &key, &ua_chan->expected_stream_count);
if (ret < 0) {
goto error;
}
LTTNG_ASSERT(ua_chan->expected_stream_count > 0);
}
- DBG2("UST ask channel %" PRIu64 " successfully done with %u stream(s)", key,
- ua_chan->expected_stream_count);
+ DBG2("UST ask channel %" PRIu64 " successfully done with %u stream(s)",
+ key,
+ ua_chan->expected_stream_count);
error:
free(pathname);
* Returns 0 on success else a negative value.
*/
int ust_consumer_ask_channel(struct ust_app_session *ua_sess,
- struct ust_app_channel *ua_chan,
- struct consumer_output *consumer,
- struct consumer_socket *socket,
- lsu::registry_session *registry,
- struct lttng_trace_chunk * trace_chunk)
+ struct ust_app_channel *ua_chan,
+ struct consumer_output *consumer,
+ struct consumer_socket *socket,
+ lsu::registry_session *registry,
+ struct lttng_trace_chunk *trace_chunk)
{
int ret;
}
pthread_mutex_lock(socket->lock);
- ret = ask_channel_creation(ua_sess, ua_chan, consumer, socket, registry,
- trace_chunk);
+ ret = ask_channel_creation(ua_sess, ua_chan, consumer, socket, registry, trace_chunk);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
ERR("ask_channel_creation consumer command failed");
*
* Return 0 on success else a negative value.
*/
-int ust_consumer_get_channel(struct consumer_socket *socket,
- struct ust_app_channel *ua_chan)
+int ust_consumer_get_channel(struct consumer_socket *socket, struct ust_app_channel *ua_chan)
{
int ret;
struct lttcomm_consumer_msg msg;
if (ret < 0) {
if (ret != -EPIPE) {
ERR("Error recv channel from consumer %d with ret %d",
- *socket->fd_ptr, ret);
+ *socket->fd_ptr,
+ ret);
} else {
DBG3("UST app recv channel from consumer. Consumer is dead.");
}
}
if (ret != -EPIPE) {
ERR("Recv stream from consumer %d with ret %d",
- *socket->fd_ptr, ret);
+ *socket->fd_ptr,
+ ret);
} else {
DBG3("UST app recv stream from consumer. Consumer is dead.");
}
*
* Return 0 on success else a negative value.
*/
-int ust_consumer_destroy_channel(struct consumer_socket *socket,
- struct ust_app_channel *ua_chan)
+int ust_consumer_destroy_channel(struct consumer_socket *socket, struct ust_app_channel *ua_chan)
{
int ret;
struct lttcomm_consumer_msg msg;
* On success return 0 else a negative value.
*/
int ust_consumer_send_stream_to_ust(struct ust_app *app,
- struct ust_app_channel *channel, struct ust_app_stream *stream)
+ struct ust_app_channel *channel,
+ struct ust_app_stream *stream)
{
int ret;
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app send stream to ust failed. Application is dead. (pid: %d, sock: %d).",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app send stream to ust failed. Communication time out (pid: %d, sock: %d).",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app send stream, handle %d, to ust failed with ret %d (pid: %d, sock: %d).",
- stream->obj->handle, ret, app->pid,
- app->sock);
+ stream->obj->handle,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
* On success return 0 else a negative value.
*/
int ust_consumer_send_channel_to_ust(struct ust_app *app,
- struct ust_app_session *ua_sess, struct ust_app_channel *channel)
+ struct ust_app_session *ua_sess,
+ struct ust_app_channel *channel)
{
int ret;
LTTNG_ASSERT(channel->obj);
DBG2("UST app send channel to sock %d pid %d (name: %s, key: %" PRIu64 ")",
- app->sock, app->pid, channel->name, channel->tracing_channel_id);
+ app->sock,
+ app->pid,
+ channel->name,
+ channel->tracing_channel_id);
/* Send stream to application. */
pthread_mutex_lock(&app->sock_lock);
if (ret < 0) {
if (ret == -EPIPE || ret == -LTTNG_UST_ERR_EXITING) {
DBG3("UST app send channel to ust failed. Application is dead (pid: %d, sock: %d).",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else if (ret == -EAGAIN) {
WARN("UST app send channel to ust failed. Communication timeout (pid: %d, sock: %d).",
- app->pid, app->sock);
+ app->pid,
+ app->sock);
} else {
ERR("UST app send channel %s, to ust failed with ret %d (pid: %d, sock: %d).",
- channel->name, ret, app->pid,
- app->sock);
+ channel->name,
+ ret,
+ app->pid,
+ app->sock);
}
goto error;
}
}
DBG("Metadata request received for session %" PRIu64 ", key %" PRIu64,
- request.session_id, request.key);
+ request.session_id,
+ request.key);
- reg_uid = buffer_reg_uid_find(request.session_id,
- request.bits_per_long, request.uid);
+ reg_uid = buffer_reg_uid_find(request.session_id, request.bits_per_long, request.uid);
if (reg_uid) {
ust_reg = reg_uid->registry->reg.ust;
} else {
- struct buffer_reg_pid *reg_pid =
- buffer_reg_pid_find(request.session_id_per_pid);
+ struct buffer_reg_pid *reg_pid = buffer_reg_pid_find(request.session_id_per_pid);
if (!reg_pid) {
DBG("PID registry not found for session id %" PRIu64,
- request.session_id_per_pid);
+ request.session_id_per_pid);
memset(&msg, 0, sizeof(msg));
msg.cmd_type = LTTNG_ERR_UND;
class session_attributes {
public:
using registry_enum_getter_fn =
- std::function<lsu::registry_enum::const_rcu_protected_reference(
- const char *name, uint64_t id)>;
+ std::function<lsu::registry_enum::const_rcu_protected_reference(const char *name,
+ uint64_t id)>;
session_attributes(registry_enum_getter_fn reg_enum_getter,
- lst::byte_order native_trace_byte_order) :
- get_registry_enum{reg_enum_getter}, _native_trace_byte_order{native_trace_byte_order}
+ lst::byte_order native_trace_byte_order) :
+ get_registry_enum{ reg_enum_getter },
+ _native_trace_byte_order{ native_trace_byte_order }
{
}
using publish_field_fn = std::function<void(lst::field::uptr)>;
/* Look-up field from a field location. */
-using lookup_field_fn = std::function<const lst::field &(const lst::field_location &)>;
-
-lst::type::cuptr create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements& current_field_location_elements,
- lsu::ctl_field_quirks quirks);
+using lookup_field_fn = std::function<const lst::field&(const lst::field_location&)>;
+
+lst::type::cuptr
+create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks);
void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements& current_field_location_elements,
- lsu::ctl_field_quirks quirks);
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks);
template <class UstCtlEncodingType>
-enum lst::null_terminated_string_type::encoding ust_ctl_encoding_to_string_field_encoding(UstCtlEncodingType encoding)
+enum lst::null_terminated_string_type::encoding
+ust_ctl_encoding_to_string_field_encoding(UstCtlEncodingType encoding)
{
- static const std::unordered_map<UstCtlEncodingType, enum lst::null_terminated_string_type::encoding>
- encoding_conversion_map = {
- {(UstCtlEncodingType) lttng_ust_ctl_encode_ASCII,
- lst::null_terminated_string_type::encoding::ASCII},
- {(UstCtlEncodingType) lttng_ust_ctl_encode_UTF8,
- lst::null_terminated_string_type::encoding::UTF8},
- };
+ static const std::unordered_map<UstCtlEncodingType,
+ enum lst::null_terminated_string_type::encoding>
+ encoding_conversion_map = {
+ { (UstCtlEncodingType) lttng_ust_ctl_encode_ASCII,
+ lst::null_terminated_string_type::encoding::ASCII },
+ { (UstCtlEncodingType) lttng_ust_ctl_encode_UTF8,
+ lst::null_terminated_string_type::encoding::UTF8 },
+ };
const auto encoding_it = encoding_conversion_map.find(encoding);
if (encoding_it == encoding_conversion_map.end()) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unknown lttng_ust_ctl_string_encodings value `{}` encountered when decoding integer field",
- encoding));
+ "Unknown lttng_ust_ctl_string_encodings value `{}` encountered when decoding integer field",
+ encoding));
}
return encoding_it->second;
enum lst::integer_type::base ust_ctl_base_to_integer_field_base(UstCtlBaseType base)
{
static const std::unordered_map<UstCtlBaseType, enum lst::integer_type::base>
- base_conversion_map = {{2, lst::integer_type::base::BINARY},
- {8, lst::integer_type::base::OCTAL},
- {10, lst::integer_type::base::DECIMAL},
- {16, lst::integer_type::base::HEXADECIMAL}};
+ base_conversion_map = { { 2, lst::integer_type::base::BINARY },
+ { 8, lst::integer_type::base::OCTAL },
+ { 10, lst::integer_type::base::DECIMAL },
+ { 16, lst::integer_type::base::HEXADECIMAL } };
const auto base_it = base_conversion_map.find(base);
if (base_it == base_conversion_map.end()) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unknown integer base value `{}` encountered when decoding integer field",
- base));
+ "Unknown integer base value `{}` encountered when decoding integer field",
+ base));
}
return base_it->second;
}
-lst::type::cuptr create_integer_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_integer_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto base = ust_ctl_base_to_integer_field_base(current->type.u.integer.base);
const auto signedness = current->type.u.integer.signedness ?
- lst::integer_type::signedness::SIGNED :
- lst::integer_type::signedness::UNSIGNED;
+ lst::integer_type::signedness::SIGNED :
+ lst::integer_type::signedness::UNSIGNED;
const auto byte_order = current->type.u.integer.reverse_byte_order ?
- lst::type::reverse_byte_order(session_attributes._native_trace_byte_order) :
- session_attributes._native_trace_byte_order;
+ lst::type::reverse_byte_order(session_attributes._native_trace_byte_order) :
+ session_attributes._native_trace_byte_order;
*next_ust_ctl_field = current + 1;
return lttng::make_unique<const lst::integer_type>(current->type.u.integer.alignment,
- byte_order, current->type.u.integer.size, signedness, base);
+ byte_order,
+ current->type.u.integer.size,
+ signedness,
+ base);
}
-lst::type::cuptr create_floating_point_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_floating_point_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
*next_ust_ctl_field = current + 1;
const auto byte_order = current->type.u._float.reverse_byte_order ?
- lst::type::reverse_byte_order(session_attributes._native_trace_byte_order) :
- session_attributes._native_trace_byte_order;
+ lst::type::reverse_byte_order(session_attributes._native_trace_byte_order) :
+ session_attributes._native_trace_byte_order;
try {
return lttng::make_unique<const lst::floating_point_type>(
- current->type.u._float.alignment, byte_order,
- current->type.u._float.exp_dig, current->type.u._float.mant_dig);
+ current->type.u._float.alignment,
+ byte_order,
+ current->type.u._float.exp_dig,
+ current->type.u._float.mant_dig);
} catch (lttng::invalid_argument_error& ex) {
- LTTNG_THROW_PROTOCOL_ERROR(fmt::format("Invalid floating point attribute in {}: {}",
- typeid(*current), ex.what()));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "Invalid floating point attribute in {}: {}", typeid(*current), ex.what()));
}
}
-lst::type::cuptr create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
uint64_t enumeration_id;
const auto& enum_uctl_field = *current;
const char *enumeration_name;
const auto *enum_container_uctl_type =
- ¤t->type.u.legacy.basic.enumeration.container_type;
+ ¤t->type.u.legacy.basic.enumeration.container_type;
if (enum_uctl_field.type.atype == lttng_ust_ctl_atype_enum_nestable) {
/* Nestable enumeration fields are followed by their container type. */
++current;
if (current >= end) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Array of {} is too short to contain nestable enumeration's container",
- typeid(*current)));
+ "Array of {} is too short to contain nestable enumeration's container",
+ typeid(*current)));
}
if (current->type.atype != lttng_ust_ctl_atype_integer) {
- LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Invalid type of nestable enum container: type id = {}",
- current->type.atype));
+ LTTNG_THROW_PROTOCOL_ERROR(
+ fmt::format("Invalid type of nestable enum container: type id = {}",
+ current->type.atype));
}
enum_container_uctl_type = ¤t->type.u.integer;
const auto base = ust_ctl_base_to_integer_field_base(enum_container_uctl_type->base);
const auto byte_order = enum_container_uctl_type->reverse_byte_order ?
- lst::integer_type::reverse_byte_order(
- session_attributes._native_trace_byte_order) :
- session_attributes._native_trace_byte_order;
+ lst::integer_type::reverse_byte_order(session_attributes._native_trace_byte_order) :
+ session_attributes._native_trace_byte_order;
const auto signedness = enum_container_uctl_type->signedness ?
- lst::integer_type::signedness::SIGNED :
- lst::integer_type::signedness::UNSIGNED;
+ lst::integer_type::signedness::SIGNED :
+ lst::integer_type::signedness::UNSIGNED;
if (signedness == lst::integer_type::signedness::SIGNED) {
const auto& enum_registry = static_cast<const lsu::registry_signed_enum&>(
- *session_attributes.get_registry_enum(
- enumeration_name, enumeration_id));
+ *session_attributes.get_registry_enum(enumeration_name, enumeration_id));
return lttng::make_unique<const lst::signed_enumeration_type>(
- enum_container_uctl_type->alignment, byte_order,
- enum_container_uctl_type->size, base,
- enum_registry._mappings);
+ enum_container_uctl_type->alignment,
+ byte_order,
+ enum_container_uctl_type->size,
+ base,
+ enum_registry._mappings);
} else {
const auto& enum_registry = static_cast<const lsu::registry_unsigned_enum&>(
- *session_attributes.get_registry_enum(
- enumeration_name, enumeration_id));
+ *session_attributes.get_registry_enum(enumeration_name, enumeration_id));
return lttng::make_unique<const lst::unsigned_enumeration_type>(
- enum_container_uctl_type->alignment, byte_order,
- enum_container_uctl_type->size, base,
- enum_registry._mappings);
+ enum_container_uctl_type->alignment,
+ byte_order,
+ enum_container_uctl_type->size,
+ base,
+ enum_registry._mappings);
}
}
-lst::type::cuptr create_string_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes __attribute__((unused)),
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_string_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes
+ __attribute__((unused)),
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& string_uctl_field = *current;
*next_ust_ctl_field = current + 1;
- const auto encoding = ust_ctl_encoding_to_string_field_encoding(
- string_uctl_field.type.u.string.encoding);
+ const auto encoding =
+ ust_ctl_encoding_to_string_field_encoding(string_uctl_field.type.u.string.encoding);
return lttng::make_unique<const lst::null_terminated_string_type>(1, encoding);
}
-lst::type::cuptr create_integer_type_from_ust_ctl_basic_type(
- const lttng_ust_ctl_basic_type& type, const session_attributes& session_attributes)
+lst::type::cuptr
+create_integer_type_from_ust_ctl_basic_type(const lttng_ust_ctl_basic_type& type,
+ const session_attributes& session_attributes)
{
/* Checked by caller. */
LTTNG_ASSERT(type.atype == lttng_ust_ctl_atype_integer);
const auto byte_order = type.u.basic.integer.reverse_byte_order ?
- lst::integer_type::reverse_byte_order(
- session_attributes._native_trace_byte_order) :
- session_attributes._native_trace_byte_order;
+ lst::integer_type::reverse_byte_order(session_attributes._native_trace_byte_order) :
+ session_attributes._native_trace_byte_order;
const auto signedness = type.u.basic.integer.signedness ?
- lst::integer_type::signedness::SIGNED :
- lst::integer_type::signedness::UNSIGNED;
+ lst::integer_type::signedness::SIGNED :
+ lst::integer_type::signedness::UNSIGNED;
const auto base = ust_ctl_base_to_integer_field_base(type.u.basic.integer.base);
const auto size = type.u.basic.integer.size;
const auto alignment = type.u.basic.integer.alignment;
return lttng::make_unique<const lst::integer_type>(
- alignment, byte_order, size, signedness, base);
+ alignment, byte_order, size, signedness, base);
}
-lst::type::cuptr create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& array_uctl_field = *current;
const auto& element_uctl_type = array_uctl_field.type.u.legacy.array.elem_type;
if (element_uctl_type.atype != lttng_ust_ctl_atype_integer) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected legacy array element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
- element_uctl_type.atype, lttng_ust_ctl_atype_integer));
+ "Unexpected legacy array element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
+ element_uctl_type.atype,
+ lttng_ust_ctl_atype_integer));
}
- element_type = create_integer_type_from_ust_ctl_basic_type(
- element_uctl_type, session_attributes);
+ element_type =
+ create_integer_type_from_ust_ctl_basic_type(element_uctl_type, session_attributes);
if (element_uctl_type.atype == lttng_ust_ctl_atype_integer &&
- element_uctl_type.u.basic.integer.encoding != lttng_ust_ctl_encode_none) {
+ element_uctl_type.u.basic.integer.encoding != lttng_ust_ctl_encode_none) {
/* Element represents a text character. */
element_encoding = ust_ctl_encoding_to_string_field_encoding(
- element_uctl_type.u.basic.integer.encoding);
+ element_uctl_type.u.basic.integer.encoding);
}
*next_ust_ctl_field = current + 1;
if (element_encoding) {
const auto integer_element_size =
- static_cast<const lst::integer_type&>(*element_type).size;
+ static_cast<const lst::integer_type&>(*element_type).size;
if (integer_element_size != 8) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}",
- integer_element_size));
+ "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}",
+ integer_element_size));
}
/* Array is a static-length string. */
return lttng::make_unique<lst::static_length_string_type>(
- array_alignment, *element_encoding, array_length);
+ array_alignment, *element_encoding, array_length);
}
return lttng::make_unique<lst::static_length_array_type>(
- array_alignment, std::move(element_type), array_length);
+ array_alignment, std::move(element_type), array_length);
}
-lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements ¤t_field_location_elements,
- lsu::ctl_field_quirks quirks)
+lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields(
+ const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks)
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& array_uctl_field = *current;
const auto& element_uctl_field = *(current + 1);
/* next_ust_ctl_field is updated as needed. */
- element_type = create_type_from_ust_ctl_fields(&element_uctl_field, end, session_attributes,
- next_ust_ctl_field, publish_field, lookup_field, lookup_root,
- current_field_location_elements, quirks);
+ element_type = create_type_from_ust_ctl_fields(&element_uctl_field,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
if (element_uctl_field.type.atype == lttng_ust_ctl_atype_integer &&
- element_uctl_field.type.u.integer.encoding != lttng_ust_ctl_encode_none) {
+ element_uctl_field.type.u.integer.encoding != lttng_ust_ctl_encode_none) {
/* Element represents a text character. */
element_encoding = ust_ctl_encoding_to_string_field_encoding(
- element_uctl_field.type.u.integer.encoding);
+ element_uctl_field.type.u.integer.encoding);
}
if (element_encoding) {
const auto integer_element_size =
- static_cast<const lst::integer_type&>(*element_type).size;
+ static_cast<const lst::integer_type&>(*element_type).size;
if (integer_element_size != 8) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected array element type: integer has encoding but size is not 8: size = {}",
- integer_element_size));
+ "Unexpected array element type: integer has encoding but size is not 8: size = {}",
+ integer_element_size));
}
/* Array is a static-length string. */
return lttng::make_unique<lst::static_length_string_type>(
- array_alignment, *element_encoding, array_length);
+ array_alignment, *element_encoding, array_length);
}
return lttng::make_unique<lst::static_length_array_type>(
- array_alignment, std::move(element_type), array_length);
+ array_alignment, std::move(element_type), array_length);
}
/*
* For legacy sequence types, LTTng-UST expresses both the sequence and sequence
* length as part of the same lttng_ust_ctl_field entry.
*/
-lst::type::cuptr create_sequence_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements ¤t_field_location_elements,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr create_sequence_type_from_ust_ctl_fields(
+ const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& sequence_uctl_field = *current;
if (element_uctl_type.atype != lttng_ust_ctl_atype_integer) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected legacy sequence element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
- element_uctl_type.atype, lttng_ust_ctl_atype_integer));
+ "Unexpected legacy sequence element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
+ element_uctl_type.atype,
+ lttng_ust_ctl_atype_integer));
}
if (length_uctl_type.atype != lttng_ust_ctl_atype_integer) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected legacy sequence length field type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
- length_uctl_type.atype, lttng_ust_ctl_atype_integer));
+ "Unexpected legacy sequence length field type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})",
+ length_uctl_type.atype,
+ lttng_ust_ctl_atype_integer));
}
nonstd::optional<enum lst::string_type::encoding> element_encoding;
if (element_uctl_type.atype == lttng_ust_ctl_atype_integer &&
- element_uctl_type.u.basic.integer.encoding != lttng_ust_ctl_encode_none) {
+ element_uctl_type.u.basic.integer.encoding != lttng_ust_ctl_encode_none) {
/* Element represents a text character. */
element_encoding = ust_ctl_encoding_to_string_field_encoding(
- element_uctl_type.u.basic.integer.encoding);
+ element_uctl_type.u.basic.integer.encoding);
}
const auto length_field_name = fmt::format("_{}_length", sequence_uctl_field.name);
- auto element_type = create_integer_type_from_ust_ctl_basic_type(
- element_uctl_type, session_attributes);
- auto length_type = create_integer_type_from_ust_ctl_basic_type(
- length_uctl_type, session_attributes);
+ auto element_type =
+ create_integer_type_from_ust_ctl_basic_type(element_uctl_type, session_attributes);
+ auto length_type =
+ create_integer_type_from_ust_ctl_basic_type(length_uctl_type, session_attributes);
lst::field_location::elements length_field_location_elements =
- current_field_location_elements;
+ current_field_location_elements;
length_field_location_elements.emplace_back(length_field_name);
const lst::field_location length_field_location{
- lookup_root, std::move(length_field_location_elements)};
+ lookup_root, std::move(length_field_location_elements)
+ };
/* Publish an implicit length field _before_ the sequence field. */
- publish_field(lttng::make_unique<lst::field>(std::move(length_field_name), std::move(length_type)));
+ publish_field(lttng::make_unique<lst::field>(std::move(length_field_name),
+ std::move(length_type)));
*next_ust_ctl_field = current + 1;
if (element_encoding) {
const auto integer_element_size =
- static_cast<const lst::integer_type&>(*element_type).size;
+ static_cast<const lst::integer_type&>(*element_type).size;
if (integer_element_size != 8) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}",
- integer_element_size));
+ "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}",
+ integer_element_size));
}
/* Sequence is a dynamic-length string. */
- return lttng::make_unique<lst::dynamic_length_string_type>(sequence_alignment,
- *element_encoding, std::move(length_field_location));
+ return lttng::make_unique<lst::dynamic_length_string_type>(
+ sequence_alignment, *element_encoding, std::move(length_field_location));
}
- return lttng::make_unique<lst::dynamic_length_array_type>(sequence_alignment,
- std::move(element_type), std::move(length_field_location));
+ return lttng::make_unique<lst::dynamic_length_array_type>(
+ sequence_alignment, std::move(element_type), std::move(length_field_location));
}
lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
- const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements ¤t_field_location_elements,
- lsu::ctl_field_quirks quirks)
+ const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks)
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& sequence_uctl_field = *current;
nonstd::optional<enum lst::string_type::encoding> element_encoding;
if (element_uctl_field.type.atype == lttng_ust_ctl_atype_integer &&
- element_uctl_field.type.u.integer.encoding != lttng_ust_ctl_encode_none) {
+ element_uctl_field.type.u.integer.encoding != lttng_ust_ctl_encode_none) {
/* Element represents a text character. */
element_encoding = ust_ctl_encoding_to_string_field_encoding(
- element_uctl_field.type.u.integer.encoding);
+ element_uctl_field.type.u.integer.encoding);
}
/* next_ust_ctl_field is updated as needed. */
- auto element_type = create_type_from_ust_ctl_fields(&element_uctl_field, end,
- session_attributes, next_ust_ctl_field, publish_field, lookup_field,
- lookup_root, current_field_location_elements, quirks);
+ auto element_type = create_type_from_ust_ctl_fields(&element_uctl_field,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
if (lttng_strnlen(sequence_uctl_field.type.u.sequence_nestable.length_name,
- sizeof(sequence_uctl_field.type.u.sequence_nestable.length_name)) ==
- sizeof(sequence_uctl_field.type.u.sequence_nestable.length_name)) {
+ sizeof(sequence_uctl_field.type.u.sequence_nestable.length_name)) ==
+ sizeof(sequence_uctl_field.type.u.sequence_nestable.length_name)) {
LTTNG_THROW_PROTOCOL_ERROR("Sequence length field name is not null terminated");
}
lst::field_location::elements length_field_location_elements =
- current_field_location_elements;
+ current_field_location_elements;
length_field_location_elements.emplace_back(std::move(length_field_name));
const lst::field_location length_field_location{
- lookup_root, std::move(length_field_location_elements)};
+ lookup_root, std::move(length_field_location_elements)
+ };
/* Validate existence of length field (throws if not found). */
- const auto &length_field = lookup_field(length_field_location);
+ const auto& length_field = lookup_field(length_field_location);
const auto *integer_selector_field =
- dynamic_cast<const lst::integer_type *>(&length_field.get_type());
+ dynamic_cast<const lst::integer_type *>(&length_field.get_type());
if (!integer_selector_field) {
- LTTNG_THROW_PROTOCOL_ERROR("Invalid selector field type referenced from sequence: expected integer or enumeration");
+ LTTNG_THROW_PROTOCOL_ERROR(
+ "Invalid selector field type referenced from sequence: expected integer or enumeration");
}
if (element_encoding) {
const auto integer_element_size =
- static_cast<const lst::integer_type&>(*element_type).size;
+ static_cast<const lst::integer_type&>(*element_type).size;
if (integer_element_size != 8) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unexpected array element type: integer has encoding but size is not 8: size = {}",
- integer_element_size));
+ "Unexpected array element type: integer has encoding but size is not 8: size = {}",
+ integer_element_size));
}
/* Sqeuence is a dynamic-length string. */
- return lttng::make_unique<lst::dynamic_length_string_type>(sequence_alignment,
- *element_encoding, std::move(length_field_location));
+ return lttng::make_unique<lst::dynamic_length_string_type>(
+ sequence_alignment, *element_encoding, std::move(length_field_location));
}
- return lttng::make_unique<lst::dynamic_length_array_type>(sequence_alignment,
- std::move(element_type), std::move(length_field_location));
+ return lttng::make_unique<lst::dynamic_length_array_type>(
+ sequence_alignment, std::move(element_type), std::move(length_field_location));
}
-lst::type::cuptr create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes __attribute__((unused)),
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lsu::ctl_field_quirks quirks __attribute__((unused)))
+lst::type::cuptr
+create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes
+ __attribute__((unused)),
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lsu::ctl_field_quirks quirks __attribute__((unused)))
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
uint32_t field_count;
if (field_count != 0) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Only empty structures are supported by LTTng-UST: nr_fields = {}",
- field_count));
+ "Only empty structures are supported by LTTng-UST: nr_fields = {}",
+ field_count));
}
*next_ust_ctl_field = current + 1;
}
template <class VariantSelectorMappingIntegerType>
-typename lst::variant_type<VariantSelectorMappingIntegerType>::choices create_typed_variant_choices(
- const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements& current_field_location_elements,
- unsigned int choice_count,
- const lst::field& selector_field,
- lsu::ctl_field_quirks quirks)
+typename lst::variant_type<VariantSelectorMappingIntegerType>::choices
+create_typed_variant_choices(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ unsigned int choice_count,
+ const lst::field& selector_field,
+ lsu::ctl_field_quirks quirks)
{
typename lst::variant_type<VariantSelectorMappingIntegerType>::choices choices;
- const auto& typed_enumeration = static_cast<
- const lst::typed_enumeration_type<VariantSelectorMappingIntegerType>&>(
+ const auto& typed_enumeration =
+ static_cast<const lst::typed_enumeration_type<VariantSelectorMappingIntegerType>&>(
selector_field.get_type());
for (unsigned int i = 0; i < choice_count; i++) {
create_field_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field,
- [&choices, typed_enumeration, &selector_field, quirks](
- lst::field::uptr field) {
- /*
- * Find the enumeration mapping that matches the
- * field's name.
- */
- const auto mapping_it = std::find_if(
- typed_enumeration.mappings_->begin(),
- typed_enumeration.mappings_->end(),
- [&field, quirks](const typename std::remove_reference<
- decltype(typed_enumeration)>::type::
- mapping& mapping) {
- if (static_cast<bool>(quirks & lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS)) {
- /*
- * Check if they match with
- * a prepended underscore
- * and, if not, perform the
- * regular check.
- */
- if ((std::string("_") + field->name) == mapping.name) {
- return true;
- }
- }
-
- return mapping.name == field->name;
- });
-
- if (mapping_it == typed_enumeration.mappings_->end()) {
- LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Invalid variant choice: `{}` does not match any mapping in `{}` enumeration",
- field->name, selector_field.name));
- }
-
- choices.emplace_back(*mapping_it, field->move_type());
- },
- lookup_field, lookup_root, current_field_location_elements, quirks);
+ current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ [&choices, typed_enumeration, &selector_field, quirks](
+ lst::field::uptr field) {
+ /*
+ * Find the enumeration mapping that matches the
+ * field's name.
+ */
+ const auto mapping_it = std::find_if(
+ typed_enumeration.mappings_->begin(),
+ typed_enumeration.mappings_->end(),
+ [&field,
+ quirks](const typename std::remove_reference<
+ decltype(typed_enumeration)>::type::mapping&
+ mapping) {
+ if (static_cast<bool>(
+ quirks &
+ lsu::ctl_field_quirks::
+ UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS)) {
+ /*
+ * Check if they match with
+ * a prepended underscore
+ * and, if not, perform the
+ * regular check.
+ */
+ if ((std::string("_") + field->name) ==
+ mapping.name) {
+ return true;
+ }
+ }
+
+ return mapping.name == field->name;
+ });
+
+ if (mapping_it == typed_enumeration.mappings_->end()) {
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "Invalid variant choice: `{}` does not match any mapping in `{}` enumeration",
+ field->name,
+ selector_field.name));
+ }
+
+ choices.emplace_back(*mapping_it, field->move_type());
+ },
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
current = *next_ust_ctl_field;
}
return choices;
}
-lst::type::cuptr create_variant_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements ¤t_field_location_elements,
- lsu::ctl_field_quirks quirks)
+lst::type::cuptr create_variant_field_from_ust_ctl_fields(
+ const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks)
{
if (current >= end) {
- LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("End of {} array reached unexpectedly during decoding",
- typeid(*current)));
+ LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+ "End of {} array reached unexpectedly during decoding", typeid(*current)));
}
const auto& variant_uctl_field = *current;
}
lst::field_location::elements selector_field_location_elements =
- current_field_location_elements;
+ current_field_location_elements;
selector_field_location_elements.emplace_back(tag_name);
const lst::field_location selector_field_location{
- lookup_root, std::move(selector_field_location_elements)};
+ lookup_root, std::move(selector_field_location_elements)
+ };
/* Validate existence of selector field (throws if not found). */
- const auto &selector_field = lookup_field(selector_field_location);
+ const auto& selector_field = lookup_field(selector_field_location);
const auto *enumeration_selector_type =
- dynamic_cast<const lst::enumeration_type *>(&selector_field.get_type());
+ dynamic_cast<const lst::enumeration_type *>(&selector_field.get_type());
if (!enumeration_selector_type) {
- LTTNG_THROW_PROTOCOL_ERROR("Invalid selector field type referenced from variant: expected enumeration");
+ LTTNG_THROW_PROTOCOL_ERROR(
+ "Invalid selector field type referenced from variant: expected enumeration");
}
const bool selector_is_signed = enumeration_selector_type->signedness_ ==
- lst::integer_type::signedness::SIGNED;
+ lst::integer_type::signedness::SIGNED;
/* Choices follow. next_ust_ctl_field is updated as needed. */
if (selector_is_signed) {
lst::variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>::
- choices choices = create_typed_variant_choices<int64_t>(current,
- end, session_attributes, next_ust_ctl_field,
- lookup_field, lookup_root,
- current_field_location_elements, choice_count,
- selector_field, quirks);
+ choices choices = create_typed_variant_choices<int64_t>(
+ current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ choice_count,
+ selector_field,
+ quirks);
return lttng::make_unique<lst::variant_type<int64_t>>(
- alignment, std::move(selector_field_location), std::move(choices));
+ alignment, std::move(selector_field_location), std::move(choices));
} else {
- lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::
- choices choices = create_typed_variant_choices<uint64_t>(current,
- end, session_attributes, next_ust_ctl_field,
- lookup_field, lookup_root,
- current_field_location_elements, choice_count,
- selector_field, quirks);
+ lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::choices
+ choices = create_typed_variant_choices<uint64_t>(
+ current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ choice_count,
+ selector_field,
+ quirks);
return lttng::make_unique<lst::variant_type<uint64_t>>(
- alignment, std::move(selector_field_location), std::move(choices));
+ alignment, std::move(selector_field_location), std::move(choices));
}
}
-lst::type::cuptr create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements& current_field_location_elements,
- lsu::ctl_field_quirks quirks)
+lst::type::cuptr
+create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks)
{
switch (current->type.atype) {
case lttng_ust_ctl_atype_integer:
return create_integer_type_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_enum:
case lttng_ust_ctl_atype_enum_nestable:
return create_enumeration_type_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_float:
return create_floating_point_type_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_string:
return create_string_type_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_array:
return create_array_type_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_array_nestable:
- return create_array_nestable_type_from_ust_ctl_fields(current, end,
- session_attributes, next_ust_ctl_field, publish_field, lookup_field,
- lookup_root, current_field_location_elements, quirks);
+ return create_array_nestable_type_from_ust_ctl_fields(
+ current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
case lttng_ust_ctl_atype_sequence:
- return create_sequence_type_from_ust_ctl_fields(current, end, session_attributes,
- next_ust_ctl_field, publish_field, lookup_root,
- current_field_location_elements, quirks);
+ return create_sequence_type_from_ust_ctl_fields(current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
case lttng_ust_ctl_atype_sequence_nestable:
- return create_sequence_nestable_type_from_ust_ctl_fields(current, end,
- session_attributes, next_ust_ctl_field, publish_field, lookup_field,
- lookup_root, current_field_location_elements, quirks);
+ return create_sequence_nestable_type_from_ust_ctl_fields(
+ current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
case lttng_ust_ctl_atype_struct:
case lttng_ust_ctl_atype_struct_nestable:
return create_structure_field_from_ust_ctl_fields(
- current, end, session_attributes, next_ust_ctl_field, quirks);
+ current, end, session_attributes, next_ust_ctl_field, quirks);
case lttng_ust_ctl_atype_variant:
case lttng_ust_ctl_atype_variant_nestable:
- return create_variant_field_from_ust_ctl_fields(current, end, session_attributes,
- next_ust_ctl_field, lookup_field, lookup_root,
- current_field_location_elements, quirks);
+ return create_variant_field_from_ust_ctl_fields(current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks);
default:
- LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unknown {} value `{}` encountered while converting {} to {}",
- typeid(current->type.atype), current->type.atype, typeid(*current),
- typeid(lst::type::cuptr::element_type)));
+ LTTNG_THROW_PROTOCOL_ERROR(
+ fmt::format("Unknown {} value `{}` encountered while converting {} to {}",
+ typeid(current->type.atype),
+ current->type.atype,
+ typeid(*current),
+ typeid(lst::type::cuptr::element_type)));
}
}
void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- const session_attributes& session_attributes,
- const lttng_ust_ctl_field **next_ust_ctl_field,
- publish_field_fn publish_field,
- lookup_field_fn lookup_field,
- lst::field_location::root lookup_root,
- lst::field_location::elements& current_field_location_elements,
- lsu::ctl_field_quirks quirks)
+ const lttng_ust_ctl_field *end,
+ const session_attributes& session_attributes,
+ const lttng_ust_ctl_field **next_ust_ctl_field,
+ publish_field_fn publish_field,
+ lookup_field_fn lookup_field,
+ lst::field_location::root lookup_root,
+ lst::field_location::elements& current_field_location_elements,
+ lsu::ctl_field_quirks quirks)
{
LTTNG_ASSERT(current < end);
if (lttng_strnlen(current->name, sizeof(current->name)) == sizeof(current->name)) {
LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("Name of {} is not null-terminated", typeid(*current)));
- }
-
- publish_field(lttng::make_unique<lst::field>(current->name,
- create_type_from_ust_ctl_fields(current, end, session_attributes,
- next_ust_ctl_field, publish_field, lookup_field,
- lookup_root, current_field_location_elements, quirks)));
+ fmt::format("Name of {} is not null-terminated", typeid(*current)));
+ }
+
+ publish_field(lttng::make_unique<lst::field>(
+ current->name,
+ create_type_from_ust_ctl_fields(current,
+ end,
+ session_attributes,
+ next_ust_ctl_field,
+ publish_field,
+ lookup_field,
+ lookup_root,
+ current_field_location_elements,
+ quirks)));
}
-std::vector<lst::field::cuptr>::iterator lookup_field_in_vector(
- std::vector<lst::field::cuptr>& fields, const lst::field_location& location)
+std::vector<lst::field::cuptr>::iterator
+lookup_field_in_vector(std::vector<lst::field::cuptr>& fields, const lst::field_location& location)
{
if (location.elements_.size() != 1) {
LTTNG_THROW_ERROR(fmt::format(
- "Unexpected field location received during field look-up: location = {}",
- location));
+ "Unexpected field location received during field look-up: location = {}",
+ location));
}
/*
* location has a depth of 1 and directly refers to a field
* in the 'fields' vector.
*/
- const auto field_it = std::find_if(fields.begin(), fields.end(),
- [location](lst::field::cuptr &field) {
- return field->name == location.elements_[0];
- });
+ const auto field_it =
+ std::find_if(fields.begin(), fields.end(), [location](lst::field::cuptr& field) {
+ return field->name == location.elements_[0];
+ });
if (field_it == fields.end()) {
LTTNG_THROW_PROTOCOL_ERROR(
- fmt::format("Failed to look-up field: location = {}", location));
+ fmt::format("Failed to look-up field: location = {}", location));
}
return field_it;
*
* Always returns a new field, throws on error.
*/
-std::vector<lst::field::cuptr> create_fields_from_ust_ctl_fields(
- const lsu::registry_session& session,
- const lttng_ust_ctl_field *current,
- const lttng_ust_ctl_field *end,
- lst::field_location::root lookup_root,
- lsu::ctl_field_quirks quirks)
+std::vector<lst::field::cuptr>
+create_fields_from_ust_ctl_fields(const lsu::registry_session& session,
+ const lttng_ust_ctl_field *current,
+ const lttng_ust_ctl_field *end,
+ lst::field_location::root lookup_root,
+ lsu::ctl_field_quirks quirks)
{
std::vector<lst::field::cuptr> fields;
const auto trace_native_byte_order = session.abi.byte_order;
const session_attributes session_attributes{
- [&session](const char *enum_name, uint64_t enum_id) {
- return session.enumeration(enum_name, enum_id);
- },
- trace_native_byte_order};
+ [&session](const char *enum_name, uint64_t enum_id) {
+ return session.enumeration(enum_name, enum_id);
+ },
+ trace_native_byte_order
+ };
/* Location of field being created. */
lst::field_location::elements current_field_location_elements;
* needed depending on the decoded field's type.
*/
create_field_from_ust_ctl_fields(
- current, end, session_attributes, &next_field,
- [&fields](lst::field::cuptr field) {
- /* Publishing a field simply adds it to the converted
- * fields. */
- fields.emplace_back(std::move(field));
- },
- [&fields](const lst::field_location& location)
- -> lookup_field_fn::result_type {
- /* Resolve location to a previously-constructed field. */
- return **lookup_field_in_vector(fields, location);
- },
- lookup_root, current_field_location_elements, quirks);
+ current,
+ end,
+ session_attributes,
+ &next_field,
+ [&fields](lst::field::cuptr field) {
+ /* Publishing a field simply adds it to the converted
+ * fields. */
+ fields.emplace_back(std::move(field));
+ },
+ [&fields](const lst::field_location& location)
+ -> lookup_field_fn::result_type {
+ /* Resolve location to a previously-constructed field. */
+ return **lookup_field_in_vector(fields, location);
+ },
+ lookup_root,
+ current_field_location_elements,
+ quirks);
current = next_field;
}
}
} /* namespace */
-std::vector<lst::field::cuptr> lsu::create_trace_fields_from_ust_ctl_fields(
- const lsu::registry_session& session,
- const lttng_ust_ctl_field *fields,
- std::size_t field_count,
- lst::field_location::root lookup_root,
- lsu::ctl_field_quirks quirks)
+std::vector<lst::field::cuptr>
+lsu::create_trace_fields_from_ust_ctl_fields(const lsu::registry_session& session,
+ const lttng_ust_ctl_field *fields,
+ std::size_t field_count,
+ lst::field_location::root lookup_root,
+ lsu::ctl_field_quirks quirks)
{
return create_fields_from_ust_ctl_fields(
- session, fields, fields + field_count, lookup_root, quirks);
+ session, fields, fields + field_count, lookup_root, quirks);
}
*/
#define _LGPL_SOURCE
+#include "tsdl-environment-visitor.hpp"
+#include "ust-app.hpp"
+#include "ust-clock-class.hpp"
+#include "ust-registry.hpp"
+
+#include <common/common.hpp>
+#include <common/exception.hpp>
+#include <common/format.hpp>
+#include <common/time.hpp>
+#include <common/uuid.hpp>
+
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <unistd.h>
#include <vector>
-#include <common/common.hpp>
-#include <common/exception.hpp>
-#include <common/format.hpp>
-#include <common/time.hpp>
-#include <common/uuid.hpp>
-
-#include "ust-app.hpp"
-#include "ust-clock-class.hpp"
-#include "ust-registry.hpp"
-#include "tsdl-environment-visitor.hpp"
-
namespace ls = lttng::sessiond;
namespace lsu = lttng::sessiond::ust;
*
*/
-#include "ust-registry-channel.hpp"
#include "ust-app.hpp"
+#include "ust-registry-channel.hpp"
#include "ust-registry-event.hpp"
#include <common/error.hpp>
{
uint64_t hashed_key;
const lttng::sessiond::ust::registry_event *key =
- (lttng::sessiond::ust::registry_event *) _key;
+ (lttng::sessiond::ust::registry_event *) _key;
LTTNG_ASSERT(key);
return 0;
}
-lst::type::cuptr create_event_header(const lst::abi& trace_abi, lst::stream_class::header_type header_type)
+lst::type::cuptr create_event_header(const lst::abi& trace_abi,
+ lst::stream_class::header_type header_type)
{
lst::structure_type::fields event_header_fields;
if (header_type == lst::stream_class::header_type::COMPACT) {
auto enum_mappings = std::make_shared<lst::unsigned_enumeration_type::mappings>();
lst::unsigned_enumeration_type::mapping compact_mapping{
- "compact", lst::unsigned_enumeration_type::mapping::range_t(0, 30)};
- lst::unsigned_enumeration_type::mapping extended_mapping{"extended", 31};
+ "compact", lst::unsigned_enumeration_type::mapping::range_t(0, 30)
+ };
+ lst::unsigned_enumeration_type::mapping extended_mapping{ "extended", 31 };
enum_mappings->emplace_back(compact_mapping);
enum_mappings->emplace_back(extended_mapping);
- lst::type::cuptr choice_enum = lttng::make_unique<lst::unsigned_enumeration_type>(1,
- trace_abi.byte_order, 5, lst::integer_type::base::DECIMAL,
- std::move(enum_mappings),
- std::initializer_list<lst::integer_type::role>(
- {lst::integer_type::role::EVENT_RECORD_CLASS_ID}));
+ lst::type::cuptr choice_enum = lttng::make_unique<lst::unsigned_enumeration_type>(
+ 1,
+ trace_abi.byte_order,
+ 5,
+ lst::integer_type::base::DECIMAL,
+ std::move(enum_mappings),
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::EVENT_RECORD_CLASS_ID }));
- lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::
- choices variant_choices;
+ lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::choices
+ variant_choices;
lst::structure_type::fields compact_fields;
- compact_fields.emplace_back(lttng::make_unique<lst::field>("timestamp",
- lttng::make_unique<lst::integer_type>(1, trace_abi.byte_order, 27,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- DEFAULT_CLOCK_TIMESTAMP}))));
-
- auto compact_type = lttng::make_unique<lst::structure_type>(
- 0, std::move(compact_fields));
+ compact_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp",
+ lttng::make_unique<lst::integer_type>(
+ 1,
+ trace_abi.byte_order,
+ 27,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP }))));
+
+ auto compact_type =
+ lttng::make_unique<lst::structure_type>(0, std::move(compact_fields));
variant_choices.emplace_back(std::move(compact_mapping), std::move(compact_type));
lst::structure_type::fields extended_fields;
- extended_fields.emplace_back(lttng::make_unique<lst::field>("id",
- lttng::make_unique<lst::integer_type>(trace_abi.uint32_t_alignment,
- trace_abi.byte_order, 32,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- EVENT_RECORD_CLASS_ID}))));
- extended_fields.emplace_back(lttng::make_unique<lst::field>("timestamp",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- DEFAULT_CLOCK_TIMESTAMP}))));
-
- lst::type::cuptr extended_type = lttng::make_unique<lst::structure_type>(0, std::move(extended_fields));
+ extended_fields.emplace_back(lttng::make_unique<lst::field>(
+ "id",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint32_t_alignment,
+ trace_abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::EVENT_RECORD_CLASS_ID }))));
+ extended_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP }))));
+
+ lst::type::cuptr extended_type =
+ lttng::make_unique<lst::structure_type>(0, std::move(extended_fields));
variant_choices.emplace_back(std::move(extended_mapping), std::move(extended_type));
auto variant = lttng::make_unique<lst::variant_type<
- lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>>(
- 0,
- lst::field_location(lst::field_location::root::EVENT_RECORD_HEADER,
- {"id"}),
- std::move(variant_choices));
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>>(
+ 0,
+ lst::field_location(lst::field_location::root::EVENT_RECORD_HEADER,
+ { "id" }),
+ std::move(variant_choices));
- event_header_fields.emplace_back(lttng::make_unique<lst::field>("id", std::move(choice_enum)));
event_header_fields.emplace_back(
- lttng::make_unique<lst::field>("v", std::move(variant)));
+ lttng::make_unique<lst::field>("id", std::move(choice_enum)));
+ event_header_fields.emplace_back(
+ lttng::make_unique<lst::field>("v", std::move(variant)));
} else {
auto enum_mappings = std::make_shared<lst::unsigned_enumeration_type::mappings>();
- lst::unsigned_enumeration_type::mapping compact_mapping{"compact",
- lst::unsigned_enumeration_type::mapping::range_t(0, 65534)};
- lst::unsigned_enumeration_type::mapping extended_mapping{"extended", 65535};
+ lst::unsigned_enumeration_type::mapping compact_mapping{
+ "compact", lst::unsigned_enumeration_type::mapping::range_t(0, 65534)
+ };
+ lst::unsigned_enumeration_type::mapping extended_mapping{ "extended", 65535 };
enum_mappings->emplace_back(compact_mapping);
enum_mappings->emplace_back(extended_mapping);
auto choice_enum = lttng::make_unique<lst::unsigned_enumeration_type>(
- trace_abi.uint16_t_alignment, trace_abi.byte_order, 16,
- lst::integer_type::base::DECIMAL, std::move(enum_mappings),
- std::initializer_list<lst::integer_type::role>(
- {lst::integer_type::role::EVENT_RECORD_CLASS_ID}));
-
- lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::
- choices variant_choices;
+ trace_abi.uint16_t_alignment,
+ trace_abi.byte_order,
+ 16,
+ lst::integer_type::base::DECIMAL,
+ std::move(enum_mappings),
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::EVENT_RECORD_CLASS_ID }));
+
+ lst::variant_type<
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::choices
+ variant_choices;
lst::structure_type::fields compact_fields;
- compact_fields.emplace_back(lttng::make_unique<lst::field>("timestamp",
- lttng::make_unique<lst::integer_type>(trace_abi.uint32_t_alignment,
- trace_abi.byte_order, 32,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- DEFAULT_CLOCK_TIMESTAMP}))));
-
- lst::type::cuptr compact_type = lttng::make_unique<lst::structure_type>(
- 0, std::move(compact_fields));
+ compact_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint32_t_alignment,
+ trace_abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP }))));
+
+ lst::type::cuptr compact_type =
+ lttng::make_unique<lst::structure_type>(0, std::move(compact_fields));
variant_choices.emplace_back(std::move(compact_mapping), std::move(compact_type));
lst::structure_type::fields extended_fields;
- extended_fields.emplace_back(lttng::make_unique<lst::field>("id",
- lttng::make_unique<lst::integer_type>(trace_abi.uint32_t_alignment,
- trace_abi.byte_order, 32,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- EVENT_RECORD_CLASS_ID}))));
- extended_fields.emplace_back(lttng::make_unique<lst::field>("timestamp",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::
- role>({lst::integer_type::role::
- DEFAULT_CLOCK_TIMESTAMP}))));
-
- auto extended_type = lttng::make_unique<lst::structure_type>(
- 0, std::move(extended_fields));
+ extended_fields.emplace_back(lttng::make_unique<lst::field>(
+ "id",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint32_t_alignment,
+ trace_abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::EVENT_RECORD_CLASS_ID }))));
+ extended_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP }))));
+
+ auto extended_type =
+ lttng::make_unique<lst::structure_type>(0, std::move(extended_fields));
variant_choices.emplace_back(std::move(extended_mapping), std::move(extended_type));
auto variant = lttng::make_unique<lst::variant_type<
- lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>>(
- 0,
- lst::field_location(lst::field_location::root::EVENT_RECORD_HEADER,
- {"id"}),
- std::move(variant_choices));
+ lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>>(
+ 0,
+ lst::field_location(lst::field_location::root::EVENT_RECORD_HEADER,
+ { "id" }),
+ std::move(variant_choices));
event_header_fields.emplace_back(
- lttng::make_unique<lst::field>("id", std::move(choice_enum)));
+ lttng::make_unique<lst::field>("id", std::move(choice_enum)));
event_header_fields.emplace_back(
- lttng::make_unique<lst::field>("v", std::move(variant)));
+ lttng::make_unique<lst::field>("v", std::move(variant)));
}
return lttng::make_unique<lst::structure_type>(0, std::move(event_header_fields));
lst::structure_type::fields packet_context_fields;
/* uint64_t timestamp_begin */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("timestamp_begin",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp_begin",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DEFAULT_CLOCK_TIMESTAMP }))));
/* uint64_t timestamp_end */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("timestamp_end",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_END_DEFAULT_CLOCK_TIMESTAMP}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "timestamp_end",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::PACKET_END_DEFAULT_CLOCK_TIMESTAMP }))));
/* uint64_t content_size */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("content_size",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_CONTENT_LENGTH}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "content_size",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::PACKET_CONTENT_LENGTH }))));
/* uint64_t packet_size */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("packet_size",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_TOTAL_LENGTH}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "packet_size",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::PACKET_TOTAL_LENGTH }))));
/* uint64_t packet_seq_num */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("packet_seq_num",
- lttng::make_unique<lst::integer_type>(trace_abi.uint64_t_alignment,
- trace_abi.byte_order, 64,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_SEQUENCE_NUMBER}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "packet_seq_num",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.uint64_t_alignment,
+ trace_abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::PACKET_SEQUENCE_NUMBER }))));
/* unsigned long events_discarded */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("events_discarded",
- lttng::make_unique<lst::integer_type>(trace_abi.long_alignment,
- trace_abi.byte_order, trace_abi.bits_per_long,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DISCARDED_EVENT_RECORD_COUNTER_SNAPSHOT}))));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "events_discarded",
+ lttng::make_unique<lst::integer_type>(
+ trace_abi.long_alignment,
+ trace_abi.byte_order,
+ trace_abi.bits_per_long,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::
+ DISCARDED_EVENT_RECORD_COUNTER_SNAPSHOT }))));
/* uint32_t cpu_id */
- packet_context_fields.emplace_back(lttng::make_unique<lst::field>("cpu_id",
- lttng::make_unique<lst::integer_type>(trace_abi.uint32_t_alignment,
- trace_abi.byte_order, 32,
- lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL)));
+ packet_context_fields.emplace_back(lttng::make_unique<lst::field>(
+ "cpu_id",
+ lttng::make_unique<lst::integer_type>(trace_abi.uint32_t_alignment,
+ trace_abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL)));
return lttng::make_unique<lst::structure_type>(0, std::move(packet_context_fields));
}
}; /* namespace */
-lsu::registry_channel::registry_channel(unsigned int channel_id,
- const lst::abi& trace_abi,
- std::string in_default_clock_class_name,
- lsu::registry_channel::registered_listener_fn channel_registered_listener,
- lsu::registry_channel::event_added_listener_fn event_added_listener) :
+lsu::registry_channel::registry_channel(
+ unsigned int channel_id,
+ const lst::abi& trace_abi,
+ std::string in_default_clock_class_name,
+ lsu::registry_channel::registered_listener_fn channel_registered_listener,
+ lsu::registry_channel::event_added_listener_fn event_added_listener) :
lst::stream_class(channel_id,
- lst::stream_class::header_type::LARGE,
- std::move(in_default_clock_class_name)),
- _key{-1ULL},
- _consumer_key{-1ULL},
- _next_event_id{0},
- _is_registered_listener{channel_registered_listener},
- _event_added_listener{event_added_listener},
- _is_registered{false}
+ lst::stream_class::header_type::LARGE,
+ std::move(in_default_clock_class_name)),
+ _key{ -1ULL },
+ _consumer_key{ -1ULL },
+ _next_event_id{ 0 },
+ _is_registered_listener{ channel_registered_listener },
+ _event_added_listener{ event_added_listener },
+ _is_registered{ false }
{
_events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
if (!_events) {
_event_header = create_event_header(trace_abi, header_type_);
}
-void lsu::registry_channel::add_event(
- int session_objd,
- int channel_objd,
- std::string name,
- std::string signature,
- std::vector<lst::field::cuptr> event_fields,
- int loglevel_value,
- nonstd::optional<std::string> model_emf_uri,
- lttng_buffer_type buffer_type,
- const ust_app& app,
- uint32_t& out_event_id)
+void lsu::registry_channel::add_event(int session_objd,
+ int channel_objd,
+ std::string name,
+ std::string signature,
+ std::vector<lst::field::cuptr> event_fields,
+ int loglevel_value,
+ nonstd::optional<std::string> model_emf_uri,
+ lttng_buffer_type buffer_type,
+ const ust_app& app,
+ uint32_t& out_event_id)
{
uint32_t event_id;
struct cds_lfht_node *nptr;
*/
if (session_objd < 0) {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "Invalid session object descriptor provided by application: session descriptor = {}, app = {}",
- session_objd, app));
+ "Invalid session object descriptor provided by application: session descriptor = {}, app = {}",
+ session_objd,
+ app));
}
if (channel_objd < 0) {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "Invalid channel object descriptor provided by application: channel descriptor = {}, app = {}",
- channel_objd, app));
+ "Invalid channel object descriptor provided by application: channel descriptor = {}, app = {}",
+ channel_objd,
+ app));
}
/* Check if we've reached the maximum possible id. */
if (is_max_event_id(_next_event_id)) {
LTTNG_THROW_ERROR(fmt::format(
- "Failed to allocate new event id (id would overflow): app = {}",
- app));
+ "Failed to allocate new event id (id would overflow): app = {}", app));
}
auto event = lttng::make_unique_wrapper<lsu::registry_event, registry_event_destroy>(
- new lsu::registry_event(_next_event_id, id, session_objd, channel_objd,
- std::move(name), std::move(signature),
- std::move(event_fields), loglevel_value,
+ new lsu::registry_event(_next_event_id,
+ id,
+ session_objd,
+ channel_objd,
+ std::move(name),
+ std::move(signature),
+ std::move(event_fields),
+ loglevel_value,
std::move(model_emf_uri)));
DBG3("%s", fmt::format("UST registry creating event: event = {}", *event).c_str());
* This is an add unique with a custom match function for event. The node
* are matched using the event name and signature.
*/
- nptr = cds_lfht_add_unique(_events->ht, _events->hash_fct(event.get(), lttng_ht_seed),
- _events->match_fct, event.get(), &event->_node);
+ nptr = cds_lfht_add_unique(_events->ht,
+ _events->hash_fct(event.get(), lttng_ht_seed),
+ _events->match_fct,
+ event.get(),
+ &event->_node);
if (nptr != &event->_node) {
if (buffer_type == LTTNG_BUFFER_PER_UID) {
/*
* returned node.
*/
const auto existing_event = lttng::utils::container_of(
- nptr, <tng::sessiond::ust::registry_event::_node);
+ nptr, <tng::sessiond::ust::registry_event::_node);
event_id = existing_event->id;
} else {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "UST registry create event add unique failed for event: event = {}",
- *event));
+ "UST registry create event add unique failed for event: event = {}",
+ *event));
}
} else {
const auto& event_ref = *event;
lttng_ht_destroy(_events);
}
-const lttng::sessiond::trace::type* lsu::registry_channel::event_context() const
+const lttng::sessiond::trace::type *lsu::registry_channel::event_context() const
{
LTTNG_ASSERT(_is_registered);
return lst::stream_class::event_context();
}
void lsu::registry_channel::_accept_on_event_classes(
- lttng::sessiond::trace::trace_class_visitor& visitor) const
+ lttng::sessiond::trace::trace_class_visitor& visitor) const
{
std::vector<const lttng::sessiond::ust::registry_event *> sorted_event_classes;
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- cds_lfht_for_each_entry(_events->ht, &iter.iter, event, _node) {
+ cds_lfht_for_each_entry (_events->ht, &iter.iter, event, _node) {
sorted_event_classes.emplace_back(event);
}
DIAGNOSTIC_POP
}
- std::sort(sorted_event_classes.begin(), sorted_event_classes.end(),
- [](const lttng::sessiond::ust::registry_event *a,
- const lttng::sessiond::ust::registry_event *b) {
- return a->id < b->id;
- });
+ std::sort(sorted_event_classes.begin(),
+ sorted_event_classes.end(),
+ [](const lttng::sessiond::ust::registry_event *a,
+ const lttng::sessiond::ust::registry_event *b) { return a->id < b->id; });
for (const auto event : sorted_event_classes) {
event->accept(visitor);
namespace lsu = lttng::sessiond::ust;
lsu::registry_event::registry_event(unsigned int in_id,
- unsigned int in_stream_class_id,
- int in_session_objd,
- int in_channel_objd,
- std::string in_name,
- std::string in_signature,
- std::vector<lttng::sessiond::trace::field::cuptr> in_fields,
- int in_loglevel_value,
- nonstd::optional<std::string> in_model_emf_uri) :
+ unsigned int in_stream_class_id,
+ int in_session_objd,
+ int in_channel_objd,
+ std::string in_name,
+ std::string in_signature,
+ std::vector<lttng::sessiond::trace::field::cuptr> in_fields,
+ int in_loglevel_value,
+ nonstd::optional<std::string> in_model_emf_uri) :
lst::event_class(in_id,
- in_stream_class_id,
- in_loglevel_value,
- std::move(in_name),
- std::move(in_model_emf_uri),
- lttng::make_unique<lst::structure_type>(0, std::move(in_fields))),
- session_objd{in_session_objd},
- channel_objd{in_channel_objd},
- signature{std::move(in_signature)},
- _metadata_dumped{false}
+ in_stream_class_id,
+ in_loglevel_value,
+ std::move(in_name),
+ std::move(in_model_emf_uri),
+ lttng::make_unique<lst::structure_type>(0, std::move(in_fields))),
+ session_objd{ in_session_objd },
+ channel_objd{ in_channel_objd },
+ signature{ std::move(in_signature) },
+ _metadata_dumped{ false }
{
cds_lfht_node_init(&_node);
_head = {};
namespace lsu = lttng::sessiond::ust;
lsu::registry_session_per_pid::registry_session_per_pid(const struct ust_app& app,
- const struct lst::abi& in_abi,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id) :
- registry_session{in_abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id},
- _tracer_patch_level_version{app.version.patchlevel},
- _vpid{app.pid},
- _procname{app.name},
- _app_creation_time{app.registration_time}
+ const struct lst::abi& in_abi,
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id) :
+ registry_session{ in_abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id },
+ _tracer_patch_level_version{ app.version.patchlevel },
+ _vpid{ app.pid },
+ _procname{ app.name },
+ _app_creation_time{ app.registration_time }
{
lttng::pthread::lock_guard registry_lock(_lock);
_generate_metadata();
{
registry_session::accept(visitor);
visitor.visit(lst::environment_field<int64_t>("tracer_buffering_id", _vpid));
- visitor.visit(lst::environment_field<int64_t>(
- "tracer_patchlevel", _tracer_patch_level_version));
+ visitor.visit(
+ lst::environment_field<int64_t>("tracer_patchlevel", _tracer_patch_level_version));
visitor.visit(lst::environment_field<int64_t>("vpid", _vpid));
visitor.visit(lst::environment_field<std::string>("procname", _procname));
visitor.visit(lst::environment_field<std::string>(
- "vpid_datetime", lttng::utils::time_to_iso8601_str(_app_creation_time)));
+ "vpid_datetime", lttng::utils::time_to_iso8601_str(_app_creation_time)));
}
namespace lst = lttng::sessiond::trace;
namespace lsu = lttng::sessiond::ust;
-lsu::registry_session_per_uid::registry_session_per_uid(
- const struct lst::abi& in_abi,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id,
- uid_t tracing_uid) :
- registry_session{in_abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id},
- _tracing_uid{tracing_uid}
+lsu::registry_session_per_uid::registry_session_per_uid(const struct lst::abi& in_abi,
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id,
+ uid_t tracing_uid) :
+ registry_session{ in_abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id },
+ _tracing_uid{ tracing_uid }
{
lttng::pthread::lock_guard registry_lock(_lock);
_generate_metadata();
*
*/
+#include "ctf2-trace-class-visitor.hpp"
#include "field.hpp"
#include "lttng-sessiond.hpp"
#include "notification-thread-commands.hpp"
#include "session.hpp"
#include "trace-class.hpp"
#include "tsdl-trace-class-visitor.hpp"
-#include "ctf2-trace-class-visitor.hpp"
#include "ust-app.hpp"
#include "ust-field-convert.hpp"
#include "ust-registry.hpp"
{
const auto lseek_ret = lseek(fd, 0, SEEK_SET);
if (lseek_ret < 0) {
- LTTNG_THROW_POSIX("Failed to seek to the beginning of the metadata file while clearing it", errno);
+ LTTNG_THROW_POSIX(
+ "Failed to seek to the beginning of the metadata file while clearing it",
+ errno);
}
const auto ret = ftruncate(fd, 0);
if (notify) {
cmd_ret = notification_thread_command_remove_channel(
- the_notification_thread_handle,
- chan->_consumer_key, LTTNG_DOMAIN_UST);
+ the_notification_thread_handle, chan->_consumer_key, LTTNG_DOMAIN_UST);
if (cmd_ret != LTTNG_OK) {
ERR("Failed to remove channel from notification thread");
}
/* Destroy all event associated with this registry. */
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- cds_lfht_for_each_entry(
- chan->_events->ht, &iter.iter, event, _node) {
+ cds_lfht_for_each_entry (chan->_events->ht, &iter.iter, event, _node) {
/* Delete the node from the ht and free it. */
ust_registry_channel_destroy_event(chan, event);
}
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- _enum = caa_container_of(node, lsu::registry_enum,
- node.node);
+ _enum = caa_container_of(node, lsu::registry_enum, node.node);
DIAGNOSTIC_POP
LTTNG_ASSERT(_enum);
}
lsu::registry_session::registry_session(const struct lst::abi& in_abi,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id) :
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id) :
lst::trace_class(in_abi, generate_uuid_or_throw()),
- _root_shm_path{root_shm_path ? root_shm_path : ""},
- _shm_path{shm_path ? shm_path : ""},
- _metadata_path{_shm_path.size() > 0 ? fmt::format("{}/metadata", _shm_path) :
- std::string("")},
- _uid{euid},
- _gid{egid},
- _app_tracer_version{.major = major, .minor = minor},
- _tracing_id{tracing_id},
- _clock{lttng::make_unique<lsu::clock_class>()},
- _metadata_generating_visitor{lttng::make_unique<ls::tsdl::trace_class_visitor>(
- abi, [this](const std::string& fragment) {
- _append_metadata_fragment(fragment);
- })},
- _packet_header{_create_packet_header()}
+ _root_shm_path{ root_shm_path ? root_shm_path : "" },
+ _shm_path{ shm_path ? shm_path : "" },
+ _metadata_path{ _shm_path.size() > 0 ? fmt::format("{}/metadata", _shm_path) :
+ std::string("") },
+ _uid{ euid },
+ _gid{ egid },
+ _app_tracer_version{ .major = major, .minor = minor },
+ _tracing_id{ tracing_id },
+ _clock{ lttng::make_unique<lsu::clock_class>() },
+ _metadata_generating_visitor{ lttng::make_unique<ls::tsdl::trace_class_visitor>(
+ abi,
+ [this](const std::string& fragment) { _append_metadata_fragment(fragment); }) },
+ _packet_header{ _create_packet_header() }
{
pthread_mutex_init(&_lock, NULL);
if (_shm_path.size() > 0) {
if (_metadata_path.size() > 0) {
/* Create metadata file. */
- const int ret = run_as_open(_metadata_path.c_str(), O_WRONLY | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR, euid, egid);
+ const int ret = run_as_open(_metadata_path.c_str(),
+ O_WRONLY | O_CREAT | O_EXCL,
+ S_IRUSR | S_IWUSR,
+ euid,
+ egid);
if (ret < 0) {
- LTTNG_THROW_POSIX(fmt::format("Failed to open metadata file during registry session creation: path = {}",
- _metadata_path), errno);
+ LTTNG_THROW_POSIX(
+ fmt::format(
+ "Failed to open metadata file during registry session creation: path = {}",
+ _metadata_path),
+ errno);
}
_metadata_fd = ret;
lst::structure_type::fields packet_header_fields;
/* uint32_t magic */
- packet_header_fields.emplace_back(lttng::make_unique<lst::field>("magic",
- lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
- abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::HEXADECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_MAGIC_NUMBER}))));
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>(
+ "magic",
+ lttng::make_unique<lst::integer_type>(
+ abi.uint32_t_alignment,
+ abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::HEXADECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::PACKET_MAGIC_NUMBER }))));
/* uuid */
- packet_header_fields.emplace_back(lttng::make_unique<lst::field>("uuid",
- lttng::make_unique<lst::static_length_blob_type>(0, 16,
- std::initializer_list<lst::static_length_blob_type::role>({lst::static_length_blob_type::role::METADATA_STREAM_UUID}))));
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>(
+ "uuid",
+ lttng::make_unique<lst::static_length_blob_type>(
+ 0,
+ 16,
+ std::initializer_list<lst::static_length_blob_type::role>(
+ { lst::static_length_blob_type::role::METADATA_STREAM_UUID }))));
/* uint32_t stream_id */
- packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_id",
- lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
- abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_CLASS_ID}))));
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>(
+ "stream_id",
+ lttng::make_unique<lst::integer_type>(
+ abi.uint32_t_alignment,
+ abi.byte_order,
+ 32,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DATA_STREAM_CLASS_ID }))));
/* uint64_t stream_instance_id */
- packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_instance_id",
- lttng::make_unique<lst::integer_type>(abi.uint64_t_alignment,
- abi.byte_order, 64, lst::integer_type::signedness::UNSIGNED,
- lst::integer_type::base::DECIMAL,
- std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_ID}))));
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>(
+ "stream_instance_id",
+ lttng::make_unique<lst::integer_type>(
+ abi.uint64_t_alignment,
+ abi.byte_order,
+ 64,
+ lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>(
+ { lst::integer_type::role::DATA_STREAM_ID }))));
return lttng::make_unique<lst::structure_type>(0, std::move(packet_header_fields));
}
/* Destroy all event associated with this registry. */
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- cds_lfht_for_each_entry(_channels->ht, &iter.iter, chan, _node.node) {
+ cds_lfht_for_each_entry (_channels->ht, &iter.iter, chan, _node.node) {
/* Delete the node from the ht and free it. */
ret = lttng_ht_del(_channels.get(), &iter);
LTTNG_ASSERT(!ret);
if (_root_shm_path[0]) {
/* Try to delete the directory hierarchy. */
- (void) run_as_rmdir_recursive(_root_shm_path.c_str(), _uid, _gid,
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ (void) run_as_rmdir_recursive(_root_shm_path.c_str(),
+ _uid,
+ _gid,
+ LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
}
/* Destroy the enum hash table */
* the metadata can be dumped for that event.
*/
if (is_max_channel_id(_used_channel_id)) {
- LTTNG_THROW_ERROR(fmt::format("Failed to allocate unique id for channel under session while adding channel"));
+ LTTNG_THROW_ERROR(fmt::format(
+ "Failed to allocate unique id for channel under session while adding channel"));
}
auto chan = new lsu::registry_channel(
- _get_next_channel_id(), abi, _clock->name,
- /* Registered channel listener. */
- [this](const lsu::registry_channel& registered_channel) {
- /*
- * Channel registration completed, serialize it's layout's
- * description.
- */
- registered_channel.accept(*_metadata_generating_visitor);
- },
- /* Added event listener. */
- [this](const lsu::registry_channel& channel,
- const lsu::registry_event& added_event) {
- /*
- * The channel and its event classes will be dumped at once when
- * it is registered. This check prevents event classes from being
- * declared before their stream class.
- */
- if (channel.is_registered()) {
- added_event.accept(*_metadata_generating_visitor);
- }
- });
+ _get_next_channel_id(),
+ abi,
+ _clock->name,
+ /* Registered channel listener. */
+ [this](const lsu::registry_channel& registered_channel) {
+ /*
+ * Channel registration completed, serialize it's layout's
+ * description.
+ */
+ registered_channel.accept(*_metadata_generating_visitor);
+ },
+ /* Added event listener. */
+ [this](const lsu::registry_channel& channel,
+ const lsu::registry_event& added_event) {
+ /*
+ * The channel and its event classes will be dumped at once when
+ * it is registered. This check prevents event classes from being
+ * declared before their stream class.
+ */
+ if (channel.is_registered()) {
+ added_event.accept(*_metadata_generating_visitor);
+ }
+ });
lttng::urcu::read_lock_guard rcu_read_lock_guard;
lttng_ht_node_init_u64(&chan->_node, key);
lttng_ht_add_unique_u64(_channels.get(), &chan->_node);
}
-lttng::sessiond::ust::registry_channel& lsu::registry_session::channel(
- uint64_t channel_key) const
+lttng::sessiond::ust::registry_channel& lsu::registry_session::channel(uint64_t channel_key) const
{
lttng::urcu::read_lock_guard read_lock_guard;
struct lttng_ht_node_u64 *node;
lttng_ht_lookup(_channels.get(), &channel_key, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (!node) {
- LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "Invalid channel key provided: channel key = {}", channel_key));
+ LTTNG_THROW_INVALID_ARGUMENT_ERROR(
+ fmt::format("Invalid channel key provided: channel key = {}", channel_key));
}
DIAGNOSTIC_PUSH
}
void lsu::registry_session::accept(
- lttng::sessiond::trace::trace_class_environment_visitor& visitor) const
+ lttng::sessiond::trace::trace_class_environment_visitor& visitor) const
{
ASSERT_LOCKED(_lock);
visitor.visit(lst::environment_field<const char *>("tracer_name", "lttng-ust"));
visitor.visit(lst::environment_field<int64_t>("tracer_major", _app_tracer_version.major));
visitor.visit(lst::environment_field<int64_t>("tracer_minor", _app_tracer_version.minor));
- visitor.visit(lst::environment_field<const char *>("tracer_buffering_scheme",
- buffering_scheme() == LTTNG_BUFFER_PER_PID ? "pid" : "uid"));
+ visitor.visit(lst::environment_field<const char *>(
+ "tracer_buffering_scheme",
+ buffering_scheme() == LTTNG_BUFFER_PER_PID ? "pid" : "uid"));
visitor.visit(lst::environment_field<int64_t>("architecture_bit_width", abi.bits_per_long));
{
LTTNG_ASSERT(session);
ASSERT_LOCKED(session->lock);
- visitor.visit(lst::environment_field<const char *>("trace_name",
- session->has_auto_generated_name ? DEFAULT_SESSION_NAME :
- session->name));
- visitor.visit(lst::environment_field<std::string>("trace_creation_datetime",
- lttng::utils::time_to_iso8601_str(session->creation_time)));
+ visitor.visit(lst::environment_field<const char *>(
+ "trace_name",
+ session->has_auto_generated_name ? DEFAULT_SESSION_NAME : session->name));
+ visitor.visit(lst::environment_field<std::string>(
+ "trace_creation_datetime",
+ lttng::utils::time_to_iso8601_str(session->creation_time)));
visitor.visit(lst::environment_field<const char *>("hostname", session->hostname));
}
}
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- cds_lfht_for_each_entry(_channels->ht, &channel_it.iter, channel, _node.node) {
+ cds_lfht_for_each_entry (_channels->ht, &channel_it.iter, channel, _node.node) {
sorted_stream_classes.emplace_back(channel);
}
DIAGNOSTIC_POP
}
- std::sort(sorted_stream_classes.begin(), sorted_stream_classes.end(),
- [](const lttng::sessiond::ust::registry_channel *a,
- const lttng::sessiond::ust::registry_channel *b) {
- return a->id < b->id;
- });
+ std::sort(sorted_stream_classes.begin(),
+ sorted_stream_classes.end(),
+ [](const lttng::sessiond::ust::registry_channel *a,
+ const lttng::sessiond::ust::registry_channel *b) { return a->id < b->id; });
for (const auto stream_class : sorted_stream_classes) {
stream_class->accept(visitor);
/* Rounding the new allocation length to the next power of 2 would overflow. */
if (new_alloc_len > (UINT32_MAX >> 1)) {
- LTTNG_THROW_ERROR("Failed to reserve trace metadata storage as the new size would overflow");
+ LTTNG_THROW_ERROR(
+ "Failed to reserve trace metadata storage as the new size would overflow");
}
/* The current allocation length is already the largest we can afford. */
if ((old_alloc_len << 1) > (UINT32_MAX >> 1)) {
- LTTNG_THROW_ERROR("Failed to reserve trace metadata storage as the max size was already reached");
+ LTTNG_THROW_ERROR(
+ "Failed to reserve trace metadata storage as the max size was already reached");
}
if (new_alloc_len > old_alloc_len) {
- new_alloc_len = std::max<size_t>(
- 1U << get_count_order(new_alloc_len), old_alloc_len << 1);
+ new_alloc_len =
+ std::max<size_t>(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
auto newptr = (char *) realloc(_metadata, new_alloc_len);
if (!newptr) {
if (_metadata_fd >= 0) {
const auto bytes_written =
- lttng_write(_metadata_fd, fragment.c_str(), fragment.size());
+ lttng_write(_metadata_fd, fragment.c_str(), fragment.size());
if (bytes_written != fragment.size()) {
- LTTNG_THROW_POSIX("Failed to write trace metadata fragment to file",
- errno);
+ LTTNG_THROW_POSIX("Failed to write trace metadata fragment to file", errno);
}
}
}
reg_enum_lookup.id = enum_id;
cds_lfht_lookup(_enums->ht,
ht_hash_enum((void *) ®_enum_lookup, lttng_ht_seed),
- ht_match_enum_id, ®_enum_lookup, &iter.iter);
+ ht_match_enum_id,
+ ®_enum_lookup,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (!node) {
LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
- "Unknown enumeration referenced by application event field: enum name = `{}`, enum id = {}",
- enum_name, enum_id));
+ "Unknown enumeration referenced by application event field: enum name = `{}`, enum id = {}",
+ enum_name,
+ enum_id));
}
DIAGNOSTIC_PUSH
reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
DIAGNOSTIC_POP
- return lsu::registry_enum::const_rcu_protected_reference{*reg_enum, std::move(rcu_lock)};
+ return lsu::registry_enum::const_rcu_protected_reference{ *reg_enum, std::move(rcu_lock) };
}
/*
* Lookup enumeration by name and comparing enumeration entries.
* Needs to be called from RCU read-side critical section.
*/
-lsu::registry_enum *lsu::registry_session::_lookup_enum(
- const lsu::registry_enum *reg_enum_lookup) const
+lsu::registry_enum *
+lsu::registry_session::_lookup_enum(const lsu::registry_enum *reg_enum_lookup) const
{
lsu::registry_enum *reg_enum = NULL;
struct lttng_ht_node_str *node;
ASSERT_RCU_READ_LOCKED();
- cds_lfht_lookup(_enums->ht, ht_hash_enum((void *) reg_enum_lookup, lttng_ht_seed),
- ht_match_enum, reg_enum_lookup, &iter.iter);
+ cds_lfht_lookup(_enums->ht,
+ ht_hash_enum((void *) reg_enum_lookup, lttng_ht_seed),
+ ht_match_enum,
+ reg_enum_lookup,
+ &iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
if (!node) {
goto end;
*
* We receive ownership of entries.
*/
-void lsu::registry_session::create_or_find_enum(
- int session_objd, const char *enum_name,
- struct lttng_ust_ctl_enum_entry *raw_entries, size_t nr_entries,
- uint64_t *enum_id)
+void lsu::registry_session::create_or_find_enum(int session_objd,
+ const char *enum_name,
+ struct lttng_ust_ctl_enum_entry *raw_entries,
+ size_t nr_entries,
+ uint64_t *enum_id)
{
struct cds_lfht_node *nodep;
lsu::registry_enum *reg_enum = NULL, *old_reg_enum;
lttng::urcu::read_lock_guard read_lock_guard;
- auto entries = lttng::make_unique_wrapper<lttng_ust_ctl_enum_entry, lttng::free>(raw_entries);
+ auto entries =
+ lttng::make_unique_wrapper<lttng_ust_ctl_enum_entry, lttng::free>(raw_entries);
LTTNG_ASSERT(enum_name);
*/
if (session_objd < 0) {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "Invalid parameters used to create or look-up enumeration from registry session: session_objd = {}",
- session_objd));
+ "Invalid parameters used to create or look-up enumeration from registry session: session_objd = {}",
+ session_objd));
}
if (nr_entries == 0) {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
- "Invalid parameters used to create or look-up enumeration from registry session: nr_entries = {}",
- nr_entries));
+ "Invalid parameters used to create or look-up enumeration from registry session: nr_entries = {}",
+ nr_entries));
}
- if (lttng_strnlen(enum_name, LTTNG_UST_ABI_SYM_NAME_LEN) ==
- LTTNG_UST_ABI_SYM_NAME_LEN) {
+ if (lttng_strnlen(enum_name, LTTNG_UST_ABI_SYM_NAME_LEN) == LTTNG_UST_ABI_SYM_NAME_LEN) {
LTTNG_THROW_INVALID_ARGUMENT_ERROR(
- "Invalid parameters used to create or look-up enumeration from registry session: enumeration name is not null terminated");
+ "Invalid parameters used to create or look-up enumeration from registry session: enumeration name is not null terminated");
}
if (entries->start.signedness) {
- reg_enum = new lsu::registry_signed_enum(
- enum_name, entries.get(), nr_entries);
+ reg_enum = new lsu::registry_signed_enum(enum_name, entries.get(), nr_entries);
} else {
- reg_enum = new lsu::registry_unsigned_enum(
- enum_name, entries.get(), nr_entries);
+ reg_enum = new lsu::registry_unsigned_enum(enum_name, entries.get(), nr_entries);
}
old_reg_enum = _lookup_enum(reg_enum);
destroy_enum(reg_enum);
reg_enum = old_reg_enum;
} else {
- DBG("UST registry creating enum: %s, sess_objd: %u",
- enum_name, session_objd);
+ DBG("UST registry creating enum: %s, sess_objd: %u", enum_name, session_objd);
if (_next_enum_id == -1ULL) {
destroy_enum(reg_enum);
- LTTNG_THROW_ERROR("Failed to allocate unique enumeration ID as it would overflow");
+ LTTNG_THROW_ERROR(
+ "Failed to allocate unique enumeration ID as it would overflow");
}
reg_enum->id = _next_enum_id++;
nodep = cds_lfht_add_unique(_enums->ht,
- ht_hash_enum(reg_enum, lttng_ht_seed),
- ht_match_enum_id, reg_enum,
- ®_enum->node.node);
+ ht_hash_enum(reg_enum, lttng_ht_seed),
+ ht_match_enum_id,
+ reg_enum,
+ ®_enum->node.node);
LTTNG_ASSERT(nodep == ®_enum->node.node);
}
DBG("UST registry reply with enum %s with id %" PRIu64 " in sess_objd: %u",
- enum_name, reg_enum->id, session_objd);
+ enum_name,
+ reg_enum->id,
+ session_objd);
*enum_id = reg_enum->id;
}
#define _LGPL_SOURCE
-#include "ust-registry.hpp"
#include "lttng-sessiond.hpp"
#include "notification-thread-commands.hpp"
#include "ust-app.hpp"
#include "ust-registry-session-pid.hpp"
#include "ust-registry-session-uid.hpp"
+#include "ust-registry.hpp"
#include "utils.hpp"
#include <common/common.hpp>
#include <common/format.hpp>
#include <common/hashtable/utils.hpp>
#include <common/make-unique-wrapper.hpp>
+
#include <lttng/lttng.h>
#include <inttypes.h>
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
lttng::sessiond::ust::registry_event *event =
- lttng::utils::container_of(head, <tng::sessiond::ust::registry_event::_head);
+ lttng::utils::container_of(head, <tng::sessiond::ust::registry_event::_head);
DIAGNOSTIC_POP
lttng::sessiond::ust::registry_event_destroy(event);
* This MUST be called within a RCU read side lock section.
*/
void ust_registry_channel_destroy_event(lsu::registry_channel *chan,
- lttng::sessiond::ust::registry_event *event)
+ lttng::sessiond::ust::registry_event *event)
{
int ret;
struct lttng_ht_iter iter;
}
lsu::registry_session *ust_registry_session_per_uid_create(const lttng::sessiond::trace::abi& abi,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id,
- uid_t tracing_uid)
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id,
+ uid_t tracing_uid)
{
try {
- return new lsu::registry_session_per_uid(abi, major, minor, root_shm_path, shm_path,
- euid, egid, tracing_id, tracing_uid);
+ return new lsu::registry_session_per_uid(abi,
+ major,
+ minor,
+ root_shm_path,
+ shm_path,
+ euid,
+ egid,
+ tracing_id,
+ tracing_uid);
} catch (const std::exception& ex) {
ERR("Failed to create per-uid registry session: %s", ex.what());
return nullptr;
}
lsu::registry_session *ust_registry_session_per_pid_create(struct ust_app *app,
- const lttng::sessiond::trace::abi& abi,
- uint32_t major,
- uint32_t minor,
- const char *root_shm_path,
- const char *shm_path,
- uid_t euid,
- gid_t egid,
- uint64_t tracing_id)
+ const lttng::sessiond::trace::abi& abi,
+ uint32_t major,
+ uint32_t minor,
+ const char *root_shm_path,
+ const char *shm_path,
+ uid_t euid,
+ gid_t egid,
+ uint64_t tracing_id)
{
try {
- return new lsu::registry_session_per_pid(*app, abi, major, minor, root_shm_path,
- shm_path, euid, egid, tracing_id);
+ return new lsu::registry_session_per_pid(
+ *app, abi, major, minor, root_shm_path, shm_path, euid, egid, tracing_id);
} catch (const std::exception& ex) {
ERR("Failed to create per-pid registry session: %s", ex.what());
return nullptr;
delete reg;
}
-lsu::registry_enum::registry_enum(
- std::string in_name, enum lst::integer_type::signedness in_signedness) :
- name{std::move(in_name)}, signedness{in_signedness}
+lsu::registry_enum::registry_enum(std::string in_name,
+ enum lst::integer_type::signedness in_signedness) :
+ name{ std::move(in_name) }, signedness{ in_signedness }
{
cds_lfht_node_init(&this->node.node);
this->rcu_head = {};
*
*/
-#include <lttng/ust-sigbus.h>
-#include <lttng/ust-ctl.h>
-#include <lttng/lttng-export.h>
#include "ust-sigbus.hpp"
+#include <lttng/lttng-export.h>
+#include <lttng/ust-ctl.h>
+#include <lttng/ust-sigbus.h>
+
LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
void lttng_ust_handle_sigbus(void *address)
{
- lttng_ust_ctl_sigbus_handle(address);
+ lttng_ust_ctl_sigbus_handle(address);
}
*/
#define _LGPL_SOURCE
-#include <stdlib.h>
-#include <unistd.h>
+#include "lttng-sessiond.hpp"
+#include "snapshot.hpp"
+#include "utils.hpp"
#include <common/error.hpp>
-#include "utils.hpp"
-#include "snapshot.hpp"
-#include "lttng-sessiond.hpp"
+#include <stdlib.h>
+#include <unistd.h>
/*
* Write to writable pipe used to notify a thread.
return (int) ret;
}
-int loglevels_match(int a_loglevel_type, int a_loglevel_value,
- int b_loglevel_type, int b_loglevel_value, int loglevel_all_type)
+int loglevels_match(int a_loglevel_type,
+ int a_loglevel_value,
+ int b_loglevel_type,
+ int b_loglevel_value,
+ int loglevel_all_type)
{
int match = 1;
const char *consumer_output_get_base_path(const struct consumer_output *output)
{
- return output->type == CONSUMER_DST_LOCAL ?
- output->dst.session_root_path :
- output->dst.net.base_dir;
+ return output->type == CONSUMER_DST_LOCAL ? output->dst.session_root_path :
+ output->dst.net.base_dir;
}
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/domain-internal.hpp>
+
#include <ctype.h>
#include <popt.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-
#include <urcu/list.h>
-#include <lttng/domain-internal.hpp>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
static char *opt_channel_name;
static char *opt_session_name;
static int opt_kernel;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-add-context.1.h>
-;
+ ;
#endif
enum {
* Taken from the LTTng ABI except for "UNKNOWN".
*/
enum context_type {
- CONTEXT_UNKNOWN = -1,
- CONTEXT_PID = 0,
- CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
- CONTEXT_PROCNAME = 2,
- CONTEXT_PRIO = 3,
- CONTEXT_NICE = 4,
- CONTEXT_VPID = 5,
- CONTEXT_TID = 6,
- CONTEXT_VTID = 7,
- CONTEXT_PPID = 8,
- CONTEXT_VPPID = 9,
- CONTEXT_PTHREAD_ID = 10,
- CONTEXT_HOSTNAME = 11,
- CONTEXT_IP = 12,
+ CONTEXT_UNKNOWN = -1,
+ CONTEXT_PID = 0,
+ CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
+ CONTEXT_PROCNAME = 2,
+ CONTEXT_PRIO = 3,
+ CONTEXT_NICE = 4,
+ CONTEXT_VPID = 5,
+ CONTEXT_TID = 6,
+ CONTEXT_VTID = 7,
+ CONTEXT_PPID = 8,
+ CONTEXT_VPPID = 9,
+ CONTEXT_PTHREAD_ID = 10,
+ CONTEXT_HOSTNAME = 11,
+ CONTEXT_IP = 12,
CONTEXT_PERF_CPU_COUNTER = 13,
CONTEXT_PERF_THREAD_COUNTER = 14,
- CONTEXT_APP_CONTEXT = 15,
+ CONTEXT_APP_CONTEXT = 15,
CONTEXT_INTERRUPTIBLE = 16,
- CONTEXT_PREEMPTIBLE = 17,
+ CONTEXT_PREEMPTIBLE = 17,
CONTEXT_NEED_RESCHEDULE = 18,
- CONTEXT_MIGRATABLE = 19,
+ CONTEXT_MIGRATABLE = 19,
CONTEXT_CALLSTACK_KERNEL = 20,
CONTEXT_CALLSTACK_USER = 21,
- CONTEXT_CGROUP_NS = 22,
- CONTEXT_IPC_NS = 23,
- CONTEXT_MNT_NS = 24,
- CONTEXT_NET_NS = 25,
- CONTEXT_PID_NS = 26,
- CONTEXT_USER_NS = 27,
- CONTEXT_UTS_NS = 28,
- CONTEXT_UID = 29,
- CONTEXT_EUID = 30,
- CONTEXT_SUID = 31,
- CONTEXT_GID = 32,
- CONTEXT_EGID = 33,
- CONTEXT_SGID = 34,
- CONTEXT_VUID = 35,
- CONTEXT_VEUID = 36,
- CONTEXT_VSUID = 37,
- CONTEXT_VGID = 38,
- CONTEXT_VEGID = 39,
- CONTEXT_VSGID = 40,
- CONTEXT_TIME_NS = 41,
+ CONTEXT_CGROUP_NS = 22,
+ CONTEXT_IPC_NS = 23,
+ CONTEXT_MNT_NS = 24,
+ CONTEXT_NET_NS = 25,
+ CONTEXT_PID_NS = 26,
+ CONTEXT_USER_NS = 27,
+ CONTEXT_UTS_NS = 28,
+ CONTEXT_UID = 29,
+ CONTEXT_EUID = 30,
+ CONTEXT_SUID = 31,
+ CONTEXT_GID = 32,
+ CONTEXT_EGID = 33,
+ CONTEXT_SGID = 34,
+ CONTEXT_VUID = 35,
+ CONTEXT_VEUID = 36,
+ CONTEXT_VSUID = 37,
+ CONTEXT_VGID = 38,
+ CONTEXT_VEGID = 39,
+ CONTEXT_VSGID = 40,
+ CONTEXT_TIME_NS = 41,
};
/*
};
enum perf_count_hard {
- PERF_COUNT_HW_CPU_CYCLES = 0,
- PERF_COUNT_HW_INSTRUCTIONS = 1,
- PERF_COUNT_HW_CACHE_REFERENCES = 2,
- PERF_COUNT_HW_CACHE_MISSES = 3,
- PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
- PERF_COUNT_HW_BRANCH_MISSES = 5,
- PERF_COUNT_HW_BUS_CYCLES = 6,
- PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
- PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
+ PERF_COUNT_HW_CPU_CYCLES = 0,
+ PERF_COUNT_HW_INSTRUCTIONS = 1,
+ PERF_COUNT_HW_CACHE_REFERENCES = 2,
+ PERF_COUNT_HW_CACHE_MISSES = 3,
+ PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4,
+ PERF_COUNT_HW_BRANCH_MISSES = 5,
+ PERF_COUNT_HW_BUS_CYCLES = 6,
+ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
+ PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
};
enum perf_count_soft {
- PERF_COUNT_SW_CPU_CLOCK = 0,
- PERF_COUNT_SW_TASK_CLOCK = 1,
- PERF_COUNT_SW_PAGE_FAULTS = 2,
+ PERF_COUNT_SW_CPU_CLOCK = 0,
+ PERF_COUNT_SW_TASK_CLOCK = 1,
+ PERF_COUNT_SW_PAGE_FAULTS = 2,
PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
- PERF_COUNT_SW_CPU_MIGRATIONS = 4,
- PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
- PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
+ PERF_COUNT_SW_CPU_MIGRATIONS = 4,
+ PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
+ PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
PERF_COUNT_SW_ALIGNMENT_FAULTS = 7,
PERF_COUNT_SW_EMULATION_FAULTS = 8,
};
* { accesses, misses }
*/
enum perf_hw_cache_id {
- PERF_COUNT_HW_CACHE_L1D = 0,
- PERF_COUNT_HW_CACHE_L1I = 1,
- PERF_COUNT_HW_CACHE_LL = 2,
- PERF_COUNT_HW_CACHE_DTLB = 3,
- PERF_COUNT_HW_CACHE_ITLB = 4,
- PERF_COUNT_HW_CACHE_BPU = 5,
-
- PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
+ PERF_COUNT_HW_CACHE_L1D = 0,
+ PERF_COUNT_HW_CACHE_L1I = 1,
+ PERF_COUNT_HW_CACHE_LL = 2,
+ PERF_COUNT_HW_CACHE_DTLB = 3,
+ PERF_COUNT_HW_CACHE_ITLB = 4,
+ PERF_COUNT_HW_CACHE_BPU = 5,
+
+ PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
};
enum perf_hw_cache_op_id {
- PERF_COUNT_HW_CACHE_OP_READ = 0,
- PERF_COUNT_HW_CACHE_OP_WRITE = 1,
- PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
+ PERF_COUNT_HW_CACHE_OP_READ = 0,
+ PERF_COUNT_HW_CACHE_OP_WRITE = 1,
+ PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
- PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */
+ PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */
};
enum perf_hw_cache_op_result_id {
- PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
- PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
+ PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
+ PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
- PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */
+ PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */
};
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"jul", 'j', POPT_ARG_NONE, 0, OPT_JUL, 0, 0},
- {"log4j", 'l', POPT_ARG_NONE, 0, OPT_LOG4J, 0, 0},
- {"type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0},
- {"list", 0, POPT_ARG_NONE, NULL, OPT_LIST, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
+ { "jul", 'j', POPT_ARG_NONE, 0, OPT_JUL, 0, 0 },
+ { "log4j", 'l', POPT_ARG_NONE, 0, OPT_LOG4J, 0, 0 },
+ { "type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0 },
+ { "list", 0, POPT_ARG_NONE, NULL, OPT_LIST, NULL, NULL },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
* Context options
*/
-#define PERF_HW(optstr, name, type, hide) \
- { \
- optstr, type, PERF_COUNT_HW_##name, hide \
+#define PERF_HW(optstr, name, type, hide) \
+ { \
+ optstr, type, PERF_COUNT_HW_##name, hide \
}
-#define PERF_SW(optstr, name, type, hide) \
- { \
- optstr, type, PERF_COUNT_SW_##name, hide \
+#define PERF_SW(optstr, name, type, hide) \
+ { \
+ optstr, type, PERF_COUNT_SW_##name, hide \
}
-#define _PERF_HW_CACHE(optstr, name, type, op, result, hide) \
- { \
- optstr, type, \
- PERF_COUNT_HW_CACHE_##name, \
- PERF_COUNT_HW_CACHE_OP_##op, \
- PERF_COUNT_HW_CACHE_RESULT_##result, \
- hide, \
+#define _PERF_HW_CACHE(optstr, name, type, op, result, hide) \
+ { \
+ optstr, type, PERF_COUNT_HW_CACHE_##name, PERF_COUNT_HW_CACHE_OP_##op, \
+ PERF_COUNT_HW_CACHE_RESULT_##result, hide, \
}
-#define PERF_HW_CACHE(optstr, name, type, hide) \
- _PERF_HW_CACHE(optstr "-loads", name, type, \
- READ, ACCESS, hide), \
- _PERF_HW_CACHE(optstr "-load-misses", name, type, \
- READ, MISS, hide), \
- _PERF_HW_CACHE(optstr "-stores", name, type, \
- WRITE, ACCESS, hide), \
- _PERF_HW_CACHE(optstr "-store-misses", name, type, \
- WRITE, MISS, hide), \
- _PERF_HW_CACHE(optstr "-prefetches", name, type, \
- PREFETCH, ACCESS, hide), \
- _PERF_HW_CACHE(optstr "-prefetch-misses", name, type, \
- PREFETCH, MISS, hide)
+#define PERF_HW_CACHE(optstr, name, type, hide) \
+ _PERF_HW_CACHE(optstr "-loads", name, type, READ, ACCESS, hide), \
+ _PERF_HW_CACHE(optstr "-load-misses", name, type, READ, MISS, hide), \
+ _PERF_HW_CACHE(optstr "-stores", name, type, WRITE, ACCESS, hide), \
+ _PERF_HW_CACHE(optstr "-store-misses", name, type, WRITE, MISS, hide), \
+ _PERF_HW_CACHE(optstr "-prefetches", name, type, PREFETCH, ACCESS, hide), \
+ _PERF_HW_CACHE(optstr "-prefetch-misses", name, type, PREFETCH, MISS, hide)
namespace {
const struct ctx_opts {
/* Needed for end-of-list item. */
- ctx_opts()
- : ctx_opts(nullptr, CONTEXT_UNKNOWN)
- {}
+ ctx_opts() : ctx_opts(nullptr, CONTEXT_UNKNOWN)
+ {
+ }
- ctx_opts(const char *symbol_, context_type ctx_type_, bool hide_help_ = false)
- : symbol((char *) symbol_), ctx_type(ctx_type_), hide_help(hide_help_)
- {}
+ ctx_opts(const char *symbol_, context_type ctx_type_, bool hide_help_ = false) :
+ symbol((char *) symbol_), ctx_type(ctx_type_), hide_help(hide_help_)
+ {
+ }
- ctx_opts(const char *symbol_, context_type ctx_type_, perf_count_hard perf_count_hard, bool hide_help_)
- : ctx_opts(symbol_, ctx_type_, hide_help_)
+ ctx_opts(const char *symbol_,
+ context_type ctx_type_,
+ perf_count_hard perf_count_hard,
+ bool hide_help_) :
+ ctx_opts(symbol_, ctx_type_, hide_help_)
{
u.perf.type = PERF_TYPE_HARDWARE;
u.perf.config = perf_count_hard;
}
- ctx_opts(const char *symbol_, context_type ctx_type_, perf_count_soft perf_count_soft, bool hide_help_)
- : ctx_opts(symbol_, ctx_type_, hide_help_)
+ ctx_opts(const char *symbol_,
+ context_type ctx_type_,
+ perf_count_soft perf_count_soft,
+ bool hide_help_) :
+ ctx_opts(symbol_, ctx_type_, hide_help_)
{
u.perf.type = PERF_TYPE_SOFTWARE;
u.perf.config = perf_count_soft;
}
- ctx_opts(const char *symbol_, context_type ctx_type_,
- perf_hw_cache_id perf_hw_cache_id,
- perf_hw_cache_op_id perf_hw_cache_op_id,
- perf_hw_cache_op_result_id perf_hw_cache_op_result_id,
- bool hide_help_)
- : ctx_opts(symbol_, ctx_type_, hide_help_)
+ ctx_opts(const char *symbol_,
+ context_type ctx_type_,
+ perf_hw_cache_id perf_hw_cache_id,
+ perf_hw_cache_op_id perf_hw_cache_op_id,
+ perf_hw_cache_op_result_id perf_hw_cache_op_result_id,
+ bool hide_help_) :
+ ctx_opts(symbol_, ctx_type_, hide_help_)
{
u.perf.type = PERF_TYPE_HW_CACHE;
- u.perf.config = perf_hw_cache_id | perf_hw_cache_op_id << 8 | perf_hw_cache_op_result_id << 16;
+ u.perf.config = perf_hw_cache_id | perf_hw_cache_op_id << 8 |
+ perf_hw_cache_op_result_id << 16;
}
char *symbol;
enum context_type ctx_type;
- bool hide_help; /* Hide from --help */
+ bool hide_help; /* Hide from --help */
union {
struct {
uint32_t type;
/* Perf options */
/* Perf per-CPU counters */
- PERF_HW("perf:cpu:cpu-cycles", CPU_CYCLES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:cycles", CPU_CYCLES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:stalled-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:idle-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:stalled-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:idle-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:instructions", INSTRUCTIONS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:cache-references", CACHE_REFERENCES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:cache-misses", CACHE_MISSES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:branch-instructions", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:branches", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:branch-misses", BRANCH_MISSES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW("perf:cpu:bus-cycles", BUS_CYCLES,
- CONTEXT_PERF_CPU_COUNTER, 0),
-
- PERF_HW_CACHE("perf:cpu:L1-dcache", L1D,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW_CACHE("perf:cpu:L1-icache", L1I,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW_CACHE("perf:cpu:LLC", LL,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_HW_CACHE("perf:cpu:dTLB", DTLB,
- CONTEXT_PERF_CPU_COUNTER, 0),
- _PERF_HW_CACHE("perf:cpu:iTLB-loads", ITLB,
- CONTEXT_PERF_CPU_COUNTER, READ, ACCESS, 0),
- _PERF_HW_CACHE("perf:cpu:iTLB-load-misses", ITLB,
- CONTEXT_PERF_CPU_COUNTER, READ, MISS, 0),
- _PERF_HW_CACHE("perf:cpu:branch-loads", BPU,
- CONTEXT_PERF_CPU_COUNTER, READ, ACCESS, 0),
- _PERF_HW_CACHE("perf:cpu:branch-load-misses", BPU,
- CONTEXT_PERF_CPU_COUNTER, READ, MISS, 0),
-
- PERF_SW("perf:cpu:cpu-clock", CPU_CLOCK,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:task-clock", TASK_CLOCK,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:page-fault", PAGE_FAULTS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:faults", PAGE_FAULTS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:major-faults", PAGE_FAULTS_MAJ,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:minor-faults", PAGE_FAULTS_MIN,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:context-switches", CONTEXT_SWITCHES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:cs", CONTEXT_SWITCHES,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:cpu-migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:alignment-faults", ALIGNMENT_FAULTS,
- CONTEXT_PERF_CPU_COUNTER, 0),
- PERF_SW("perf:cpu:emulation-faults", EMULATION_FAULTS,
- CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:cpu-cycles", CPU_CYCLES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:cycles", CPU_CYCLES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:stalled-cycles-frontend",
+ STALLED_CYCLES_FRONTEND,
+ CONTEXT_PERF_CPU_COUNTER,
+ 0),
+ PERF_HW("perf:cpu:idle-cycles-frontend",
+ STALLED_CYCLES_FRONTEND,
+ CONTEXT_PERF_CPU_COUNTER,
+ 0),
+ PERF_HW("perf:cpu:stalled-cycles-backend",
+ STALLED_CYCLES_BACKEND,
+ CONTEXT_PERF_CPU_COUNTER,
+ 0),
+ PERF_HW("perf:cpu:idle-cycles-backend", STALLED_CYCLES_BACKEND, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:instructions", INSTRUCTIONS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:cache-references", CACHE_REFERENCES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:cache-misses", CACHE_MISSES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:branch-instructions", BRANCH_INSTRUCTIONS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:branches", BRANCH_INSTRUCTIONS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:branch-misses", BRANCH_MISSES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW("perf:cpu:bus-cycles", BUS_CYCLES, CONTEXT_PERF_CPU_COUNTER, 0),
+
+ PERF_HW_CACHE("perf:cpu:L1-dcache", L1D, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW_CACHE("perf:cpu:L1-icache", L1I, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW_CACHE("perf:cpu:LLC", LL, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_HW_CACHE("perf:cpu:dTLB", DTLB, CONTEXT_PERF_CPU_COUNTER, 0),
+ _PERF_HW_CACHE("perf:cpu:iTLB-loads", ITLB, CONTEXT_PERF_CPU_COUNTER, READ, ACCESS, 0),
+ _PERF_HW_CACHE("perf:cpu:iTLB-load-misses", ITLB, CONTEXT_PERF_CPU_COUNTER, READ, MISS, 0),
+ _PERF_HW_CACHE("perf:cpu:branch-loads", BPU, CONTEXT_PERF_CPU_COUNTER, READ, ACCESS, 0),
+ _PERF_HW_CACHE("perf:cpu:branch-load-misses", BPU, CONTEXT_PERF_CPU_COUNTER, READ, MISS, 0),
+
+ PERF_SW("perf:cpu:cpu-clock", CPU_CLOCK, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:task-clock", TASK_CLOCK, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:page-fault", PAGE_FAULTS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:faults", PAGE_FAULTS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:major-faults", PAGE_FAULTS_MAJ, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:minor-faults", PAGE_FAULTS_MIN, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:context-switches", CONTEXT_SWITCHES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:cs", CONTEXT_SWITCHES, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:cpu-migrations", CPU_MIGRATIONS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:migrations", CPU_MIGRATIONS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:alignment-faults", ALIGNMENT_FAULTS, CONTEXT_PERF_CPU_COUNTER, 0),
+ PERF_SW("perf:cpu:emulation-faults", EMULATION_FAULTS, CONTEXT_PERF_CPU_COUNTER, 0),
/* Perf per-thread counters */
- PERF_HW("perf:thread:cpu-cycles", CPU_CYCLES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:cycles", CPU_CYCLES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:stalled-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:idle-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:stalled-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:idle-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:instructions", INSTRUCTIONS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:cache-references", CACHE_REFERENCES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:cache-misses", CACHE_MISSES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:branch-instructions", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:branches", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:branch-misses", BRANCH_MISSES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW("perf:thread:bus-cycles", BUS_CYCLES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
-
- PERF_HW_CACHE("perf:thread:L1-dcache", L1D,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW_CACHE("perf:thread:L1-icache", L1I,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW_CACHE("perf:thread:LLC", LL,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_HW_CACHE("perf:thread:dTLB", DTLB,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- _PERF_HW_CACHE("perf:thread:iTLB-loads", ITLB,
- CONTEXT_PERF_THREAD_COUNTER, READ, ACCESS, 0),
- _PERF_HW_CACHE("perf:thread:iTLB-load-misses", ITLB,
- CONTEXT_PERF_THREAD_COUNTER, READ, MISS, 0),
- _PERF_HW_CACHE("perf:thread:branch-loads", BPU,
- CONTEXT_PERF_THREAD_COUNTER, READ, ACCESS, 0),
- _PERF_HW_CACHE("perf:thread:branch-load-misses", BPU,
- CONTEXT_PERF_THREAD_COUNTER, READ, MISS, 0),
-
- PERF_SW("perf:thread:cpu-clock", CPU_CLOCK,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:task-clock", TASK_CLOCK,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:page-fault", PAGE_FAULTS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:faults", PAGE_FAULTS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:major-faults", PAGE_FAULTS_MAJ,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:minor-faults", PAGE_FAULTS_MIN,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:context-switches", CONTEXT_SWITCHES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:cs", CONTEXT_SWITCHES,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:cpu-migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:alignment-faults", ALIGNMENT_FAULTS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
- PERF_SW("perf:thread:emulation-faults", EMULATION_FAULTS,
- CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:cpu-cycles", CPU_CYCLES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:cycles", CPU_CYCLES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:stalled-cycles-frontend",
+ STALLED_CYCLES_FRONTEND,
+ CONTEXT_PERF_THREAD_COUNTER,
+ 0),
+ PERF_HW("perf:thread:idle-cycles-frontend",
+ STALLED_CYCLES_FRONTEND,
+ CONTEXT_PERF_THREAD_COUNTER,
+ 0),
+ PERF_HW("perf:thread:stalled-cycles-backend",
+ STALLED_CYCLES_BACKEND,
+ CONTEXT_PERF_THREAD_COUNTER,
+ 0),
+ PERF_HW("perf:thread:idle-cycles-backend",
+ STALLED_CYCLES_BACKEND,
+ CONTEXT_PERF_THREAD_COUNTER,
+ 0),
+ PERF_HW("perf:thread:instructions", INSTRUCTIONS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:cache-references", CACHE_REFERENCES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:cache-misses", CACHE_MISSES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:branch-instructions",
+ BRANCH_INSTRUCTIONS,
+ CONTEXT_PERF_THREAD_COUNTER,
+ 0),
+ PERF_HW("perf:thread:branches", BRANCH_INSTRUCTIONS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:branch-misses", BRANCH_MISSES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW("perf:thread:bus-cycles", BUS_CYCLES, CONTEXT_PERF_THREAD_COUNTER, 0),
+
+ PERF_HW_CACHE("perf:thread:L1-dcache", L1D, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW_CACHE("perf:thread:L1-icache", L1I, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW_CACHE("perf:thread:LLC", LL, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_HW_CACHE("perf:thread:dTLB", DTLB, CONTEXT_PERF_THREAD_COUNTER, 0),
+ _PERF_HW_CACHE("perf:thread:iTLB-loads", ITLB, CONTEXT_PERF_THREAD_COUNTER, READ, ACCESS, 0),
+ _PERF_HW_CACHE(
+ "perf:thread:iTLB-load-misses", ITLB, CONTEXT_PERF_THREAD_COUNTER, READ, MISS, 0),
+ _PERF_HW_CACHE(
+ "perf:thread:branch-loads", BPU, CONTEXT_PERF_THREAD_COUNTER, READ, ACCESS, 0),
+ _PERF_HW_CACHE(
+ "perf:thread:branch-load-misses", BPU, CONTEXT_PERF_THREAD_COUNTER, READ, MISS, 0),
+
+ PERF_SW("perf:thread:cpu-clock", CPU_CLOCK, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:task-clock", TASK_CLOCK, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:page-fault", PAGE_FAULTS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:faults", PAGE_FAULTS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:major-faults", PAGE_FAULTS_MAJ, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:minor-faults", PAGE_FAULTS_MIN, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:context-switches", CONTEXT_SWITCHES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:cs", CONTEXT_SWITCHES, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:cpu-migrations", CPU_MIGRATIONS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:migrations", CPU_MIGRATIONS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:alignment-faults", ALIGNMENT_FAULTS, CONTEXT_PERF_THREAD_COUNTER, 0),
+ PERF_SW("perf:thread:emulation-faults", EMULATION_FAULTS, CONTEXT_PERF_THREAD_COUNTER, 0),
/*
* Perf per-CPU counters, backward compatibilty for names.
* Hidden from help listing.
*/
- PERF_HW("perf:cpu-cycles", CPU_CYCLES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:cycles", CPU_CYCLES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:stalled-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:idle-cycles-frontend", STALLED_CYCLES_FRONTEND,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:stalled-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:idle-cycles-backend", STALLED_CYCLES_BACKEND,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:instructions", INSTRUCTIONS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:cache-references", CACHE_REFERENCES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:cache-misses", CACHE_MISSES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:branch-instructions", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:branches", BRANCH_INSTRUCTIONS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:branch-misses", BRANCH_MISSES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW("perf:bus-cycles", BUS_CYCLES,
- CONTEXT_PERF_COUNTER, 1),
-
- PERF_HW_CACHE("perf:L1-dcache", L1D,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW_CACHE("perf:L1-icache", L1I,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW_CACHE("perf:LLC", LL,
- CONTEXT_PERF_COUNTER, 1),
- PERF_HW_CACHE("perf:dTLB", DTLB,
- CONTEXT_PERF_COUNTER, 1),
- _PERF_HW_CACHE("perf:iTLB-loads", ITLB,
- CONTEXT_PERF_COUNTER, READ, ACCESS, 1),
- _PERF_HW_CACHE("perf:iTLB-load-misses", ITLB,
- CONTEXT_PERF_COUNTER, READ, MISS, 1),
- _PERF_HW_CACHE("perf:branch-loads", BPU,
- CONTEXT_PERF_COUNTER, READ, ACCESS, 1),
- _PERF_HW_CACHE("perf:branch-load-misses", BPU,
- CONTEXT_PERF_COUNTER, READ, MISS, 1),
-
- PERF_SW("perf:cpu-clock", CPU_CLOCK,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:task-clock", TASK_CLOCK,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:page-fault", PAGE_FAULTS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:faults", PAGE_FAULTS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:major-faults", PAGE_FAULTS_MAJ,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:minor-faults", PAGE_FAULTS_MIN,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:context-switches", CONTEXT_SWITCHES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:cs", CONTEXT_SWITCHES,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:cpu-migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:migrations", CPU_MIGRATIONS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:alignment-faults", ALIGNMENT_FAULTS,
- CONTEXT_PERF_COUNTER, 1),
- PERF_SW("perf:emulation-faults", EMULATION_FAULTS,
- CONTEXT_PERF_COUNTER, 1),
-
- {}, /* Closure */
+ PERF_HW("perf:cpu-cycles", CPU_CYCLES, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:cycles", CPU_CYCLES, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:stalled-cycles-frontend", STALLED_CYCLES_FRONTEND, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:idle-cycles-frontend", STALLED_CYCLES_FRONTEND, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:stalled-cycles-backend", STALLED_CYCLES_BACKEND, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:idle-cycles-backend", STALLED_CYCLES_BACKEND, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:instructions", INSTRUCTIONS, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:cache-references", CACHE_REFERENCES, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:cache-misses", CACHE_MISSES, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:branch-instructions", BRANCH_INSTRUCTIONS, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:branches", BRANCH_INSTRUCTIONS, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:branch-misses", BRANCH_MISSES, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW("perf:bus-cycles", BUS_CYCLES, CONTEXT_PERF_COUNTER, 1),
+
+ PERF_HW_CACHE("perf:L1-dcache", L1D, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW_CACHE("perf:L1-icache", L1I, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW_CACHE("perf:LLC", LL, CONTEXT_PERF_COUNTER, 1),
+ PERF_HW_CACHE("perf:dTLB", DTLB, CONTEXT_PERF_COUNTER, 1),
+ _PERF_HW_CACHE("perf:iTLB-loads", ITLB, CONTEXT_PERF_COUNTER, READ, ACCESS, 1),
+ _PERF_HW_CACHE("perf:iTLB-load-misses", ITLB, CONTEXT_PERF_COUNTER, READ, MISS, 1),
+ _PERF_HW_CACHE("perf:branch-loads", BPU, CONTEXT_PERF_COUNTER, READ, ACCESS, 1),
+ _PERF_HW_CACHE("perf:branch-load-misses", BPU, CONTEXT_PERF_COUNTER, READ, MISS, 1),
+
+ PERF_SW("perf:cpu-clock", CPU_CLOCK, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:task-clock", TASK_CLOCK, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:page-fault", PAGE_FAULTS, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:faults", PAGE_FAULTS, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:major-faults", PAGE_FAULTS_MAJ, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:minor-faults", PAGE_FAULTS_MIN, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:context-switches", CONTEXT_SWITCHES, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:cs", CONTEXT_SWITCHES, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:cpu-migrations", CPU_MIGRATIONS, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:migrations", CPU_MIGRATIONS, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:alignment-faults", ALIGNMENT_FAULTS, CONTEXT_PERF_COUNTER, 1),
+ PERF_SW("perf:emulation-faults", EMULATION_FAULTS, CONTEXT_PERF_COUNTER, 1),
+
+ {}, /* Closure */
};
#undef PERF_HW_CACHE
return ret;
}
-static
-enum lttng_domain_type get_domain(void)
+static enum lttng_domain_type get_domain(void)
{
if (opt_kernel) {
return LTTNG_DOMAIN_KERNEL;
}
}
-static
-int mi_open(void)
+static int mi_open(void)
{
int ret;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_add_context);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_add_context);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
return ret;
}
-static
-int mi_close(enum cmd_error_code success)
+static int mi_close(enum cmd_error_code success)
{
int ret;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, !success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, !success);
if (ret) {
ret = CMD_ERROR;
goto end;
return ret;
}
-static
-void populate_context(struct lttng_event_context *context,
- const struct ctx_opts *opt)
+static void populate_context(struct lttng_event_context *context, const struct ctx_opts *opt)
{
char *ptr;
case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
context->u.perf_counter.type = opt->u.perf.type;
context->u.perf_counter.config = opt->u.perf.config;
- strncpy(context->u.perf_counter.name, opt->symbol,
- LTTNG_SYMBOL_NAME_LEN);
+ strncpy(context->u.perf_counter.name, opt->symbol, LTTNG_SYMBOL_NAME_LEN);
context->u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
/* Replace : and - by _ */
while ((ptr = strchr(context->u.perf_counter.name, '-')) != NULL) {
}
break;
case LTTNG_EVENT_CONTEXT_APP_CONTEXT:
- context->u.app_ctx.provider_name =
- opt->u.app_ctx.provider_name;
- context->u.app_ctx.ctx_name =
- opt->u.app_ctx.ctx_name;
+ context->u.app_ctx.provider_name = opt->u.app_ctx.provider_name;
+ context->u.app_ctx.ctx_name = opt->u.app_ctx.ctx_name;
break;
default:
break;
/*
* Pretty print context type.
*/
-static
-int print_ctx_type(void)
+static int print_ctx_type(void)
{
-
FILE *ofp = stdout;
int i = 0;
int ret;
}
ret = mi_lttng_writer_write_element_string(
- writer,
- mi_lttng_element_context_symbol,
- ctx_opts[i].symbol);
+ writer,
+ mi_lttng_element_context_symbol,
+ ctx_opts[i].symbol);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Iterate over all the context types given */
- cds_list_for_each_entry(type, &ctx_type_list.head, list) {
+ cds_list_for_each_entry (type, &ctx_type_list.head, list) {
DBG("Adding context...");
populate_context(&context, type->opt);
goto error;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_context_symbol,
- type->opt->symbol);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_context_symbol, type->opt->symbol);
if (ret) {
ret = CMD_ERROR;
goto error;
} else {
if (opt_channel_name) {
MSG("%s context %s added to channel %s",
- lttng_domain_type_str(dom.type),
- type->opt->symbol,
- opt_channel_name);
+ lttng_domain_type_str(dom.type),
+ type->opt->symbol,
+ opt_channel_name);
} else {
MSG("%s context %s added to all channels",
- lttng_domain_type_str(dom.type),
- type->opt->symbol);
+ lttng_domain_type_str(dom.type),
+ type->opt->symbol);
}
success = 1;
}
if (lttng_opt_mi) {
/* Is the single operation a success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_success, success);
if (ret) {
ret = CMD_ERROR;
goto error;
return ret;
}
-static
-void destroy_ctx_type(struct ctx_type *type)
+static void destroy_ctx_type(struct ctx_type *type)
{
if (!type) {
return;
free(type);
}
-static
-struct ctx_type *create_ctx_type(void)
+static struct ctx_type *create_ctx_type(void)
{
struct ctx_type *type = zmalloc<ctx_type>();
return type;
}
-static
-int find_ctx_type_perf_raw(const char *ctx, struct ctx_type *type)
+static int find_ctx_type_perf_raw(const char *ctx, struct ctx_type *type)
{
int ret;
int field_pos = 0;
goto end;
}
errno = 0;
- type->opt->u.perf.config = strtoll(next + 1, &endptr, 16);
+ type->opt->u.perf.config = strtoll(next + 1, &endptr, 16);
if (errno != 0 || !endptr || *endptr) {
ERR("Wrong perf raw mask format: expected rNNN");
ret = -1;
if (field_pos < 5) {
ERR("Invalid perf counter specifier, expected a specifier of "
- "the form perf:cpu:raw:rNNN:<name> or "
- "perf:thread:raw:rNNN:<name>");
+ "the form perf:cpu:raw:rNNN:<name> or "
+ "perf:thread:raw:rNNN:<name>");
ret = -1;
goto end;
}
return ret;
}
-static
-struct ctx_type *get_context_type(const char *ctx)
+static struct ctx_type *get_context_type(const char *ctx)
{
int opt_index, ret;
struct ctx_type *type = NULL;
* No colon found or no ctx name ("$app.provider:") or no provider name
* given ("$app.:..."), which is invalid.
*/
- if (!colon_pos || colon_pos == len ||
- colon_pos == sizeof(app_ctx_prefix)) {
+ if (!colon_pos || colon_pos == len || colon_pos == sizeof(app_ctx_prefix)) {
ERR("Invalid application context provided: no provider or context name provided.");
goto not_found;
}
PERROR("malloc provider_name");
goto not_found;
}
- strncpy(provider_name, ctx + sizeof(app_ctx_prefix) - 1,
- provider_name_len - 1);
+ strncpy(provider_name, ctx + sizeof(app_ctx_prefix) - 1, provider_name_len - 1);
type->opt->u.app_ctx.provider_name = provider_name;
ctx_name_len = len - colon_pos;
goto end;
}
- ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace + opt_jul + opt_log4j, true);
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace + opt_jul + opt_log4j,
+ true);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Cleanup allocated memory */
- cds_list_for_each_entry_safe(type, tmptype, &ctx_type_list.head, list) {
+ cds_list_for_each_entry_safe (type, tmptype, &ctx_type_list.head, list) {
destroy_ctx_type(type);
}
*
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
#include "../command.hpp"
#include "../loglevel.hpp"
#include "../uprobe.hpp"
-
-#include "common/argpar/argpar.h"
#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/argpar/argpar.h"
#include "common/dynamic-array.hpp"
#include "common/mi-lttng.hpp"
#include "common/string-utils/string-utils.hpp"
#include "common/utils.hpp"
+
#include <lttng/domain-internal.hpp>
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
/* For lttng_event_rule_type_str(). */
-#include <lttng/event-rule/event-rule-internal.hpp>
-#include <lttng/lttng.h>
+#include "common/dynamic-array.hpp"
#include "common/filter/filter-ast.hpp"
#include "common/filter/filter-ir.hpp"
-#include "common/dynamic-array.hpp"
+
+#include <lttng/event-rule/event-rule-internal.hpp>
+#include <lttng/lttng.h>
#if (LTTNG_SYMBOL_NAME_LEN == 256)
#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-add-trigger.1.h>
-;
+ ;
#endif
enum {
ARGPAR_OPT_DESCR_SENTINEL
};
-static
-bool has_syscall_prefix(const char *arg)
+static bool has_syscall_prefix(const char *arg)
{
bool matches = false;
const char kernel_syscall_type_opt_prefix[] = "kernel:syscall";
const size_t kernel_syscall_type_opt_prefix_len =
- sizeof(kernel_syscall_type_opt_prefix) - 1;
+ sizeof(kernel_syscall_type_opt_prefix) - 1;
const char syscall_type_opt_prefix[] = "syscall";
- const size_t syscall_type_opt_prefix_len =
- sizeof(syscall_type_opt_prefix) - 1;
+ const size_t syscall_type_opt_prefix_len = sizeof(syscall_type_opt_prefix) - 1;
- if (strncmp(arg, syscall_type_opt_prefix,
- syscall_type_opt_prefix_len) == 0) {
+ if (strncmp(arg, syscall_type_opt_prefix, syscall_type_opt_prefix_len) == 0) {
matches = true;
- } else if (strncmp(arg, kernel_syscall_type_opt_prefix,
- kernel_syscall_type_opt_prefix_len) == 0) {
+ } else if (strncmp(arg,
+ kernel_syscall_type_opt_prefix,
+ kernel_syscall_type_opt_prefix_len) == 0) {
matches = true;
} else {
matches = false;
return matches;
}
-static
-bool assign_event_rule_type(enum lttng_event_rule_type *dest, const char *arg)
+static bool assign_event_rule_type(enum lttng_event_rule_type *dest, const char *arg)
{
bool ret;
if (strcmp(arg, "user") == 0 || strcmp(arg, "user:tracepoint") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT;
- } else if (strcmp(arg, "kernel") == 0 ||
- strcmp(arg, "kernel:tracepoint") == 0) {
+ } else if (strcmp(arg, "kernel") == 0 || strcmp(arg, "kernel:tracepoint") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT;
} else if (strcmp(arg, "jul") == 0 || strcmp(arg, "jul:logging") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_JUL_LOGGING;
- } else if (strcmp(arg, "log4j") == 0 ||
- strcmp(arg, "log4j:logging") == 0) {
+ } else if (strcmp(arg, "log4j") == 0 || strcmp(arg, "log4j:logging") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING;
- } else if (strcmp(arg, "python") == 0 ||
- strcmp(arg, "python:logging") == 0) {
+ } else if (strcmp(arg, "python") == 0 || strcmp(arg, "python:logging") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING;
- } else if (strcmp(arg, "kprobe") == 0 ||
- strcmp(arg, "kernel:kprobe") == 0) {
+ } else if (strcmp(arg, "kprobe") == 0 || strcmp(arg, "kernel:kprobe") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE;
} else if (strcmp(arg, "kernel:uprobe") == 0) {
*dest = LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE;
return ret;
}
-static
-bool assign_string(char **dest, const char *src, const char *opt_name)
+static bool assign_string(char **dest, const char *src, const char *opt_name)
{
bool ret;
return ret;
}
-static bool parse_syscall_emission_site_from_type(const char *str,
- enum lttng_event_rule_kernel_syscall_emission_site *type)
+static bool
+parse_syscall_emission_site_from_type(const char *str,
+ enum lttng_event_rule_kernel_syscall_emission_site *type)
{
bool ret = false;
const char kernel_prefix[] = "kernel:";
str = &str[kernel_prefix_len];
}
- if (strcmp(str, "syscall") == 0 ||
- strcmp(str, "syscall:entry+exit") == 0) {
+ if (strcmp(str, "syscall") == 0 || strcmp(str, "syscall:entry+exit") == 0) {
*type = LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY_EXIT;
} else if (strcmp(str, "syscall:entry") == 0) {
*type = LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY;
* Return true if the string was successfully parsed as a log level string.
*/
static bool parse_log_level_string(const char *str,
- enum lttng_event_rule_type event_rule_type,
- int *log_level,
- bool *log_level_only)
+ enum lttng_event_rule_type event_rule_type,
+ int *log_level,
+ bool *log_level_only)
{
bool ret;
case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT:
{
enum lttng_loglevel log_level_min, log_level_max;
- if (!loglevel_parse_range_string(
- str, &log_level_min, &log_level_max)) {
+ if (!loglevel_parse_range_string(str, &log_level_min, &log_level_max)) {
goto error;
}
/* Only support VAL and VAL.. for now. */
- if (log_level_min != log_level_max &&
- log_level_max != LTTNG_LOGLEVEL_EMERG) {
+ if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_EMERG) {
goto error;
}
case LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING:
{
enum lttng_loglevel_log4j log_level_min, log_level_max;
- if (!loglevel_log4j_parse_range_string(
- str, &log_level_min, &log_level_max)) {
+ if (!loglevel_log4j_parse_range_string(str, &log_level_min, &log_level_max)) {
goto error;
}
/* Only support VAL and VAL.. for now. */
- if (log_level_min != log_level_max &&
- log_level_max != LTTNG_LOGLEVEL_LOG4J_FATAL) {
+ if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_LOG4J_FATAL) {
goto error;
}
case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING:
{
enum lttng_loglevel_jul log_level_min, log_level_max;
- if (!loglevel_jul_parse_range_string(
- str, &log_level_min, &log_level_max)) {
+ if (!loglevel_jul_parse_range_string(str, &log_level_min, &log_level_max)) {
goto error;
}
/* Only support VAL and VAL.. for now. */
- if (log_level_min != log_level_max &&
- log_level_max != LTTNG_LOGLEVEL_JUL_SEVERE) {
+ if (log_level_min != log_level_max && log_level_max != LTTNG_LOGLEVEL_JUL_SEVERE) {
goto error;
}
case LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING:
{
enum lttng_loglevel_python log_level_min, log_level_max;
- if (!loglevel_python_parse_range_string(
- str, &log_level_min, &log_level_max)) {
+ if (!loglevel_python_parse_range_string(str, &log_level_min, &log_level_max)) {
goto error;
}
/* Only support VAL and VAL.. for now. */
if (log_level_min != log_level_max &&
- log_level_max !=
- LTTNG_LOGLEVEL_PYTHON_CRITICAL) {
+ log_level_max != LTTNG_LOGLEVEL_PYTHON_CRITICAL) {
goto error;
}
}
static int parse_kernel_probe_opts(const char *source,
- struct lttng_kernel_probe_location **location)
+ struct lttng_kernel_probe_location **location)
{
int ret = 0;
int match;
uint64_t offset;
/* Check for symbol+offset. */
- match = sscanf(source,
- "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
- "[^'+']+%18s",
- name, s_hex);
+ match = sscanf(
+ source, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "[^'+']+%18s", name, s_hex);
if (match == 2) {
if (*s_hex == '\0') {
ERR("Kernel probe symbol offset is missing.");
}
offset = strtoull(s_hex, NULL, 0);
- *location = lttng_kernel_probe_location_symbol_create(
- symbol_name, offset);
+ *location = lttng_kernel_probe_location_symbol_create(symbol_name, offset);
if (!*location) {
ERR("Failed to create symbol kernel probe location.");
goto error;
/* Check for symbol. */
if (isalpha(name[0]) || name[0] == '_') {
- match = sscanf(source,
- "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
- "s",
- name);
+ match = sscanf(source, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "s", name);
if (match == 1) {
symbol_name = strndup(name, LTTNG_SYMBOL_NAME_LEN);
if (!symbol_name) {
goto error;
}
- *location = lttng_kernel_probe_location_symbol_create(
- symbol_name, 0);
+ *location = lttng_kernel_probe_location_symbol_create(symbol_name, 0);
if (!*location) {
ERR("Failed to create symbol kernel probe location.");
goto error;
return ret;
}
-static
-struct lttng_event_expr *ir_op_load_expr_to_event_expr(
- const struct ir_load_expression *load_expr,
- const char *capture_str)
+static struct lttng_event_expr *
+ir_op_load_expr_to_event_expr(const struct ir_load_expression *load_expr, const char *capture_str)
{
char *provider_name = NULL;
struct lttng_event_expr *event_expr = NULL;
const struct ir_load_expression_op *load_expr_op = load_expr->child;
- const enum ir_load_expression_type load_expr_child_type =
- load_expr_op->type;
+ const enum ir_load_expression_type load_expr_child_type = load_expr_op->type;
switch (load_expr_child_type) {
case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
LTTNG_ASSERT(field_name);
event_expr = load_expr_child_type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
- lttng_event_expr_event_payload_field_create(field_name) :
- lttng_event_expr_channel_context_field_create(field_name);
+ lttng_event_expr_event_payload_field_create(field_name) :
+ lttng_event_expr_channel_context_field_create(field_name);
if (!event_expr) {
ERR("Failed to create %s event expression: field name = `%s`.",
- load_expr_child_type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
- "payload field" : "channel context",
- field_name);
+ load_expr_child_type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
+ "payload field" :
+ "channel context",
+ field_name);
goto error;
}
colon = strchr(field_name, ':');
if (!colon) {
ERR("Invalid app-specific context field name: missing colon in `%s`.",
- field_name);
+ field_name);
goto error;
}
type_name = colon + 1;
if (*type_name == '\0') {
ERR("Invalid app-specific context field name: missing type name after colon in `%s`.",
- field_name);
+ field_name);
goto error;
}
goto error;
}
- event_expr = lttng_event_expr_app_specific_context_field_create(
- provider_name, type_name);
+ event_expr = lttng_event_expr_app_specific_context_field_create(provider_name,
+ type_name);
if (!event_expr) {
ERR("Failed to create app-specific context field event expression: provider name = `%s`, type name = `%s`",
- provider_name, type_name);
+ provider_name,
+ type_name);
goto error;
}
break;
}
default:
- ERR("%s: unexpected load expr type %d.", __func__,
- load_expr_op->type);
+ ERR("%s: unexpected load expr type %d.", __func__, load_expr_op->type);
abort();
}
break;
case IR_LOAD_EXPRESSION_GET_SYMBOL:
ERR("While parsing expression `%s`: Capturing subfields is not supported.",
- capture_str);
+ capture_str);
goto error;
default:
- ERR("%s: unexpected load expression operator %s.", __func__,
- ir_load_expression_type_str(load_expr_op->type));
+ ERR("%s: unexpected load expression operator %s.",
+ __func__,
+ ir_load_expression_type_str(load_expr_op->type));
abort();
}
return event_expr;
}
-static
-struct lttng_event_expr *ir_op_load_to_event_expr(
- const struct ir_op *ir, const char *capture_str)
+static struct lttng_event_expr *ir_op_load_to_event_expr(const struct ir_op *ir,
+ const char *capture_str)
{
struct lttng_event_expr *event_expr = NULL;
switch (ir->data_type) {
case IR_DATA_EXPRESSION:
{
- const struct ir_load_expression *ir_load_expr =
- ir->u.load.u.expression;
+ const struct ir_load_expression *ir_load_expr = ir->u.load.u.expression;
- event_expr = ir_op_load_expr_to_event_expr(
- ir_load_expr, capture_str);
+ event_expr = ir_op_load_expr_to_event_expr(ir_load_expr, capture_str);
break;
}
default:
- ERR("%s: unexpected data type: %s.", __func__,
- ir_data_type_str(ir->data_type));
+ ERR("%s: unexpected data type: %s.", __func__, ir_data_type_str(ir->data_type));
abort();
}
return event_expr;
}
-static
-const char *ir_operator_type_human_str(enum ir_op_type op)
+static const char *ir_operator_type_human_str(enum ir_op_type op)
{
const char *name;
return name;
}
-static
-struct lttng_event_expr *ir_op_root_to_event_expr(const struct ir_op *ir,
- const char *capture_str)
+static struct lttng_event_expr *ir_op_root_to_event_expr(const struct ir_op *ir,
+ const char *capture_str)
{
struct lttng_event_expr *event_expr = NULL;
case IR_OP_UNARY:
case IR_OP_LOGICAL:
ERR("While parsing expression `%s`: %s operators are not allowed in capture expressions.",
- capture_str,
- ir_operator_type_human_str(ir->op));
+ capture_str,
+ ir_operator_type_human_str(ir->op));
break;
default:
- ERR("%s: unexpected IR op type: %s.", __func__,
- ir_op_type_str(ir->op));
+ ERR("%s: unexpected IR op type: %s.", __func__, ir_op_type_str(ir->op));
abort();
}
return event_expr;
}
-static
-void destroy_event_expr(void *ptr)
+static void destroy_event_expr(void *ptr)
{
lttng_event_expr_destroy((lttng_event_expr *) ptr);
}
};
} /* namespace */
-static
-struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv,
- int argc_offset)
+static struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv, int argc_offset)
{
- enum lttng_event_rule_type event_rule_type =
- LTTNG_EVENT_RULE_TYPE_UNKNOWN;
+ enum lttng_event_rule_type event_rule_type = LTTNG_EVENT_RULE_TYPE_UNKNOWN;
struct argpar_iter *argpar_iter = NULL;
const struct argpar_item *argpar_item = NULL;
int consumed_args = -1;
/* Log level. */
char *log_level_str = NULL;
- lttng_dynamic_pointer_array_init(&res.capture_descriptors,
- destroy_event_expr);
+ lttng_dynamic_pointer_array_init(&res.capture_descriptors, destroy_event_expr);
lttng_dynamic_pointer_array_init(&exclude_names, free);
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item,
- argc_offset, *argv, false, NULL, NULL);
+ status = parse_next_item(
+ argpar_iter, &argpar_item, argc_offset, *argv, false, NULL, NULL);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
LTTNG_ASSERT(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
const char *arg = argpar_item_opt_arg(argpar_item);
switch (descr->id) {
}
/* Save the string for later use. */
- if (!assign_string(&event_rule_type_str, arg,
- "--type/-t")) {
+ if (!assign_string(&event_rule_type_str, arg, "--type/-t")) {
goto error;
}
break;
case OPT_LOCATION:
- if (!assign_string(&location, arg,
- "--location/-L")) {
+ if (!assign_string(&location, arg, "--location/-L")) {
goto error;
}
break;
case OPT_EVENT_NAME:
- if (!assign_string(&event_name, arg,
- "--event-name/-E")) {
+ if (!assign_string(&event_name, arg, "--event-name/-E")) {
goto error;
}
break;
case OPT_FILTER:
- if (!assign_string(&filter, arg,
- "--filter/-f")) {
+ if (!assign_string(&filter, arg, "--filter/-f")) {
goto error;
}
break;
case OPT_NAME:
- if (!assign_string(&name, arg,
- "--name/-n")) {
+ if (!assign_string(&name, arg, "--name/-n")) {
goto error;
}
{
int ret;
- ret = lttng_dynamic_pointer_array_add_pointer(
- &exclude_names,
- strdup(arg));
+ ret = lttng_dynamic_pointer_array_add_pointer(&exclude_names,
+ strdup(arg));
if (ret != 0) {
ERR("Failed to add pointer to dynamic pointer array.");
goto error;
break;
}
case OPT_LOG_LEVEL:
- if (!assign_string(&log_level_str, arg,
- "--log-level/-l")) {
+ if (!assign_string(&log_level_str, arg, "--log-level/-l")) {
goto error;
}
{
int ret;
- ret = filter_parser_ctx_create_from_filter_expression(
- arg, &parser_ctx);
+ ret = filter_parser_ctx_create_from_filter_expression(arg,
+ &parser_ctx);
if (ret) {
ERR("Failed to parse capture expression `%s`.", arg);
goto error;
}
- event_expr = ir_op_root_to_event_expr(
- parser_ctx->ir_root, arg);
+ event_expr = ir_op_root_to_event_expr(parser_ctx->ir_root, arg);
filter_parser_ctx_free(parser_ctx);
parser_ctx = nullptr;
if (!event_expr) {
}
ret = lttng_dynamic_pointer_array_add_pointer(
- &res.capture_descriptors,
- event_expr);
+ &res.capture_descriptors, event_expr);
if (ret) {
goto error;
}
default:
if (name) {
ERR("Can't use --name with %s event rules.",
- lttng_event_rule_type_str(
- event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
if (lttng_dynamic_pointer_array_get_count(&exclude_names) > 0) {
ERR("Can't use --exclude-name/-x with %s event rules.",
- lttng_event_rule_type_str(
- event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
}
case LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE:
if (!location) {
ERR("Event rule of type %s requires a --location.",
- lttng_event_rule_type_str(event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
default:
if (location) {
ERR("Can't use --location with %s event rules.",
- lttng_event_rule_type_str(event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
if (event_name) {
ERR("Can't use --event-name with %s event rules.",
- lttng_event_rule_type_str(
- event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
}
break;
default:
ERR("Filter expressions are not supported for %s event rules.",
- lttng_event_rule_type_str(event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
}
if (lttng_dynamic_pointer_array_get_count(&exclude_names) > 0) {
if (event_rule_type != LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT) {
ERR("Event name exclusions are not yet implemented for %s event rules.",
- lttng_event_rule_type_str(event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
break;
}
- if (!parse_log_level_string(log_level_str, event_rule_type,
- &log_level, &log_level_only)) {
- ERR("Failed to parse log level string `%s`.",
- log_level_str);
+ if (!parse_log_level_string(
+ log_level_str, event_rule_type, &log_level, &log_level_only)) {
+ ERR("Failed to parse log level string `%s`.", log_level_str);
goto error;
}
if (log_level_only) {
log_level_rule = lttng_log_level_rule_exactly_create(log_level);
} else {
- log_level_rule = lttng_log_level_rule_at_least_as_severe_as_create(log_level);
+ log_level_rule = lttng_log_level_rule_at_least_as_severe_as_create(
+ log_level);
}
if (log_level_rule == NULL) {
}
default:
ERR("Log levels are not supported for %s event rules.",
- lttng_event_rule_type_str(event_rule_type));
+ lttng_event_rule_type_str(event_rule_type));
goto error;
}
}
}
/* Set pattern. */
- event_rule_status = lttng_event_rule_user_tracepoint_set_name_pattern(
- res.er, name);
+ event_rule_status = lttng_event_rule_user_tracepoint_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set user_tracepoint event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set user_tracepoint event rule's pattern to '%s'.", name);
goto error;
}
/* Set filter. */
if (filter) {
- event_rule_status = lttng_event_rule_user_tracepoint_set_filter(
- res.er, filter);
+ event_rule_status =
+ lttng_event_rule_user_tracepoint_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set user_tracepoint event rule's filter to '%s'.",
- filter);
+ filter);
goto error;
}
}
/* Set exclusion list. */
if (lttng_dynamic_pointer_array_get_count(&exclude_names) > 0) {
int n;
- int count = lttng_dynamic_pointer_array_get_count(
- &exclude_names);
+ int count = lttng_dynamic_pointer_array_get_count(&exclude_names);
for (n = 0; n < count; n++) {
const char *exclude_name =
- (const char *) lttng_dynamic_pointer_array_get_pointer(
- &exclude_names,
- n);
+ (const char *) lttng_dynamic_pointer_array_get_pointer(
+ &exclude_names, n);
event_rule_status =
- lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(
- res.er,
- exclude_name);
- if (event_rule_status !=
- LTTNG_EVENT_RULE_STATUS_OK) {
+ lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(
+ res.er, exclude_name);
+ if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set user_tracepoint exclusion list element '%s'",
- exclude_name);
+ exclude_name);
goto error;
}
}
}
if (log_level_rule) {
- event_rule_status =
- lttng_event_rule_user_tracepoint_set_log_level_rule(
- res.er, log_level_rule);
+ event_rule_status = lttng_event_rule_user_tracepoint_set_log_level_rule(
+ res.er, log_level_rule);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set log level on event fule.");
}
/* Set pattern. */
- event_rule_status = lttng_event_rule_kernel_tracepoint_set_name_pattern(
- res.er, name);
+ event_rule_status =
+ lttng_event_rule_kernel_tracepoint_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set kernel_tracepoint event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set kernel_tracepoint event rule's pattern to '%s'.", name);
goto error;
}
/* Set filter. */
if (filter) {
- event_rule_status = lttng_event_rule_kernel_tracepoint_set_filter(
- res.er, filter);
+ event_rule_status =
+ lttng_event_rule_kernel_tracepoint_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set kernel_tracepoint event rule's filter to '%s'.",
- filter);
+ filter);
goto error;
}
}
}
/* Set pattern. */
- event_rule_status = lttng_event_rule_jul_logging_set_name_pattern(
- res.er, name);
+ event_rule_status = lttng_event_rule_jul_logging_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set jul_logging event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set jul_logging event rule's pattern to '%s'.", name);
goto error;
}
/* Set filter. */
if (filter) {
- event_rule_status = lttng_event_rule_jul_logging_set_filter(
- res.er, filter);
+ event_rule_status = lttng_event_rule_jul_logging_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set jul_logging event rule's filter to '%s'.",
- filter);
+ filter);
goto error;
}
}
if (log_level_rule) {
- event_rule_status =
- lttng_event_rule_jul_logging_set_log_level_rule(
- res.er, log_level_rule);
+ event_rule_status = lttng_event_rule_jul_logging_set_log_level_rule(
+ res.er, log_level_rule);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set log level on event fule.");
}
/* Set pattern. */
- event_rule_status = lttng_event_rule_log4j_logging_set_name_pattern(
- res.er, name);
+ event_rule_status = lttng_event_rule_log4j_logging_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set jul_logging event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set jul_logging event rule's pattern to '%s'.", name);
goto error;
}
/* Set filter. */
if (filter) {
- event_rule_status = lttng_event_rule_log4j_logging_set_filter(
- res.er, filter);
+ event_rule_status =
+ lttng_event_rule_log4j_logging_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set jul_logging event rule's filter to '%s'.",
- filter);
+ filter);
goto error;
}
}
if (log_level_rule) {
- event_rule_status =
- lttng_event_rule_log4j_logging_set_log_level_rule(
- res.er, log_level_rule);
+ event_rule_status = lttng_event_rule_log4j_logging_set_log_level_rule(
+ res.er, log_level_rule);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set log level on event fule.");
}
/* Set pattern. */
- event_rule_status = lttng_event_rule_python_logging_set_name_pattern(
- res.er, name);
+ event_rule_status = lttng_event_rule_python_logging_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set jul_logging event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set jul_logging event rule's pattern to '%s'.", name);
goto error;
}
/* Set filter. */
if (filter) {
- event_rule_status = lttng_event_rule_python_logging_set_filter(
- res.er, filter);
+ event_rule_status =
+ lttng_event_rule_python_logging_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set jul_logging event rule's filter to '%s'.",
- filter);
+ filter);
goto error;
}
}
if (log_level_rule) {
- event_rule_status =
- lttng_event_rule_python_logging_set_log_level_rule(
- res.er, log_level_rule);
+ event_rule_status = lttng_event_rule_python_logging_set_log_level_rule(
+ res.er, log_level_rule);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set log level on event fule.");
int ret;
enum lttng_event_rule_status event_rule_status;
- ret = parse_kernel_probe_opts(
- location, &kernel_probe_location);
+ ret = parse_kernel_probe_opts(location, &kernel_probe_location);
if (ret) {
ERR("Failed to parse kernel probe location.");
goto error;
}
event_rule_status =
- lttng_event_rule_kernel_kprobe_set_event_name(
- res.er, event_name);
+ lttng_event_rule_kernel_kprobe_set_event_name(res.er, event_name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set kprobe event rule's name to '%s'.",
- event_name);
+ ERR("Failed to set kprobe event rule's name to '%s'.", event_name);
goto error;
}
int ret;
enum lttng_event_rule_status event_rule_status;
- ret = parse_userspace_probe_opts(
- location, &userspace_probe_location);
+ ret = parse_userspace_probe_opts(location, &userspace_probe_location);
if (ret) {
ERR("Failed to parse user space probe location.");
goto error;
}
event_rule_status =
- lttng_event_rule_kernel_uprobe_set_event_name(
- res.er, event_name);
+ lttng_event_rule_kernel_uprobe_set_event_name(res.er, event_name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set user space probe event rule's name to '%s'.",
- event_name);
+ event_name);
goto error;
}
enum lttng_event_rule_status event_rule_status;
enum lttng_event_rule_kernel_syscall_emission_site emission_site;
- if (!parse_syscall_emission_site_from_type(
- event_rule_type_str, &emission_site)) {
+ if (!parse_syscall_emission_site_from_type(event_rule_type_str, &emission_site)) {
ERR("Failed to parse syscall type '%s'.", event_rule_type_str);
goto error;
}
goto error;
}
- event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(
- res.er, name);
+ event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(res.er, name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set syscall event rule's pattern to '%s'.",
- name);
+ ERR("Failed to set syscall event rule's pattern to '%s'.", name);
goto error;
}
if (filter) {
- event_rule_status = lttng_event_rule_kernel_syscall_set_filter(
- res.er, filter);
+ event_rule_status =
+ lttng_event_rule_kernel_syscall_set_filter(res.er, filter);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
- ERR("Failed to set syscall event rule's filter to '%s'.",
- filter);
+ ERR("Failed to set syscall event rule's filter to '%s'.", filter);
goto error;
}
}
return res;
}
-static
-struct lttng_condition *handle_condition_event(int *argc, const char ***argv,
- int argc_offset)
+static struct lttng_condition *
+handle_condition_event(int *argc, const char ***argv, int argc_offset)
{
struct parse_event_rule_res res;
struct lttng_condition *c;
goto error;
}
- for (i = 0; i < lttng_dynamic_pointer_array_get_count(&res.capture_descriptors);
- i++) {
+ for (i = 0; i < lttng_dynamic_pointer_array_get_count(&res.capture_descriptors); i++) {
enum lttng_condition_status status;
struct lttng_event_expr **expr =
- (lttng_event_expr **) lttng_dynamic_array_get_element(
- &res.capture_descriptors.array, i);
+ (lttng_event_expr **) lttng_dynamic_array_get_element(
+ &res.capture_descriptors.array, i);
LTTNG_ASSERT(expr);
LTTNG_ASSERT(*expr);
- status = lttng_condition_event_rule_matches_append_capture_descriptor(
- c, *expr);
+ status = lttng_condition_event_rule_matches_append_capture_descriptor(c, *expr);
if (status != LTTNG_CONDITION_STATUS_OK) {
if (status == LTTNG_CONDITION_STATUS_UNSUPPORTED) {
ERR("The capture feature is unsupported by the event-rule condition type");
namespace {
struct condition_descr {
const char *name;
- struct lttng_condition *(*handler) (int *argc, const char ***argv,
- int argc_offset);
+ struct lttng_condition *(*handler)(int *argc, const char ***argv, int argc_offset);
};
} /* namespace */
-static const
-struct condition_descr condition_descrs[] = {
+static const struct condition_descr condition_descrs[] = {
{ "event-rule-matches", handle_condition_event },
};
-static
-void print_valid_condition_names(void)
+static void print_valid_condition_names(void)
{
unsigned int i;
}
}
-static
-struct lttng_condition *parse_condition(const char *condition_name, int *argc,
- const char ***argv, int argc_offset, int orig_arg_index,
- const char *orig_arg)
+static struct lttng_condition *parse_condition(const char *condition_name,
+ int *argc,
+ const char ***argv,
+ int argc_offset,
+ int orig_arg_index,
+ const char *orig_arg)
{
int i;
struct lttng_condition *cond;
if (!descr) {
ERR(WHILE_PARSING_ARG_N_ARG_FMT "Unknown condition name '%s'",
- orig_arg_index + 1, orig_arg, condition_name);
+ orig_arg_index + 1,
+ orig_arg,
+ condition_name);
print_valid_condition_names();
goto error;
}
/* Parse the value. */
if (utils_parse_unsigned_long_long(policy_value_str, &value) != 0) {
- ERR("Failed to parse rate policy value `%s` as an integer.",
- policy_value_str);
+ ERR("Failed to parse rate policy value `%s` as an integer.", policy_value_str);
goto end;
}
}
static const struct argpar_opt_descr notify_action_opt_descrs[] = {
- { OPT_RATE_POLICY, '\0', "rate-policy", true },
- ARGPAR_OPT_DESCR_SENTINEL
+ { OPT_RATE_POLICY, '\0', "rate-policy", true }, ARGPAR_OPT_DESCR_SENTINEL
};
-static
-struct lttng_action *handle_action_notify(int *argc, const char ***argv,
- int argc_offset)
+static struct lttng_action *handle_action_notify(int *argc, const char ***argv, int argc_offset)
{
struct lttng_action *action = NULL;
struct argpar_iter *argpar_iter = NULL;
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item,
- argc_offset, *argv, false, NULL,
- "While parsing `notify` action:");
+ status = parse_next_item(argpar_iter,
+ &argpar_item,
+ argc_offset,
+ *argv,
+ false,
+ NULL,
+ "While parsing `notify` action:");
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
LTTNG_ASSERT(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
const char *arg = argpar_item_opt_arg(argpar_item);
switch (descr->id) {
* optional rate policy.
*/
-static struct lttng_action *handle_action_simple_session_with_policy(int *argc,
- const char ***argv,
- int argc_offset,
- struct lttng_action *(*create_action_cb)(void),
- enum lttng_action_status (*set_session_name_cb)(
- struct lttng_action *, const char *),
- enum lttng_action_status (*set_rate_policy_cb)(
- struct lttng_action *,
- const struct lttng_rate_policy *),
- const char *action_name)
+static struct lttng_action *handle_action_simple_session_with_policy(
+ int *argc,
+ const char ***argv,
+ int argc_offset,
+ struct lttng_action *(*create_action_cb)(void),
+ enum lttng_action_status (*set_session_name_cb)(struct lttng_action *, const char *),
+ enum lttng_action_status (*set_rate_policy_cb)(struct lttng_action *,
+ const struct lttng_rate_policy *),
+ const char *action_name)
{
struct lttng_action *action = NULL;
struct argpar_iter *argpar_iter = NULL;
LTTNG_ASSERT(set_rate_policy_cb);
const struct argpar_opt_descr rate_policy_opt_descrs[] = {
- { OPT_RATE_POLICY, '\0', "rate-policy", true },
- ARGPAR_OPT_DESCR_SENTINEL
+ { OPT_RATE_POLICY, '\0', "rate-policy", true }, ARGPAR_OPT_DESCR_SENTINEL
};
argpar_iter = argpar_iter_create(*argc, *argv, rate_policy_opt_descrs);
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, argc_offset,
- *argv, false, NULL,
- "While parsing `%s` action:", action_name);
+ status = parse_next_item(argpar_iter,
+ &argpar_item,
+ argc_offset,
+ *argv,
+ false,
+ NULL,
+ "While parsing `%s` action:",
+ action_name);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
LTTNG_ASSERT(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
const char *arg = argpar_item_opt_arg(argpar_item);
switch (descr->id) {
action_status = set_session_name_cb(action, session_name_arg);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to set action %s session's session name to '%s'.",
- action_name, session_name_arg);
+ action_name,
+ session_name_arg);
goto error;
}
return action;
}
-static
-struct lttng_action *handle_action_start_session(int *argc,
- const char ***argv, int argc_offset)
+static struct lttng_action *
+handle_action_start_session(int *argc, const char ***argv, int argc_offset)
{
- return handle_action_simple_session_with_policy(argc, argv,
- argc_offset,
- lttng_action_start_session_create,
- lttng_action_start_session_set_session_name,
- lttng_action_start_session_set_rate_policy, "start");
+ return handle_action_simple_session_with_policy(argc,
+ argv,
+ argc_offset,
+ lttng_action_start_session_create,
+ lttng_action_start_session_set_session_name,
+ lttng_action_start_session_set_rate_policy,
+ "start");
}
-static
-struct lttng_action *handle_action_stop_session(int *argc,
- const char ***argv, int argc_offset)
+static struct lttng_action *
+handle_action_stop_session(int *argc, const char ***argv, int argc_offset)
{
- return handle_action_simple_session_with_policy(argc, argv,
- argc_offset,
- lttng_action_stop_session_create,
- lttng_action_stop_session_set_session_name,
- lttng_action_stop_session_set_rate_policy, "stop");
+ return handle_action_simple_session_with_policy(argc,
+ argv,
+ argc_offset,
+ lttng_action_stop_session_create,
+ lttng_action_stop_session_set_session_name,
+ lttng_action_stop_session_set_rate_policy,
+ "stop");
}
-static
-struct lttng_action *handle_action_rotate_session(int *argc,
- const char ***argv, int argc_offset)
+static struct lttng_action *
+handle_action_rotate_session(int *argc, const char ***argv, int argc_offset)
{
- return handle_action_simple_session_with_policy(argc, argv,
+ return handle_action_simple_session_with_policy(
+ argc,
+ argv,
argc_offset,
lttng_action_rotate_session_create,
lttng_action_rotate_session_set_session_name,
ARGPAR_OPT_DESCR_SENTINEL
};
-static
-struct lttng_action *handle_action_snapshot_session(int *argc,
- const char ***argv, int argc_offset)
+static struct lttng_action *
+handle_action_snapshot_session(int *argc, const char ***argv, int argc_offset)
{
struct lttng_action *action = NULL;
struct argpar_iter *argpar_iter = NULL;
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, argc_offset,
- *argv, false, NULL, "While parsing `snapshot` action:");
+ status = parse_next_item(argpar_iter,
+ &argpar_item,
+ argc_offset,
+ *argv,
+ false,
+ NULL,
+ "While parsing `snapshot` action:");
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
LTTNG_ASSERT(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
const char *arg = argpar_item_opt_arg(argpar_item);
switch (descr->id) {
goto error;
}
- action_status = lttng_action_snapshot_session_set_session_name(
- action, session_name_arg);
+ action_status = lttng_action_snapshot_session_set_session_name(action, session_name_arg);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to set action snapshot session's session name to '%s'.",
- session_name_arg);
+ session_name_arg);
goto error;
}
goto error;
}
- ret = lttng_snapshot_output_set_name(
- snapshot_name_arg, snapshot_output);
+ ret = lttng_snapshot_output_set_name(snapshot_name_arg, snapshot_output);
if (ret != 0) {
ERR("Failed to set name of snapshot output.");
goto error;
ret = lttng_snapshot_output_set_size(max_size, snapshot_output);
if (ret != 0) {
ERR("Failed to set snapshot output's max size to %" PRIu64 " bytes.",
- max_size);
+ max_size);
goto error;
}
}
}
if (uris[0].dtype == LTTNG_DST_PATH) {
- ret = lttng_snapshot_output_set_local_path(
- uris[0].dst.path, snapshot_output);
+ ret = lttng_snapshot_output_set_local_path(uris[0].dst.path,
+ snapshot_output);
free(uris);
if (ret != 0) {
- ERR("Failed to assign '%s' as a local destination.",
- url_arg);
+ ERR("Failed to assign '%s' as a local destination.", url_arg);
goto error;
}
} else {
- ret = lttng_snapshot_output_set_network_url(
- url_arg, snapshot_output);
+ ret = lttng_snapshot_output_set_network_url(url_arg, snapshot_output);
free(uris);
if (ret != 0) {
- ERR("Failed to assign '%s' as a network URL.",
- url_arg);
+ ERR("Failed to assign '%s' as a network URL.", url_arg);
goto error;
}
}
}
if (path_arg) {
- ret = lttng_snapshot_output_set_local_path(
- path_arg, snapshot_output);
+ ret = lttng_snapshot_output_set_local_path(path_arg, snapshot_output);
if (ret != 0) {
ERR("Failed to parse '%s' as a local path.", path_arg);
goto error;
* data URLs.
*/
ret = lttng_snapshot_output_set_network_urls(
- ctrl_url_arg, data_url_arg, snapshot_output);
+ ctrl_url_arg, data_url_arg, snapshot_output);
if (ret != 0) {
ERR("Failed to parse `%s` and `%s` as control and data URLs.",
- ctrl_url_arg, data_url_arg);
+ ctrl_url_arg,
+ data_url_arg);
goto error;
}
}
if (snapshot_output) {
- action_status = lttng_action_snapshot_session_set_output(
- action, snapshot_output);
+ action_status = lttng_action_snapshot_session_set_output(action, snapshot_output);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to set snapshot session action's output.");
goto error;
if (policy) {
enum lttng_action_status status;
- status = lttng_action_snapshot_session_set_rate_policy(
- action, policy);
+ status = lttng_action_snapshot_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to set rate policy");
goto error;
namespace {
struct action_descr {
const char *name;
- struct lttng_action *(*handler) (int *argc, const char ***argv,
- int argc_offset);
+ struct lttng_action *(*handler)(int *argc, const char ***argv, int argc_offset);
};
} /* namespace */
-static const
-struct action_descr action_descrs[] = {
+static const struct action_descr action_descrs[] = {
{ "notify", handle_action_notify },
{ "start-session", handle_action_start_session },
{ "stop-session", handle_action_stop_session },
{ "snapshot-session", handle_action_snapshot_session },
};
-static
-void print_valid_action_names(void)
+static void print_valid_action_names(void)
{
unsigned int i;
}
}
-static
-struct lttng_action *parse_action(const char *action_name, int *argc,
- const char ***argv, int argc_offset, int orig_arg_index,
- const char *orig_arg)
+static struct lttng_action *parse_action(const char *action_name,
+ int *argc,
+ const char ***argv,
+ int argc_offset,
+ int orig_arg_index,
+ const char *orig_arg)
{
int i;
struct lttng_action *action;
if (!descr) {
ERR(WHILE_PARSING_ARG_N_ARG_FMT "Unknown action name '%s'",
- orig_arg_index + 1, orig_arg, action_name);
+ orig_arg_index + 1,
+ orig_arg,
+ action_name);
print_valid_action_names();
goto error;
}
return action;
}
-static const
-struct argpar_opt_descr add_trigger_options[] = {
+static const struct argpar_opt_descr add_trigger_options[] = {
{ OPT_HELP, 'h', "help", false },
{ OPT_LIST_OPTIONS, '\0', "list-options", false },
{ OPT_CONDITION, '\0', "condition", true },
ARGPAR_OPT_DESCR_SENTINEL,
};
-static
-void lttng_actions_destructor(void *p)
+static void lttng_actions_destructor(void *p)
{
struct lttng_action *action = (lttng_action *) p;
lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor);
if (lttng_opt_mi) {
- mi_writer = mi_lttng_writer_create(
- fileno(stdout), lttng_opt_mi);
+ mi_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
if (!mi_writer) {
ret = CMD_ERROR;
goto error;
}
/* Open command element. */
- ret = mi_lttng_writer_command_open(mi_writer,
- mi_lttng_element_command_add_trigger);
+ ret = mi_lttng_writer_command_open(mi_writer, mi_lttng_element_command_add_trigger);
if (ret) {
ret = CMD_ERROR;
goto error;
}
/* Open output element. */
- ret = mi_lttng_writer_open_element(
- mi_writer, mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(mi_writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto error;
const char *arg;
argpar_iter_destroy(argpar_iter);
- argpar_iter = argpar_iter_create(my_argc, my_argv,
- add_trigger_options);
+ argpar_iter = argpar_iter_create(my_argc, my_argv, add_trigger_options);
if (!argpar_iter) {
ERR("Failed to create argpar iter.");
goto error;
}
- status = parse_next_item(argpar_iter, &argpar_item,
- argc - my_argc, my_argv, true, &argpar_error, NULL);
+ status = parse_next_item(argpar_iter,
+ &argpar_item,
+ argc - my_argc,
+ my_argv,
+ true,
+ &argpar_error,
+ NULL);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR) {
-
- if (argpar_error_type(argpar_error) ==
- ARGPAR_ERROR_TYPE_MISSING_OPT_ARG) {
+ if (argpar_error_type(argpar_error) == ARGPAR_ERROR_TYPE_MISSING_OPT_ARG) {
int opt_id = argpar_error_opt_descr(argpar_error, NULL)->id;
if (opt_id == OPT_CONDITION) {
LTTNG_ASSERT(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_NON_OPT) {
- ERR("Unexpected argument `%s`.",
- argpar_item_non_opt_arg(argpar_item));
+ ERR("Unexpected argument `%s`.", argpar_item_non_opt_arg(argpar_item));
goto error;
}
goto error;
}
- condition = parse_condition(arg, &my_argc, &my_argv,
- argc - my_argc, argc - my_argc - ingested_args,
- my_argv[-ingested_args]);
+ condition = parse_condition(arg,
+ &my_argc,
+ &my_argv,
+ argc - my_argc,
+ argc - my_argc - ingested_args,
+ my_argv[-ingested_args]);
if (!condition) {
/*
* An error message was already printed by
}
case OPT_ACTION:
{
- action = parse_action(arg, &my_argc, &my_argv,
- argc - my_argc, argc - my_argc - ingested_args,
- my_argv[-ingested_args]);
+ action = parse_action(arg,
+ &my_argc,
+ &my_argv,
+ argc - my_argc,
+ argc - my_argc - ingested_args,
+ my_argv[-ingested_args]);
if (!action) {
/*
* An error message was already printed by
goto error;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &actions, action);
+ ret = lttng_dynamic_pointer_array_add_pointer(&actions, action);
if (ret) {
ERR("Failed to add pointer to pointer array.");
goto error;
}
case OPT_OWNER_UID:
{
- if (!assign_string(&owner_uid, arg,
- "--owner-uid")) {
+ if (!assign_string(&owner_uid, arg, "--owner-uid")) {
goto error;
}
}
if (ret_code != LTTNG_OK) {
- ERR("Failed to register trigger: %s.",
- lttng_strerror(-ret_code));
+ ERR("Failed to register trigger: %s.", lttng_strerror(-ret_code));
goto error;
}
} else {
const char *returned_trigger_name;
const enum lttng_trigger_status trigger_status =
- lttng_trigger_get_name(trigger,
- &returned_trigger_name);
+ lttng_trigger_get_name(trigger, &returned_trigger_name);
if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
WARN("Failed to retrieve the added trigger's name.");
goto cleanup;
}
- mi_ret = mi_lttng_writer_write_element_bool(mi_writer,
- mi_lttng_element_command_success, ret ? 0 : 1);
+ mi_ret = mi_lttng_writer_write_element_bool(
+ mi_writer, mi_lttng_element_command_success, ret ? 0 : 1);
if (mi_ret) {
ret = 1;
goto cleanup;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
#include <popt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <stdbool.h>
-#include <lttng/lttng.h>
-
-#include "../command.hpp"
-
-#include <common/mi-lttng.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
static int opt_clear_all;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-clear.1.h>
-;
+ ;
#endif
/* Mi writer */
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"all", 'a', POPT_ARG_VAL, &opt_clear_all, 1, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "all", 'a', POPT_ARG_VAL, &opt_clear_all, 1, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
*/
static int clear_session(struct lttng_session *session)
{
- enum lttng_clear_handle_status status =
- LTTNG_CLEAR_HANDLE_STATUS_OK;
+ enum lttng_clear_handle_status status = LTTNG_CLEAR_HANDLE_STATUS_OK;
struct lttng_clear_handle *handle = NULL;
enum lttng_error_code ret_code;
bool printed_wait_msg = false;
}
do {
- status = lttng_clear_handle_wait_for_completion(handle,
- DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US / USEC_PER_MSEC);
+ status = lttng_clear_handle_wait_for_completion(
+ handle, DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US / USEC_PER_MSEC);
switch (status) {
case LTTNG_CLEAR_HANDLE_STATUS_TIMEOUT:
if (!printed_wait_msg) {
- _MSG("Waiting for clear of session \"%s\"",
- session->name);
+ _MSG("Waiting for clear of session \"%s\"", session->name);
printed_wait_msg = true;
}
_MSG(".");
break;
default:
ERR("Failed to wait for the completion of clear for session \"%s\"",
- session->name);
+ session->name);
ret = -1;
goto error;
}
goto error;
}
- MSG("%sSession \"%s\" cleared", printed_wait_msg ? "\n" : "",
- session->name);
+ MSG("%sSession \"%s\" cleared", printed_wait_msg ? "\n" : "", session->name);
printed_wait_msg = false;
if (lttng_opt_mi) {
int cmd_clear(int argc, const char **argv)
{
int opt;
- int ret = CMD_SUCCESS , i, command_ret = CMD_SUCCESS, success = 1;
+ int ret = CMD_SUCCESS, i, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
const char *arg_session_name = NULL;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_clear);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_clear);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
-#include <ctype.h>
-#include <popt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <common/compat/time.hpp>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-#include <common/mi-lttng.hpp>
-
#include "../command.hpp"
#include "../utils.hpp"
+#include <common/compat/time.hpp>
#include <common/defaults.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/path.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/uri.hpp>
#include <common/utils.hpp>
-#include <common/path.hpp>
+
#include <lttng/lttng.h>
+#include <ctype.h>
+#include <popt.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
static char *opt_output_path;
static char *opt_url;
static char *opt_ctrl_url;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-create.1.h>
-;
+ ;
#endif
enum {
static struct mi_writer *writer;
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"output", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
- {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
- {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
- {"no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0},
- {"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0},
- {"snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0},
- {"live", 0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0},
- {"shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
+ { "output", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0 },
+ { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0 },
+ { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0 },
+ { "no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0 },
+ { "no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0 },
+ { "snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0 },
+ { "live", 0, POPT_ARG_INT | POPT_ARGFLAG_OPTIONAL, 0, OPT_LIVE_TIMER, 0, 0 },
+ { "shm-path", 0, POPT_ARG_STRING, &opt_shm_path, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
return ret;
}
-static
-struct lttng_session_descriptor *create_session_descriptor(const char *session_name)
+static struct lttng_session_descriptor *create_session_descriptor(const char *session_name)
{
ssize_t uri_count;
enum output_type output_type;
ERR("Failed to expand output path.");
goto end;
}
- ret = lttng_strncpy(local_output_path, expanded_output_path,
- sizeof(local_output_path));
+ ret = lttng_strncpy(
+ local_output_path, expanded_output_path, sizeof(local_output_path));
free(expanded_output_path);
if (ret) {
ERR("Output path exceeds the maximal supported length (%zu bytes)",
- sizeof(local_output_path));
+ sizeof(local_output_path));
goto end;
}
} else if (opt_url || opt_ctrl_url) {
ERR("Unrecognized URL format.");
goto end;
}
- ret = lttng_strncpy(local_output_path, uris[0].dst.path,
- sizeof(local_output_path));
+ ret = lttng_strncpy(
+ local_output_path, uris[0].dst.path, sizeof(local_output_path));
if (ret) {
ERR("Output path exceeds the maximal supported length (%zu bytes)",
- sizeof(local_output_path));
+ sizeof(local_output_path));
}
break;
case 2:
case OUTPUT_UNSPECIFIED:
case OUTPUT_LOCAL:
descriptor = lttng_session_descriptor_snapshot_local_create(
- session_name,
- output_type == OUTPUT_LOCAL ?
- local_output_path : NULL);
+ session_name,
+ output_type == OUTPUT_LOCAL ? local_output_path : NULL);
break;
case OUTPUT_NONE:
- descriptor = lttng_session_descriptor_snapshot_create(
- session_name);
+ descriptor = lttng_session_descriptor_snapshot_create(session_name);
break;
case OUTPUT_NETWORK:
descriptor = lttng_session_descriptor_snapshot_network_create(
- session_name, uri_str1, uri_str2);
+ session_name, uri_str1, uri_str2);
break;
default:
abort();
}
} else if (opt_live_timer) {
/* Live session. */
- if (output_type != OUTPUT_UNSPECIFIED &&
- output_type != OUTPUT_NETWORK) {
+ if (output_type != OUTPUT_UNSPECIFIED && output_type != OUTPUT_NETWORK) {
ERR("Unsupported output type specified for live session.");
goto end;
}
descriptor = lttng_session_descriptor_live_network_create(
- session_name, uri_str1, uri_str2,
- opt_live_timer);
+ session_name, uri_str1, uri_str2, opt_live_timer);
} else {
/* Regular session. */
switch (output_type) {
case OUTPUT_UNSPECIFIED:
case OUTPUT_LOCAL:
descriptor = lttng_session_descriptor_local_create(
- session_name,
- output_type == OUTPUT_LOCAL ?
- local_output_path : NULL);
+ session_name,
+ output_type == OUTPUT_LOCAL ? local_output_path : NULL);
break;
case OUTPUT_NONE:
- descriptor = lttng_session_descriptor_create(
- session_name);
+ descriptor = lttng_session_descriptor_create(session_name);
break;
case OUTPUT_NETWORK:
descriptor = lttng_session_descriptor_network_create(
- session_name, uri_str1, uri_str2);
+ session_name, uri_str1, uri_str2);
break;
default:
abort();
* Auto-launch the relay daemon when a live session
* is created using default URLs.
*/
- if (!opt_url && !opt_ctrl_url && !opt_data_url &&
- opt_live_timer && !check_relayd()) {
+ if (!opt_url && !opt_ctrl_url && !opt_data_url && opt_live_timer &&
+ !check_relayd()) {
int ret;
- const char *pathname = opt_relayd_path ? :
- INSTALL_BIN_PATH "/lttng-relayd";
+ const char *pathname = opt_relayd_path ?: INSTALL_BIN_PATH "/lttng-relayd";
ret = spawn_relayd(pathname, 0);
if (ret < 0) {
/* Validate options. */
if (session_name) {
if (strlen(session_name) > NAME_MAX) {
- ERR("Session name too long. Length must be lower or equal to %d",
- NAME_MAX);
+ ERR("Session name too long. Length must be lower or equal to %d", NAME_MAX);
ret = CMD_ERROR;
goto error;
}
* Both are reserved for the default session name. See bug #449 to
* understand why we need to check both here.
*/
- if ((strncmp(session_name, DEFAULT_SESSION_NAME "-",
- strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
- (strncmp(session_name, DEFAULT_SESSION_NAME,
- strlen(DEFAULT_SESSION_NAME)) == 0 &&
- strlen(session_name) == strlen(DEFAULT_SESSION_NAME))) {
+ if ((strncmp(session_name,
+ DEFAULT_SESSION_NAME "-",
+ strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
+ (strncmp(session_name, DEFAULT_SESSION_NAME, strlen(DEFAULT_SESSION_NAME)) ==
+ 0 &&
+ strlen(session_name) == strlen(DEFAULT_SESSION_NAME))) {
ERR("%s is a reserved keyword for default session(s)",
- DEFAULT_SESSION_NAME);
+ DEFAULT_SESSION_NAME);
ret = CMD_ERROR;
goto error;
}
goto error;
}
- descriptor_status = lttng_session_descriptor_get_session_name(
- session_descriptor, &created_session_name);
+ descriptor_status = lttng_session_descriptor_get_session_name(session_descriptor,
+ &created_session_name);
if (descriptor_status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
ERR("Failed to obtain created session name");
ret = CMD_ERROR;
ret = lttng_list_sessions(&sessions);
if (ret < 0) {
- ERR("Failed to fetch properties of created session: %s",
- lttng_strerror(ret));
+ ERR("Failed to fetch properties of created session: %s", lttng_strerror(ret));
ret = CMD_ERROR;
goto error;
}
time_t creation_time_t;
size_t strftime_ret;
- ret_code = lttng_session_get_creation_time(
- created_session,
- &creation_time);
+ ret_code = lttng_session_get_creation_time(created_session, &creation_time);
if (ret_code != LTTNG_OK) {
ERR("%s", lttng_strerror(-ret_code));
ret = CMD_ERROR;
goto error;
}
strftime_ret = strftime(datetime_suffix,
- sizeof(datetime_suffix),
- "-%Y%m%d-%H%M%S", timeinfo);
+ sizeof(datetime_suffix),
+ "-%Y%m%d-%H%M%S",
+ timeinfo);
if (strftime_ret == 0) {
ERR("Failed to format session creation time.");
ret = CMD_ERROR;
}
}
- ret = snprintf(shm_path, sizeof(shm_path),
- "%s/%s%s", opt_shm_path, created_session_name,
- datetime_suffix);
+ ret = snprintf(shm_path,
+ sizeof(shm_path),
+ "%s/%s%s",
+ opt_shm_path,
+ created_session_name,
+ datetime_suffix);
if (ret < 0 || ret >= sizeof(shm_path)) {
ERR("Failed to format the shared memory path.");
ret = CMD_ERROR;
goto error;
}
- ret = lttng_set_session_shm_path(created_session_name,
- shm_path);
+ ret = lttng_set_session_shm_path(created_session_name, shm_path);
if (ret < 0) {
lttng_destroy_session(created_session_name);
ret = CMD_ERROR;
MSG("Traces will be output to %s", created_session->path);
if (opt_live_timer) {
- MSG("Live timer interval set to %u %s", opt_live_timer,
- USEC_UNIT);
+ MSG("Live timer interval set to %u %s", opt_live_timer, USEC_UNIT);
}
} else if (opt_snapshot) {
struct lttng_snapshot_output_list *list;
while ((iter = lttng_snapshot_output_list_get_next(list))) {
const char *url = NULL;
- url = lttng_snapshot_output_get_ctrl_url(
- iter);
- ret = lttng_strncpy(snapshot_url, url,
- sizeof(snapshot_url));
+ url = lttng_snapshot_output_get_ctrl_url(iter);
+ ret = lttng_strncpy(snapshot_url, url, sizeof(snapshot_url));
if (ret) {
snapshot_url[0] = '\0';
ERR("Failed to retrieve snapshot output destination");
lttng_snapshot_output_list_destroy(list);
if (*snapshot_url) {
- MSG("Default snapshot output set to %s",
- snapshot_url);
+ MSG("Default snapshot output set to %s", snapshot_url);
}
MSG("Every channel enabled for this session will be set to mmap output and default to overwrite mode.");
}
/*
* Spawn session daemon in daemon mode.
*/
- execlp(pathname, "lttng-sessiond",
- "--daemonize", NULL);
+ execlp(pathname, "lttng-sessiond", "--daemonize", NULL);
/* execlp only returns if error happened */
if (errno == ENOENT) {
ERR("No session daemon found. Use --sessiond-path.");
} else {
PERROR("execlp");
}
- kill(getppid(), SIGTERM); /* wake parent */
+ kill(getppid(), SIGTERM); /* wake parent */
exit(EXIT_FAILURE);
} else if (pid > 0) {
/*
}
if (WIFSIGNALED(status)) {
- ERR("Session daemon was killed by signal %d",
- WTERMSIG(status));
+ ERR("Session daemon was killed by signal %d", WTERMSIG(status));
ret = -1;
- goto end;
+ goto end;
} else if (WIFEXITED(status)) {
DBG("Session daemon terminated normally (exit status: %d)",
- WEXITSTATUS(status));
+ WEXITSTATUS(status));
if (WEXITSTATUS(status) != 0) {
ERR("Session daemon terminated with an error (exit status: %d)",
- WEXITSTATUS(status));
+ WEXITSTATUS(status));
ret = -1;
- goto end;
+ goto end;
}
break;
}
ret = spawn_sessiond(pathname);
end:
if (ret) {
- ERR("Problem occurred while launching session daemon (%s)",
- pathname);
+ ERR("Problem occurred while launching session daemon (%s)", pathname);
}
return ret;
}
-static
-int validate_url_option_combination(void)
+static int validate_url_option_combination(void)
{
int ret = 0;
int used_count = 0;
/* Set up default values. */
opt_live_timer = (uint32_t) DEFAULT_LTTNG_LIVE_TIMER;
DBG("Session live timer interval set to default value %d",
- opt_live_timer);
+ opt_live_timer);
break;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_create);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_create);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
#include <popt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <stdbool.h>
-#include <lttng/lttng.h>
-
-#include "../command.hpp"
-
-#include <common/mi-lttng.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
static int opt_destroy_all;
static int opt_no_wait;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-destroy.1.h>
-;
+ ;
#endif
/* Mi writer */
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"all", 'a', POPT_ARG_VAL, &opt_destroy_all, 1, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "all", 'a', POPT_ARG_VAL, &opt_destroy_all, 1, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
*/
if (ret) {
if (!printed_destroy_msg) {
- _MSG("Destroying session %s",
- session->name);
+ _MSG("Destroying session %s", session->name);
newline_needed = true;
printed_destroy_msg = true;
fflush(stdout);
do {
status = lttng_destruction_handle_wait_for_completion(
- handle, DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US /
- USEC_PER_MSEC);
+ handle, DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US / USEC_PER_MSEC);
switch (status) {
case LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT:
if (!printed_destroy_msg) {
break;
default:
ERR("%sFailed to wait for the completion of the destruction of session \"%s\"",
- newline_needed ? "\n" : "",
- session->name);
+ newline_needed ? "\n" : "",
+ session->name);
newline_needed = false;
ret = -1;
goto error;
status = lttng_destruction_handle_get_result(handle, &ret_code);
if (status != LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
ERR("%sFailed to get the result of session destruction",
- newline_needed ? "\n" : "");
+ newline_needed ? "\n" : "");
ret = -1;
newline_needed = false;
goto error;
goto error;
}
- status = lttng_destruction_handle_get_rotation_state(
- handle, &rotation_state);
+ status = lttng_destruction_handle_get_rotation_state(handle, &rotation_state);
if (status != LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
ERR("%sFailed to get rotation state from destruction handle",
- newline_needed ? "\n" : "");
+ newline_needed ? "\n" : "");
newline_needed = false;
goto skip_wait_rotation;
}
{
const struct lttng_trace_archive_location *location;
- status = lttng_destruction_handle_get_archive_location(
- handle, &location);
+ status = lttng_destruction_handle_get_archive_location(handle, &location);
if (status == LTTNG_DESTRUCTION_HANDLE_STATUS_OK) {
- ret = print_trace_archive_location(
- location, session->name);
+ ret = print_trace_archive_location(location, session->name);
if (ret) {
ERR("%sFailed to print the location of trace archive",
- newline_needed ? "\n" : "");
+ newline_needed ? "\n" : "");
newline_needed = false;
goto skip_wait_rotation;
}
/* fall-through. */
default:
ERR("%sFailed to get the location of the rotation performed during the session's destruction",
- newline_needed ? "\n" : "");
+ newline_needed ? "\n" : "");
newline_needed = false;
goto skip_wait_rotation;
}
skip_wait_rotation:
- MSG("%sSession %s destroyed", newline_needed ? "\n" : "",
- session->name);
+ MSG("%sSession %s destroyed", newline_needed ? "\n" : "", session->name);
newline_needed = false;
if (stats_str) {
MSG("%s", stats_str);
if (ret < 0) {
ERR("%s during the destruction of session \"%s\"",
- lttng_strerror(ret),
- sessions[i].name);
+ lttng_strerror(ret),
+ sessions[i].name);
/* Continue to next session. */
error_occurred = true;
}
int cmd_destroy(int argc, const char **argv)
{
int opt;
- int ret = CMD_SUCCESS , i, command_ret = CMD_SUCCESS, success = 1;
+ int ret = CMD_SUCCESS, i, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
char *session_name = NULL;
const char *arg_session_name = NULL;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_destroy);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_destroy);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
if (command_ret) {
success = 0;
ERR("%s during the destruction of session \"%s\"",
- lttng_strerror(command_ret),
- sessions[i].name);
+ lttng_strerror(command_ret),
+ sessions[i].name);
}
}
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/domain-internal.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.hpp>
-
-#include "../command.hpp"
-
static int opt_kernel;
static char *opt_session_name;
static int opt_userspace;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-disable-channel.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
-static int mi_partial_channel_print(char *channel_name, unsigned int enabled,
- int success)
+static int mi_partial_channel_print(char *channel_name, unsigned int enabled, int success)
{
int ret;
}
/* Name */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- channel_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, channel_name);
if (ret) {
goto end;
}
/* Enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled,
- enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled);
if (ret) {
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_success, success);
if (ret) {
goto end;
}
ret = CMD_ERROR;
goto error;
}
-
}
/* Strip channel list */
ret = lttng_disable_channel(handle, channel_name);
if (ret < 0) {
- ERR("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
+ ERR("Channel %s: %s (session %s)",
+ channel_name,
+ lttng_strerror(ret),
+ session_name);
warn = 1;
/*
} else {
MSG("%s channel %s disabled for session %s",
- lttng_domain_type_str(dom.type),
- channel_name, session_name);
+ lttng_domain_type_str(dom.type),
+ channel_name,
+ session_name);
enabled = 0;
success = 1;
}
}
}
- ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace, false);
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace, false);
if (ret) {
ret = CMD_ERROR;
goto end;
/* Open command element */
ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_disable_channel);
+ mi_lttng_element_command_disable_channel);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/domain-internal.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-#include <lttng/domain-internal.hpp>
-
-#include "../command.hpp"
-
static int opt_kernel;
static char *opt_channel_name;
static char *opt_session_name;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-disable-event.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0},
- {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
- {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
- {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0},
- {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
- {"syscall", 0, POPT_ARG_NONE, 0, OPT_TYPE_SYSCALL, 0, 0},
- {"probe", 0, POPT_ARG_NONE, 0, OPT_TYPE_PROBE, 0, 0},
- {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TYPE_TRACEPOINT, 0, 0},
- {"function", 0, POPT_ARG_NONE, 0, OPT_TYPE_FUNCTION, 0, 0},
- {"all", 0, POPT_ARG_NONE, 0, OPT_TYPE_ALL, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0 },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0 },
+ { "syscall", 0, POPT_ARG_NONE, 0, OPT_TYPE_SYSCALL, 0, 0 },
+ { "probe", 0, POPT_ARG_NONE, 0, OPT_TYPE_PROBE, 0, 0 },
+ { "tracepoint", 0, POPT_ARG_NONE, 0, OPT_TYPE_TRACEPOINT, 0, 0 },
+ { "function", 0, POPT_ARG_NONE, 0, OPT_TYPE_FUNCTION, 0, 0 },
+ { "all", 0, POPT_ARG_NONE, 0, OPT_TYPE_ALL, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
-static
-const char *print_channel_name(const char *name)
+static const char *print_channel_name(const char *name)
{
- return name ? : DEFAULT_CHANNEL_NAME;
+ return name ?: DEFAULT_CHANNEL_NAME;
}
-static
-const char *print_raw_channel_name(const char *name)
+static const char *print_raw_channel_name(const char *name)
{
- return name ? : "<default>";
+ return name ?: "<default>";
}
-static
-const char *print_event_type(const enum lttng_event_type ev_type)
+static const char *print_event_type(const enum lttng_event_type ev_type)
{
switch (ev_type) {
case LTTNG_EVENT_ALL:
}
/* Print the name of event */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, event_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, event_name);
if (ret) {
goto end;
}
/* Print enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- config_element_enabled, enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled);
if (ret) {
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_command_success, success);
if (ret) {
goto end;
}
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, print_channel_name(channel_name));
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, print_channel_name(channel_name));
if (ret) {
ret = CMD_ERROR;
goto end;
enabled = 0;
success = 1;
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),
- print_channel_name(channel_name));
+ lttng_domain_type_str(dom.type),
+ print_event_type((lttng_event_type) opt_event_type),
+ print_channel_name(channel_name));
}
if (lttng_opt_mi) {
command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL);
if (command_ret < 0) {
ERR("%s of type %s : %s (channel %s, session %s)",
- event_name,
- print_event_type((lttng_event_type) opt_event_type),
- lttng_strerror(command_ret),
- command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
- ? print_raw_channel_name(channel_name)
- : print_channel_name(channel_name),
- session_name);
+ event_name,
+ print_event_type((lttng_event_type) opt_event_type),
+ lttng_strerror(command_ret),
+ command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
+ print_raw_channel_name(channel_name) :
+ print_channel_name(channel_name),
+ session_name);
warn = 1;
success = 0;
/*
enabled = 1;
} else {
MSG("%s %s of type %s disabled in channel %s for session %s",
- lttng_domain_type_str(dom.type),
- event_name,
- print_event_type((lttng_event_type) opt_event_type),
- print_channel_name(channel_name),
- session_name);
+ lttng_domain_type_str(dom.type),
+ event_name,
+ print_event_type((lttng_event_type) opt_event_type),
+ print_channel_name(channel_name),
+ session_name);
success = 1;
enabled = 0;
}
}
ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace + opt_jul + opt_log4j +
- opt_python,
- true);
+ opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python, true);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Ust and agent only support ALL event type */
- if ((opt_userspace || opt_jul || opt_log4j || opt_python)
- && opt_event_type != LTTNG_EVENT_ALL) {
+ if ((opt_userspace || opt_jul || opt_log4j || opt_python) &&
+ opt_event_type != LTTNG_EVENT_ALL) {
ERR("Disabling userspace and agent (-j | -l | -p) event(s) based on instrumentation type is not supported.\n");
ret = CMD_ERROR;
goto end;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_disable_event);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_disable_event);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
goto end;
}
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <lttng/lttng.h>
+
+#include <ctype.h>
+#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <ctype.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-#include <lttng/lttng.h>
static char *opt_session_name;
static struct mi_writer *writer;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-disable-rotation.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"timer", 0, POPT_ARG_NONE, 0, OPT_TIMER, 0, 0},
- {"size", 0, POPT_ARG_NONE, 0, OPT_SIZE, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "timer", 0, POPT_ARG_NONE, 0, OPT_TIMER, 0, 0 },
+ { "size", 0, POPT_ARG_NONE, 0, OPT_SIZE, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static const char *schedule_type_str[] = {
"size-based",
};
-static const struct lttng_rotation_schedule *get_schedule(
- const char *session_name,
- const struct lttng_rotation_schedules *schedules,
- enum lttng_rotation_schedule_type schedule_type)
+static const struct lttng_rotation_schedule *
+get_schedule(const char *session_name,
+ const struct lttng_rotation_schedules *schedules,
+ enum lttng_rotation_schedule_type schedule_type)
{
unsigned int count, i;
enum lttng_rotation_status status;
status = lttng_rotation_schedules_get_count(schedules, &count);
if (status != LTTNG_ROTATION_STATUS_OK) {
ERR("Unable to determine the number of rotation schedules of session %s",
- session_name);
+ session_name);
goto end;
}
schedule = lttng_rotation_schedules_get_at_index(schedules, i);
if (!schedule) {
- ERR("Unable to retrieve rotation schedule at index %u",
- i);
+ ERR("Unable to retrieve rotation schedule at index %u", i);
goto end;
}
- if (lttng_rotation_schedule_get_type(schedule) ==
- schedule_type) {
+ if (lttng_rotation_schedule_get_type(schedule) == schedule_type) {
ret = schedule;
break;
}
if (!ret) {
ERR("No %s rotation schedule active on session %s",
- schedule_type_str[schedule_type], session_name);
+ schedule_type_str[schedule_type],
+ session_name);
}
end:
return ret;
}
-static struct lttng_rotation_schedule *create_empty_schedule(
- enum lttng_rotation_schedule_type type)
+static struct lttng_rotation_schedule *create_empty_schedule(enum lttng_rotation_schedule_type type)
{
struct lttng_rotation_schedule *schedule = NULL;
}
static enum cmd_error_code remove_schedule(const char *session_name,
- enum lttng_rotation_schedule_type schedule_type)
+ enum lttng_rotation_schedule_type schedule_type)
{
enum cmd_error_code cmd_ret;
int ret;
ret = lttng_session_list_rotation_schedules(session_name, &schedules);
if (ret != LTTNG_OK) {
- ERR("Failed to list rotation schedules of session %s",
- session_name);
+ ERR("Failed to list rotation schedules of session %s", session_name);
goto error;
}
status = lttng_session_remove_rotation_schedule(session_name, schedule);
switch (status) {
case LTTNG_ROTATION_STATUS_OK:
- MSG("Disabled %s rotation on session %s",
- schedule_type_name, session_name);
+ MSG("Disabled %s rotation on session %s", schedule_type_name, session_name);
cmd_ret = CMD_SUCCESS;
break;
case LTTNG_ROTATION_STATUS_SCHEDULE_NOT_SET:
- ERR("No %s rotation schedule set on session %s",
- schedule_type_name,
- session_name);
+ ERR("No %s rotation schedule set on session %s", schedule_type_name, session_name);
cmd_ret = CMD_ERROR;
break;
case LTTNG_ROTATION_STATUS_ERROR:
case LTTNG_ROTATION_STATUS_INVALID:
default:
ERR("Failed to disable %s rotation schedule on session %s",
- schedule_type_name, session_name);
+ schedule_type_name,
+ session_name);
cmd_ret = CMD_ERROR;
break;
}
skip_removal:
if (lttng_opt_mi) {
- ret = mi_lttng_rotation_schedule_result(writer,
- schedule ? schedule : empty_schedule,
- cmd_ret == CMD_SUCCESS);
+ ret = mi_lttng_rotation_schedule_result(
+ writer, schedule ? schedule : empty_schedule, cmd_ret == CMD_SUCCESS);
if (ret < 0) {
goto error;
}
/* Open command element */
ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_disable_rotation);
+ mi_lttng_element_command_disable_rotation);
if (ret) {
goto error;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
goto error;
}
if (lttng_opt_mi) {
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_schedule_results);
+ mi_lttng_element_rotation_schedule_results);
if (ret) {
goto error;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_session_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto error;
}
* Continue processing even on error as multiple schedules can
* be specified at once.
*/
- cmd_ret = remove_schedule(session_name,
- LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC);
+ cmd_ret = remove_schedule(session_name, LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC);
}
if (size_rotation) {
enum cmd_error_code tmp_ret;
/* Don't overwrite cmd_ret if it already indicates an error. */
- tmp_ret = remove_schedule(session_name,
- LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD);
+ tmp_ret =
+ remove_schedule(session_name, LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD);
cmd_ret = cmd_ret ? cmd_ret : tmp_ret;
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success,
- cmd_ret == CMD_SUCCESS);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, cmd_ret == CMD_SUCCESS);
if (ret) {
goto error;
}
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+#include "../utils.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/domain-internal.hpp>
+
+#include <ctype.h>
+#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <ctype.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/utils.hpp>
-#include <common/mi-lttng.hpp>
-
-#include <lttng/domain-internal.hpp>
-
-#include "../command.hpp"
-#include "../utils.hpp"
-
static struct lttng_channel chan_opts;
static int opt_kernel;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-enable-channel.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"discard", 0, POPT_ARG_NONE, 0, OPT_DISCARD, 0, 0},
- {"overwrite", 0, POPT_ARG_NONE, 0, OPT_OVERWRITE, 0, 0},
- {"subbuf-size", 0, POPT_ARG_STRING, 0, OPT_SUBBUF_SIZE, 0, 0},
- {"num-subbuf", 0, POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0},
- {"switch-timer", 0, POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0},
- {"monitor-timer", 0, POPT_ARG_INT, 0, OPT_MONITOR_TIMER, 0, 0},
- {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0},
- {"buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0},
- {"buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0},
- {"buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0},
- {"tracefile-size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0},
- {"tracefile-count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0},
- {"blocking-timeout", 0, POPT_ARG_INT, 0, OPT_BLOCKING_TIMEOUT, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
+ { "discard", 0, POPT_ARG_NONE, 0, OPT_DISCARD, 0, 0 },
+ { "overwrite", 0, POPT_ARG_NONE, 0, OPT_OVERWRITE, 0, 0 },
+ { "subbuf-size", 0, POPT_ARG_STRING, 0, OPT_SUBBUF_SIZE, 0, 0 },
+ { "num-subbuf", 0, POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0 },
+ { "switch-timer", 0, POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0 },
+ { "monitor-timer", 0, POPT_ARG_INT, 0, OPT_MONITOR_TIMER, 0, 0 },
+ { "read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0 },
+ { "buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0 },
+ { "buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0 },
+ { "buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0 },
+ { "tracefile-size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0 },
+ { "tracefile-count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0 },
+ { "blocking-timeout", 0, POPT_ARG_INT, 0, OPT_BLOCKING_TIMEOUT, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
if (chan_opts.attr.tracefile_size == 0 && chan_opts.attr.tracefile_count) {
ERR("Missing option --tracefile-size. "
- "A file count without a size won't do anything.");
+ "A file count without a size won't do anything.");
ret = CMD_ERROR;
goto error;
}
if ((chan_opts.attr.tracefile_size > 0) &&
- (chan_opts.attr.tracefile_size < chan_opts.attr.subbuf_size)) {
+ (chan_opts.attr.tracefile_size < chan_opts.attr.subbuf_size)) {
WARN("Tracefile size rounded up from (%" PRIu64 ") to subbuffer size (%" PRIu64 ")",
- chan_opts.attr.tracefile_size, chan_opts.attr.subbuf_size);
+ chan_opts.attr.tracefile_size,
+ chan_opts.attr.subbuf_size);
chan_opts.attr.tracefile_size = chan_opts.attr.subbuf_size;
}
chan_opts.attr.output = LTTNG_EVENT_SPLICE;
} else {
ERR("Unknown output type %s. Possible values are: %s, %s\n",
- opt_output, output_mmap, output_splice);
+ opt_output,
+ output_mmap,
+ output_splice);
ret = CMD_ERROR;
goto error;
}
/* Validate channel name's length */
if (strlen(channel_name) >= sizeof(chan_opts.name)) {
ERR("Channel name is too long (max. %zu characters)",
- sizeof(chan_opts.name) - 1);
+ sizeof(chan_opts.name) - 1);
error = 1;
goto skip_enable;
}
channel->attr.extended.ptr = extended_ptr;
if (opt_monitor_timer.set) {
ret = lttng_channel_set_monitor_timer_interval(channel,
- opt_monitor_timer.interval);
+ opt_monitor_timer.interval);
if (ret) {
ERR("Failed to set the channel's monitor timer interval");
error = 1;
}
if (opt_blocking_timeout.set) {
ret = lttng_channel_set_blocking_timeout(channel,
- opt_blocking_timeout.value);
+ opt_blocking_timeout.value);
if (ret) {
ERR("Failed to set the channel's blocking timeout");
error = 1;
case LTTNG_ERR_KERN_CHAN_EXIST:
case LTTNG_ERR_UST_CHAN_EXIST:
case LTTNG_ERR_CHAN_EXIST:
- WARN("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
+ WARN("Channel %s: %s (session %s)",
+ channel_name,
+ lttng_strerror(ret),
+ session_name);
warn = 1;
break;
case LTTNG_ERR_INVALID_CHANNEL_NAME:
ERR("Invalid channel name: \"%s\". "
"Channel names may not start with '.', and "
- "may not contain '/'.", channel_name);
+ "may not contain '/'.",
+ channel_name);
error = 1;
break;
default:
- ERR("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
+ ERR("Channel %s: %s (session %s)",
+ channel_name,
+ lttng_strerror(ret),
+ session_name);
error = 1;
break;
}
} else {
MSG("%s channel %s enabled for session %s",
- lttng_domain_type_str(dom.type),
- channel_name, session_name);
+ lttng_domain_type_str(dom.type),
+ channel_name,
+ session_name);
success = 1;
}
-skip_enable:
+ skip_enable:
if (lttng_opt_mi) {
/* Mi print the channel element and leave it open */
ret = mi_lttng_channel(writer, channel, 1);
}
/* Individual Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto error;
/* Parse the size */
opt_arg = poptGetOptArg(pc);
- if (utils_parse_size_suffix(opt_arg, &chan_opts.attr.subbuf_size) < 0 || !chan_opts.attr.subbuf_size) {
+ if (utils_parse_size_suffix(opt_arg, &chan_opts.attr.subbuf_size) < 0 ||
+ !chan_opts.attr.subbuf_size) {
ERR("Wrong value in --subbuf-size parameter: %s", opt_arg);
ret = CMD_ERROR;
goto end;
rounded_size = 1ULL << order;
if (rounded_size < chan_opts.attr.subbuf_size) {
ERR("The subbuf size (%" PRIu64 ") is rounded and overflows!",
- chan_opts.attr.subbuf_size);
+ chan_opts.attr.subbuf_size);
ret = CMD_ERROR;
goto end;
}
if (rounded_size != chan_opts.attr.subbuf_size) {
- WARN("The subbuf size (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
- chan_opts.attr.subbuf_size, rounded_size);
+ WARN("The subbuf size (%" PRIu64
+ ") is rounded to the next power of 2 (%" PRIu64 ")",
+ chan_opts.attr.subbuf_size,
+ rounded_size);
chan_opts.attr.subbuf_size = rounded_size;
}
/* Should now be power of 2 */
- LTTNG_ASSERT(!((chan_opts.attr.subbuf_size - 1) & chan_opts.attr.subbuf_size));
+ LTTNG_ASSERT(
+ !((chan_opts.attr.subbuf_size - 1) & chan_opts.attr.subbuf_size));
DBG("Channel subbuf size set to %" PRIu64, chan_opts.attr.subbuf_size);
break;
LTTNG_ASSERT(order >= 0);
rounded_size = 1ULL << order;
if (rounded_size < chan_opts.attr.num_subbuf) {
- ERR("The number of subbuffers (%" PRIu64 ") is rounded and overflows!",
- chan_opts.attr.num_subbuf);
+ ERR("The number of subbuffers (%" PRIu64
+ ") is rounded and overflows!",
+ chan_opts.attr.num_subbuf);
ret = CMD_ERROR;
goto end;
}
if (rounded_size != chan_opts.attr.num_subbuf) {
- WARN("The number of subbuffers (%" PRIu64 ") is rounded to the next power of 2 (%" PRIu64 ")",
- chan_opts.attr.num_subbuf, rounded_size);
+ WARN("The number of subbuffers (%" PRIu64
+ ") is rounded to the next power of 2 (%" PRIu64 ")",
+ chan_opts.attr.num_subbuf,
+ rounded_size);
chan_opts.attr.num_subbuf = rounded_size;
}
/* Should now be power of 2 */
- LTTNG_ASSERT(!((chan_opts.attr.num_subbuf - 1) & chan_opts.attr.num_subbuf));
+ LTTNG_ASSERT(
+ !((chan_opts.attr.num_subbuf - 1) & chan_opts.attr.num_subbuf));
DBG("Channel subbuf num set to %" PRIu64, chan_opts.attr.num_subbuf);
break;
}
chan_opts.attr.switch_timer_interval = (uint32_t) v;
DBG("Channel switch timer interval set to %d %s",
- chan_opts.attr.switch_timer_interval,
- USEC_UNIT);
+ chan_opts.attr.switch_timer_interval,
+ USEC_UNIT);
break;
}
case OPT_READ_TIMER:
}
chan_opts.attr.read_timer_interval = (uint32_t) v;
DBG("Channel read timer interval set to %d %s",
- chan_opts.attr.read_timer_interval,
- USEC_UNIT);
+ chan_opts.attr.read_timer_interval,
+ USEC_UNIT);
break;
}
case OPT_MONITOR_TIMER:
opt_monitor_timer.interval = (uint64_t) v;
opt_monitor_timer.set = true;
DBG("Channel monitor timer interval set to %" PRIu64 " %s",
- opt_monitor_timer.interval,
- USEC_UNIT);
+ opt_monitor_timer.interval,
+ USEC_UNIT);
break;
}
case OPT_BLOCKING_TIMEOUT:
*/
v_msec = v / 1000;
if (v_msec != (int32_t) v_msec) {
- ERR("32-bit milliseconds overflow in --blocking-timeout parameter: %s", opt_arg);
+ ERR("32-bit milliseconds overflow in --blocking-timeout parameter: %s",
+ opt_arg);
ret = CMD_ERROR;
goto end;
}
opt_blocking_timeout.value = (int64_t) v;
opt_blocking_timeout.set = true;
DBG("Channel blocking timeout set to %" PRId64 " %s%s",
- opt_blocking_timeout.value,
- USEC_UNIT,
- opt_blocking_timeout.value == 0 ?
- " (non-blocking)" : "");
+ opt_blocking_timeout.value,
+ USEC_UNIT,
+ opt_blocking_timeout.value == 0 ? " (non-blocking)" : "");
break;
}
case OPT_USERSPACE:
goto end;
}
DBG("Maximum tracefile size set to %" PRIu64,
- chan_opts.attr.tracefile_size);
+ chan_opts.attr.tracefile_size);
break;
case OPT_TRACEFILE_COUNT:
{
}
chan_opts.attr.tracefile_count = (uint32_t) v;
DBG("Maximum tracefile count set to %" PRIu64,
- chan_opts.attr.tracefile_count);
+ chan_opts.attr.tracefile_count);
break;
}
case OPT_LIST_OPTIONS:
}
}
- ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace, false);
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace, false);
if (ret) {
ret = CMD_ERROR;
goto end;
}
if (chan_opts.attr.overwrite == 1 && opt_blocking_timeout.set &&
- opt_blocking_timeout.value != 0) {
+ opt_blocking_timeout.value != 0) {
ERR("You cannot specify --overwrite and --blocking-timeout=N, "
- "where N is different than 0");
+ "where N is different than 0");
ret = CMD_ERROR;
goto end;
}
/* Open command element */
ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_enable_channels);
+ mi_lttng_element_command_enable_channels);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
goto end;
}
*/
#define _LGPL_SOURCE
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/string-utils/string-utils.hpp>
+#include <common/utils.hpp>
+
+#include <ctype.h>
+#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <ctype.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/compat/string.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/string-utils/string-utils.hpp>
-#include <common/utils.hpp>
/* Mi dependancy */
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
+
#include <common/mi-lttng.hpp>
#include <lttng/domain-internal.hpp>
#include <lttng/event-internal.hpp>
-#include "../command.hpp"
-#include "../loglevel.hpp"
-#include "../uprobe.hpp"
-
#if (LTTNG_SYMBOL_NAME_LEN == 256)
-#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
+#define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
#endif
static int opt_event_type;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-enable-event.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0},
- {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
- {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0},
- {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
- {"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
- {"probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0},
- {"userspace-probe",0, POPT_ARG_STRING, &opt_userspace_probe, OPT_USERSPACE_PROBE, 0, 0},
- {"function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0},
- {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0},
- {"loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0},
- {"loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"filter", 'f', POPT_ARG_STRING, &opt_filter, OPT_FILTER, 0, 0},
- {"exclude", 'x', POPT_ARG_STRING, &opt_exclude, OPT_EXCLUDE, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "all", 'a', POPT_ARG_VAL, &opt_enable_all, 1, 0, 0 },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
+ { "tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0 },
+ { "probe", 0, POPT_ARG_STRING, &opt_probe, OPT_PROBE, 0, 0 },
+ { "userspace-probe", 0, POPT_ARG_STRING, &opt_userspace_probe, OPT_USERSPACE_PROBE, 0, 0 },
+ { "function", 0, POPT_ARG_STRING, &opt_function, OPT_FUNCTION, 0, 0 },
+ { "syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0 },
+ { "loglevel", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL, 0, 0 },
+ { "loglevel-only", 0, POPT_ARG_STRING, 0, OPT_LOGLEVEL_ONLY, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "filter", 'f', POPT_ARG_STRING, &opt_filter, OPT_FILTER, 0, 0 },
+ { "exclude", 'x', POPT_ARG_STRING, &opt_exclude, OPT_EXCLUDE, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
int ret = CMD_SUCCESS;
int match;
char s_hex[19];
-#define S_HEX_LEN_SCANF_IS_A_BROKEN_API "18" /* 18 is (19 - 1) (\0 is extra) */
+#define S_HEX_LEN_SCANF_IS_A_BROKEN_API "18" /* 18 is (19 - 1) (\0 is extra) */
char name[LTTNG_SYMBOL_NAME_LEN];
if (opt == NULL) {
}
/* Check for symbol+offset */
- match = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
- "[^'+']+%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s", name, s_hex);
+ match = sscanf(opt,
+ "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API
+ "[^'+']+%" S_HEX_LEN_SCANF_IS_A_BROKEN_API "s",
+ name,
+ s_hex);
if (match == 2) {
strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
/* Check for symbol */
if (isalpha(name[0]) || name[0] == '_') {
- match = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "s",
- name);
+ match = sscanf(opt, "%" LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "s", name);
if (match == 1) {
strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
return ret;
}
-static
-const char *print_channel_name(const char *name)
+static const char *print_channel_name(const char *name)
{
- return name ? : DEFAULT_CHANNEL_NAME;
+ return name ?: DEFAULT_CHANNEL_NAME;
}
-static
-const char *print_raw_channel_name(const char *name)
+static const char *print_raw_channel_name(const char *name)
{
- return name ? : "<default>";
+ return name ?: "<default>";
}
/*
* Mi print exlcusion list
*/
-static
-int mi_print_exclusion(const struct lttng_dynamic_pointer_array *exclusions)
+static int mi_print_exclusion(const struct lttng_dynamic_pointer_array *exclusions)
{
int ret;
size_t i;
}
for (i = 0; i < count; i++) {
- const char *exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(
- exclusions, i);
+ const char *exclusion =
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions, i);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_exclusion, exclusion);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_exclusion, exclusion);
if (ret) {
goto end;
}
/*
* Return allocated string for pretty-printing exclusion names.
*/
-static
-char *print_exclusions(const struct lttng_dynamic_pointer_array *exclusions)
+static char *print_exclusions(const struct lttng_dynamic_pointer_array *exclusions)
{
int length = 0;
size_t i;
/* Calculate total required length. */
for (i = 0; i < count; i++) {
- const char *exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(
- exclusions, i);
+ const char *exclusion =
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions, i);
length += strlen(exclusion) + 4;
}
strncpy(ret, preamble, length);
for (i = 0; i < count; i++) {
- const char *exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(
- exclusions, i);
+ const char *exclusion =
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions, i);
strcat(ret, "\"");
strcat(ret, exclusion);
return ret;
}
-static
-int check_exclusion_subsets(const char *event_name, const char *exclusion)
+static int check_exclusion_subsets(const char *event_name, const char *exclusion)
{
bool warn = false;
int ret = 0;
if (*x == '*') {
/* Event is a subset of the excluder */
ERR("Event %s: %s excludes all events from %s",
- event_name, exclusion, event_name);
+ event_name,
+ exclusion,
+ event_name);
goto error;
}
goto end;
}
-cmp_chars:
+ cmp_chars:
if (*x != *e) {
warn = true;
break;
end:
if (warn) {
WARN("Event %s: %s does not exclude any events from %s",
- event_name, exclusion, event_name);
+ event_name,
+ exclusion,
+ event_name);
}
return ret;
}
int validate_exclusion_list(const char *event_name,
- const struct lttng_dynamic_pointer_array *exclusions)
+ const struct lttng_dynamic_pointer_array *exclusions)
{
int ret;
/* Event name must be a valid globbing pattern to allow exclusions. */
if (!strutils_is_star_glob_pattern(event_name)) {
- ERR("Event %s: Exclusions can only be used with a globbing pattern",
- event_name);
+ ERR("Event %s: Exclusions can only be used with a globbing pattern", event_name);
goto error;
}
for (i = 0; i < num_exclusions; i++) {
const char *exclusion =
- (const char *) lttng_dynamic_pointer_array_get_pointer(
- exclusions, i);
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions,
+ i);
if (!strutils_is_star_glob_pattern(exclusion) ||
- strutils_is_star_at_the_end_only_glob_pattern(exclusion)) {
+ strutils_is_star_at_the_end_only_glob_pattern(exclusion)) {
ret = check_exclusion_subsets(event_name, exclusion);
if (ret) {
goto error;
}
static int create_exclusion_list_and_validate(const char *event_name,
- const char *exclusions_arg,
- struct lttng_dynamic_pointer_array *exclusions)
+ const char *exclusions_arg,
+ struct lttng_dynamic_pointer_array *exclusions)
{
int ret = 0;
goto error;
}
- if (validate_exclusion_list(event_name, exclusions) !=
- 0) {
+ if (validate_exclusion_list(event_name, exclusions) != 0) {
goto error;
}
}
static void warn_on_truncated_exclusion_names(const struct lttng_dynamic_pointer_array *exclusions,
- int *warn)
+ int *warn)
{
size_t i;
const size_t num_exclusions = lttng_dynamic_pointer_array_get_count(exclusions);
for (i = 0; i < num_exclusions; i++) {
- const char * const exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions, i);
+ const char *const exclusion =
+ (const char *) lttng_dynamic_pointer_array_get_pointer(exclusions, i);
if (strlen(exclusion) >= LTTNG_SYMBOL_NAME_LEN) {
- WARN("Event exclusion \"%s\" will be truncated",
- exclusion);
+ WARN("Event exclusion \"%s\" will be truncated", exclusion);
*warn = 1;
}
}
case LTTNG_DOMAIN_LOG4J:
case LTTNG_DOMAIN_PYTHON:
ERR("Event name exclusions are not yet implemented for %s events",
- lttng_domain_type_str(dom.type));
+ lttng_domain_type_str(dom.type));
ret = CMD_ERROR;
goto error;
case LTTNG_DOMAIN_UST:
case LTTNG_EVENT_USERSPACE_PROBE:
case LTTNG_EVENT_FUNCTION:
ERR("Filter expressions are not supported for %s events",
- get_event_type_str((lttng_event_type) opt_event_type));
+ get_event_type_str((lttng_event_type) opt_event_type));
ret = CMD_ERROR;
goto error;
default:
if (opt_userspace) {
enum lttng_loglevel loglevel;
- name_search_ret = loglevel_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret =
+ loglevel_name_to_value(opt_loglevel, &loglevel);
ev->loglevel = (int) loglevel;
} else if (opt_jul) {
enum lttng_loglevel_jul loglevel;
- name_search_ret = loglevel_jul_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret =
+ loglevel_jul_name_to_value(opt_loglevel, &loglevel);
ev->loglevel = (int) loglevel;
} else if (opt_log4j) {
enum lttng_loglevel_log4j loglevel;
- name_search_ret = loglevel_log4j_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret = loglevel_log4j_name_to_value(opt_loglevel,
+ &loglevel);
ev->loglevel = (int) loglevel;
} else {
/* python domain. */
enum lttng_loglevel_python loglevel;
- name_search_ret = loglevel_python_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret = loglevel_python_name_to_value(
+ opt_loglevel, &loglevel);
ev->loglevel = (int) loglevel;
}
}
if (opt_exclude) {
- ret = create_exclusion_list_and_validate("*",
- opt_exclude, &exclusions);
+ ret = create_exclusion_list_and_validate("*", opt_exclude, &exclusions);
if (ret) {
ret = CMD_ERROR;
goto error;
}
ev->exclusion = 1;
- warn_on_truncated_exclusion_names(&exclusions,
- &warn);
+ warn_on_truncated_exclusion_names(&exclusions, &warn);
}
if (!opt_filter) {
- ret = lttng_enable_event_with_exclusions(handle,
- ev, channel_name,
- NULL,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
+ ret = lttng_enable_event_with_exclusions(
+ handle,
+ ev,
+ channel_name,
+ NULL,
+ lttng_dynamic_pointer_array_get_count(&exclusions),
+ (char **) exclusions.array.buffer.data);
if (ret < 0) {
switch (-ret) {
case LTTNG_ERR_KERN_EVENT_EXIST:
WARN("Kernel events already enabled (channel %s, session %s)",
- print_channel_name(channel_name), session_name);
+ print_channel_name(channel_name),
+ session_name);
warn = 1;
break;
case LTTNG_ERR_TRACE_ALREADY_STARTED:
{
- const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
+ const char *msg =
+ "The command tried to enable an event in a new domain for a session that has already been started once.";
ERR("Events: %s (channel %s, session %s)",
- msg,
- print_channel_name(channel_name),
- session_name);
+ msg,
+ print_channel_name(channel_name),
+ session_name);
error = 1;
break;
}
default:
ERR("Events: %s (channel %s, session %s)",
- lttng_strerror(ret),
- ret == -LTTNG_ERR_NEED_CHANNEL_NAME
- ? print_raw_channel_name(channel_name)
- : print_channel_name(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);
error = 1;
break;
}
goto end;
}
MSG("All %s tracepoints%s are enabled in channel %s for loglevel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name),
- opt_loglevel);
+ lttng_domain_type_str(dom.type),
+ exclusion_string,
+ print_channel_name(channel_name),
+ opt_loglevel);
free(exclusion_string);
} else {
char *exclusion_string = print_exclusions(&exclusions);
goto end;
}
MSG("All %s tracepoints%s are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name));
+ lttng_domain_type_str(dom.type),
+ exclusion_string,
+ print_channel_name(channel_name));
free(exclusion_string);
}
break;
case LTTNG_EVENT_SYSCALL:
if (opt_kernel) {
MSG("All %s system calls are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- print_channel_name(channel_name));
+ lttng_domain_type_str(dom.type),
+ print_channel_name(channel_name));
}
break;
case LTTNG_EVENT_ALL:
goto end;
}
MSG("All %s events%s are enabled in channel %s for loglevel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name),
- opt_loglevel);
+ lttng_domain_type_str(dom.type),
+ exclusion_string,
+ print_channel_name(channel_name),
+ opt_loglevel);
free(exclusion_string);
} else {
char *exclusion_string = print_exclusions(&exclusions);
goto end;
}
MSG("All %s events%s are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name));
+ lttng_domain_type_str(dom.type),
+ exclusion_string,
+ print_channel_name(channel_name));
free(exclusion_string);
}
break;
}
if (opt_filter) {
- command_ret = lttng_enable_event_with_exclusions(handle, ev, channel_name,
- opt_filter,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
+ command_ret = lttng_enable_event_with_exclusions(
+ handle,
+ ev,
+ channel_name,
+ opt_filter,
+ lttng_dynamic_pointer_array_get_count(&exclusions),
+ (char **) exclusions.array.buffer.data);
if (command_ret < 0) {
switch (-command_ret) {
case LTTNG_ERR_FILTER_EXIST:
WARN("Filter on all events is already enabled"
- " (channel %s, session %s)",
- print_channel_name(channel_name), session_name);
+ " (channel %s, session %s)",
+ print_channel_name(channel_name),
+ session_name);
warn = 1;
break;
case LTTNG_ERR_TRACE_ALREADY_STARTED:
{
- const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
+ const char *msg =
+ "The command tried to enable an event in a new domain for a session that has already been started once.";
ERR("All events: %s (channel %s, session %s, filter \'%s\')",
- msg,
- print_channel_name(channel_name),
- session_name, opt_filter);
+ msg,
+ print_channel_name(channel_name),
+ session_name,
+ opt_filter);
error = 1;
break;
}
default:
ERR("All events: %s (channel %s, session %s, filter \'%s\')",
- lttng_strerror(command_ret),
- command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
- ? print_raw_channel_name(channel_name)
- : print_channel_name(channel_name),
- session_name, opt_filter);
+ lttng_strerror(command_ret),
+ command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
+ print_raw_channel_name(channel_name) :
+ print_channel_name(channel_name),
+ session_name,
+ opt_filter);
error = 1;
break;
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto error;
/* Kernel tracer action */
if (opt_kernel) {
DBG("Enabling kernel event %s for channel %s",
- event_name,
- print_channel_name(channel_name));
+ event_name,
+ print_channel_name(channel_name));
switch (opt_event_type) {
- case LTTNG_EVENT_ALL: /* Enable tracepoints and syscalls */
+ case LTTNG_EVENT_ALL: /* Enable tracepoints and syscalls */
/* If event name differs from *, select tracepoint. */
if (strcmp(ev->name, "*")) {
ev->type = LTTNG_EVENT_TRACEPOINT;
/* kernel loglevels not implemented */
ev->loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- } else if (opt_userspace) { /* User-space tracer action */
- DBG("Enabling UST event %s for channel %s, loglevel %s", event_name,
- print_channel_name(channel_name), opt_loglevel ? : "<all>");
+ } else if (opt_userspace) { /* User-space tracer action */
+ DBG("Enabling UST event %s for channel %s, loglevel %s",
+ event_name,
+ print_channel_name(channel_name),
+ opt_loglevel ?: "<all>");
switch (opt_event_type) {
- case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
+ case LTTNG_EVENT_ALL: /* Default behavior is tracepoint */
/* Fall-through */
case LTTNG_EVENT_TRACEPOINT:
/* Copy name and type of the event */
if (opt_exclude) {
ev->exclusion = 1;
- if (opt_event_type != LTTNG_EVENT_ALL && opt_event_type != LTTNG_EVENT_TRACEPOINT) {
+ if (opt_event_type != LTTNG_EVENT_ALL &&
+ opt_event_type != LTTNG_EVENT_TRACEPOINT) {
ERR("Exclusion option can only be used with tracepoint events");
ret = CMD_ERROR;
goto error;
/* Free previously allocated items. */
lttng_dynamic_pointer_array_reset(&exclusions);
ret = create_exclusion_list_and_validate(
- event_name, opt_exclude,
- &exclusions);
+ event_name, opt_exclude, &exclusions);
if (ret) {
ret = CMD_ERROR;
goto error;
}
- warn_on_truncated_exclusion_names(
- &exclusions, &warn);
+ warn_on_truncated_exclusion_names(&exclusions, &warn);
}
ev->loglevel_type = (lttng_loglevel_type) opt_loglevel_type;
if (opt_loglevel) {
enum lttng_loglevel loglevel;
- const int name_search_ret = loglevel_name_to_value(opt_loglevel, &loglevel);
+ const int name_search_ret =
+ loglevel_name_to_value(opt_loglevel, &loglevel);
if (name_search_ret == -1) {
ERR("Unknown loglevel %s", opt_loglevel);
}
} else if (opt_jul || opt_log4j || opt_python) {
if (opt_event_type != LTTNG_EVENT_ALL &&
- opt_event_type != LTTNG_EVENT_TRACEPOINT) {
+ opt_event_type != LTTNG_EVENT_TRACEPOINT) {
ERR("Event type not supported for domain.");
ret = CMD_UNSUPPORTED;
goto error;
if (opt_jul) {
enum lttng_loglevel_jul loglevel;
- name_search_ret = loglevel_jul_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret =
+ loglevel_jul_name_to_value(opt_loglevel, &loglevel);
ev->loglevel = (int) loglevel;
} else if (opt_log4j) {
enum lttng_loglevel_log4j loglevel;
- name_search_ret = loglevel_log4j_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret = loglevel_log4j_name_to_value(opt_loglevel,
+ &loglevel);
ev->loglevel = (int) loglevel;
} else {
/* python domain. */
enum lttng_loglevel_python loglevel;
- name_search_ret = loglevel_python_name_to_value(opt_loglevel, &loglevel);
+ name_search_ret = loglevel_python_name_to_value(
+ opt_loglevel, &loglevel);
ev->loglevel = (int) loglevel;
}
if (!opt_filter) {
char *exclusion_string;
- command_ret = lttng_enable_event_with_exclusions(handle,
- ev, channel_name,
- NULL,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
+ command_ret = lttng_enable_event_with_exclusions(
+ handle,
+ ev,
+ channel_name,
+ NULL,
+ lttng_dynamic_pointer_array_get_count(&exclusions),
+ (char **) exclusions.array.buffer.data);
exclusion_string = print_exclusions(&exclusions);
if (!exclusion_string) {
PERROR("Cannot allocate exclusion_string");
switch (-command_ret) {
case LTTNG_ERR_KERN_EVENT_EXIST:
WARN("Kernel event %s%s already enabled (channel %s, session %s)",
- event_name,
- exclusion_string,
- print_channel_name(channel_name), session_name);
+ event_name,
+ exclusion_string,
+ print_channel_name(channel_name),
+ session_name);
warn = 1;
break;
case LTTNG_ERR_TRACE_ALREADY_STARTED:
{
- const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
- ERR("Event %s%s: %s (channel %s, session %s)", event_name,
- exclusion_string,
- msg,
- print_channel_name(channel_name),
- session_name);
+ const char *msg =
+ "The command tried to enable an event in a new domain for a session that has already been started once.";
+ ERR("Event %s%s: %s (channel %s, session %s)",
+ event_name,
+ exclusion_string,
+ msg,
+ print_channel_name(channel_name),
+ session_name);
error = 1;
break;
}
case LTTNG_ERR_SDT_PROBE_SEMAPHORE:
ERR("SDT probes %s guarded by semaphores are not supported (channel %s, session %s)",
- event_name, print_channel_name(channel_name),
- session_name);
+ event_name,
+ print_channel_name(channel_name),
+ session_name);
error = 1;
break;
default:
- ERR("Event %s%s: %s (channel %s, session %s)", event_name,
- exclusion_string,
- lttng_strerror(command_ret),
- command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
- ? print_raw_channel_name(channel_name)
- : print_channel_name(channel_name),
- session_name);
+ ERR("Event %s%s: %s (channel %s, session %s)",
+ event_name,
+ exclusion_string,
+ lttng_strerror(command_ret),
+ command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
+ print_raw_channel_name(channel_name) :
+ print_channel_name(channel_name),
+ session_name);
error = 1;
break;
}
case LTTNG_DOMAIN_KERNEL:
case LTTNG_DOMAIN_UST:
MSG("%s event %s%s created in channel %s",
- lttng_domain_type_str(dom.type),
- event_name,
- exclusion_string,
- print_channel_name(channel_name));
+ lttng_domain_type_str(dom.type),
+ event_name,
+ exclusion_string,
+ print_channel_name(channel_name));
break;
case LTTNG_DOMAIN_JUL:
case LTTNG_DOMAIN_LOG4J:
* name for agent domains.
*/
MSG("%s event %s%s enabled",
- lttng_domain_type_str(dom.type),
- event_name,
- exclusion_string);
+ lttng_domain_type_str(dom.type),
+ event_name,
+ exclusion_string);
break;
default:
abort();
/* Filter present */
ev->filter = 1;
- command_ret = lttng_enable_event_with_exclusions(handle, ev, channel_name,
- opt_filter,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
+ command_ret = lttng_enable_event_with_exclusions(
+ handle,
+ ev,
+ channel_name,
+ opt_filter,
+ lttng_dynamic_pointer_array_get_count(&exclusions),
+ (char **) exclusions.array.buffer.data);
exclusion_string = print_exclusions(&exclusions);
if (!exclusion_string) {
PERROR("Cannot allocate exclusion_string");
switch (-command_ret) {
case LTTNG_ERR_FILTER_EXIST:
WARN("Filter on event %s%s is already enabled"
- " (channel %s, session %s)",
- event_name,
- exclusion_string,
- print_channel_name(channel_name), session_name);
+ " (channel %s, session %s)",
+ event_name,
+ exclusion_string,
+ print_channel_name(channel_name),
+ session_name);
warn = 1;
break;
case LTTNG_ERR_TRACE_ALREADY_STARTED:
{
- const char *msg = "The command tried to enable an event in a new domain for a session that has already been started once.";
- ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev->name,
- exclusion_string,
- msg,
- print_channel_name(channel_name),
- session_name, opt_filter);
+ const char *msg =
+ "The command tried to enable an event in a new domain for a session that has already been started once.";
+ ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')",
+ ev->name,
+ exclusion_string,
+ msg,
+ print_channel_name(channel_name),
+ session_name,
+ opt_filter);
error = 1;
break;
}
default:
- ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')", ev->name,
- exclusion_string,
- lttng_strerror(command_ret),
- command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME
- ? print_raw_channel_name(channel_name)
- : print_channel_name(channel_name),
- session_name, opt_filter);
+ ERR("Event %s%s: %s (channel %s, session %s, filter \'%s\')",
+ ev->name,
+ exclusion_string,
+ lttng_strerror(command_ret),
+ command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
+ print_raw_channel_name(channel_name) :
+ print_channel_name(channel_name),
+ session_name,
+ opt_filter);
error = 1;
break;
}
} else {
MSG("Event %s%s: Filter '%s' successfully set",
- event_name, exclusion_string,
- opt_filter);
+ event_name,
+ exclusion_string,
+ opt_filter);
}
free(exclusion_string);
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
}
ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace + opt_jul + opt_log4j +
- opt_python,
- true);
+ opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python, true);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_enable_event);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_enable_event);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
goto end;
}
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
poptFreeContext(pc);
return ret;
}
-
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
+#include <ctype.h>
+#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <ctype.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/mi-lttng.hpp>
-#include <common/utils.hpp>
-
-#include "../command.hpp"
-#include <lttng/lttng.h>
static char *opt_session_name;
static struct mi_writer *writer;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-enable-rotation.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"timer", 0, POPT_ARG_INT, 0, OPT_TIMER, 0, 0},
- {"size", 0, POPT_ARG_INT, 0, OPT_SIZE, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "timer", 0, POPT_ARG_INT, 0, OPT_TIMER, 0, 0 },
+ { "size", 0, POPT_ARG_INT, 0, OPT_SIZE, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static const char *schedule_type_str[] = {
};
static enum cmd_error_code add_schedule(const char *session_name,
- enum lttng_rotation_schedule_type schedule_type, uint64_t value)
+ enum lttng_rotation_schedule_type schedule_type,
+ uint64_t value)
{
enum cmd_error_code ret = CMD_SUCCESS;
struct lttng_rotation_schedule *schedule = NULL;
ret = CMD_ERROR;
goto end;
}
- status = lttng_rotation_schedule_periodic_set_period(schedule,
- value);
+ status = lttng_rotation_schedule_periodic_set_period(schedule, value);
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
schedule = lttng_rotation_schedule_size_threshold_create();
ret = CMD_ERROR;
goto end;
}
- status = lttng_rotation_schedule_size_threshold_set_threshold(
- schedule, value);
+ status = lttng_rotation_schedule_size_threshold_set_threshold(schedule, value);
break;
default:
ERR("Unknown schedule type");
ret = CMD_ERROR;
goto end;
default:
- ERR("Unknown error occurred setting %s rotation schedule",
- schedule_type_name);
+ ERR("Unknown error occurred setting %s rotation schedule", schedule_type_name);
ret = CMD_ERROR;
goto end;
}
switch (schedule_type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
MSG("Enabled %s rotations every %" PRIu64 " %s on session %s",
- schedule_type_name, value, USEC_UNIT, session_name);
+ schedule_type_name,
+ value,
+ USEC_UNIT,
+ session_name);
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
MSG("Enabled %s rotations every %" PRIu64 " bytes written on session %s",
- schedule_type_name, value, session_name);
+ schedule_type_name,
+ value,
+ session_name);
break;
default:
abort();
}
break;
case LTTNG_ROTATION_STATUS_INVALID:
- ERR("Invalid parameter for %s rotation schedule",
- schedule_type_name);
+ ERR("Invalid parameter for %s rotation schedule", schedule_type_name);
ret = CMD_ERROR;
break;
case LTTNG_ROTATION_STATUS_SCHEDULE_ALREADY_SET:
ERR("A %s rotation schedule is already set on session %s",
- schedule_type_name,
- session_name);
+ schedule_type_name,
+ session_name);
ret = CMD_ERROR;
break;
case LTTNG_ROTATION_STATUS_ERROR:
default:
ERR("Failed to enable %s rotation schedule on session %s",
- schedule_type_name,
- session_name);
+ schedule_type_name,
+ session_name);
ret = CMD_ERROR;
break;
}
if (lttng_opt_mi) {
int mi_ret;
- mi_ret = mi_lttng_rotation_schedule_result(writer,
- schedule, ret == CMD_SUCCESS);
+ mi_ret = mi_lttng_rotation_schedule_result(writer, schedule, ret == CMD_SUCCESS);
if (mi_ret < 0) {
ret = CMD_ERROR;
goto end;
/* Open command element */
ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_enable_rotation);
+ mi_lttng_element_command_enable_rotation);
if (ret) {
goto error;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
goto error;
}
if (lttng_opt_mi) {
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_schedule_results);
+ mi_lttng_element_rotation_schedule_results);
if (ret) {
goto error;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_session_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto error;
}
* Continue processing even on error as multiple schedules can
* be specified at once.
*/
- cmd_ret = add_schedule(session_name,
- LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC,
- timer_us);
+ cmd_ret =
+ add_schedule(session_name, LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC, timer_us);
}
if (size_rotation) {
enum cmd_error_code tmp_ret;
/* Don't overwrite cmd_ret if it already indicates an error. */
- tmp_ret = add_schedule(session_name,
- LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD,
- size_bytes);
+ tmp_ret = add_schedule(
+ session_name, LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD, size_bytes);
cmd_ret = cmd_ret ? cmd_ret : tmp_ret;
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success,
- cmd_ret == CMD_SUCCESS);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, cmd_ret == CMD_SUCCESS);
if (ret) {
goto error;
}
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/utils.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "../command.hpp"
-#include <common/utils.hpp>
-
#ifdef LTTNG_EMBED_HELP
static const char *help_msg =
#include <lttng-help.1.h>
-;
+ ;
#endif
static const char *lttng_help_msg =
#ifdef LTTNG_EMBED_HELP
#include <lttng.1.h>
#else
-NULL
+ NULL
#endif
-;
+ ;
enum {
OPT_HELP = 1,
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
#include <stdint.h>
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <popt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include "../command.hpp"
#include <common/mi-lttng.hpp>
#include <common/time.hpp>
#include <common/tracker.hpp>
+
#include <lttng/domain-internal.hpp>
#include <lttng/lttng.h>
-#include "../command.hpp"
+#include <inttypes.h>
+#include <popt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
static int opt_userspace;
static int opt_kernel;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-list.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0},
- {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0},
- {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
- {"channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0},
- {"domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
- {"fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0},
- {"syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0 },
+ { "jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0 },
+ { "log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0 },
+ { "python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0 },
+ { "userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0 },
+ { "channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0 },
+ { "domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0 },
+ { "fields", 'f', POPT_ARG_VAL, &opt_fields, 1, 0, 0 },
+ { "syscall", 'S', POPT_ARG_VAL, &opt_syscall, 1, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
return cmdline;
}
-static
-const char *active_string(int value)
+static const char *active_string(int value)
{
switch (value) {
- case 0: return "inactive";
- case 1: return "active";
- case -1: return "";
- default: return NULL;
+ case 0:
+ return "inactive";
+ case 1:
+ return "active";
+ case -1:
+ return "";
+ default:
+ return NULL;
}
}
}
}
-static
-const char *enabled_string(int value)
+static const char *enabled_string(int value)
{
switch (value) {
- case 0: return " [disabled]";
- case 1: return " [enabled]";
- case -1: return "";
- default: return NULL;
+ case 0:
+ return " [disabled]";
+ case 1:
+ return " [enabled]";
+ case -1:
+ return "";
+ default:
+ return NULL;
}
}
-static
-const char *safe_string(const char *str)
+static const char *safe_string(const char *str)
{
return str ? str : "";
}
char *exclusion_msg = NULL;
char *at;
size_t i;
- const char * const exclusion_fmt = " [exclusions: ";
+ const char *const exclusion_fmt = " [exclusions: ";
const size_t exclusion_fmt_len = strlen(exclusion_fmt);
exclusion_count = lttng_event_get_exclusion_name_count(event);
* a comma per entry, the entry count (fixed-size), a closing
* bracket, and a trailing \0.
*/
- exclusion_msg = (char *) malloc(exclusion_count +
- exclusion_count * LTTNG_SYMBOL_NAME_LEN +
- exclusion_fmt_len + 1);
+ exclusion_msg = (char *) malloc(exclusion_count + exclusion_count * LTTNG_SYMBOL_NAME_LEN +
+ exclusion_fmt_len + 1);
if (!exclusion_msg) {
goto end;
}
MSG("%sType: Function", indent8);
function_name = lttng_userspace_probe_location_function_get_function_name(location);
- binary_path = realpath(lttng_userspace_probe_location_function_get_binary_path(location), NULL);
+ binary_path = realpath(
+ lttng_userspace_probe_location_function_get_binary_path(location), NULL);
MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
MSG("%sFunction: %s()", indent8, function_name ? function_name : "NULL");
MSG("%sType: Tracepoint", indent8);
probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
- binary_path = realpath(lttng_userspace_probe_location_tracepoint_get_binary_path(location), NULL);
+ provider_name =
+ lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+ binary_path = realpath(
+ lttng_userspace_probe_location_tracepoint_get_binary_path(location), NULL);
MSG("%sBinary path: %s", indent8, binary_path ? binary_path : "NULL");
- MSG("%sTracepoint: %s:%s", indent8, provider_name ? provider_name : "NULL", probe_name ? probe_name : "NULL");
+ MSG("%sTracepoint: %s:%s",
+ indent8,
+ provider_name ? provider_name : "NULL",
+ probe_name ? probe_name : "NULL");
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
MSG("%sLookup method: SDT", indent8);
{
if (event->loglevel != -1) {
MSG("%s%s (loglevel%s %s (%d)) (type: tracepoint)%s%s%s",
- indent6, event->name,
- logleveltype_string(
- event->loglevel_type),
- mi_lttng_loglevel_string(
- event->loglevel,
- the_handle->domain.type),
- event->loglevel,
- enabled_string(event->enabled),
- safe_string(exclusion_msg),
- safe_string(filter_msg));
+ indent6,
+ event->name,
+ logleveltype_string(event->loglevel_type),
+ mi_lttng_loglevel_string(event->loglevel, the_handle->domain.type),
+ event->loglevel,
+ enabled_string(event->enabled),
+ safe_string(exclusion_msg),
+ safe_string(filter_msg));
} else {
MSG("%s%s (type: tracepoint)%s%s%s",
- indent6,
- event->name,
- enabled_string(event->enabled),
- safe_string(exclusion_msg),
- safe_string(filter_msg));
+ indent6,
+ event->name,
+ enabled_string(event->enabled),
+ safe_string(exclusion_msg),
+ safe_string(filter_msg));
}
break;
}
case LTTNG_EVENT_FUNCTION:
- MSG("%s%s (type: function)%s%s", indent6,
- event->name, enabled_string(event->enabled),
- safe_string(filter_msg));
+ MSG("%s%s (type: function)%s%s",
+ indent6,
+ event->name,
+ enabled_string(event->enabled),
+ safe_string(filter_msg));
if (event->attr.probe.addr != 0) {
MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
} else {
}
break;
case LTTNG_EVENT_PROBE:
- MSG("%s%s (type: probe)%s%s", indent6,
- event->name, enabled_string(event->enabled),
- safe_string(filter_msg));
+ MSG("%s%s (type: probe)%s%s",
+ indent6,
+ event->name,
+ enabled_string(event->enabled),
+ safe_string(filter_msg));
if (event->attr.probe.addr != 0) {
MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
} else {
print_userspace_probe_location(event);
break;
case LTTNG_EVENT_FUNCTION_ENTRY:
- MSG("%s%s (type: function)%s%s", indent6,
- event->name, enabled_string(event->enabled),
- safe_string(filter_msg));
+ MSG("%s%s (type: function)%s%s",
+ indent6,
+ event->name,
+ enabled_string(event->enabled),
+ safe_string(filter_msg));
MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
break;
case LTTNG_EVENT_SYSCALL:
- MSG("%s%s%s%s%s%s", indent6, event->name,
- (opt_syscall ? "" : " (type:syscall)"),
- enabled_string(event->enabled),
- bitness_event(event->flags),
- safe_string(filter_msg));
+ MSG("%s%s%s%s%s%s",
+ indent6,
+ event->name,
+ (opt_syscall ? "" : " (type:syscall)"),
+ enabled_string(event->enabled),
+ bitness_event(event->flags),
+ safe_string(filter_msg));
break;
case LTTNG_EVENT_NOOP:
- MSG("%s (type: noop)%s%s", indent6,
- enabled_string(event->enabled),
- safe_string(filter_msg));
+ MSG("%s (type: noop)%s%s",
+ indent6,
+ enabled_string(event->enabled),
+ safe_string(filter_msg));
break;
case LTTNG_EVENT_ALL:
/* Fall-through. */
static const char *field_type(struct lttng_event_field *field)
{
- switch(field->type) {
+ switch (field->type) {
case LTTNG_EVENT_FIELD_INTEGER:
return "integer";
case LTTNG_EVENT_FIELD_ENUM:
case LTTNG_EVENT_FIELD_STRING:
return "string";
case LTTNG_EVENT_FIELD_OTHER:
- default: /* fall-through */
+ default: /* fall-through */
return "unknown";
}
}
if (!field->field_name[0]) {
return;
}
- MSG("%sfield: %s (%s)%s", indent8, field->field_name,
- field_type(field), field->nowrite ? " [no write]" : "");
+ MSG("%sfield: %s (%s)%s",
+ indent8,
+ field->field_name,
+ field_type(field),
+ field->nowrite ? " [no write]" : "");
}
/*
* Machine interface
* Jul and ust event listing
*/
-static int mi_list_agent_ust_events(struct lttng_event *events, int count,
- struct lttng_domain *domain)
+static int
+mi_list_agent_ust_events(struct lttng_event *events, int count, struct lttng_domain *domain)
{
int ret, i;
pid_t cur_pid = 0;
if (cur_pid != events[i].pid) {
if (pid_element_open) {
/* Close the previous events and pid element */
- ret = mi_lttng_close_multi_element(
- the_writer, 2);
+ ret = mi_lttng_close_multi_element(the_writer, 2);
if (ret) {
goto end;
}
if (!pid_element_open) {
/* Open and write a pid element */
- ret = mi_lttng_pid(the_writer, cur_pid, cmdline,
- 1);
+ ret = mi_lttng_pid(the_writer, cur_pid, cmdline, 1);
if (ret) {
goto error;
}
}
/* Write an event */
- ret = mi_lttng_event(the_writer, &events[i], 0,
- the_handle->domain.type);
+ ret = mi_lttng_event(the_writer, &events[i], 0, the_handle->domain.type);
if (ret) {
goto end;
}
size = lttng_list_tracepoints(handle, &event_list);
if (size < 0) {
- ERR("Unable to list %s events: %s", agent_domain_str,
- lttng_strerror(size));
+ ERR("Unable to list %s events: %s", agent_domain_str, lttng_strerror(size));
ret = CMD_ERROR;
goto end;
}
}
} else {
/* Pretty print */
- MSG("%s events (Logger name):\n-------------------------",
- agent_domain_str);
+ MSG("%s events (Logger name):\n-------------------------", agent_domain_str);
if (size == 0) {
MSG("None");
* Machine interface
* List all ust event with their fields
*/
-static int mi_list_ust_event_fields(struct lttng_event_field *fields, int count,
- struct lttng_domain *domain)
+static int
+mi_list_ust_event_fields(struct lttng_event_field *fields, int count, struct lttng_domain *domain)
{
int ret, i;
pid_t cur_pid = 0;
if (pid_element_open) {
if (event_element_open) {
/* Close the previous field element and event. */
- ret = mi_lttng_close_multi_element(
- the_writer, 2);
+ ret = mi_lttng_close_multi_element(the_writer, 2);
if (ret) {
goto end;
}
event_element_open = 0;
}
/* Close the previous events, pid element */
- ret = mi_lttng_close_multi_element(
- the_writer, 2);
+ ret = mi_lttng_close_multi_element(the_writer, 2);
if (ret) {
goto end;
}
cmdline = get_cmdline_by_pid(cur_pid);
if (!pid_element_open) {
/* Open and write a pid element */
- ret = mi_lttng_pid(the_writer, cur_pid, cmdline,
- 1);
+ ret = mi_lttng_pid(the_writer, cur_pid, cmdline, 1);
if (ret) {
goto error;
}
if (strcmp(cur_event.name, fields[i].event.name) != 0) {
if (event_element_open) {
/* Close the previous fields element and the previous event */
- ret = mi_lttng_close_multi_element(
- the_writer, 2);
+ ret = mi_lttng_close_multi_element(the_writer, 2);
if (ret) {
goto end;
}
event_element_open = 0;
}
- memcpy(&cur_event, &fields[i].event,
- sizeof(cur_event));
+ memcpy(&cur_event, &fields[i].event, sizeof(cur_event));
if (!event_element_open) {
/* Open and write the event */
- ret = mi_lttng_event(the_writer, &cur_event, 1,
- the_handle->domain.type);
+ ret = mi_lttng_event(
+ the_writer, &cur_event, 1, the_handle->domain.type);
if (ret) {
goto end;
}
}
if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) {
print_events(&event_field_list[i].event);
- memcpy(&cur_event, &event_field_list[i].event,
- sizeof(cur_event));
+ memcpy(&cur_event, &event_field_list[i].event, sizeof(cur_event));
}
print_event_field(&event_field_list[i]);
}
* Machine interface
* Print a list of kernel events
*/
-static int mi_list_kernel_events(struct lttng_event *events, int count,
- struct lttng_domain *domain)
+static int mi_list_kernel_events(struct lttng_event *events, int count, struct lttng_domain *domain)
{
int ret, i;
}
for (i = 0; i < count; i++) {
- ret = mi_lttng_event(the_writer, &events[i], 0,
- the_handle->domain.type);
+ ret = mi_lttng_event(the_writer, &events[i], 0, the_handle->domain.type);
if (ret) {
goto end;
}
}
for (i = 0; i < count; i++) {
- ret = mi_lttng_event(the_writer, &events[i], 0,
- the_handle->domain.type);
+ ret = mi_lttng_event(the_writer, &events[i], 0, the_handle->domain.type);
if (ret) {
goto end;
}
}
for (i = 0; i < count; i++) {
- ret = mi_lttng_event(the_writer, &events[i], 0,
- the_handle->domain.type);
+ ret = mi_lttng_event(the_writer, &events[i], 0, the_handle->domain.type);
if (ret) {
goto end;
}
char *filter_msg = NULL;
struct lttng_event *event = &events[i];
- ret = lttng_event_get_filter_expression(event,
- &filter_str);
+ ret = lttng_event_get_filter_expression(event, &filter_str);
if (ret) {
filter_msg = strdup(" [failed to retrieve filter]");
} else if (filter_str) {
}
}
- if (event->loglevel_type !=
- LTTNG_EVENT_LOGLEVEL_ALL) {
- MSG("%s- %s%s (loglevel%s %s)%s", indent4,
- event->name,
- enabled_string(event->enabled),
- logleveltype_string(
- event->loglevel_type),
- mi_lttng_loglevel_string(
- event->loglevel,
- the_handle->domain
- .type),
- safe_string(filter_msg));
+ if (event->loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
+ MSG("%s- %s%s (loglevel%s %s)%s",
+ indent4,
+ event->name,
+ enabled_string(event->enabled),
+ logleveltype_string(event->loglevel_type),
+ mi_lttng_loglevel_string(event->loglevel,
+ the_handle->domain.type),
+ safe_string(filter_msg));
} else {
- MSG("%s- %s%s%s", indent4, event->name,
- enabled_string(event->enabled),
- safe_string(filter_msg));
+ MSG("%s- %s%s%s",
+ indent4,
+ event->name,
+ enabled_string(event->enabled),
+ safe_string(filter_msg));
}
free(filter_msg);
}
}
for (i = 0; i < count; i++) {
- ret = mi_lttng_event(the_writer, &events[i], 0,
- the_handle->domain.type);
+ ret = mi_lttng_event(the_writer, &events[i], 0, the_handle->domain.type);
if (ret) {
goto end;
}
return ret;
}
-static
-void print_timer(const char *timer_name, uint32_t space_count, int64_t value)
+static void print_timer(const char *timer_name, uint32_t space_count, int64_t value)
{
uint32_t i;
uint64_t discarded_events, lost_packets, monitor_timer_interval;
int64_t blocking_timeout;
- ret = lttng_channel_get_discarded_event_count(channel,
- &discarded_events);
+ ret = lttng_channel_get_discarded_event_count(channel, &discarded_events);
if (ret) {
ERR("Failed to retrieve discarded event count of channel");
return;
}
- ret = lttng_channel_get_lost_packet_count(channel,
- &lost_packets);
+ ret = lttng_channel_get_lost_packet_count(channel, &lost_packets);
if (ret) {
ERR("Failed to retrieve lost packet count of channel");
return;
}
- ret = lttng_channel_get_monitor_timer_interval(channel,
- &monitor_timer_interval);
+ ret = lttng_channel_get_monitor_timer_interval(channel, &monitor_timer_interval);
if (ret) {
ERR("Failed to retrieve monitor interval of channel");
return;
}
- ret = lttng_channel_get_blocking_timeout(channel,
- &blocking_timeout);
+ ret = lttng_channel_get_blocking_timeout(channel, &blocking_timeout);
if (ret) {
ERR("Failed to retrieve blocking timeout of channel");
return;
MSG("%sSub-buffer count: %" PRIu64, indent6, channel->attr.num_subbuf);
print_timer("Switch timer", 5, channel->attr.switch_timer_interval);
- print_timer("Read timer", 7, channel->attr.read_timer_interval);
+ print_timer("Read timer", 7, channel->attr.read_timer_interval);
print_timer("Monitor timer", 4, monitor_timer_interval);
if (!channel->attr.overwrite) {
if (blocking_timeout == -1) {
MSG("%sBlocking timeout: infinite", indent6);
} else {
- MSG("%sBlocking timeout: %" PRId64 " %s", indent6,
- blocking_timeout, USEC_UNIT);
+ MSG("%sBlocking timeout: %" PRId64 " %s",
+ indent6,
+ blocking_timeout,
+ USEC_UNIT);
}
}
- MSG("%sTrace file count: %" PRIu64 " per stream", indent6,
- channel->attr.tracefile_count == 0 ?
- 1 : channel->attr.tracefile_count);
- if (channel->attr.tracefile_size != 0 ) {
- MSG("%sTrace file size: %" PRIu64 " bytes", indent6,
- channel->attr.tracefile_size);
+ MSG("%sTrace file count: %" PRIu64 " per stream",
+ indent6,
+ channel->attr.tracefile_count == 0 ? 1 : channel->attr.tracefile_count);
+ if (channel->attr.tracefile_size != 0) {
+ MSG("%sTrace file size: %" PRIu64 " bytes", indent6, channel->attr.tracefile_size);
} else {
MSG("%sTrace file size: %s", indent6, "unlimited");
}
switch (channel->attr.output) {
- case LTTNG_EVENT_SPLICE:
- MSG("%sOutput mode: splice", indent6);
- break;
- case LTTNG_EVENT_MMAP:
- MSG("%sOutput mode: mmap", indent6);
- break;
+ case LTTNG_EVENT_SPLICE:
+ MSG("%sOutput mode: splice", indent6);
+ break;
+ case LTTNG_EVENT_MMAP:
+ MSG("%sOutput mode: mmap", indent6);
+ break;
}
MSG("\n%sStatistics:", indent4);
* Print a list of channel
*
*/
-static int mi_list_channels(struct lttng_channel *channels, int count,
- const char *channel_name)
+static int mi_list_channels(struct lttng_channel *channels, int count, const char *channel_name)
{
int i, ret;
unsigned int chan_found = 0;
unsigned int chan_found = 0;
struct lttng_channel *channels = NULL;
- DBG("Listing channel(s) (%s)", channel_name ? : "<all>");
+ DBG("Listing channel(s) (%s)", channel_name ?: "<all>");
count = lttng_list_channels(the_handle, &channels);
if (count < 0) {
}
static int handle_process_attr_status(enum lttng_process_attr process_attr,
- enum lttng_process_attr_tracker_handle_status status)
+ enum lttng_process_attr_tracker_handle_status status)
{
int ret = CMD_SUCCESS;
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_COMMUNICATION_ERROR:
ERR("Communication occurred while fetching %s tracker",
- lttng_process_attr_to_string(process_attr));
+ lttng_process_attr_to_string(process_attr));
ret = CMD_ERROR;
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST:
ERR("Failed to get the inclusion set of the %s tracker: session `%s` no longer exists",
- lttng_process_attr_to_string(process_attr),
- the_handle->session_name);
+ lttng_process_attr_to_string(process_attr),
+ the_handle->session_name);
ret = CMD_ERROR;
break;
default:
ERR("Unknown error occurred while fetching the inclusion set of the %s tracker",
- lttng_process_attr_to_string(process_attr));
+ lttng_process_attr_to_string(process_attr));
ret = CMD_ERROR;
break;
}
return ret;
}
-static inline bool is_value_type_name(
- enum lttng_process_attr_value_type value_type)
+static inline bool is_value_type_name(enum lttng_process_attr_value_type value_type)
{
return value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ||
- value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME;
+ value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME;
}
/*
const struct lttng_process_attr_values *values;
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
- ret_code = lttng_session_get_tracker_handle(the_handle->session_name,
- the_handle->domain.type, process_attr, &tracker_handle);
+ ret_code = lttng_session_get_tracker_handle(
+ the_handle->session_name, the_handle->domain.type, process_attr, &tracker_handle);
if (ret_code != LTTNG_OK) {
- ERR("Failed to get process attribute tracker handle: %s",
- lttng_strerror(ret_code));
+ ERR("Failed to get process attribute tracker handle: %s", lttng_strerror(ret_code));
ret = CMD_ERROR;
goto end;
}
- handle_status = lttng_process_attr_tracker_handle_get_inclusion_set(
- tracker_handle, &values);
+ handle_status =
+ lttng_process_attr_tracker_handle_get_inclusion_set(tracker_handle, &values);
ret = handle_process_attr_status(process_attr, handle_status);
if (ret != CMD_SUCCESS) {
goto end;
}
- handle_status = lttng_process_attr_tracker_handle_get_tracking_policy(
- tracker_handle, &policy);
+ handle_status =
+ lttng_process_attr_tracker_handle_get_tracking_policy(tracker_handle, &policy);
ret = handle_process_attr_status(process_attr, handle_status);
if (ret != CMD_SUCCESS) {
goto end;
{
char *process_attr_name;
- const int print_ret = asprintf(&process_attr_name, "%ss:",
- get_capitalized_process_attr_str(process_attr));
+ const int print_ret = asprintf(
+ &process_attr_name, "%ss:", get_capitalized_process_attr_str(process_attr));
if (print_ret == -1) {
ret = CMD_FATAL;
goto end;
default:
ERR("Unknown tracking policy encoutered while listing the %s process attribute tracker of session `%s`",
- lttng_process_attr_to_string(process_attr),
- the_handle->session_name);
+ lttng_process_attr_to_string(process_attr),
+ the_handle->session_name);
ret = CMD_FATAL;
goto end;
}
values_status = lttng_process_attr_values_get_count(values, &count);
if (values_status != LTTNG_PROCESS_ATTR_VALUES_STATUS_OK) {
ERR("Failed to get the count of values in the inclusion set of the %s process attribute tracker of session `%s`",
- lttng_process_attr_to_string(process_attr),
- the_handle->session_name);
+ lttng_process_attr_to_string(process_attr),
+ the_handle->session_name);
ret = CMD_FATAL;
goto end;
}
/* Mi tracker_id element */
if (the_writer) {
/* Open tracker_id and targets elements */
- ret = mi_lttng_process_attribute_tracker_open(
- the_writer, process_attr);
+ ret = mi_lttng_process_attribute_tracker_open(the_writer, process_attr);
if (ret) {
goto end;
}
for (i = 0; i < count; i++) {
const enum lttng_process_attr_value_type value_type =
- lttng_process_attr_values_get_type_at_index(
- values, i);
+ lttng_process_attr_values_get_type_at_index(values, i);
int64_t integral_value = INT64_MAX;
const char *name = "error";
{
pid_t pid;
- values_status = lttng_process_attr_values_get_pid_at_index(
- values, i, &pid);
+ values_status = lttng_process_attr_values_get_pid_at_index(values, i, &pid);
integral_value = (int64_t) pid;
break;
}
{
uid_t uid;
- values_status = lttng_process_attr_values_get_uid_at_index(
- values, i, &uid);
+ values_status = lttng_process_attr_values_get_uid_at_index(values, i, &uid);
integral_value = (int64_t) uid;
break;
}
{
gid_t gid;
- values_status = lttng_process_attr_values_get_gid_at_index(
- values, i, &gid);
+ values_status = lttng_process_attr_values_get_gid_at_index(values, i, &gid);
integral_value = (int64_t) gid;
break;
}
case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
- values_status = lttng_process_attr_values_get_user_name_at_index(
- values, i, &name);
+ values_status =
+ lttng_process_attr_values_get_user_name_at_index(values, i, &name);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME:
- values_status = lttng_process_attr_values_get_group_name_at_index(
- values, i, &name);
+ values_status =
+ lttng_process_attr_values_get_group_name_at_index(values, i, &name);
break;
default:
ret = CMD_ERROR;
/* Mi */
if (the_writer) {
ret = is_value_type_name(value_type) ?
- mi_lttng_string_process_attribute_value(
- the_writer,
- process_attr, name,
- false) :
- mi_lttng_integral_process_attribute_value(
- the_writer,
- process_attr,
- integral_value, false);
+ mi_lttng_string_process_attribute_value(
+ the_writer, process_attr, name, false) :
+ mi_lttng_integral_process_attribute_value(
+ the_writer, process_attr, integral_value, false);
if (ret) {
goto end;
}
goto end;
}
/* vpid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
if (ret) {
goto end;
}
goto end;
}
/* vuid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
if (ret) {
goto end;
}
goto end;
}
/* vgid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
if (ret) {
goto end;
}
break;
case LTTNG_DOMAIN_UST:
/* vpid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
if (ret) {
goto end;
}
/* vuid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
if (ret) {
goto end;
}
/* vgid tracker */
- ret = list_process_attr_tracker(
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ ret = list_process_attr_tracker(LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
if (ret) {
goto end;
}
return ret;
}
-static enum cmd_error_code print_periodic_rotation_schedule(
- const struct lttng_rotation_schedule *schedule)
+static enum cmd_error_code
+print_periodic_rotation_schedule(const struct lttng_rotation_schedule *schedule)
{
enum cmd_error_code ret;
enum lttng_rotation_status status;
uint64_t value;
- status = lttng_rotation_schedule_periodic_get_period(schedule,
- &value);
+ status = lttng_rotation_schedule_periodic_get_period(schedule, &value);
if (status != LTTNG_ROTATION_STATUS_OK) {
ERR("Failed to retrieve period parameter from periodic rotation schedule.");
ret = CMD_ERROR;
goto end;
}
- MSG(" timer period: %" PRIu64" %s", value, USEC_UNIT);
+ MSG(" timer period: %" PRIu64 " %s", value, USEC_UNIT);
ret = CMD_SUCCESS;
end:
return ret;
}
-static enum cmd_error_code print_size_threshold_rotation_schedule(
- const struct lttng_rotation_schedule *schedule)
+static enum cmd_error_code
+print_size_threshold_rotation_schedule(const struct lttng_rotation_schedule *schedule)
{
enum cmd_error_code ret;
enum lttng_rotation_status status;
uint64_t value;
- status = lttng_rotation_schedule_size_threshold_get_threshold(schedule,
- &value);
+ status = lttng_rotation_schedule_size_threshold_get_threshold(schedule, &value);
if (status != LTTNG_ROTATION_STATUS_OK) {
ERR("Failed to retrieve size parameter from size-based rotation schedule.");
ret = CMD_ERROR;
goto end;
}
- MSG(" size threshold: %" PRIu64" bytes", value);
+ MSG(" size threshold: %" PRIu64 " bytes", value);
ret = CMD_SUCCESS;
end:
return ret;
}
-static enum cmd_error_code print_rotation_schedule(
- const struct lttng_rotation_schedule *schedule)
+static enum cmd_error_code print_rotation_schedule(const struct lttng_rotation_schedule *schedule)
{
enum cmd_error_code ret;
MSG("Automatic rotation schedules:");
if (lttng_opt_mi) {
- ret = mi_lttng_writer_open_element(the_writer,
- mi_lttng_element_rotation_schedules);
+ ret = mi_lttng_writer_open_element(the_writer, mi_lttng_element_rotation_schedules);
if (ret) {
cmd_ret = CMD_ERROR;
goto end;
* Find the session with session_name as name
* and print his informations.
*/
-static int mi_list_session(const char *session_name,
- struct lttng_session *sessions, int count)
+static int mi_list_session(const char *session_name, struct lttng_session *sessions, int count)
{
int ret, i;
unsigned int session_found = 0;
if (session_name != NULL) {
if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
session_found = 1;
- MSG("Recording session %s: [%s%s]", session_name,
- active_string(sessions[i].enabled),
- snapshot_string(sessions[i].snapshot_mode));
+ MSG("Recording session %s: [%s%s]",
+ session_name,
+ active_string(sessions[i].enabled),
+ snapshot_string(sessions[i].snapshot_mode));
if (*sessions[i].path) {
- MSG("%sTrace output: %s\n", indent4, sessions[i].path);
+ MSG("%sTrace output: %s\n",
+ indent4,
+ sessions[i].path);
}
memcpy(&the_listed_session,
- &sessions[i],
- sizeof(the_listed_session));
+ &sessions[i],
+ sizeof(the_listed_session));
break;
}
} else {
- MSG(" %d) %s [%s%s]", i + 1,
- sessions[i].name,
- active_string(sessions[i].enabled),
- snapshot_string(sessions[i].snapshot_mode));
+ MSG(" %d) %s [%s%s]",
+ i + 1,
+ sessions[i].name,
+ active_string(sessions[i].enabled),
+ snapshot_string(sessions[i].snapshot_mode));
if (*sessions[i].path) {
MSG("%sTrace output: %s", indent4, sessions[i].path);
}
if (sessions[i].live_timer_interval != 0) {
- MSG("%sLive timer interval: %u %s", indent4,
- sessions[i].live_timer_interval,
- USEC_UNIT);
+ MSG("%sLive timer interval: %u %s",
+ indent4,
+ sessions[i].live_timer_interval,
+ USEC_UNIT);
}
MSG("");
}
return ret;
}
-
/*
* Machine Interface
* list available domain(s) for a session.
int i, count, ret = CMD_SUCCESS;
struct lttng_domain *domains = NULL;
-
count = lttng_list_domains(session_name, &domains);
if (count < 0) {
ret = CMD_ERROR;
/* Mi check */
if (lttng_opt_mi) {
- the_writer = mi_lttng_writer_create(
- fileno(stdout), lttng_opt_mi);
+ the_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
if (!the_writer) {
ret = CMD_ERROR;
goto end;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(
- the_writer, mi_lttng_element_command_list);
+ ret = mi_lttng_writer_command_open(the_writer, mi_lttng_element_command_list);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(
- the_writer, mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(the_writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
if (arg_session_name == NULL) {
- if (!opt_kernel && !opt_userspace && !opt_jul && !opt_log4j
- && !opt_python) {
+ if (!opt_kernel && !opt_userspace && !opt_jul && !opt_log4j && !opt_python) {
ret = list_sessions(NULL);
if (ret) {
goto end;
if (ret) {
goto end;
}
-
}
-
/* Trackers */
ret = list_trackers(&domain);
if (ret) {
if (lttng_opt_mi) {
/* Close domain and domain element */
- ret = mi_lttng_close_multi_element(
- the_writer, 2);
+ ret = mi_lttng_close_multi_element(the_writer, 2);
}
if (ret) {
goto end;
}
-
} else {
int i, nb_domain;
case LTTNG_DOMAIN_UST:
MSG("=== Domain: User space ===\n");
MSG("Buffering scheme: %s\n",
- domains[i].buf_type ==
- LTTNG_BUFFER_PER_PID ? "per-process" : "per-user");
+ domains[i].buf_type == LTTNG_BUFFER_PER_PID ?
+ "per-process" :
+ "per-user");
break;
case LTTNG_DOMAIN_JUL:
MSG("=== Domain: java.util.logging (JUL) ===\n");
}
if (lttng_opt_mi) {
- ret = mi_lttng_domain(the_writer,
- &domains[i], 1);
+ ret = mi_lttng_domain(the_writer, &domains[i], 1);
if (ret) {
ret = CMD_ERROR;
goto end;
lttng_destroy_handle(the_handle);
}
- the_handle = lttng_create_handle(
- arg_session_name, &domains[i]);
+ the_handle = lttng_create_handle(arg_session_name, &domains[i]);
if (the_handle == NULL) {
ret = CMD_FATAL;
goto end;
}
if (domains[i].type == LTTNG_DOMAIN_JUL ||
- domains[i].type == LTTNG_DOMAIN_LOG4J ||
- domains[i].type == LTTNG_DOMAIN_PYTHON) {
+ domains[i].type == LTTNG_DOMAIN_LOG4J ||
+ domains[i].type == LTTNG_DOMAIN_PYTHON) {
ret = list_session_agent_events();
if (ret) {
goto end;
goto end;
}
-next_domain:
+ next_domain:
if (lttng_opt_mi) {
/* Close domain element */
- ret = mi_lttng_writer_close_element(
- the_writer);
+ ret = mi_lttng_writer_close_element(the_writer);
if (ret) {
ret = CMD_ERROR;
goto end;
}
}
-
}
if (lttng_opt_mi) {
/* Close the domains, session and sessions element */
- ret = mi_lttng_close_multi_element(
- the_writer, 3);
+ ret = mi_lttng_close_multi_element(the_writer, 3);
if (ret) {
ret = CMD_ERROR;
goto end;
*
*/
-#include <stdio.h>
-
#include "../command.hpp"
-
-#include "common/argpar/argpar.h"
#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/argpar/argpar.h"
#include "common/dynamic-array.hpp"
#include "common/mi-lttng.hpp"
+
+#include <stdio.h>
/* For lttng_condition_type_str(). */
#include "lttng/condition/condition-internal.hpp"
-#include "lttng/condition/event-rule-matches.h"
#include "lttng/condition/event-rule-matches-internal.hpp"
+#include "lttng/condition/event-rule-matches.h"
/* For lttng_domain_type_str(). */
#include "lttng/domain-internal.hpp"
/* For lttng_event_rule_kernel_syscall_emission_site_str() */
-#include "lttng/event-rule/kernel-syscall-internal.hpp"
#include "../loglevel.hpp"
+#include "lttng/event-rule/kernel-syscall-internal.hpp"
+
#include <lttng/lttng.h>
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-list-triggers.1.h>
-;
+ ;
#endif
#define INDENTATION_LEVEL_STR " "
typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
- const struct lttng_event_rule *rule, const char **pattern);
+ const struct lttng_event_rule *rule, const char **pattern);
typedef enum lttng_event_rule_status (*event_rule_logging_get_filter)(
- const struct lttng_event_rule *rule, const char **expression);
+ const struct lttng_event_rule *rule, const char **expression);
typedef enum lttng_event_rule_status (*event_rule_logging_get_log_level_rule)(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule);
+ const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule);
enum {
OPT_HELP,
OPT_LIST_OPTIONS,
};
-static const
-struct argpar_opt_descr list_trigger_options[] = {
+static const struct argpar_opt_descr list_trigger_options[] = {
{ OPT_HELP, 'h', "help", false },
{ OPT_LIST_OPTIONS, '\0', "list-options", false },
ARGPAR_OPT_DESCR_SENTINEL,
};
-static void print_condition_session_consumed_size(
- const struct lttng_condition *condition)
+static void print_condition_session_consumed_size(const struct lttng_condition *condition)
{
enum lttng_condition_status condition_status;
const char *session_name;
uint64_t threshold;
condition_status =
- lttng_condition_session_consumed_size_get_session_name(
- condition, &session_name);
+ lttng_condition_session_consumed_size_get_session_name(condition, &session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- lttng_condition_session_consumed_size_get_threshold(
- condition, &threshold);
+ lttng_condition_session_consumed_size_get_threshold(condition, &threshold);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
MSG(" session name: %s", session_name);
MSG(" threshold: %" PRIu64 " bytes", threshold);
}
-static void print_condition_buffer_usage(
- const struct lttng_condition *condition)
+static void print_condition_buffer_usage(const struct lttng_condition *condition)
{
enum lttng_condition_status condition_status;
const char *session_name, *channel_name;
enum lttng_domain_type domain_type;
uint64_t threshold;
- condition_status = lttng_condition_buffer_usage_get_session_name(
- condition, &session_name);
+ condition_status = lttng_condition_buffer_usage_get_session_name(condition, &session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- condition_status = lttng_condition_buffer_usage_get_channel_name(
- condition, &channel_name);
+ condition_status = lttng_condition_buffer_usage_get_channel_name(condition, &channel_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- condition_status = lttng_condition_buffer_usage_get_domain_type(
- condition, &domain_type);
+ condition_status = lttng_condition_buffer_usage_get_domain_type(condition, &domain_type);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
MSG(" session name: %s", session_name);
MSG(" channel name: %s", channel_name);
MSG(" domain: %s", lttng_domain_type_str(domain_type));
- condition_status = lttng_condition_buffer_usage_get_threshold(
- condition, &threshold);
+ condition_status = lttng_condition_buffer_usage_get_threshold(condition, &threshold);
if (condition_status == LTTNG_CONDITION_STATUS_OK) {
MSG(" threshold (bytes): %" PRIu64, threshold);
} else {
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_UNSET);
- condition_status =
- lttng_condition_buffer_usage_get_threshold_ratio(
- condition, &threshold_ratio);
+ condition_status = lttng_condition_buffer_usage_get_threshold_ratio(
+ condition, &threshold_ratio);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
MSG(" threshold (ratio): %.2f", threshold_ratio);
}
}
-static void print_condition_session_rotation(
- const struct lttng_condition *condition)
+static void print_condition_session_rotation(const struct lttng_condition *condition)
{
enum lttng_condition_status condition_status;
const char *session_name;
- condition_status = lttng_condition_session_rotation_get_session_name(
- condition, &session_name);
+ condition_status =
+ lttng_condition_session_rotation_get_session_name(condition, &session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
MSG(" session name: %s", session_name);
* values (a value can fall between two labels). In those cases, NULL is
* returned.
*/
-static const char *get_pretty_loglevel_name(
- enum lttng_event_rule_type event_rule_type, int loglevel)
+static const char *get_pretty_loglevel_name(enum lttng_event_rule_type event_rule_type,
+ int loglevel)
{
const char *name = NULL;
return name;
}
-static
-void print_event_rule_user_tracepoint(const struct lttng_event_rule *event_rule)
+static void print_event_rule_user_tracepoint(const struct lttng_event_rule *event_rule)
{
enum lttng_event_rule_status event_rule_status;
const char *pattern;
unsigned int exclusions_count;
int i;
- event_rule_status = lttng_event_rule_user_tracepoint_get_name_pattern(
- event_rule, &pattern);
+ event_rule_status = lttng_event_rule_user_tracepoint_get_name_pattern(event_rule, &pattern);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
_MSG(" rule: %s (type: user tracepoint", pattern);
- event_rule_status = lttng_event_rule_user_tracepoint_get_filter(
- event_rule, &filter);
+ event_rule_status = lttng_event_rule_user_tracepoint_get_filter(event_rule, &filter);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
_MSG(", filter: %s", filter);
} else {
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET);
}
- event_rule_status = lttng_event_rule_user_tracepoint_get_log_level_rule(
- event_rule, &log_level_rule);
+ event_rule_status =
+ lttng_event_rule_user_tracepoint_get_log_level_rule(event_rule, &log_level_rule);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
enum lttng_log_level_rule_status llr_status;
const char *log_level_op;
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
log_level_op = "is";
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &log_level);
+ llr_status =
+ lttng_log_level_rule_exactly_get_level(log_level_rule, &log_level);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
log_level_op = "at least";
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &log_level);
+ log_level_rule, &log_level);
break;
default:
abort();
LTTNG_ASSERT(llr_status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
- pretty_loglevel_name = get_pretty_loglevel_name(
- LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT, log_level);
+ pretty_loglevel_name =
+ get_pretty_loglevel_name(LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT, log_level);
if (pretty_loglevel_name) {
- _MSG(", log level %s %s", log_level_op,
- pretty_loglevel_name);
+ _MSG(", log level %s %s", log_level_op, pretty_loglevel_name);
} else {
_MSG(", log level %s %d", log_level_op, log_level);
}
}
event_rule_status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
- event_rule, &exclusions_count);
+ event_rule, &exclusions_count);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
if (exclusions_count > 0) {
_MSG(", exclusions: ");
for (i = 0; i < exclusions_count; i++) {
const char *exclusion;
- event_rule_status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
+ event_rule_status =
+ lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
event_rule, i, &exclusion);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
MSG(")");
}
-static
-void print_event_rule_kernel_tracepoint(const struct lttng_event_rule *event_rule)
+static void print_event_rule_kernel_tracepoint(const struct lttng_event_rule *event_rule)
{
enum lttng_event_rule_status event_rule_status;
const char *pattern;
const char *filter;
- event_rule_status = lttng_event_rule_kernel_tracepoint_get_name_pattern(
- event_rule, &pattern);
+ event_rule_status =
+ lttng_event_rule_kernel_tracepoint_get_name_pattern(event_rule, &pattern);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
_MSG(" rule: %s (type: kernel tracepoint", pattern);
- event_rule_status = lttng_event_rule_kernel_tracepoint_get_filter(
- event_rule, &filter);
+ event_rule_status = lttng_event_rule_kernel_tracepoint_get_filter(event_rule, &filter);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
_MSG(", filter: %s", filter);
} else {
MSG(")");
}
-static
-void print_event_rule_logging(const struct lttng_event_rule *event_rule)
+static void print_event_rule_logging(const struct lttng_event_rule *event_rule)
{
enum lttng_event_rule_status event_rule_status;
enum lttng_event_rule_type event_rule_type = lttng_event_rule_get_type(event_rule);
switch (event_rule_type) {
case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_jul_logging_get_name_pattern;
+ logging_get_name_pattern = lttng_event_rule_jul_logging_get_name_pattern;
logging_get_filter = lttng_event_rule_jul_logging_get_filter;
- logging_get_log_level_rule =
- lttng_event_rule_jul_logging_get_log_level_rule;
+ logging_get_log_level_rule = lttng_event_rule_jul_logging_get_log_level_rule;
type_str = "jul";
break;
case LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_log4j_logging_get_name_pattern;
+ logging_get_name_pattern = lttng_event_rule_log4j_logging_get_name_pattern;
logging_get_filter = lttng_event_rule_log4j_logging_get_filter;
- logging_get_log_level_rule =
- lttng_event_rule_log4j_logging_get_log_level_rule;
+ logging_get_log_level_rule = lttng_event_rule_log4j_logging_get_log_level_rule;
type_str = "log4j";
break;
case LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING:
- logging_get_name_pattern =
- lttng_event_rule_python_logging_get_name_pattern;
+ logging_get_name_pattern = lttng_event_rule_python_logging_get_name_pattern;
logging_get_filter = lttng_event_rule_python_logging_get_filter;
- logging_get_log_level_rule =
- lttng_event_rule_python_logging_get_log_level_rule;
+ logging_get_log_level_rule = lttng_event_rule_python_logging_get_log_level_rule;
type_str = "python";
break;
default:
break;
}
- event_rule_status = logging_get_name_pattern(
- event_rule, &pattern);
+ event_rule_status = logging_get_name_pattern(event_rule, &pattern);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
_MSG(" rule: %s (type: %s:logging", pattern, type_str);
- event_rule_status = logging_get_filter(
- event_rule, &filter);
+ event_rule_status = logging_get_filter(event_rule, &filter);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
_MSG(", filter: %s", filter);
} else {
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET);
}
- event_rule_status = logging_get_log_level_rule(
- event_rule, &log_level_rule);
+ event_rule_status = logging_get_log_level_rule(event_rule, &log_level_rule);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
enum lttng_log_level_rule_status llr_status;
const char *log_level_op;
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
log_level_op = "is";
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &log_level);
+ llr_status =
+ lttng_log_level_rule_exactly_get_level(log_level_rule, &log_level);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
log_level_op = "at least";
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &log_level);
+ log_level_rule, &log_level);
break;
default:
abort();
LTTNG_ASSERT(llr_status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
- pretty_loglevel_name = get_pretty_loglevel_name(
- event_rule_type, log_level);
+ pretty_loglevel_name = get_pretty_loglevel_name(event_rule_type, log_level);
if (pretty_loglevel_name) {
- _MSG(", log level %s %s", log_level_op,
- pretty_loglevel_name);
+ _MSG(", log level %s %s", log_level_op, pretty_loglevel_name);
} else {
_MSG(", log level %s %d", log_level_op, log_level);
}
MSG(")");
}
-static void print_kernel_probe_location(
- const struct lttng_kernel_probe_location *location)
+static void print_kernel_probe_location(const struct lttng_kernel_probe_location *location)
{
enum lttng_kernel_probe_location_status status;
switch (lttng_kernel_probe_location_get_type(location)) {
{
uint64_t address;
- status = lttng_kernel_probe_location_address_get_address(
- location, &address);
+ status = lttng_kernel_probe_location_address_get_address(location, &address);
if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) {
ERR("Getting kernel probe location address failed.");
goto end;
uint64_t offset;
const char *symbol_name;
- symbol_name = lttng_kernel_probe_location_symbol_get_name(
- location);
+ symbol_name = lttng_kernel_probe_location_symbol_get_name(location);
if (!symbol_name) {
ERR("Getting kernel probe location symbol name failed.");
goto end;
}
- status = lttng_kernel_probe_location_symbol_get_offset(
- location, &offset);
+ status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) {
ERR("Getting kernel probe location address failed.");
goto end;
return;
}
-static
-void print_event_rule_kernel_probe(const struct lttng_event_rule *event_rule)
+static void print_event_rule_kernel_probe(const struct lttng_event_rule *event_rule)
{
enum lttng_event_rule_status event_rule_status;
const char *name;
goto end;
}
- event_rule_status = lttng_event_rule_kernel_kprobe_get_location(
- event_rule, &location);
+ event_rule_status = lttng_event_rule_kernel_kprobe_get_location(event_rule, &location);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to get kprobe event rule's location.");
goto end;
return;
}
-static
-void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule)
+static void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule)
{
enum lttng_event_rule_status event_rule_status;
const char *name;
LTTNG_ASSERT(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE);
- event_rule_status = lttng_event_rule_kernel_uprobe_get_event_name(
- event_rule, &name);
+ event_rule_status = lttng_event_rule_kernel_uprobe_get_event_name(event_rule, &name);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to get uprobe event rule's name.");
goto end;
}
- event_rule_status = lttng_event_rule_kernel_uprobe_get_location(
- event_rule, &location);
+ event_rule_status = lttng_event_rule_kernel_uprobe_get_location(event_rule, &location);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to get uprobe event rule's location.");
goto end;
_MSG(" rule: %s (type: kernel:uprobe, ", name);
- userspace_probe_location_type =
- lttng_userspace_probe_location_get_type(location);
+ userspace_probe_location_type = lttng_userspace_probe_location_get_type(location);
switch (userspace_probe_location_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
{
const char *binary_path, *function_name;
- binary_path = lttng_userspace_probe_location_function_get_binary_path(
- location);
- function_name = lttng_userspace_probe_location_function_get_function_name(
- location);
+ binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
+ function_name = lttng_userspace_probe_location_function_get_function_name(location);
_MSG("location type: ELF, location: %s:%s", binary_path, function_name);
break;
{
const char *binary_path, *provider_name, *probe_name;
- binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
- location);
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
- location);
- probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
- location);
- _MSG("location type: SDT, location: %s:%s:%s", binary_path, provider_name, probe_name);
+ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
+ provider_name =
+ lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
+ _MSG("location type: SDT, location: %s:%s:%s",
+ binary_path,
+ provider_name,
+ probe_name);
break;
}
default:
return;
}
-static
-void print_event_rule_syscall(const struct lttng_event_rule *event_rule)
+static void print_event_rule_syscall(const struct lttng_event_rule *event_rule)
{
const char *pattern, *filter;
enum lttng_event_rule_status event_rule_status;
LTTNG_ASSERT(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL);
- emission_site =
- lttng_event_rule_kernel_syscall_get_emission_site(event_rule);
+ emission_site = lttng_event_rule_kernel_syscall_get_emission_site(event_rule);
- event_rule_status = lttng_event_rule_kernel_syscall_get_name_pattern(
- event_rule, &pattern);
+ event_rule_status = lttng_event_rule_kernel_syscall_get_name_pattern(event_rule, &pattern);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
- _MSG(" rule: %s (type: kernel:syscall:%s", pattern,
- lttng_event_rule_kernel_syscall_emission_site_str(
- emission_site));
+ _MSG(" rule: %s (type: kernel:syscall:%s",
+ pattern,
+ lttng_event_rule_kernel_syscall_emission_site_str(emission_site));
- event_rule_status = lttng_event_rule_kernel_syscall_get_filter(
- event_rule, &filter);
+ event_rule_status = lttng_event_rule_kernel_syscall_get_filter(event_rule, &filter);
if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) {
_MSG(", filter: %s", filter);
} else {
MSG(")");
}
-static
-void print_event_rule(const struct lttng_event_rule *event_rule)
+static void print_event_rule(const struct lttng_event_rule *event_rule)
{
- const enum lttng_event_rule_type event_rule_type =
- lttng_event_rule_get_type(event_rule);
+ const enum lttng_event_rule_type event_rule_type = lttng_event_rule_get_type(event_rule);
switch (event_rule_type) {
case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT:
}
}
-static
-void print_one_event_expr(const struct lttng_event_expr *event_expr)
+static void print_one_event_expr(const struct lttng_event_expr *event_expr)
{
enum lttng_event_expr_type type;
{
const char *name;
- name = lttng_event_expr_event_payload_field_get_name(
- event_expr);
+ name = lttng_event_expr_event_payload_field_get_name(event_expr);
_MSG("%s", name);
break;
{
const char *name;
- name = lttng_event_expr_channel_context_field_get_name(
- event_expr);
+ name = lttng_event_expr_channel_context_field_get_name(event_expr);
_MSG("$ctx.%s", name);
break;
const char *provider_name;
const char *type_name;
- provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(
- event_expr);
- type_name = lttng_event_expr_app_specific_context_field_get_type_name(
- event_expr);
+ provider_name =
+ lttng_event_expr_app_specific_context_field_get_provider_name(event_expr);
+ type_name = lttng_event_expr_app_specific_context_field_get_type_name(event_expr);
_MSG("$app.%s:%s", provider_name, type_name);
const struct lttng_event_expr *parent_expr;
enum lttng_event_expr_status status;
- parent_expr = lttng_event_expr_array_field_element_get_parent_expr(
- event_expr);
+ parent_expr = lttng_event_expr_array_field_element_get_parent_expr(event_expr);
LTTNG_ASSERT(parent_expr != NULL);
print_one_event_expr(parent_expr);
- status = lttng_event_expr_array_field_element_get_index(
- event_expr, &index);
+ status = lttng_event_expr_array_field_element_get_index(event_expr, &index);
LTTNG_ASSERT(status == LTTNG_EVENT_EXPR_STATUS_OK);
_MSG("[%u]", index);
}
}
-static
-void print_indentation(unsigned int indentation_level)
+static void print_indentation(unsigned int indentation_level)
{
unsigned int i;
}
}
-static
-void print_error_query_results(struct lttng_error_query_results *results,
- unsigned int base_indentation_level)
+static void print_error_query_results(struct lttng_error_query_results *results,
+ unsigned int base_indentation_level)
{
unsigned int i, count, printed_errors_count = 0;
enum lttng_error_query_results_status results_status;
const char *result_description;
uint64_t result_value;
- results_status = lttng_error_query_results_get_result(
- results, &result, i);
+ results_status = lttng_error_query_results_get_result(results, &result, i);
LTTNG_ASSERT(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
- result_status = lttng_error_query_result_get_name(
- result, &result_name);
+ result_status = lttng_error_query_result_get_name(result, &result_name);
LTTNG_ASSERT(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
- result_status = lttng_error_query_result_get_description(
- result, &result_description);
+ result_status =
+ lttng_error_query_result_get_description(result, &result_description);
LTTNG_ASSERT(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
-
if (lttng_error_query_result_get_type(result) ==
- LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
- result_status = lttng_error_query_result_counter_get_value(
- result, &result_value);
- LTTNG_ASSERT(result_status ==
- LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+ LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
+ result_status =
+ lttng_error_query_result_counter_get_value(result, &result_value);
+ LTTNG_ASSERT(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
if (result_value == 0) {
continue;
}
MSG("");
print_indentation(base_indentation_level + 1);
_MSG("Unknown error query result type for result '%s' (%s)",
- result_name, result_description);
+ result_name,
+ result_description);
continue;
}
}
}
}
-static void print_condition_event_rule_matches(
- const struct lttng_condition *condition)
+static void print_condition_event_rule_matches(const struct lttng_condition *condition)
{
const struct lttng_event_rule *event_rule;
enum lttng_condition_status condition_status;
unsigned int cap_desc_count, i;
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &event_rule);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
print_event_rule(event_rule);
- condition_status =
- lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &cap_desc_count);
+ condition_status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
+ condition, &cap_desc_count);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
if (cap_desc_count > 0) {
for (i = 0; i < cap_desc_count; i++) {
const struct lttng_event_expr *cap_desc =
- lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition, i);
_MSG(" - ");
print_one_event_expr(cap_desc);
}
static void print_action_errors(const struct lttng_trigger *trigger,
- const uint64_t *action_path_indexes,
- size_t action_path_length)
+ const uint64_t *action_path_indexes,
+ size_t action_path_length)
{
enum lttng_error_code error_query_ret;
struct lttng_error_query_results *results = NULL;
uid_t trigger_uid;
enum lttng_trigger_status trigger_status;
struct lttng_error_query *query;
- struct lttng_action_path *action_path = lttng_action_path_create(
- action_path_indexes, action_path_length);
+ struct lttng_action_path *action_path =
+ lttng_action_path_create(action_path_indexes, action_path_length);
LTTNG_ASSERT(action_path);
trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- error_query_ret = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, &results);
+ error_query_ret =
+ lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, &results);
if (error_query_ret != LTTNG_OK) {
ERR("Failed to query errors of trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-error_query_ret));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-error_query_ret));
goto end;
}
lttng_action_path_destroy(action_path);
}
-static
-void print_one_action(const struct lttng_trigger *trigger,
- const struct lttng_action *action,
- const uint64_t *action_path_indexes,
- size_t action_path_length)
+static void print_one_action(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ const uint64_t *action_path_indexes,
+ size_t action_path_length)
{
enum lttng_action_type action_type;
enum lttng_action_status action_status;
case LTTNG_ACTION_TYPE_NOTIFY:
_MSG("notify");
- action_status = lttng_action_notify_get_rate_policy(
- action, &policy);
+ action_status = lttng_action_notify_get_rate_policy(action, &policy);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to retrieve rate policy.");
goto end;
}
break;
case LTTNG_ACTION_TYPE_START_SESSION:
- action_status = lttng_action_start_session_get_session_name(
- action, &value);
+ action_status = lttng_action_start_session_get_session_name(action, &value);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
_MSG("start session `%s`", value);
- action_status = lttng_action_start_session_get_rate_policy(
- action, &policy);
+ action_status = lttng_action_start_session_get_rate_policy(action, &policy);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to retrieve rate policy.");
goto end;
}
break;
case LTTNG_ACTION_TYPE_STOP_SESSION:
- action_status = lttng_action_stop_session_get_session_name(
- action, &value);
+ action_status = lttng_action_stop_session_get_session_name(action, &value);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
_MSG("stop session `%s`", value);
- action_status = lttng_action_stop_session_get_rate_policy(
- action, &policy);
+ action_status = lttng_action_stop_session_get_rate_policy(action, &policy);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to retrieve rate policy.");
goto end;
}
break;
case LTTNG_ACTION_TYPE_ROTATE_SESSION:
- action_status = lttng_action_rotate_session_get_session_name(
- action, &value);
+ action_status = lttng_action_rotate_session_get_session_name(action, &value);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
_MSG("rotate session `%s`", value);
- action_status = lttng_action_rotate_session_get_rate_policy(
- action, &policy);
+ action_status = lttng_action_rotate_session_get_rate_policy(action, &policy);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to retrieve rate policy.");
goto end;
{
const struct lttng_snapshot_output *output;
- action_status = lttng_action_snapshot_session_get_session_name(
- action, &value);
+ action_status = lttng_action_snapshot_session_get_session_name(action, &value);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
_MSG("snapshot session `%s`", value);
- action_status = lttng_action_snapshot_session_get_output(
- action, &output);
+ action_status = lttng_action_snapshot_session_get_output(action, &output);
if (action_status == LTTNG_ACTION_STATUS_OK) {
const char *name;
uint64_t max_size;
}
}
- action_status = lttng_action_snapshot_session_get_rate_policy(
- action, &policy);
+ action_status = lttng_action_snapshot_session_get_rate_policy(action, &policy);
if (action_status != LTTNG_ACTION_STATUS_OK) {
ERR("Failed to retrieve rate policy.");
goto end;
switch (policy_type) {
case LTTNG_RATE_POLICY_TYPE_EVERY_N:
- policy_status = lttng_rate_policy_every_n_get_interval(
- policy, &policy_value);
+ policy_status =
+ lttng_rate_policy_every_n_get_interval(policy, &policy_value);
if (policy_status != LTTNG_RATE_POLICY_STATUS_OK) {
ERR("Failed to get action rate policy interval");
goto end;
/* The default is 1 so print only when it is a
* special case.
*/
- _MSG(", rate policy: every %" PRIu64
- " occurrences",
- policy_value);
+ _MSG(", rate policy: every %" PRIu64 " occurrences", policy_value);
}
break;
case LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N:
- policy_status = lttng_rate_policy_once_after_n_get_threshold(
- policy, &policy_value);
+ policy_status =
+ lttng_rate_policy_once_after_n_get_threshold(policy, &policy_value);
if (policy_status != LTTNG_RATE_POLICY_STATUS_OK) {
ERR("Failed to get action rate policy interval");
goto end;
}
- _MSG(", rate policy: once after %" PRIu64
- " occurrences",
- policy_value);
+ _MSG(", rate policy: once after %" PRIu64 " occurrences", policy_value);
break;
default:
abort();
}
MSG("");
- print_action_errors(trigger, action_path_indexes,
- action_path_length);
+ print_action_errors(trigger, action_path_indexes, action_path_length);
end:
return;
}
-static
-void print_trigger_errors(const struct lttng_trigger *trigger)
+static void print_trigger_errors(const struct lttng_trigger *trigger)
{
enum lttng_error_code error_query_ret;
struct lttng_error_query_results *results = NULL;
enum lttng_trigger_status trigger_status;
const char *trigger_name;
uid_t trigger_uid;
- struct lttng_error_query *query =
- lttng_error_query_trigger_create(trigger);
+ struct lttng_error_query *query = lttng_error_query_trigger_create(trigger);
LTTNG_ASSERT(query);
/*
trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- error_query_ret = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, &results);
+ error_query_ret =
+ lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, &results);
if (error_query_ret != LTTNG_OK) {
ERR("Failed to query errors of trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-error_query_ret));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-error_query_ret));
goto end;
}
lttng_error_query_results_destroy(results);
}
-static
-void print_condition_errors(const struct lttng_trigger *trigger)
+static void print_condition_errors(const struct lttng_trigger *trigger)
{
enum lttng_error_code error_query_ret;
struct lttng_error_query_results *results = NULL;
enum lttng_trigger_status trigger_status;
const char *trigger_name;
uid_t trigger_uid;
- struct lttng_error_query *query =
- lttng_error_query_condition_create(trigger);
+ struct lttng_error_query *query = lttng_error_query_condition_create(trigger);
LTTNG_ASSERT(query);
/*
trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- error_query_ret = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, &results);
+ error_query_ret =
+ lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, &results);
if (error_query_ret != LTTNG_OK) {
ERR("Failed to query errors of condition of trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-error_query_ret));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-error_query_ret));
goto end;
}
lttng_error_query_results_destroy(results);
}
-static
-void print_one_trigger(const struct lttng_trigger *trigger)
+static void print_one_trigger(const struct lttng_trigger *trigger)
{
const struct lttng_condition *condition;
enum lttng_condition_type condition_type;
for (i = 0; i < count; i++) {
const uint64_t action_path_index = i;
const struct lttng_action *subaction =
- lttng_action_list_get_at_index(
- action, i);
+ lttng_action_list_get_at_index(action, i);
_MSG(" ");
- print_one_action(trigger, subaction, &action_path_index,
- 1);
+ print_one_action(trigger, subaction, &action_path_index, 1);
}
} else {
_MSG(" action:");
return;
}
-static
-int compare_triggers_by_name(const void *a, const void *b)
+static int compare_triggers_by_name(const void *a, const void *b)
{
const struct lttng_trigger *trigger_a = *((const struct lttng_trigger **) a);
const struct lttng_trigger *trigger_b = *((const struct lttng_trigger **) b);
for (i = 0; i < num_triggers; i++) {
int add_ret;
const char *unused_name;
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
trigger_status = lttng_trigger_get_name(trigger, &unused_name);
switch (trigger_status) {
abort();
}
- add_ret = lttng_dynamic_pointer_array_add_pointer(
- &sorted_triggers, (void *) trigger);
+ add_ret =
+ lttng_dynamic_pointer_array_add_pointer(&sorted_triggers, (void *) trigger);
if (add_ret) {
ERR("Failed to allocate array of struct lttng_trigger *.");
goto error;
}
}
- qsort(sorted_triggers.array.buffer.data, num_triggers,
- sizeof(struct lttng_trigger *),
- compare_triggers_by_name);
+ qsort(sorted_triggers.array.buffer.data,
+ num_triggers,
+ sizeof(struct lttng_trigger *),
+ compare_triggers_by_name);
- for (i = 0; i < lttng_dynamic_pointer_array_get_count(&sorted_triggers);
- i++) {
- const struct lttng_trigger *trigger_to_print = (const struct lttng_trigger
- *)
- lttng_dynamic_pointer_array_get_pointer(
- &sorted_triggers, i);
+ for (i = 0; i < lttng_dynamic_pointer_array_get_count(&sorted_triggers); i++) {
+ const struct lttng_trigger *trigger_to_print =
+ (const struct lttng_trigger *) lttng_dynamic_pointer_array_get_pointer(
+ &sorted_triggers, i);
print_one_trigger(trigger_to_print);
}
return ret;
}
-static enum lttng_error_code mi_error_query_trigger_callback(
- const struct lttng_trigger *trigger,
- struct lttng_error_query_results **results)
+static enum lttng_error_code
+mi_error_query_trigger_callback(const struct lttng_trigger *trigger,
+ struct lttng_error_query_results **results)
{
enum lttng_error_code ret_code;
- struct lttng_error_query *query =
- lttng_error_query_trigger_create(trigger);
+ struct lttng_error_query *query = lttng_error_query_trigger_create(trigger);
LTTNG_ASSERT(results);
LTTNG_ASSERT(query);
- ret_code = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, results);
+ ret_code = lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, results);
if (ret_code != LTTNG_OK) {
enum lttng_trigger_status trigger_status;
const char *trigger_name;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
ERR("Failed to query errors of trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-ret_code));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-ret_code));
}
lttng_error_query_destroy(query);
return ret_code;
}
-static enum lttng_error_code mi_error_query_action_callback(
- const struct lttng_trigger *trigger,
- const struct lttng_action_path *action_path,
- struct lttng_error_query_results **results)
+static enum lttng_error_code
+mi_error_query_action_callback(const struct lttng_trigger *trigger,
+ const struct lttng_action_path *action_path,
+ struct lttng_error_query_results **results)
{
enum lttng_error_code ret_code;
- struct lttng_error_query *query =
- lttng_error_query_action_create(trigger, action_path);
+ struct lttng_error_query *query = lttng_error_query_action_create(trigger, action_path);
LTTNG_ASSERT(results);
LTTNG_ASSERT(query);
- ret_code = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, results);
+ ret_code = lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, results);
if (ret_code != LTTNG_OK) {
enum lttng_trigger_status trigger_status;
const char *trigger_name;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
ERR("Failed to query errors of an action for trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-ret_code));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-ret_code));
}
lttng_error_query_destroy(query);
return ret_code;
}
-static enum lttng_error_code mi_error_query_condition_callback(
- const struct lttng_trigger *trigger,
- struct lttng_error_query_results **results)
+static enum lttng_error_code
+mi_error_query_condition_callback(const struct lttng_trigger *trigger,
+ struct lttng_error_query_results **results)
{
enum lttng_error_code ret_code;
- struct lttng_error_query *query =
- lttng_error_query_condition_create(trigger);
+ struct lttng_error_query *query = lttng_error_query_condition_create(trigger);
LTTNG_ASSERT(results);
LTTNG_ASSERT(query);
- ret_code = lttng_error_query_execute(
- query, lttng_session_daemon_command_endpoint, results);
+ ret_code = lttng_error_query_execute(query, lttng_session_daemon_command_endpoint, results);
if (ret_code != LTTNG_OK) {
enum lttng_trigger_status trigger_status;
const char *trigger_name;
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
ERR("Failed to query errors of of condition for condition of trigger '%s' (owner uid: %d): %s",
- trigger_name, (int) trigger_uid,
- lttng_strerror(-ret_code));
+ trigger_name,
+ (int) trigger_uid,
+ lttng_strerror(-ret_code));
}
lttng_error_query_destroy(query);
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, 1, argv,
- true, NULL, NULL);
+ status = parse_next_item(argpar_iter, &argpar_item, 1, argv, true, NULL, NULL);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
assert(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
switch (descr->id) {
case OPT_HELP:
goto end;
case OPT_LIST_OPTIONS:
- list_cmd_options_argpar(
- stdout, list_trigger_options);
+ list_cmd_options_argpar(stdout, list_trigger_options);
ret = 0;
goto end;
}
} else {
- ERR("Unexpected argument: %s",
- argpar_item_non_opt_arg(argpar_item));
+ ERR("Unexpected argument: %s", argpar_item_non_opt_arg(argpar_item));
}
}
}
if (lttng_opt_mi) {
- mi_writer = mi_lttng_writer_create(
- fileno(stdout), lttng_opt_mi);
+ mi_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
if (!mi_writer) {
ret = CMD_ERROR;
goto end;
/* Open command element. */
ret = mi_lttng_writer_command_open(mi_writer,
- mi_lttng_element_command_list_trigger);
+ mi_lttng_element_command_list_trigger);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element. */
- ret = mi_lttng_writer_open_element(
- mi_writer, mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(mi_writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
.action_cb = mi_error_query_action_callback,
};
- ret = lttng_triggers_mi_serialize(
- triggers, mi_writer, &callbacks);
+ ret = lttng_triggers_mi_serialize(triggers, mi_writer, &callbacks);
if (ret != LTTNG_OK) {
- ERR("Error printing MI triggers: %s.",
- lttng_strerror(-ret));
+ ERR("Error printing MI triggers: %s.", lttng_strerror(-ret));
goto error;
}
} else {
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/config/session-config.hpp>
+#include <common/mi-lttng.hpp>
+
+#include <lttng/lttng.h>
+
#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.hpp>
-#include <common/config/session-config.hpp>
-#include <lttng/lttng.h>
-
-#include "../command.hpp"
-
static char *the_opt_input_path;
static char *the_opt_override_url;
static char *the_opt_override_session_name;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-load.1.h>
-;
+ ;
#endif
enum {
static struct poptOption the_load_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0},
- {"input-path", 'i', POPT_ARG_STRING, &the_opt_input_path, 0, 0, 0},
- {"force", 'f', POPT_ARG_NONE, 0, OPT_FORCE, 0, 0},
- {"override-url", 0, POPT_ARG_STRING, &the_opt_override_url, 0, 0, 0},
- {"override-name", 0, POPT_ARG_STRING, &the_opt_override_session_name, 0, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0 },
+ { "input-path", 'i', POPT_ARG_STRING, &the_opt_input_path, 0, 0, 0 },
+ { "force", 'f', POPT_ARG_NONE, 0, OPT_FORCE, 0, 0 },
+ { "override-url", 0, POPT_ARG_STRING, &the_opt_override_url, 0, 0, 0 },
+ { "override-name", 0, POPT_ARG_STRING, &the_opt_override_session_name, 0, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static int mi_partial_session(const char *session_name)
goto end;
}
- ret = mi_lttng_writer_write_element_string(the_writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(the_writer, config_element_name, session_name);
if (ret) {
goto end;
}
/* Path element */
if (the_opt_input_path) {
- ret = mi_lttng_writer_write_element_string(the_writer, config_element_path,
- the_opt_input_path);
+ ret = mi_lttng_writer_write_element_string(
+ the_writer, config_element_path, the_opt_input_path);
if (ret) {
goto end;
}
/* Session name override element */
if (the_opt_override_session_name) {
- ret = mi_lttng_writer_write_element_string(the_writer,
- config_element_name, the_opt_override_session_name);
+ ret = mi_lttng_writer_write_element_string(
+ the_writer, config_element_name, the_opt_override_session_name);
if (ret) {
goto end;
}
/* Session url override element */
if (the_opt_override_url) {
- ret = mi_lttng_writer_write_element_string(the_writer,
- mi_lttng_element_load_override_url,
- the_opt_override_url);
+ ret = mi_lttng_writer_write_element_string(
+ the_writer, mi_lttng_element_load_override_url, the_opt_override_url);
if (ret) {
goto end;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(the_writer,
- mi_lttng_element_command_load);
+ ret = mi_lttng_writer_command_open(the_writer, mi_lttng_element_command_load);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(the_writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(the_writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
input_path = NULL;
}
- ret = lttng_load_session_attr_set_input_url(session_attr,
- input_path);
+ ret = lttng_load_session_attr_set_input_url(session_attr, input_path);
if (ret) {
ERR("Invalid input path");
ret = CMD_ERROR;
}
/* Set the session name. NULL means all sessions should be loaded */
- ret = lttng_load_session_attr_set_session_name(session_attr,
- the_session_name);
+ ret = lttng_load_session_attr_set_session_name(session_attr, the_session_name);
if (ret) {
ERR("Invalid session name");
ret = CMD_ERROR;
/* Set the overrides attributes if any */
if (the_opt_override_url) {
- ret = lttng_load_session_attr_set_override_url(session_attr,
- the_opt_override_url);
+ ret = lttng_load_session_attr_set_override_url(session_attr, the_opt_override_url);
if (ret) {
ERR("Url override is invalid");
goto end;
ret = CMD_ERROR;
goto end;
}
- ret = lttng_load_session_attr_set_override_session_name(session_attr,
- the_opt_override_session_name);
+ ret = lttng_load_session_attr_set_override_session_name(
+ session_attr, the_opt_override_session_name);
if (ret) {
ERR("Failed to set session name override");
ret = CMD_ERROR;
} else if (the_session_name) {
ret = config_init((char *) the_session_name);
if (ret < 0) {
- WARN("Could not set %s as the default session",
- the_session_name);
+ WARN("Could not set %s as the default session", the_session_name);
}
MSG("Session %s has been loaded successfully", the_session_name);
} else {
}
if (the_opt_override_session_name) {
- MSG("Session name overridden with %s",
- the_opt_override_session_name);
+ MSG("Session name overridden with %s", the_opt_override_session_name);
}
if (the_opt_override_url) {
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(the_writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ the_writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
#include <ctype.h>
#include <popt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
static char *opt_session_name;
static char *session_name = NULL;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-metadata.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* { longName, shortName, argInfo, argPtr, value, descrip, argDesc, } */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0, },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, 0, 0, },
- { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL},
- { 0, 0, 0, 0, 0, 0, 0, },
+ {
+ "help",
+ 'h',
+ POPT_ARG_NONE,
+ 0,
+ OPT_HELP,
+ 0,
+ 0,
+ },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ {
+ "list-options",
+ 0,
+ POPT_ARG_NONE,
+ NULL,
+ OPT_LIST_OPTIONS,
+ 0,
+ 0,
+ },
+ { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ },
};
static struct cmd_struct actions[] = {
- { "regenerate", metadata_regenerate },
- { NULL, NULL } /* Array closure */
+ { "regenerate", metadata_regenerate }, { NULL, NULL } /* Array closure */
};
/*
return i;
}
-static int metadata_regenerate(int argc,
- const char **argv __attribute__((unused)))
+static int metadata_regenerate(int argc, const char **argv __attribute__((unused)))
{
int ret;
if (strcmp(argv[0], cmd->name) == 0) {
if (lttng_opt_mi) {
/* Action element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_metadata_action);
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_command_metadata_action);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Name of the action */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, argv[0]);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, argv[0]);
if (ret) {
ret = CMD_ERROR;
goto end;
goto end;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_metadata);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_metadata);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
#include <ctype.h>
#include <popt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
static char *opt_session_name;
static char *session_name = NULL;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-regenerate.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* { longName, shortName, argInfo, argPtr, value, descrip, argDesc, } */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0, },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, 0, 0, },
- { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL},
- { 0, 0, 0, 0, 0, 0, 0, },
+ {
+ "help",
+ 'h',
+ POPT_ARG_NONE,
+ 0,
+ OPT_HELP,
+ 0,
+ 0,
+ },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ {
+ "list-options",
+ 0,
+ POPT_ARG_NONE,
+ NULL,
+ OPT_LIST_OPTIONS,
+ 0,
+ 0,
+ },
+ { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ },
};
static struct cmd_struct actions[] = {
{ "metadata", regenerate_metadata },
{ "statedump", regenerate_statedump },
- { NULL, NULL } /* Array closure */
+ { NULL, NULL } /* Array closure */
};
/*
return i;
}
-static int regenerate_metadata(int argc,
- const char **argv __attribute__((unused)))
+static int regenerate_metadata(int argc, const char **argv __attribute__((unused)))
{
int ret;
return ret;
}
-static int regenerate_statedump(int argc,
- const char **argv __attribute__((unused)))
+static int regenerate_statedump(int argc, const char **argv __attribute__((unused)))
{
int ret;
if (strcmp(argv[0], cmd->name) == 0) {
if (lttng_opt_mi) {
/* Action element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_regenerate_action);
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_command_regenerate_action);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Name of the action */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, argv[0]);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, argv[0]);
if (ret) {
ret = CMD_ERROR;
goto end;
goto end;
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_regenerate);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_regenerate);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#include "../command.hpp"
-#include "common/argpar/argpar.h"
#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/argpar/argpar.h"
#include "common/mi-lttng.hpp"
+
#include <lttng/lttng.h>
+
#include <stdio.h>
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-remove-trigger.1.h>
-;
+ ;
#endif
enum {
OPT_OWNER_UID,
};
-static const
-struct argpar_opt_descr remove_trigger_options[] = {
+static const struct argpar_opt_descr remove_trigger_options[] = {
{ OPT_HELP, 'h', "help", false },
{ OPT_LIST_OPTIONS, '\0', "list-options", false },
{ OPT_OWNER_UID, '\0', "owner-uid", true },
ARGPAR_OPT_DESCR_SENTINEL,
};
-static
-bool assign_string(char **dest, const char *src, const char *opt_name)
+static bool assign_string(char **dest, const char *src, const char *opt_name)
{
bool ret;
struct mi_writer *mi_writer = NULL;
if (lttng_opt_mi) {
- mi_writer = mi_lttng_writer_create(
- fileno(stdout), lttng_opt_mi);
+ mi_writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
if (!mi_writer) {
ret = CMD_ERROR;
goto error;
/* Open command element. */
ret = mi_lttng_writer_command_open(mi_writer,
- mi_lttng_element_command_remove_trigger);
+ mi_lttng_element_command_remove_trigger);
if (ret) {
ret = CMD_ERROR;
goto error;
}
/* Open output element. */
- ret = mi_lttng_writer_open_element(
- mi_writer, mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(mi_writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto error;
while (true) {
enum parse_next_item_status status;
- status = parse_next_item(argpar_iter, &argpar_item, 1, argv,
- true, NULL, NULL);
+ status = parse_next_item(argpar_iter, &argpar_item, 1, argv, true, NULL, NULL);
if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
- status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+ status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
goto error;
} else if (status == PARSE_NEXT_ITEM_STATUS_END) {
break;
assert(status == PARSE_NEXT_ITEM_STATUS_OK);
if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
- const struct argpar_opt_descr *descr =
- argpar_item_opt_descr(argpar_item);
+ const struct argpar_opt_descr *descr = argpar_item_opt_descr(argpar_item);
const char *arg = argpar_item_opt_arg(argpar_item);
switch (descr->id) {
ret = 0;
goto end;
case OPT_LIST_OPTIONS:
- list_cmd_options_argpar(stdout,
- remove_trigger_options);
+ list_cmd_options_argpar(stdout, remove_trigger_options);
ret = 0;
goto end;
case OPT_OWNER_UID:
{
- if (!assign_string(&owner_uid, arg,
- "--owner-uid")) {
+ if (!assign_string(&owner_uid, arg, "--owner-uid")) {
goto error;
}
break;
abort();
}
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
if (trigger_uid == uid && strcmp(trigger_name, name) == 0) {
}
if (lttng_opt_mi) {
- ret_code = lttng_trigger_mi_serialize(
- trigger_to_remove, mi_writer, NULL);
+ ret_code = lttng_trigger_mi_serialize(trigger_to_remove, mi_writer, NULL);
if (ret_code != LTTNG_OK) {
goto error;
}
goto cleanup;
}
- mi_ret = mi_lttng_writer_write_element_bool(mi_writer,
- mi_lttng_element_command_success, ret ? 0 : 1);
+ mi_ret = mi_lttng_writer_write_element_bool(
+ mi_writer, mi_lttng_element_command_success, ret ? 0 : 1);
if (mi_ret) {
ret = 1;
goto cleanup;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <lttng/lttng.h>
+
+#include <ctype.h>
+#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-#include <ctype.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-#include <lttng/lttng.h>
static int opt_no_wait;
static struct mi_writer *writer;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-rotate.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static int rotate_tracing(char *session_name)
}
do {
- rotation_status = lttng_rotation_handle_get_state(handle,
- &rotation_state);
+ rotation_status = lttng_rotation_handle_get_state(handle, &rotation_state);
if (rotation_status != LTTNG_ROTATION_STATUS_OK) {
MSG("");
ERR("Failed to query the state of the rotation.");
skip_wait:
switch (rotation_state) {
case LTTNG_ROTATION_STATE_COMPLETED:
- rotation_status = lttng_rotation_handle_get_archive_location(
- handle, &location);
+ rotation_status = lttng_rotation_handle_get_archive_location(handle, &location);
if (rotation_status != LTTNG_ROTATION_STATUS_OK) {
ERR("Failed to retrieve the rotation's completed chunk archive location.");
cmd_ret = CMD_ERROR;
}
if (!lttng_opt_mi && print_location) {
- ret = print_trace_archive_location(location,
- session_name);
+ ret = print_trace_archive_location(location, session_name);
} else if (lttng_opt_mi) {
- ret = mi_lttng_rotate(writer, session_name, rotation_state,
- location);
+ ret = mi_lttng_rotate(writer, session_name, rotation_state, location);
}
if (ret < 0) {
}
/* Open rotate command */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_rotate);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_rotate);
if (ret) {
cmd_ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
cmd_ret = CMD_ERROR;
goto end;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success,
- cmd_ret == CMD_SUCCESS);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, cmd_ret == CMD_SUCCESS);
if (ret) {
cmd_ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
+#include <lttng/lttng.h>
+
#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-#include <lttng/lttng.h>
-
static char *opt_output_path;
static bool opt_force;
static bool opt_save_all;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-save.1.h>
-;
+ ;
#endif
enum {
static struct poptOption save_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"all", 'a', POPT_ARG_NONE, NULL, OPT_ALL, NULL, NULL},
- {"output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL},
- {"force", 'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
+ { "all", 'a', POPT_ARG_NONE, NULL, OPT_ALL, NULL, NULL },
+ { "output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL },
+ { "force", 'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static int mi_partial_session(const char *session_name)
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
/* Path element */
if (opt_output_path) {
- ret = mi_lttng_writer_write_element_string(writer, config_element_path,
- opt_output_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_path, opt_output_path);
if (ret) {
goto end;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_save);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_save);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;
} else {
/* Inform the user of what just happened on success. */
if (arg_session_name && opt_output_path) {
- MSG("Session %s saved successfully in %s.", arg_session_name,
- opt_output_path);
+ MSG("Session %s saved successfully in %s.",
+ arg_session_name,
+ opt_output_path);
} else if (arg_session_name && !opt_output_path) {
MSG("Session %s saved successfully.", arg_session_name);
} else if (!arg_session_name && opt_output_path) {
- MSG("All sessions have been saved successfully in %s.",
- opt_output_path);
+ MSG("All sessions have been saved successfully in %s.", opt_output_path);
} else {
MSG("All sessions have been saved successfully.");
}
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end_destroy;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-set-session.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
}
/* Session name */
- ret = mi_lttng_writer_write_element_string(writer , config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
struct lttng_session *sessions;
if (session_name && strlen(session_name) > NAME_MAX) {
- ERR("Session name too long. Length must be lower or equal to %d",
- NAME_MAX);
+ ERR("Session name too long. Length must be lower or equal to %d", NAME_MAX);
ret = CMD_ERROR;
goto end;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_set_session);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_set_session);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
#include <inttypes.h>
#include <popt.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/utils.hpp>
-#include <common/mi-lttng.hpp>
-#include <lttng/lttng.h>
-
-#include "../command.hpp"
-
static const char *opt_session_name;
static const char *opt_output_name;
static const char *opt_data_url;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-snapshot.1.h>
-;
+ ;
#endif
enum {
static struct poptOption snapshot_opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
- {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
- {"name", 'n', POPT_ARG_STRING, &opt_output_name, 0, 0, 0},
- {"max-size", 'm', POPT_ARG_STRING, 0, OPT_MAX_SIZE, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0 },
+ { "ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0 },
+ { "data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0 },
+ { "name", 'n', POPT_ARG_STRING, &opt_output_name, 0, 0, 0 },
+ { "max-size", 'm', POPT_ARG_STRING, 0, OPT_MAX_SIZE, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "list-commands", 0, POPT_ARG_NONE, NULL, OPT_LIST_COMMANDS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static struct cmd_struct actions[] = {
{ "del-output", cmd_del_output },
{ "list-output", cmd_list_output },
{ "record", cmd_record },
- { NULL, NULL } /* Array closure */
+ { NULL, NULL } /* Array closure */
};
/*
MSG("Snapshot output list for session %s", current_session_name);
if (lttng_opt_mi) {
- ret = mi_lttng_snapshot_output_session_name(writer,
- current_session_name);
+ ret = mi_lttng_snapshot_output_session_name(writer, current_session_name);
if (ret) {
ret = CMD_ERROR;
goto end;
while ((s_iter = lttng_snapshot_output_list_get_next(list)) != NULL) {
if (lttng_snapshot_output_get_maxsize(s_iter)) {
- MSG("%s[%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)", indent4,
- lttng_snapshot_output_get_id(s_iter),
- lttng_snapshot_output_get_name(s_iter),
- lttng_snapshot_output_get_ctrl_url(s_iter),
- lttng_snapshot_output_get_maxsize(s_iter));
+ MSG("%s[%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)",
+ indent4,
+ lttng_snapshot_output_get_id(s_iter),
+ lttng_snapshot_output_get_name(s_iter),
+ lttng_snapshot_output_get_ctrl_url(s_iter),
+ lttng_snapshot_output_get_maxsize(s_iter));
} else {
- MSG("%s[%" PRIu32 "] %s: %s", indent4,
- lttng_snapshot_output_get_id(s_iter),
- lttng_snapshot_output_get_name(s_iter),
- lttng_snapshot_output_get_ctrl_url(s_iter));
+ MSG("%s[%" PRIu32 "] %s: %s",
+ indent4,
+ lttng_snapshot_output_get_id(s_iter),
+ lttng_snapshot_output_get_name(s_iter),
+ lttng_snapshot_output_get_ctrl_url(s_iter));
}
output_seen = 1;
if (lttng_opt_mi) {
if (id != UINT32_MAX) {
MSG("Snapshot output id %" PRIu32 " successfully deleted for session %s",
- id, current_session_name);
+ id,
+ current_session_name);
} else {
MSG("Snapshot output %s successfully deleted for session %s",
- name, current_session_name);
+ name,
+ current_session_name);
}
if (lttng_opt_mi) {
- ret = mi_lttng_snapshot_del_output(writer, id, name,
- current_session_name);
+ ret = mi_lttng_snapshot_del_output(writer, id, name, current_session_name);
if (ret) {
ret = CMD_ERROR;
}
n_ptr = lttng_snapshot_output_get_name(output);
if (*n_ptr == '\0') {
int pret;
- pret = snprintf(name, sizeof(name), DEFAULT_SNAPSHOT_NAME "-%" PRIu32,
+ pret = snprintf(name,
+ sizeof(name),
+ DEFAULT_SNAPSHOT_NAME "-%" PRIu32,
lttng_snapshot_output_get_id(output));
if (pret < 0) {
PERROR("snprintf add output name");
n_ptr = name;
}
- MSG("Snapshot output successfully added for session %s",
- current_session_name);
+ MSG("Snapshot output successfully added for session %s", current_session_name);
if (opt_max_size) {
MSG(" [%" PRIu32 "] %s: %s (max size: %" PRIu64 " bytes)",
- lttng_snapshot_output_get_id(output), n_ptr,
- lttng_snapshot_output_get_ctrl_url(output),
- lttng_snapshot_output_get_maxsize(output));
+ lttng_snapshot_output_get_id(output),
+ n_ptr,
+ lttng_snapshot_output_get_ctrl_url(output),
+ lttng_snapshot_output_get_maxsize(output));
} else {
MSG(" [%" PRIu32 "] %s: %s",
- lttng_snapshot_output_get_id(output), n_ptr,
- lttng_snapshot_output_get_ctrl_url(output));
+ lttng_snapshot_output_get_id(output),
+ n_ptr,
+ lttng_snapshot_output_get_ctrl_url(output));
}
if (lttng_opt_mi) {
- ret = mi_lttng_snapshot_add_output(writer, current_session_name,
- n_ptr, output);
+ ret = mi_lttng_snapshot_add_output(writer, current_session_name, n_ptr, output);
if (ret) {
ret = CMD_ERROR;
}
switch (-ret) {
case LTTNG_ERR_SNAPSHOT_UNSUPPORTED:
ERR("Session \"%s\" contains a channel that is incompatible with the snapshot functionality.\nMake sure all channels are configured in 'mmap' output mode.",
- current_session_name);
+ current_session_name);
ret = CMD_ERROR;
break;
default:
}
static int cmd_list_output(int argc __attribute__((unused)),
- const char **argv __attribute__((unused)))
+ const char **argv __attribute__((unused)))
{
int ret;
if (url) {
MSG("Snapshot written at: %s", url);
} else if (opt_ctrl_url) {
- MSG("Snapshot written to ctrl: %s, data: %s", opt_ctrl_url,
- opt_data_url);
+ MSG("Snapshot written to ctrl: %s, data: %s", opt_ctrl_url, opt_data_url);
}
if (lttng_opt_mi) {
- ret = mi_lttng_snapshot_record(writer, url, opt_ctrl_url,
- opt_data_url);
+ ret = mi_lttng_snapshot_record(writer, url, opt_ctrl_url, opt_data_url);
if (ret) {
ret = CMD_ERROR;
}
goto end;
}
- if ((!opt_ctrl_url && opt_data_url) ||
- (opt_ctrl_url && !opt_data_url)) {
+ if ((!opt_ctrl_url && opt_data_url) || (opt_ctrl_url && !opt_data_url)) {
ERR("URLs must be specified for both data and control");
cmd_ret = CMD_ERROR;
goto end;
if (lttng_opt_mi) {
/* Action element */
- mi_ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_action);
+ mi_ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_command_action);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
}
/* Name of the action */
- mi_ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, argv[0]);
+ mi_ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, argv[0]);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
}
/* Open output element */
- mi_ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ mi_ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_command_output);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
cmd_ret = CMD_SUCCESS;
}
-
if (lttng_opt_mi) {
/* Close output and action element */
mi_ret = mi_lttng_close_multi_element(writer, 2);
}
/* Open command element */
- mi_ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_snapshot);
+ mi_ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_snapshot);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
}
/* Open output element */
- mi_ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ mi_ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
{
uint64_t val;
char *max_size_arg = poptGetOptArg(pc);
- const int parse_ret = utils_parse_size_suffix(
- (char *) max_size_arg, &val);
+ const int parse_ret = utils_parse_size_suffix((char *) max_size_arg, &val);
if (parse_ret < 0) {
- ERR("Unable to handle max-size value %s",
- max_size_arg);
+ ERR("Unable to handle max-size value %s", max_size_arg);
cmd_ret = CMD_ERROR;
free(max_size_arg);
goto end;
}
/* Success ? */
- mi_ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success,
- cmd_ret == CMD_SUCCESS);
+ mi_ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, cmd_ret == CMD_SUCCESS);
if (mi_ret) {
cmd_ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
-
static struct mi_writer *writer;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-start.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static int mi_print_session(char *session_name, int enabled)
}
/* Print session name element */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled,
- enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled);
if (ret) {
goto end;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_start);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_start);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
* Open sessions element
* For validation purpose
*/
- ret = mi_lttng_writer_open_element(writer,
- config_element_sessions);
+ ret = mi_lttng_writer_open_element(writer, config_element_sessions);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+#include "../utils.hpp"
+
+#include <config.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include "../command.hpp"
-#include "../utils.hpp"
-#include <config.h>
-
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-status.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
static int status(void)
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/mi-lttng.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-
static int opt_no_wait;
static struct mi_writer *writer;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-stop.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "no-wait", 'n', POPT_ARG_VAL, &opt_no_wait, 1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
}
/* Print session name element */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
/* Is enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled,
- enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, enabled);
if (ret) {
goto end;
}
}
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_stop);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_stop);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto end;
* Open sessions element
* For validation
*/
- ret = mi_lttng_writer_open_element(writer,
- config_element_sessions);
+ ret = mi_lttng_writer_open_element(writer, config_element_sessions);
if (ret) {
ret = CMD_ERROR;
goto end;
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, success);
if (ret) {
ret = CMD_ERROR;
goto end;
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/mi-lttng.hpp>
+#include <common/optional.hpp>
+#include <common/tracker.hpp>
+
+#include <lttng/lttng.h>
+
#include <ctype.h>
#include <popt.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-
#include <urcu/list.h>
-#include <common/dynamic-array.hpp>
-#include <common/mi-lttng.hpp>
-#include <common/optional.hpp>
-#include <common/dynamic-buffer.hpp>
-#include <common/tracker.hpp>
-
-#include <lttng/lttng.h>
-
-#include "../command.hpp"
-
namespace {
struct process_attr_command_args {
enum lttng_process_attr process_attr;
static struct poptOption long_options[] = {
/* { longName, shortName, argInfo, argPtr, value, descrip, argDesc, } */
- { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0, },
- { "session", 's', POPT_ARG_STRING, &opt_session_name, OPT_SESSION, 0, 0, },
- { "kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0, },
- { "userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0, },
- { "pid", 'p', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_PID, 0, 0, },
- { "vpid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_VPID, 0, 0, },
- { "uid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_UID, 0, 0, },
- { "vuid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_VUID, 0, 0, },
- { "gid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_GID, 0, 0, },
- { "vgid", 0, POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_str_arg, OPT_VGID, 0, 0, },
- { "all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0, },
- { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, 0, 0, },
- { 0, 0, 0, 0, 0, 0, 0, },
+ {
+ "help",
+ 'h',
+ POPT_ARG_NONE,
+ 0,
+ OPT_HELP,
+ 0,
+ 0,
+ },
+ {
+ "session",
+ 's',
+ POPT_ARG_STRING,
+ &opt_session_name,
+ OPT_SESSION,
+ 0,
+ 0,
+ },
+ {
+ "kernel",
+ 'k',
+ POPT_ARG_VAL,
+ &opt_kernel,
+ 1,
+ 0,
+ 0,
+ },
+ {
+ "userspace",
+ 'u',
+ POPT_ARG_VAL,
+ &opt_userspace,
+ 1,
+ 0,
+ 0,
+ },
+ {
+ "pid",
+ 'p',
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_PID,
+ 0,
+ 0,
+ },
+ {
+ "vpid",
+ 0,
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_VPID,
+ 0,
+ 0,
+ },
+ {
+ "uid",
+ 0,
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_UID,
+ 0,
+ 0,
+ },
+ {
+ "vuid",
+ 0,
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_VUID,
+ 0,
+ 0,
+ },
+ {
+ "gid",
+ 0,
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_GID,
+ 0,
+ 0,
+ },
+ {
+ "vgid",
+ 0,
+ POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL,
+ &opt_str_arg,
+ OPT_VGID,
+ 0,
+ 0,
+ },
+ {
+ "all",
+ 'a',
+ POPT_ARG_NONE,
+ 0,
+ OPT_ALL,
+ 0,
+ 0,
+ },
+ {
+ "list-options",
+ 0,
+ POPT_ARG_NONE,
+ NULL,
+ OPT_LIST_OPTIONS,
+ 0,
+ 0,
+ },
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ },
};
static struct process_attr_command_args
- process_attr_commands[LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID + 1];
+ process_attr_commands[LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID + 1];
static void process_attr_command_init(struct process_attr_command_args *cmd,
- enum lttng_process_attr process_attr)
+ enum lttng_process_attr process_attr)
{
cmd->process_attr = process_attr;
cmd->all = false;
break;
default:
ERR("The %s process attribute cannot be tracked in the user space domain.",
- lttng_process_attr_to_string(*process_attr));
+ lttng_process_attr_to_string(*process_attr));
supported = false;
break;
}
}
static enum cmd_error_code run_command_all(enum cmd_type cmd_type,
- const char *session_name,
- enum lttng_domain_type domain_type,
- enum lttng_process_attr process_attr,
- struct mi_writer *writer)
+ const char *session_name,
+ enum lttng_domain_type domain_type,
+ enum lttng_process_attr process_attr,
+ struct mi_writer *writer)
{
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
- const enum lttng_error_code handle_ret_code =
- lttng_session_get_tracker_handle(session_name,
- domain_type, process_attr,
- &tracker_handle);
+ const enum lttng_error_code handle_ret_code = lttng_session_get_tracker_handle(
+ session_name, domain_type, process_attr, &tracker_handle);
enum cmd_error_code cmd_ret = CMD_SUCCESS;
enum lttng_process_attr_tracker_handle_status status;
if (writer) {
- const int ret = mi_lttng_all_process_attribute_value(
- writer, process_attr, true);
+ const int ret = mi_lttng_all_process_attribute_value(writer, process_attr, true);
if (ret) {
cmd_ret = CMD_FATAL;
goto end;
}
status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- cmd_type == CMD_TRACK ?
- LTTNG_TRACKING_POLICY_INCLUDE_ALL :
+ tracker_handle,
+ cmd_type == CMD_TRACK ? LTTNG_TRACKING_POLICY_INCLUDE_ALL :
LTTNG_TRACKING_POLICY_EXCLUDE_ALL);
switch (status) {
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK:
if (cmd_type == CMD_TRACK) {
MSG("%s tracking policy set to `include all`",
- get_capitalized_process_attr_str(process_attr));
+ get_capitalized_process_attr_str(process_attr));
} else {
MSG("%s tracking policy set to `exclude all`",
- get_capitalized_process_attr_str(process_attr));
+ get_capitalized_process_attr_str(process_attr));
}
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST:
break;
default:
ERR("Unknown error encountered while setting tracking policy of %s tracker to `%s`",
- lttng_process_attr_to_string(process_attr),
- cmd_type == CMD_TRACK ? "include all" :
- "exclude all");
+ lttng_process_attr_to_string(process_attr),
+ cmd_type == CMD_TRACK ? "include all" : "exclude all");
cmd_ret = CMD_FATAL;
break;
}
end:
if (writer) {
- int ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success,
- cmd_ret == CMD_SUCCESS);
+ int ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_success, cmd_ret == CMD_SUCCESS);
if (ret) {
cmd_ret = CMD_FATAL;
}
static enum cmd_error_code run_command_string(enum cmd_type cmd_type,
- const char *session_name,
- enum lttng_domain_type domain_type,
- enum lttng_process_attr process_attr,
- const char *_args,
- struct mi_writer *writer)
+ const char *session_name,
+ enum lttng_domain_type domain_type,
+ enum lttng_process_attr process_attr,
+ const char *_args,
+ struct mi_writer *writer)
{
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
- const enum lttng_error_code handle_ret_code =
- lttng_session_get_tracker_handle(session_name,
- domain_type, process_attr,
- &tracker_handle);
+ const enum lttng_error_code handle_ret_code = lttng_session_get_tracker_handle(
+ session_name, domain_type, process_attr, &tracker_handle);
enum cmd_error_code cmd_ret = CMD_SUCCESS;
const char *one_value_str;
char *args = strdup(_args);
if (!policy_set) {
status = lttng_process_attr_tracker_handle_get_tracking_policy(
- tracker_handle, &policy);
+ tracker_handle, &policy);
if (status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
break;
}
if (policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- LTTNG_TRACKING_POLICY_INCLUDE_SET);
+ tracker_handle, LTTNG_TRACKING_POLICY_INCLUDE_SET);
if (status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
break;
}
}
if (is_numerical_argument) {
- const unsigned long one_value_int =
- strtoul(one_value_str, NULL, 10);
+ const unsigned long one_value_int = strtoul(one_value_str, NULL, 10);
if (writer) {
ret = mi_lttng_integral_process_attribute_value(
- writer, process_attr,
- (int64_t) one_value_int, true);
+ writer, process_attr, (int64_t) one_value_int, true);
if (ret) {
cmd_ret = CMD_FATAL;
goto end;
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) one_value_int) :
- lttng_process_attr_process_id_tracker_handle_remove_pid(
- tracker_handle,
- (pid_t) one_value_int);
+ lttng_process_attr_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) one_value_int) :
+ lttng_process_attr_process_id_tracker_handle_remove_pid(
+ tracker_handle, (pid_t) one_value_int);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) one_value_int) :
- lttng_process_attr_virtual_process_id_tracker_handle_remove_pid(
- tracker_handle,
- (pid_t) one_value_int);
+ lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) one_value_int) :
+ lttng_process_attr_virtual_process_id_tracker_handle_remove_pid(
+ tracker_handle, (pid_t) one_value_int);
break;
case LTTNG_PROCESS_ATTR_USER_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_user_id_tracker_handle_add_uid(
- tracker_handle,
- (uid_t) one_value_int) :
- lttng_process_attr_user_id_tracker_handle_remove_uid(
- tracker_handle,
- (uid_t) one_value_int);
+ lttng_process_attr_user_id_tracker_handle_add_uid(
+ tracker_handle, (uid_t) one_value_int) :
+ lttng_process_attr_user_id_tracker_handle_remove_uid(
+ tracker_handle, (uid_t) one_value_int);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_virtual_user_id_tracker_handle_add_uid(
- tracker_handle,
- (uid_t) one_value_int) :
- lttng_process_attr_virtual_user_id_tracker_handle_remove_uid(
- tracker_handle,
- (uid_t) one_value_int);
+ lttng_process_attr_virtual_user_id_tracker_handle_add_uid(
+ tracker_handle, (uid_t) one_value_int) :
+ lttng_process_attr_virtual_user_id_tracker_handle_remove_uid(
+ tracker_handle, (uid_t) one_value_int);
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_group_id_tracker_handle_add_gid(
- tracker_handle,
- (gid_t) one_value_int) :
- lttng_process_attr_group_id_tracker_handle_remove_gid(
- tracker_handle,
- (gid_t) one_value_int);
+ lttng_process_attr_group_id_tracker_handle_add_gid(
+ tracker_handle, (gid_t) one_value_int) :
+ lttng_process_attr_group_id_tracker_handle_remove_gid(
+ tracker_handle, (gid_t) one_value_int);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_virtual_group_id_tracker_handle_add_gid(
- tracker_handle,
- (gid_t) one_value_int) :
- lttng_process_attr_virtual_group_id_tracker_handle_remove_gid(
- tracker_handle,
- (gid_t) one_value_int);
+ lttng_process_attr_virtual_group_id_tracker_handle_add_gid(
+ tracker_handle, (gid_t) one_value_int) :
+ lttng_process_attr_virtual_group_id_tracker_handle_remove_gid(
+ tracker_handle, (gid_t) one_value_int);
break;
default:
abort();
} else {
if (writer) {
ret = mi_lttng_string_process_attribute_value(
- writer, process_attr,
- one_value_str, true);
+ writer, process_attr, one_value_str, true);
if (ret) {
cmd_ret = CMD_FATAL;
goto end;
switch (process_attr) {
case LTTNG_PROCESS_ATTR_USER_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_user_id_tracker_handle_add_user_name(
- tracker_handle,
- one_value_str) :
- lttng_process_attr_user_id_tracker_handle_remove_user_name(
- tracker_handle,
- one_value_str);
+ lttng_process_attr_user_id_tracker_handle_add_user_name(
+ tracker_handle, one_value_str) :
+ lttng_process_attr_user_id_tracker_handle_remove_user_name(
+ tracker_handle, one_value_str);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_virtual_user_id_tracker_handle_add_user_name(
- tracker_handle,
- one_value_str) :
- lttng_process_attr_virtual_user_id_tracker_handle_remove_user_name(
- tracker_handle,
- one_value_str);
+ lttng_process_attr_virtual_user_id_tracker_handle_add_user_name(
+ tracker_handle, one_value_str) :
+ lttng_process_attr_virtual_user_id_tracker_handle_remove_user_name(
+ tracker_handle, one_value_str);
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_group_id_tracker_handle_add_group_name(
- tracker_handle,
- one_value_str) :
- lttng_process_attr_group_id_tracker_handle_remove_group_name(
- tracker_handle,
- one_value_str);
+ lttng_process_attr_group_id_tracker_handle_add_group_name(
+ tracker_handle, one_value_str) :
+ lttng_process_attr_group_id_tracker_handle_remove_group_name(
+ tracker_handle, one_value_str);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
status = cmd_type == CMD_TRACK ?
- lttng_process_attr_virtual_group_id_tracker_handle_add_group_name(
- tracker_handle,
- one_value_str) :
- lttng_process_attr_virtual_group_id_tracker_handle_remove_group_name(
- tracker_handle,
- one_value_str);
+ lttng_process_attr_virtual_group_id_tracker_handle_add_group_name(
+ tracker_handle, one_value_str) :
+ lttng_process_attr_virtual_group_id_tracker_handle_remove_group_name(
+ tracker_handle, one_value_str);
break;
default:
ERR("%s is not a valid %s value; expected an integer",
- one_value_str,
- lttng_process_attr_to_string(
- process_attr));
+ one_value_str,
+ lttng_process_attr_to_string(process_attr));
cmd_ret = CMD_FATAL;
goto end;
}
}
- ret = asprintf(&prettified_arg,
- is_numerical_argument ? "%s" : "`%s`",
- one_value_str);
+ ret = asprintf(
+ &prettified_arg, is_numerical_argument ? "%s" : "`%s`", one_value_str);
if (ret < 0) {
PERROR("Failed to format argument `%s`", one_value_str);
cmd_ret = CMD_FATAL;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK:
if (cmd_type == CMD_TRACK) {
MSG("Added %s to the %s tracker inclusion set",
- one_value_str,
- lttng_process_attr_to_string(
- process_attr));
+ one_value_str,
+ lttng_process_attr_to_string(process_attr));
} else {
MSG("Removed %s from the %s tracker inclusion set",
- one_value_str,
- lttng_process_attr_to_string(
- process_attr));
+ one_value_str,
+ lttng_process_attr_to_string(process_attr));
}
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST:
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_EXISTS:
WARN("%s is already in the %s inclusion set",
- prettified_arg,
- lttng_process_attr_to_string(
- process_attr));
+ prettified_arg,
+ lttng_process_attr_to_string(process_attr));
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_MISSING:
WARN("%s is not in the %s the inclusion set",
- prettified_arg,
- lttng_process_attr_to_string(
- process_attr));
+ prettified_arg,
+ lttng_process_attr_to_string(process_attr));
break;
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_USER_NOT_FOUND:
ERR("User %s was not found", prettified_arg);
break;
default:
ERR("Unknown error encountered while %s %s %s %s tracker's inclusion set",
- cmd_type == CMD_TRACK ? "adding" :
- "removing",
- lttng_process_attr_to_string(
- process_attr),
- prettified_arg,
- cmd_type == CMD_TRACK ? "to" : "from");
+ cmd_type == CMD_TRACK ? "adding" : "removing",
+ lttng_process_attr_to_string(process_attr),
+ prettified_arg,
+ cmd_type == CMD_TRACK ? "to" : "from");
cmd_ret = CMD_FATAL;
break;
}
free(prettified_arg);
if (writer) {
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_success,
- cmd_ret == CMD_SUCCESS);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_success, cmd_ret == CMD_SUCCESS);
if (ret) {
cmd_ret = CMD_FATAL;
}
static enum cmd_error_code run_command(enum cmd_type cmd_type,
- const char *session_name,
- const struct process_attr_command_args *command_args,
- struct mi_writer *writer)
+ const char *session_name,
+ const struct process_attr_command_args *command_args,
+ struct mi_writer *writer)
{
- const enum lttng_domain_type domain_type =
- opt_kernel ? LTTNG_DOMAIN_KERNEL : LTTNG_DOMAIN_UST;
+ const enum lttng_domain_type domain_type = opt_kernel ? LTTNG_DOMAIN_KERNEL :
+ LTTNG_DOMAIN_UST;
enum cmd_error_code cmd_ret = CMD_SUCCESS;
unsigned int i;
const unsigned int string_arg_count =
- lttng_dynamic_pointer_array_get_count(
- &command_args->string_args);
+ lttng_dynamic_pointer_array_get_count(&command_args->string_args);
enum lttng_process_attr process_attr = command_args->process_attr;
if (opt_userspace) {
if (writer) {
/* Open tracker and trackers elements */
- const int ret = mi_lttng_process_attribute_tracker_open(
- writer, process_attr);
+ const int ret = mi_lttng_process_attribute_tracker_open(writer, process_attr);
if (ret) {
cmd_ret = CMD_FATAL;
goto end;
}
if (command_args->all) {
- cmd_ret = run_command_all(cmd_type, session_name, domain_type,
- process_attr, writer);
+ cmd_ret =
+ run_command_all(cmd_type, session_name, domain_type, process_attr, writer);
} else {
bool error_occurred = false;
for (i = 0; i < string_arg_count; i++) {
const char *arg = (const char *) lttng_dynamic_pointer_array_get_pointer(
- &command_args->string_args, i);
+ &command_args->string_args, i);
- cmd_ret = run_command_string(cmd_type, session_name,
- domain_type, process_attr, arg, writer);
+ cmd_ret = run_command_string(
+ cmd_type, session_name, domain_type, process_attr, arg, writer);
if (cmd_ret != CMD_SUCCESS) {
error_occurred = true;
if (cmd_ret == CMD_FATAL) {
if (writer) {
/* Close tracker and trackers elements */
- const int ret = mi_lttng_close_multi_element(
- writer, 2);
+ const int ret = mi_lttng_close_multi_element(writer, 2);
if (ret) {
cmd_ret = CMD_FATAL;
goto end;
* Add/remove tracker to/from session.
*/
static int cmd_track_untrack(enum cmd_type cmd_type,
- int argc,
- const char **argv,
- const char *help_msg __attribute__((unused)))
+ int argc,
+ const char **argv,
+ const char *help_msg __attribute__((unused)))
{
int opt, ret = 0;
bool sub_command_failed = false;
bool opt_all = false;
unsigned int selected_process_attr_tracker_count = 0;
const unsigned int command_count =
- sizeof(process_attr_commands) /
- sizeof(struct process_attr_command_args);
+ sizeof(process_attr_commands) / sizeof(struct process_attr_command_args);
enum cmd_error_code command_ret = CMD_SUCCESS;
static poptContext pc;
char *session_name = NULL;
continue;
}
ret = lttng_dynamic_pointer_array_add_pointer(
- &process_attr_commands[opt].string_args,
- opt_str_arg);
+ &process_attr_commands[opt].string_args, opt_str_arg);
if (ret) {
ERR("Allocation failed while parsing command arguments");
command_ret = CMD_ERROR;
}
}
- ret = print_missing_or_multiple_domains(
- opt_kernel + opt_userspace, false);
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace, false);
if (ret) {
command_ret = CMD_ERROR;
goto end;
}
process_attr_commands[i].all = true;
if (lttng_dynamic_pointer_array_get_count(
- &process_attr_commands[i]
- .string_args)) {
+ &process_attr_commands[i].string_args)) {
ERR("The --all option cannot be used with a list of process attribute values");
command_ret = CMD_ERROR;
goto end;
continue;
}
if (lttng_dynamic_pointer_array_get_count(
- &process_attr_commands[i]
- .string_args) == 0) {
+ &process_attr_commands[i].string_args) == 0) {
ERR("No process attribute value specified for %s tracker",
- get_capitalized_process_attr_str(
- process_attr_commands[i]
- .process_attr));
+ get_capitalized_process_attr_str(
+ process_attr_commands[i].process_attr));
command_ret = CMD_ERROR;
goto end;
}
if (writer) {
/* Open command element */
- ret = mi_lttng_writer_command_open(writer,
- get_mi_element_command(cmd_type));
+ ret = mi_lttng_writer_command_open(writer, get_mi_element_command(cmd_type));
if (ret) {
command_ret = CMD_ERROR;
goto end;
}
/* Open output element */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
command_ret = CMD_ERROR;
goto end;
if (!process_attr_commands[i].requested) {
continue;
}
- command_ret = run_command(cmd_type, session_name,
- &process_attr_commands[i], writer);
+ command_ret =
+ run_command(cmd_type, session_name, &process_attr_commands[i], writer);
if (command_ret != CMD_SUCCESS) {
sub_command_failed = true;
if (command_ret == CMD_FATAL) {
}
/* Success ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success,
- !sub_command_failed);
+ ret = mi_lttng_writer_write_element_bool(
+ writer, mi_lttng_element_command_success, !sub_command_failed);
if (ret) {
command_ret = CMD_ERROR;
goto end;
#ifdef LTTNG_EMBED_HELP
#include <lttng-track.1.h>
#else
- NULL
+ NULL
#endif
- ;
+ ;
return cmd_track_untrack(CMD_TRACK, argc, argv, help_msg);
}
#ifdef LTTNG_EMBED_HELP
#include <lttng-untrack.1.h>
#else
- NULL
+ NULL
#endif
- ;
+ ;
return cmd_track_untrack(CMD_UNTRACK, argc, argv, help_msg);
}
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+#include "version.hpp"
+
+#include <common/mi-lttng.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/mi-lttng.hpp>
-
-#include "../command.hpp"
-#include "version.hpp"
-
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-version.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/*
}
/* Open the command element */
- ret = mi_lttng_writer_command_open(writer,
- mi_lttng_element_command_version);
+ ret = mi_lttng_writer_command_open(writer, mi_lttng_element_command_version);
if (ret) {
ret = CMD_ERROR;
goto error;
}
/* Beginning of output */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_output);
if (ret) {
ret = CMD_ERROR;
goto error;
}
/* Print the machine interface of version */
- ret = mi_lttng_version(writer, &version,
- VERSION_DESCRIPTION, lttng_license);
+ ret = mi_lttng_version(writer, &version, VERSION_DESCRIPTION, lttng_license);
if (ret) {
ret = CMD_ERROR;
goto error;
ret = print_mi();
} else {
MSG("lttng version " VERSION " - " VERSION_NAME "%s",
- GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
+ GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
MSG("\n" VERSION_DESCRIPTION "\n");
MSG("Web site: https://lttng.org");
MSG("\n%s", lttng_license);
*/
#define _LGPL_SOURCE
+#include "../command.hpp"
+
+#include <common/spawn-viewer.hpp>
+
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/spawn-viewer.hpp>
-#include "../command.hpp"
-
static char *opt_viewer;
static char *opt_trace_path;
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
#include <lttng-view.1.h>
-;
+ ;
#endif
enum {
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"viewer", 'e', POPT_ARG_STRING, &opt_viewer, 0, 0, 0},
- {"trace-path", 't', POPT_ARG_STRING, &opt_trace_path, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
+ { "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0 },
+ { "list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL },
+ { "viewer", 'e', POPT_ARG_STRING, &opt_viewer, 0, 0, 0 },
+ { "trace-path", 't', POPT_ARG_STRING, &opt_trace_path, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0 }
};
/* Is the session we are trying to view is in live mode. */
goto error;
}
- ret = asprintf(&path, "net://localhost/host/%s/%s", hostname,
- session_name);
+ ret = asprintf(&path, "net://localhost/host/%s/%s", hostname, session_name);
if (ret < 0) {
PERROR("asprintf live path");
goto error;
/* Getting all sessions */
count = lttng_list_sessions(&sessions);
if (count < 0) {
- ERR("Unable to list sessions. Session name %s not found.",
- session_name);
+ ERR("Unable to list sessions. Session name %s not found.", session_name);
MSG("Is there a session daemon running?");
ret = CMD_ERROR;
goto free_error;
if (sessions[i].enabled && !session_live_mode) {
WARN("Session %s is running. Please stop it before reading it.",
- session_name);
+ session_name);
ret = CMD_ERROR;
goto free_sessions;
}
*/
#define _LGPL_SOURCE
+#include "conf.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/utils.hpp>
+
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/errno.hpp>
-#include <common/common.hpp>
-#include <common/utils.hpp>
-
-#include "conf.hpp"
-
/*
* Returns the path with '/CONFIG_FILENAME' added to it;
* path will be NULL if an error occurs.
return S_ISREG(info.st_mode) || S_ISDIR(info.st_mode);
}
-static
-int _config_read_session_name(const char *path, char **name)
+static int _config_read_session_name(const char *path, char **name)
{
int ret = 0;
FILE *fp;
char var[NAME_MAX], *session_name;
#if (NAME_MAX == 255)
-#define NAME_MAX_SCANF_IS_A_BROKEN_API "254"
+#define NAME_MAX_SCANF_IS_A_BROKEN_API "254"
#endif
session_name = calloc<char>(NAME_MAX);
}
while (!feof(fp)) {
- if ((ret = fscanf(fp, "%" NAME_MAX_SCANF_IS_A_BROKEN_API
- "[^'=']=%" NAME_MAX_SCANF_IS_A_BROKEN_API "s\n",
- var, session_name)) != 2) {
+ if ((ret = fscanf(fp,
+ "%" NAME_MAX_SCANF_IS_A_BROKEN_API
+ "[^'=']=%" NAME_MAX_SCANF_IS_A_BROKEN_API "s\n",
+ var,
+ session_name)) != 2) {
if (ret == -1) {
ERR("Missing session=NAME in config file.");
goto error_close;
*/
#include "loglevel.hpp"
+
+#include <ctype.h>
#include <string.h>
#include <strings.h>
-#include <ctype.h>
namespace {
struct loglevel_name_value {
};
} /* namespace */
-static
-const struct loglevel_name_value loglevel_values[] = {
+static const struct loglevel_name_value loglevel_values[] = {
{ .name = "EMERG", .value = LTTNG_LOGLEVEL_EMERG },
{ .name = "TRACE_EMERG", .value = LTTNG_LOGLEVEL_EMERG },
{ .name = "ALERT", .value = LTTNG_LOGLEVEL_ALERT },
{ .name = "TRACE_DEBUG", .value = LTTNG_LOGLEVEL_DEBUG },
};
-static
-const struct loglevel_name_value loglevel_log4j_values[] = {
+static const struct loglevel_name_value loglevel_log4j_values[] = {
{ .name = "OFF", .value = LTTNG_LOGLEVEL_LOG4J_OFF },
{ .name = "LOG4J_OFF", .value = LTTNG_LOGLEVEL_LOG4J_OFF },
{ .name = "FATAL", .value = LTTNG_LOGLEVEL_LOG4J_FATAL },
{ .name = "LOG4J_ALL", .value = LTTNG_LOGLEVEL_LOG4J_ALL },
};
-static
-const struct loglevel_name_value loglevel_jul_values[] = {
+static const struct loglevel_name_value loglevel_jul_values[] = {
{ .name = "OFF", .value = LTTNG_LOGLEVEL_JUL_OFF },
{ .name = "JUL_OFF", .value = LTTNG_LOGLEVEL_JUL_OFF },
{ .name = "SEVERE", .value = LTTNG_LOGLEVEL_JUL_SEVERE },
{ .name = "JUL_ALL", .value = LTTNG_LOGLEVEL_JUL_ALL },
};
-static
-const struct loglevel_name_value loglevel_python_values[] = {
+static const struct loglevel_name_value loglevel_python_values[] = {
{ .name = "CRITICAL", .value = LTTNG_LOGLEVEL_PYTHON_CRITICAL },
{ .name = "PYTHON_CRITICAL", .value = LTTNG_LOGLEVEL_PYTHON_CRITICAL },
{ .name = "ERROR", .value = LTTNG_LOGLEVEL_PYTHON_ERROR },
{ .name = "PYTHON_NOTSET", .value = LTTNG_LOGLEVEL_PYTHON_NOTSET },
};
-static
-bool string_equal_insensitive(const char *a, const char *b)
+static bool string_equal_insensitive(const char *a, const char *b)
{
return strcasecmp(a, b) == 0;
}
-static
-int lookup_value_from_name(const struct loglevel_name_value values[],
- size_t values_count, const char *name)
+static int lookup_value_from_name(const struct loglevel_name_value values[],
+ size_t values_count,
+ const char *name)
{
size_t i;
int ret = -1;
}
static bool loglevel_parse_range_string_common(const char *str,
- const struct loglevel_name_value *nvs,
- size_t nvs_count,
- int *min,
- int *max)
+ const struct loglevel_name_value *nvs,
+ size_t nvs_count,
+ int *min,
+ int *max)
{
bool ret;
int i;
int loglevel_name_to_value(const char *name, enum lttng_loglevel *loglevel)
{
- int ret = lookup_value_from_name(loglevel_values,
- ARRAY_SIZE(loglevel_values), name);
+ int ret = lookup_value_from_name(loglevel_values, ARRAY_SIZE(loglevel_values), name);
if (ret >= 0) {
*loglevel = (typeof(*loglevel)) ret;
}
bool loglevel_parse_range_string(const char *str,
- enum lttng_loglevel *min,
- enum lttng_loglevel *max)
+ enum lttng_loglevel *min,
+ enum lttng_loglevel *max)
{
int min_int, max_int;
- bool ret = loglevel_parse_range_string_common(str, loglevel_values,
- ARRAY_SIZE(loglevel_values), &min_int, &max_int);
+ bool ret = loglevel_parse_range_string_common(
+ str, loglevel_values, ARRAY_SIZE(loglevel_values), &min_int, &max_int);
*min = (lttng_loglevel) min_int;
*max = (lttng_loglevel) max_int;
return ret;
}
-int loglevel_log4j_name_to_value(
- const char *name, enum lttng_loglevel_log4j *loglevel)
+int loglevel_log4j_name_to_value(const char *name, enum lttng_loglevel_log4j *loglevel)
{
- int ret = lookup_value_from_name(loglevel_log4j_values,
- ARRAY_SIZE(loglevel_log4j_values),
- name);
+ int ret = lookup_value_from_name(
+ loglevel_log4j_values, ARRAY_SIZE(loglevel_log4j_values), name);
if (ret >= 0) {
*loglevel = (typeof(*loglevel)) ret;
}
bool loglevel_log4j_parse_range_string(const char *str,
- enum lttng_loglevel_log4j *min,
- enum lttng_loglevel_log4j *max)
+ enum lttng_loglevel_log4j *min,
+ enum lttng_loglevel_log4j *max)
{
int min_int, max_int;
- bool ret = loglevel_parse_range_string_common(str,
- loglevel_log4j_values,
- ARRAY_SIZE(loglevel_log4j_values), &min_int, &max_int);
+ bool ret = loglevel_parse_range_string_common(
+ str, loglevel_log4j_values, ARRAY_SIZE(loglevel_log4j_values), &min_int, &max_int);
*min = (lttng_loglevel_log4j) min_int;
*max = (lttng_loglevel_log4j) max_int;
return ret;
}
-int loglevel_jul_name_to_value(
- const char *name, enum lttng_loglevel_jul *loglevel)
+int loglevel_jul_name_to_value(const char *name, enum lttng_loglevel_jul *loglevel)
{
- int ret = lookup_value_from_name(loglevel_jul_values,
- ARRAY_SIZE(loglevel_jul_values),
- name);
+ int ret =
+ lookup_value_from_name(loglevel_jul_values, ARRAY_SIZE(loglevel_jul_values), name);
if (ret >= 0) {
*loglevel = (typeof(*loglevel)) ret;
}
bool loglevel_jul_parse_range_string(const char *str,
- enum lttng_loglevel_jul *min,
- enum lttng_loglevel_jul *max)
+ enum lttng_loglevel_jul *min,
+ enum lttng_loglevel_jul *max)
{
int min_int, max_int;
- bool ret = loglevel_parse_range_string_common(str, loglevel_jul_values,
- ARRAY_SIZE(loglevel_jul_values), &min_int, &max_int);
+ bool ret = loglevel_parse_range_string_common(
+ str, loglevel_jul_values, ARRAY_SIZE(loglevel_jul_values), &min_int, &max_int);
*min = (lttng_loglevel_jul) min_int;
*max = (lttng_loglevel_jul) max_int;
return ret;
}
-int loglevel_python_name_to_value(
- const char *name, enum lttng_loglevel_python *loglevel)
+int loglevel_python_name_to_value(const char *name, enum lttng_loglevel_python *loglevel)
{
- int ret = lookup_value_from_name(loglevel_python_values,
- ARRAY_SIZE(loglevel_python_values),
- name);
+ int ret = lookup_value_from_name(
+ loglevel_python_values, ARRAY_SIZE(loglevel_python_values), name);
if (ret >= 0) {
*loglevel = (typeof(*loglevel)) ret;
}
bool loglevel_python_parse_range_string(const char *str,
- enum lttng_loglevel_python *min,
- enum lttng_loglevel_python *max)
+ enum lttng_loglevel_python *min,
+ enum lttng_loglevel_python *max)
{
int min_int, max_int;
bool ret = loglevel_parse_range_string_common(str,
- loglevel_python_values,
- ARRAY_SIZE(loglevel_python_values), &min_int, &max_int);
+ loglevel_python_values,
+ ARRAY_SIZE(loglevel_python_values),
+ &min_int,
+ &max_int);
*min = (lttng_loglevel_python) min_int;
*max = (lttng_loglevel_python) max_int;
return ret;
}
-static
-const char *lookup_name_from_value(const struct loglevel_name_value values[],
- size_t values_count, int loglevel)
+static const char *
+lookup_name_from_value(const struct loglevel_name_value values[], size_t values_count, int loglevel)
{
size_t i;
const char *name = NULL;
const char *loglevel_value_to_name(int loglevel)
{
- return lookup_name_from_value(
- loglevel_values, ARRAY_SIZE(loglevel_values), loglevel);
+ return lookup_name_from_value(loglevel_values, ARRAY_SIZE(loglevel_values), loglevel);
}
const char *loglevel_log4j_value_to_name(int loglevel)
{
- return lookup_name_from_value(loglevel_log4j_values,
- ARRAY_SIZE(loglevel_log4j_values), loglevel);
+ return lookup_name_from_value(
+ loglevel_log4j_values, ARRAY_SIZE(loglevel_log4j_values), loglevel);
}
const char *loglevel_jul_value_to_name(int loglevel)
{
- return lookup_name_from_value(loglevel_jul_values,
- ARRAY_SIZE(loglevel_jul_values), loglevel);
+ return lookup_name_from_value(
+ loglevel_jul_values, ARRAY_SIZE(loglevel_jul_values), loglevel);
}
const char *loglevel_python_value_to_name(int loglevel)
{
- return lookup_name_from_value(loglevel_python_values,
- ARRAY_SIZE(loglevel_python_values), loglevel);
+ return lookup_name_from_value(
+ loglevel_python_values, ARRAY_SIZE(loglevel_python_values), loglevel);
}
*/
#define _LGPL_SOURCE
+#include "command.hpp"
+#include "version.hpp"
+
+#include <common/compat/getenv.hpp>
+#include <common/error.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/lttng.h>
+
+#include <ctype.h>
#include <getopt.h>
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <ctype.h>
-
-#include <lttng/lttng.h>
-#include <common/error.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/utils.hpp>
-
-#include "command.hpp"
-#include "version.hpp"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
#include <lttng.1.h>
#else
-NULL
+ NULL
#endif
-;
+ ;
/* Variables */
static const char *progname;
};
/* Getopt options. No first level command. */
-static struct option long_options[] = {
- {"version", 0, NULL, 'V'},
- {"help", 0, NULL, 'h'},
- {"group", 1, NULL, 'g'},
- {"verbose", 0, NULL, 'v'},
- {"quiet", 0, NULL, 'q'},
- {"mi", 1, NULL, 'm'},
- {"no-sessiond", 0, NULL, 'n'},
- {"sessiond-path", 1, NULL, OPT_SESSION_PATH},
- {"relayd-path", 1, NULL, OPT_RELAYD_PATH},
- {"list-options", 0, NULL, OPT_DUMP_OPTIONS},
- {"list-commands", 0, NULL, OPT_DUMP_COMMANDS},
- {NULL, 0, NULL, 0}
-};
+static struct option long_options[] = { { "version", 0, NULL, 'V' },
+ { "help", 0, NULL, 'h' },
+ { "group", 1, NULL, 'g' },
+ { "verbose", 0, NULL, 'v' },
+ { "quiet", 0, NULL, 'q' },
+ { "mi", 1, NULL, 'm' },
+ { "no-sessiond", 0, NULL, 'n' },
+ { "sessiond-path", 1, NULL, OPT_SESSION_PATH },
+ { "relayd-path", 1, NULL, OPT_RELAYD_PATH },
+ { "list-options", 0, NULL, OPT_DUMP_OPTIONS },
+ { "list-commands", 0, NULL, OPT_DUMP_COMMANDS },
+ { NULL, 0, NULL, 0 } };
/* First level command */
-static struct cmd_struct commands[] = {
- { "add-context", cmd_add_context},
- { "add-trigger", cmd_add_trigger},
- { "create", cmd_create},
- { "clear", cmd_clear},
- { "destroy", cmd_destroy},
- { "disable-channel", cmd_disable_channels},
- { "disable-event", cmd_disable_events},
- { "enable-channel", cmd_enable_channels},
- { "enable-event", cmd_enable_events},
- { "help", NULL},
- { "list", cmd_list},
- { "list-triggers", cmd_list_triggers},
- { "load", cmd_load},
- { "metadata", cmd_metadata},
- { "regenerate", cmd_regenerate},
- { "remove-trigger", cmd_remove_trigger},
- { "rotate", cmd_rotate},
- { "enable-rotation", cmd_enable_rotation},
- { "disable-rotation", cmd_disable_rotation},
- { "save", cmd_save},
- { "set-session", cmd_set_session},
- { "snapshot", cmd_snapshot},
- { "start", cmd_start},
- { "status", cmd_status},
- { "stop", cmd_stop},
- { "track", cmd_track},
- { "untrack", cmd_untrack},
- { "version", cmd_version},
- { "view", cmd_view},
- { NULL, NULL} /* Array closure */
+static struct cmd_struct commands[] = {
+ { "add-context", cmd_add_context },
+ { "add-trigger", cmd_add_trigger },
+ { "create", cmd_create },
+ { "clear", cmd_clear },
+ { "destroy", cmd_destroy },
+ { "disable-channel", cmd_disable_channels },
+ { "disable-event", cmd_disable_events },
+ { "enable-channel", cmd_enable_channels },
+ { "enable-event", cmd_enable_events },
+ { "help", NULL },
+ { "list", cmd_list },
+ { "list-triggers", cmd_list_triggers },
+ { "load", cmd_load },
+ { "metadata", cmd_metadata },
+ { "regenerate", cmd_regenerate },
+ { "remove-trigger", cmd_remove_trigger },
+ { "rotate", cmd_rotate },
+ { "enable-rotation", cmd_enable_rotation },
+ { "disable-rotation", cmd_disable_rotation },
+ { "save", cmd_save },
+ { "set-session", cmd_set_session },
+ { "snapshot", cmd_snapshot },
+ { "start", cmd_start },
+ { "status", cmd_status },
+ { "stop", cmd_stop },
+ { "track", cmd_track },
+ { "untrack", cmd_untrack },
+ { "version", cmd_version },
+ { "view", cmd_view },
+ { NULL, NULL } /* Array closure */
};
static void version(FILE *ofp)
{
- fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME "%s%s\n",
- progname,
- GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
- EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+ fprintf(ofp,
+ "%s (LTTng Trace Control) " VERSION " - " VERSION_NAME "%s%s\n",
+ progname,
+ GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+ EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
}
/*
/*
* clean_exit
*/
-__attribute__((noreturn))
-static void clean_exit(int code)
+__attribute__((noreturn)) static void clean_exit(int code)
{
DBG("Clean exit");
exit(code);
static void sighandler(int sig)
{
switch (sig) {
- case SIGTERM:
- DBG("SIGTERM caught");
- clean_exit(EXIT_FAILURE);
- break;
- default:
- DBG("Unknown signal %d caught", sig);
- break;
+ case SIGTERM:
+ DBG("SIGTERM caught");
+ clean_exit(EXIT_FAILURE);
+ break;
+ default:
+ DBG("Unknown signal %d caught", sig);
+ break;
}
return;
/* Special case for help command which needs the commands array */
if (strcmp(argv[0], "help") == 0) {
- ret = cmd_help(argc, (const char**) argv, commands);
+ ret = cmd_help(argc, (const char **) argv, commands);
goto end;
}
while (cmd->name != NULL) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
- ret = cmd->func(argc, (const char**) argv);
+ ret = cmd->func(argc, (const char **) argv);
goto end;
}
i++;
int opt, ret;
if (lttng_is_setuid_setgid()) {
- ERR("'%s' is not allowed to be executed as a setuid/setgid binary for security reasons. Aborting.", argv[0]);
+ ERR("'%s' is not allowed to be executed as a setuid/setgid binary for security reasons. Aborting.",
+ argv[0]);
clean_exit(EXIT_FAILURE);
}
case CMD_UNDEFINED:
if (!command_exists(*(argv + optind))) {
MSG("lttng: %s is not an lttng command. See 'lttng --help'.",
- *(argv + optind));
+ *(argv + optind));
} else {
- ERR("Unrecognized argument used with \'%s\' command",
- *(argv + optind));
+ ERR("Unrecognized argument used with \'%s\' command", *(argv + optind));
}
break;
case CMD_FATAL:
return ret;
}
-
/*
* main
*/
*
*/
-#include "uprobe.hpp"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
+#include "command.hpp"
#include "common/compat/getenv.hpp"
+#include "common/path.hpp"
#include "common/string-utils/string-utils.hpp"
#include "common/utils.hpp"
-#include "common/path.hpp"
#include "lttng/constant.h"
+#include "uprobe.hpp"
-#include "command.hpp"
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
/*
* Walk the directories in the PATH environment variable to find the target
* LTTNG_PATH_MAX bytes long.
* On failure, returns -1;
*/
-static
-int walk_command_search_path(const char *binary, char *binary_full_path)
+static int walk_command_search_path(const char *binary, char *binary_full_path)
{
char *tentative_binary_path = NULL;
char *command_search_path = NULL;
* Build the tentative path to the binary using the current
* search directory and the name of the binary.
*/
- ret = snprintf(tentative_binary_path, LTTNG_PATH_MAX, "%s/%s",
- curr_search_dir, binary);
+ ret = snprintf(
+ tentative_binary_path, LTTNG_PATH_MAX, "%s/%s", curr_search_dir, binary);
if (ret < 0) {
goto free_binary_path;
}
if (ret < LTTNG_PATH_MAX) {
- /*
- * Use STAT(2) to see if the file exists.
+ /*
+ * Use STAT(2) to see if the file exists.
*/
ret = stat(tentative_binary_path, &stat_output);
if (ret == 0) {
* symlink and not a special file (e.g.
* device).
*/
- if (S_ISREG(stat_output.st_mode)
- || S_ISLNK(stat_output.st_mode)) {
+ if (S_ISREG(stat_output.st_mode) || S_ISLNK(stat_output.st_mode)) {
/*
* Found a match, set the out parameter
* and return success.
*/
ret = lttng_strncpy(binary_full_path,
- tentative_binary_path,
- LTTNG_PATH_MAX);
+ tentative_binary_path,
+ LTTNG_PATH_MAX);
if (ret == -1) {
ERR("Source path does not fit "
- "in destination buffer.");
+ "in destination buffer.");
}
goto free_binary_path;
}
* elf:/path/to/binary:my_symbol+0x323
* elf:/path/to/binary:my_symbol+43
*/
-static
-int warn_userspace_probe_syntax(const char *symbol)
+static int warn_userspace_probe_syntax(const char *symbol)
{
int ret;
* target_path to the path to the binary.
*/
int parse_userspace_probe_opts(const char *opt,
- struct lttng_userspace_probe_location **probe_location)
+ struct lttng_userspace_probe_location **probe_location)
{
int ret = CMD_SUCCESS;
size_t num_token = 0;
case 2:
/* When the probe type is omitted we assume ELF for now. */
case 3:
- if (num_token == 3 && strcmp((const char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 0), "elf") == 0) {
+ if (num_token == 3 &&
+ strcmp((const char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 0),
+ "elf") == 0) {
target_path = (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 1);
symbol_name = (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 2);
} else if (num_token == 2) {
ret = CMD_ERROR;
goto end;
}
- lookup_method =
- lttng_userspace_probe_location_lookup_method_function_elf_create();
+ lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create();
if (!lookup_method) {
WARN("Failed to create ELF lookup method");
ret = CMD_ERROR;
}
break;
case 4:
- if (strcmp((const char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 0), "sdt") == 0) {
+ if (strcmp((const char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 0),
+ "sdt") == 0) {
target_path = (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 1);
- provider_name = (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 2);
+ provider_name =
+ (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 2);
probe_name = (char *) lttng_dynamic_pointer_array_get_pointer(&tokens, 3);
} else {
ret = CMD_ERROR;
}
probe_location_local = lttng_userspace_probe_location_function_create(
- real_target_path, symbol_name, lookup_method);
+ real_target_path, symbol_name, lookup_method);
if (!probe_location_local) {
WARN("Failed to create function probe location");
ret = CMD_ERROR;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
probe_location_local = lttng_userspace_probe_location_tracepoint_create(
- real_target_path, provider_name, probe_name, lookup_method);
+ real_target_path, provider_name, probe_name, lookup_method);
if (!probe_location_local) {
WARN("Failed to create function probe location");
ret = CMD_ERROR;
*/
#define _LGPL_SOURCE
-#include <stdlib.h>
-#include <ctype.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <inttypes.h>
-#include <unistd.h>
+#include "command.hpp"
+#include "conf.hpp"
+#include "utils.hpp"
+#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/utils.hpp>
-#include <common/defaults.hpp>
-#include "conf.hpp"
-#include "utils.hpp"
-#include "command.hpp"
+#include <arpa/inet.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
static const char *str_all = "ALL";
static const char *str_tracepoint = "Tracepoint";
static const char *str_userspace_probe = "Userspace Probe";
static const char *str_function = "Function";
-static
-char *_get_session_name(int quiet)
+static char *_get_session_name(int quiet)
{
const char *path;
char *session_name = NULL;
/* Get session name from config */
session_name = quiet ? config_read_session_name_quiet(path) :
- config_read_session_name(path);
+ config_read_session_name(path);
if (session_name == NULL) {
goto error;
}
* significant bit (from 1 to 32 on 32-bit, from 1 to 64 on 64-bit).
*/
#if defined(__i386) || defined(__x86_64)
-static inline
-unsigned int fls_u32(uint32_t x)
+static inline unsigned int fls_u32(uint32_t x)
{
int r;
"jnz 1f\n\t"
"movl $-1,%0\n\t"
"1:\n\t"
- : "=r" (r) : "rm" (x));
+ : "=r"(r)
+ : "rm"(x));
return r + 1;
}
#define HAS_FLS_U32
#endif
#if defined(__x86_64) && defined(__LP64__)
-static inline
-unsigned int fls_u64(uint64_t x)
+static inline unsigned int fls_u64(uint64_t x)
{
long r;
"jnz 1f\n\t"
"movq $-1,%0\n\t"
"1:\n\t"
- : "=r" (r) : "rm" (x));
+ : "=r"(r)
+ : "rm"(x));
return r + 1;
}
#define HAS_FLS_U64
#endif
#ifndef HAS_FLS_U64
-static __attribute__((unused))
-unsigned int fls_u64(uint64_t x)
+static __attribute__((unused)) unsigned int fls_u64(uint64_t x)
{
unsigned int r = 64;
#endif
#ifndef HAS_FLS_U32
-static __attribute__((unused))
-unsigned int fls_u32(uint32_t x)
+static __attribute__((unused)) unsigned int fls_u32(uint32_t x)
{
unsigned int r = 32;
}
#endif
-static
-unsigned int fls_ulong(unsigned long x)
+static unsigned int fls_ulong(unsigned long x)
{
#if (CAA_BITS_PER_LONG == 32)
return fls_u32(x);
} else {
PERROR("execlp");
}
- kill(getppid(), SIGTERM); /* wake parent */
+ kill(getppid(), SIGTERM); /* wake parent */
exit(EXIT_FAILURE);
} else if (pid > 0) {
goto end;
return ret;
}
-int print_missing_or_multiple_domains(unsigned int domain_count,
- bool include_agent_domains)
+int print_missing_or_multiple_domains(unsigned int domain_count, bool include_agent_domains)
{
int ret = 0;
if (domain_count == 0) {
ERR("Please specify a domain (--kernel/--userspace%s).",
- include_agent_domains ?
- "/--jul/--log4j/--python" :
- "");
+ include_agent_domains ? "/--jul/--log4j/--python" : "");
ret = -1;
} else if (domain_count > 1) {
ERR("Only one domain must be specified.");
}
}
if (!selected_session) {
- ERR("Failed to retrieve session \"%s\" description while printing session statistics.", session_name);
+ ERR("Failed to retrieve session \"%s\" description while printing session statistics.",
+ session_name);
ret = -1;
goto end;
}
goto end;
}
for (domain_idx = 0; domain_idx < nb_domains; domain_idx++) {
- struct lttng_handle *handle = lttng_create_handle(session_name,
- &domains[domain_idx]);
+ struct lttng_handle *handle =
+ lttng_create_handle(session_name, &domains[domain_idx]);
if (!handle) {
ERR("Failed to create session handle while printing session statistics.");
uint64_t discarded_events = 0, lost_packets = 0;
struct lttng_channel *channel = &channels[channel_idx];
- ret = lttng_channel_get_discarded_event_count(channel,
- &discarded_events);
+ ret = lttng_channel_get_discarded_event_count(channel, &discarded_events);
if (ret) {
ERR("Failed to retrieve discarded event count from channel %s",
- channel->name);
+ channel->name);
}
- ret = lttng_channel_get_lost_packet_count(channel,
- &lost_packets);
+ ret = lttng_channel_get_lost_packet_count(channel, &lost_packets);
if (ret) {
ERR("Failed to retrieve lost packet count from channel %s",
- channel->name);
+ channel->name);
}
discarded_events_total += discarded_events;
lttng_destroy_handle(handle);
}
- print_discarded_events = discarded_events_total > 0 &&
- !selected_session->snapshot_mode;
- print_lost_packets = lost_packets_total > 0 &&
- !selected_session->snapshot_mode;
+ print_discarded_events = discarded_events_total > 0 && !selected_session->snapshot_mode;
+ print_lost_packets = lost_packets_total > 0 && !selected_session->snapshot_mode;
if (print_discarded_events && print_lost_packets) {
ret = asprintf(&stats_str,
- "Warning: %" PRIu64
- " events were discarded and %" PRIu64
- " packets were lost, please refer to "
- "the documentation on channel configuration.",
- discarded_events_total, lost_packets_total);
+ "Warning: %" PRIu64 " events were discarded and %" PRIu64
+ " packets were lost, please refer to "
+ "the documentation on channel configuration.",
+ discarded_events_total,
+ lost_packets_total);
} else if (print_discarded_events) {
ret = asprintf(&stats_str,
- "Warning: %" PRIu64
- " events were discarded, please refer to "
- "the documentation on channel configuration.",
- discarded_events_total);
+ "Warning: %" PRIu64 " events were discarded, please refer to "
+ "the documentation on channel configuration.",
+ discarded_events_total);
} else if (print_lost_packets) {
ret = asprintf(&stats_str,
- "Warning: %" PRIu64
- " packets were lost, please refer to "
- "the documentation on channel configuration.",
- lost_packets_total);
+ "Warning: %" PRIu64 " packets were lost, please refer to "
+ "the documentation on channel configuration.",
+ lost_packets_total);
} else {
ret = 0;
}
return ret;
}
-int print_trace_archive_location(
- const struct lttng_trace_archive_location *location,
- const char *session_name)
+int print_trace_archive_location(const struct lttng_trace_archive_location *location,
+ const char *session_name)
{
int ret = 0;
enum lttng_trace_archive_location_type location_type;
location_type = lttng_trace_archive_location_get_type(location);
- _MSG("Trace chunk archive for session %s is now readable",
- session_name);
+ _MSG("Trace chunk archive for session %s is now readable", session_name);
switch (location_type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
{
const char *absolute_path;
- status = lttng_trace_archive_location_local_get_absolute_path(
- location, &absolute_path);
+ status = lttng_trace_archive_location_local_get_absolute_path(location,
+ &absolute_path);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
enum lttng_trace_archive_location_relay_protocol_type protocol;
/* Fetch all relay location parameters. */
- status = lttng_trace_archive_location_relay_get_protocol_type(
- location, &protocol);
+ status = lttng_trace_archive_location_relay_get_protocol_type(location, &protocol);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_host(
- location, &host);
+ status = lttng_trace_archive_location_relay_get_host(location, &host);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_control_port(
- location, &control_port);
+ status = lttng_trace_archive_location_relay_get_control_port(location,
+ &control_port);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_data_port(
- location, &data_port);
+ status = lttng_trace_archive_location_relay_get_data_port(location, &data_port);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_relative_path(
- location, &relative_path);
+ status = lttng_trace_archive_location_relay_get_relative_path(location,
+ &relative_path);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
break;
}
- MSG(" on relay %s://%s/%s [control port %" PRIu16 ", data port %"
- PRIu16 "]", protocol_str, host,
- relative_path, control_port, data_port);
+ MSG(" on relay %s://%s/%s [control port %" PRIu16 ", data port %" PRIu16 "]",
+ protocol_str,
+ host,
+ relative_path,
+ control_port,
+ data_port);
printed_location = true;
break;
}
#include <common/error.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
#include <lttng/action/notify-internal.hpp>
}
void lttng_action_init(struct lttng_action *action,
- enum lttng_action_type type,
- action_validate_cb validate,
- action_serialize_cb serialize,
- action_equal_cb equal,
- action_destroy_cb destroy,
- action_get_rate_policy_cb get_rate_policy,
- action_add_error_query_results_cb add_error_query_results,
- action_mi_serialize_cb mi)
+ enum lttng_action_type type,
+ action_validate_cb validate,
+ action_serialize_cb serialize,
+ action_equal_cb equal,
+ action_destroy_cb destroy,
+ action_get_rate_policy_cb get_rate_policy,
+ action_add_error_query_results_cb add_error_query_results,
+ action_mi_serialize_cb mi)
{
urcu_ref_init(&action->ref);
action->type = type;
action->execution_failure_counter = 0;
}
-static
-void action_destroy_ref(struct urcu_ref *ref)
+static void action_destroy_ref(struct urcu_ref *ref)
{
- struct lttng_action *action =
- lttng::utils::container_of(ref, <tng_action::ref);
+ struct lttng_action *action = lttng::utils::container_of(ref, <tng_action::ref);
action->destroy(action);
}
return valid;
}
-int lttng_action_serialize(struct lttng_action *action,
- struct lttng_payload *payload)
+int lttng_action_serialize(struct lttng_action *action, struct lttng_payload *payload)
{
int ret;
struct lttng_action_comm action_comm = {
.action_type = (int8_t) action->type,
};
- ret = lttng_dynamic_buffer_append(&payload->buffer, &action_comm,
- sizeof(action_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &action_comm, sizeof(action_comm));
if (ret) {
goto end;
}
}
ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
- struct lttng_action **action)
+ struct lttng_action **action)
{
ssize_t consumed_len, specific_action_consumed_len;
action_create_from_payload_cb create_from_payload_cb;
const struct lttng_action_comm *action_comm;
const struct lttng_payload_view action_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*action_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*action_comm));
if (!view || !action) {
consumed_len = -1;
action_comm = (const struct lttng_action_comm *) action_comm_view.buffer.data;
DBG("Create action from payload: action-type=%s",
- lttng_action_type_string((lttng_action_type) action_comm->action_type));
+ lttng_action_type_string((lttng_action_type) action_comm->action_type));
switch (action_comm->action_type) {
case LTTNG_ACTION_TYPE_NOTIFY:
create_from_payload_cb = lttng_action_notify_create_from_payload;
break;
case LTTNG_ACTION_TYPE_ROTATE_SESSION:
- create_from_payload_cb =
- lttng_action_rotate_session_create_from_payload;
+ create_from_payload_cb = lttng_action_rotate_session_create_from_payload;
break;
case LTTNG_ACTION_TYPE_SNAPSHOT_SESSION:
- create_from_payload_cb =
- lttng_action_snapshot_session_create_from_payload;
+ create_from_payload_cb = lttng_action_snapshot_session_create_from_payload;
break;
case LTTNG_ACTION_TYPE_START_SESSION:
- create_from_payload_cb =
- lttng_action_start_session_create_from_payload;
+ create_from_payload_cb = lttng_action_start_session_create_from_payload;
break;
case LTTNG_ACTION_TYPE_STOP_SESSION:
- create_from_payload_cb =
- lttng_action_stop_session_create_from_payload;
+ create_from_payload_cb = lttng_action_stop_session_create_from_payload;
break;
case LTTNG_ACTION_TYPE_LIST:
create_from_payload_cb = lttng_action_list_create_from_payload;
break;
default:
ERR("Failed to create action from payload, unhandled action type: action-type=%u (%s)",
- action_comm->action_type,
- lttng_action_type_string(
- (lttng_action_type) action_comm->action_type));
+ action_comm->action_type,
+ lttng_action_type_string((lttng_action_type) action_comm->action_type));
consumed_len = -1;
goto end;
}
{
/* Create buffer view for the action-type-specific data. */
struct lttng_payload_view specific_action_view =
- lttng_payload_view_from_view(view,
- sizeof(struct lttng_action_comm),
- -1);
+ lttng_payload_view_from_view(view, sizeof(struct lttng_action_comm), -1);
- specific_action_consumed_len = create_from_payload_cb(
- &specific_action_view, action);
+ specific_action_consumed_len =
+ create_from_payload_cb(&specific_action_view, action);
}
if (specific_action_consumed_len < 0) {
ERR("Failed to create specific action from buffer.");
LTTNG_ASSERT(*action);
- consumed_len = sizeof(struct lttng_action_comm) +
- specific_action_consumed_len;
+ consumed_len = sizeof(struct lttng_action_comm) + specific_action_consumed_len;
end:
return consumed_len;
}
-bool lttng_action_is_equal(const struct lttng_action *a,
- const struct lttng_action *b)
+bool lttng_action_is_equal(const struct lttng_action *a, const struct lttng_action *b)
{
bool is_equal = false;
goto end;
}
- execute = lttng_rate_policy_should_execute(
- policy, action->execution_request_counter);
+ execute = lttng_rate_policy_should_execute(policy, action->execution_request_counter);
end:
return execute;
}
-enum lttng_action_status lttng_action_add_error_query_results(
- const struct lttng_action *action,
- struct lttng_error_query_results *results)
+enum lttng_action_status
+lttng_action_add_error_query_results(const struct lttng_action *action,
+ struct lttng_error_query_results *results)
{
return action->add_error_query_results(action, results);
}
-enum lttng_action_status lttng_action_generic_add_error_query_results(
- const struct lttng_action *action,
- struct lttng_error_query_results *results)
+enum lttng_action_status
+lttng_action_generic_add_error_query_results(const struct lttng_action *action,
+ struct lttng_error_query_results *results)
{
enum lttng_action_status action_status;
struct lttng_error_query_result *error_counter = NULL;
- const uint64_t execution_failure_counter =
- uatomic_read(&action->execution_failure_counter);
+ const uint64_t execution_failure_counter = uatomic_read(&action->execution_failure_counter);
error_counter = lttng_error_query_result_counter_create(
- "total execution failures",
- "Aggregated count of errors encountered when executing the action",
- execution_failure_counter);
+ "total execution failures",
+ "Aggregated count of errors encountered when executing the action",
+ execution_failure_counter);
if (!error_counter) {
action_status = LTTNG_ACTION_STATUS_ERROR;
goto end;
}
- if (lttng_error_query_results_add_result(
- results, error_counter)) {
+ if (lttng_error_query_results_add_result(results, error_counter)) {
action_status = LTTNG_ACTION_STATUS_ERROR;
goto end;
}
return action_status;
}
-enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
- const struct lttng_action *action,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks,
- struct lttng_dynamic_array *action_path_indexes)
+enum lttng_error_code
+lttng_action_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes)
{
int ret;
enum lttng_error_code ret_code;
* Recursion is safe since action lists can't be nested for
* the moment.
*/
- ret_code = lttng_action_list_mi_serialize(trigger, action, writer,
- error_query_callbacks, action_path_indexes);
+ ret_code = lttng_action_list_mi_serialize(
+ trigger, action, writer, error_query_callbacks, action_path_indexes);
if (ret_code != LTTNG_OK) {
goto end;
}
if (error_query_callbacks && error_query_callbacks->action_cb) {
const uint64_t *action_path_indexes_raw_pointer = NULL;
const size_t action_path_indexes_size =
- lttng_dynamic_array_get_count(
- action_path_indexes);
+ lttng_dynamic_array_get_count(action_path_indexes);
if (action_path_indexes_size != 0) {
action_path_indexes_raw_pointer =
- (const uint64_t *) action_path_indexes
- ->buffer.data;
+ (const uint64_t *) action_path_indexes->buffer.data;
}
- action_path = lttng_action_path_create(
- action_path_indexes_raw_pointer,
- action_path_indexes_size);
+ action_path = lttng_action_path_create(action_path_indexes_raw_pointer,
+ action_path_indexes_size);
LTTNG_ASSERT(action_path);
ret_code = error_query_callbacks->action_cb(
- trigger, action_path, &error_query_results);
+ trigger, action_path, &error_query_results);
if (ret_code != LTTNG_OK) {
goto end;
}
/* Serialize the error query results. */
- ret_code = lttng_error_query_results_mi_serialize(
- error_query_results, writer);
+ ret_code = lttng_error_query_results_mi_serialize(error_query_results, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
#include <common/mi-lttng.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
#include <lttng/action/list.h>
-#define IS_LIST_ACTION(action) \
- (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_LIST)
+#define IS_LIST_ACTION(action) (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_LIST)
namespace {
struct lttng_action_list {
lttng_action_destroy(element);
}
-static struct lttng_action_list *action_list_from_action(
- const struct lttng_action *action)
+static struct lttng_action_list *action_list_from_action(const struct lttng_action *action)
{
LTTNG_ASSERT(action);
return lttng::utils::container_of(action, <tng_action_list::parent);
}
-static const struct lttng_action_list *action_list_from_action_const(
- const struct lttng_action *action)
+static const struct lttng_action_list *
+action_list_from_action_const(const struct lttng_action *action)
{
LTTNG_ASSERT(action);
for (i = 0; i < count; i++) {
struct lttng_action *child =
- (lttng_action *) lttng_dynamic_pointer_array_get_pointer(
- &action_list->actions, i);
+ (lttng_action *) lttng_dynamic_pointer_array_get_pointer(
+ &action_list->actions, i);
LTTNG_ASSERT(child);
return valid;
}
-static bool lttng_action_list_is_equal(
- const struct lttng_action *_a, const struct lttng_action *_b)
+static bool lttng_action_list_is_equal(const struct lttng_action *_a, const struct lttng_action *_b)
{
bool is_equal = false;
unsigned int i;
unsigned int a_count, b_count;
- if (lttng_action_list_get_count(_a, &a_count) !=
- LTTNG_ACTION_STATUS_OK) {
+ if (lttng_action_list_get_count(_a, &a_count) != LTTNG_ACTION_STATUS_OK) {
goto end;
}
- if (lttng_action_list_get_count(_b, &b_count) !=
- LTTNG_ACTION_STATUS_OK) {
+ if (lttng_action_list_get_count(_b, &b_count) != LTTNG_ACTION_STATUS_OK) {
goto end;
}
}
for (i = 0; i < a_count; i++) {
- const struct lttng_action *child_a =
- lttng_action_list_get_at_index(_a, i);
- const struct lttng_action *child_b =
- lttng_action_list_get_at_index(_b, i);
+ const struct lttng_action *child_a = lttng_action_list_get_at_index(_a, i);
+ const struct lttng_action *child_b = lttng_action_list_get_at_index(_b, i);
LTTNG_ASSERT(child_a);
LTTNG_ASSERT(child_b);
return is_equal;
}
-static int lttng_action_list_serialize(
- struct lttng_action *action, struct lttng_payload *payload)
+static int lttng_action_list_serialize(struct lttng_action *action, struct lttng_payload *payload)
{
struct lttng_action_list *action_list;
struct lttng_action_list_comm comm;
comm.action_count = count;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
ret = -1;
goto end;
for (i = 0; i < count; i++) {
struct lttng_action *child =
- (lttng_action *) lttng_dynamic_pointer_array_get_pointer(
- &action_list->actions, i);
+ (lttng_action *) lttng_dynamic_pointer_array_get_pointer(
+ &action_list->actions, i);
LTTNG_ASSERT(child);
return;
}
-ssize_t lttng_action_list_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **p_action)
+ssize_t lttng_action_list_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **p_action)
{
ssize_t consumed_len;
const struct lttng_action_list_comm *comm;
for (i = 0; i < comm->action_count; i++) {
ssize_t consumed_len_child;
- struct lttng_payload_view child_view =
- lttng_payload_view_from_view(view, consumed_len,
- view->buffer.size - consumed_len);
+ struct lttng_payload_view child_view = lttng_payload_view_from_view(
+ view, consumed_len, view->buffer.size - consumed_len);
if (!lttng_payload_view_is_valid(&child_view)) {
consumed_len = -1;
goto end;
}
- consumed_len_child = lttng_action_create_from_payload(
- &child_view, &child_action);
+ consumed_len_child = lttng_action_create_from_payload(&child_view, &child_action);
if (consumed_len_child < 0) {
consumed_len = -1;
goto end;
return consumed_len;
}
-static enum lttng_action_status lttng_action_list_add_error_query_results(
- const struct lttng_action *action,
- struct lttng_error_query_results *results)
+static enum lttng_action_status
+lttng_action_list_add_error_query_results(const struct lttng_action *action,
+ struct lttng_error_query_results *results)
{
unsigned int i, count;
enum lttng_action_status action_status;
for (i = 0; i < count; i++) {
struct lttng_action *inner_action =
- lttng_action_list_borrow_mutable_at_index(action, i);
+ lttng_action_list_borrow_mutable_at_index(action, i);
- action_status = lttng_action_add_error_query_results(
- inner_action, results);
+ action_status = lttng_action_add_error_query_results(inner_action, results);
if (action_status != LTTNG_ACTION_STATUS_OK) {
goto end;
}
return action_status;
}
-enum lttng_error_code lttng_action_list_mi_serialize(
- const struct lttng_trigger *trigger,
- const struct lttng_action *action,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks,
- struct lttng_dynamic_array *action_path_indexes)
+enum lttng_error_code
+lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes)
{
int ret;
struct lttng_action_list *action_list;
LTTNG_ASSERT(writer);
/* Open action list. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_list);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_list);
if (ret) {
goto mi_error;
}
action_list = action_list_from_action(action);
count = lttng_dynamic_pointer_array_get_count(&action_list->actions);
for (i = 0; i < count; i++) {
- const struct lttng_action *child =
- lttng_action_list_get_at_index(action, i);
+ const struct lttng_action *child = lttng_action_list_get_at_index(action, i);
const uint64_t index = (uint64_t) i;
LTTNG_ASSERT(child);
* tree in-order and to re-use the dynamic array instead of
* copying it at every level.
*/
- ret = lttng_dynamic_array_add_element(
- action_path_indexes, &index);
+ ret = lttng_dynamic_array_add_element(action_path_indexes, &index);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
- ret_code = lttng_action_mi_serialize(trigger, child, writer,
- error_query_callbacks, action_path_indexes);
+ ret_code = lttng_action_mi_serialize(
+ trigger, child, writer, error_query_callbacks, action_path_indexes);
if (ret_code != LTTNG_OK) {
goto end;
}
- ret = lttng_dynamic_array_remove_element(action_path_indexes,
- lttng_dynamic_array_get_count(
- action_path_indexes) -
- 1);
+ ret = lttng_dynamic_array_remove_element(
+ action_path_indexes,
+ lttng_dynamic_array_get_count(action_path_indexes) - 1);
if (ret) {
ret_code = LTTNG_ERR_UNK;
goto end;
* The mi for the list is handled at the lttng_action_mi level to ease
* action path management for error query.
*/
- lttng_action_init(action, LTTNG_ACTION_TYPE_LIST,
- lttng_action_list_validate, lttng_action_list_serialize,
- lttng_action_list_is_equal, lttng_action_list_destroy,
- NULL, lttng_action_list_add_error_query_results, NULL);
-
- lttng_dynamic_pointer_array_init(&action_list->actions,
- destroy_lttng_action_list_element);
+ lttng_action_init(action,
+ LTTNG_ACTION_TYPE_LIST,
+ lttng_action_list_validate,
+ lttng_action_list_serialize,
+ lttng_action_list_is_equal,
+ lttng_action_list_destroy,
+ NULL,
+ lttng_action_list_add_error_query_results,
+ NULL);
+
+ lttng_dynamic_pointer_array_init(&action_list->actions, destroy_lttng_action_list_element);
end:
return action;
}
-enum lttng_action_status lttng_action_list_add_action(
- struct lttng_action *list, struct lttng_action *action)
+enum lttng_action_status lttng_action_list_add_action(struct lttng_action *list,
+ struct lttng_action *action)
{
struct lttng_action_list *action_list;
enum lttng_action_status status;
action_list = action_list_from_action(list);
- ret = lttng_dynamic_pointer_array_add_pointer(&action_list->actions,
- action);
+ ret = lttng_dynamic_pointer_array_add_pointer(&action_list->actions, action);
if (ret < 0) {
status = LTTNG_ACTION_STATUS_ERROR;
goto end;
return status;
}
-enum lttng_action_status lttng_action_list_get_count(
- const struct lttng_action *list, unsigned int *count)
+enum lttng_action_status lttng_action_list_get_count(const struct lttng_action *list,
+ unsigned int *count)
{
const struct lttng_action_list *action_list;
enum lttng_action_status status = LTTNG_ACTION_STATUS_OK;
return status;
}
-const struct lttng_action *lttng_action_list_get_at_index(
- const struct lttng_action *list, unsigned int index)
+const struct lttng_action *lttng_action_list_get_at_index(const struct lttng_action *list,
+ unsigned int index)
{
return lttng_action_list_borrow_mutable_at_index(list, index);
}
-struct lttng_action *lttng_action_list_borrow_mutable_at_index(
- const struct lttng_action *list, unsigned int index)
+struct lttng_action *lttng_action_list_borrow_mutable_at_index(const struct lttng_action *list,
+ unsigned int index)
{
unsigned int count;
const struct lttng_action_list *action_list;
struct lttng_action *action = NULL;
- if (lttng_action_list_get_count(list, &count) !=
- LTTNG_ACTION_STATUS_OK) {
+ if (lttng_action_list_get_count(list, &count) != LTTNG_ACTION_STATUS_OK) {
goto end;
}
action_list = action_list_from_action_const(list);
action = (lttng_action *) lttng_dynamic_pointer_array_get_pointer(&action_list->actions,
- index);
+ index);
end:
return action;
}
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/notify-internal.hpp>
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/lttng-error.h>
-#define IS_NOTIFY_ACTION(action) \
- (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY)
+#define IS_NOTIFY_ACTION(action) (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY)
-static struct lttng_action_notify *action_notify_from_action(
- struct lttng_action *action)
+static struct lttng_action_notify *action_notify_from_action(struct lttng_action *action)
{
LTTNG_ASSERT(action);
return lttng::utils::container_of(action, <tng_action_notify::parent);
}
-static const struct lttng_action_notify *action_notify_from_action_const(
- const struct lttng_action *action)
+static const struct lttng_action_notify *
+action_notify_from_action_const(const struct lttng_action *action)
{
LTTNG_ASSERT(action);
return lttng::utils::container_of(action, <tng_action_notify::parent);
}
-static
-void lttng_action_notify_destroy(struct lttng_action *action)
+static void lttng_action_notify_destroy(struct lttng_action *action)
{
struct lttng_action_notify *notify_action;
notify_action = action_notify_from_action(action);
free(notify_action);
}
-static
-int lttng_action_notify_serialize(struct lttng_action *action,
- struct lttng_payload *payload)
+static int lttng_action_notify_serialize(struct lttng_action *action, struct lttng_payload *payload)
{
int ret;
struct lttng_action_notify *notify_action;
return ret;
}
-static
-bool lttng_action_notify_is_equal(const struct lttng_action *a,
- const struct lttng_action *b)
+static bool lttng_action_notify_is_equal(const struct lttng_action *a, const struct lttng_action *b)
{
const struct lttng_action_notify *_a, *_b;
return _action->policy;
}
-static enum lttng_error_code lttng_action_notify_mi_serialize(
- const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code lttng_action_notify_mi_serialize(const struct lttng_action *action,
+ struct mi_writer *writer)
{
int ret;
enum lttng_action_status status;
LTTNG_ASSERT(policy != NULL);
/* Open action notify. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_notify);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_notify);
if (ret) {
goto mi_error;
}
goto end;
}
- lttng_action_init(¬ify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL,
- lttng_action_notify_serialize,
- lttng_action_notify_is_equal,
- lttng_action_notify_destroy,
- lttng_action_notify_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results,
- lttng_action_notify_mi_serialize);
+ lttng_action_init(¬ify->parent,
+ LTTNG_ACTION_TYPE_NOTIFY,
+ NULL,
+ lttng_action_notify_serialize,
+ lttng_action_notify_is_equal,
+ lttng_action_notify_destroy,
+ lttng_action_notify_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_notify_mi_serialize);
notify->policy = policy;
policy = NULL;
return action;
}
-ssize_t lttng_action_notify_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **action)
+ssize_t lttng_action_notify_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **action)
{
enum lttng_action_status status;
ssize_t consumed_length;
struct lttng_rate_policy *rate_policy = NULL;
struct lttng_action *_action = NULL;
- consumed_length = lttng_rate_policy_create_from_payload(
- view, &rate_policy);
+ consumed_length = lttng_rate_policy_create_from_payload(view, &rate_policy);
if (!rate_policy) {
consumed_length = -1;
goto end;
return consumed_length;
}
-enum lttng_action_status lttng_action_notify_set_rate_policy(
- struct lttng_action *action,
- const struct lttng_rate_policy *policy)
+enum lttng_action_status lttng_action_notify_set_rate_policy(struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
{
enum lttng_action_status status;
struct lttng_action_notify *notify_action;
return status;
}
-enum lttng_action_status lttng_action_notify_get_rate_policy(
- const struct lttng_action *action,
- const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_notify_get_rate_policy(const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
{
enum lttng_action_status status;
const struct lttng_action_notify *notify_action;
} LTTNG_PACKED;
} /* namespace */
-struct lttng_action_path *lttng_action_path_create(
- const uint64_t *indexes, size_t index_count)
+struct lttng_action_path *lttng_action_path_create(const uint64_t *indexes, size_t index_count)
{
int ret;
size_t i;
lttng_dynamic_array_init(&path->indexes, sizeof(uint64_t), NULL);
for (i = 0; i < index_count; i++) {
- ret = lttng_dynamic_array_add_element(
- &path->indexes, &indexes[i]);
+ ret = lttng_dynamic_array_add_element(&path->indexes, &indexes[i]);
if (ret) {
goto error;
}
return path;
}
-enum lttng_action_path_status lttng_action_path_get_index_count(
- const struct lttng_action_path *path, size_t *index_count)
+enum lttng_action_path_status
+lttng_action_path_get_index_count(const struct lttng_action_path *path, size_t *index_count)
{
enum lttng_action_path_status status;
}
enum lttng_action_path_status lttng_action_path_get_index_at_index(
- const struct lttng_action_path *path,
- size_t path_index,
- uint64_t *out_index)
+ const struct lttng_action_path *path, size_t path_index, uint64_t *out_index)
{
enum lttng_action_path_status status;
- if (!path || !out_index ||
- path_index >= lttng_dynamic_array_get_count(
- &path->indexes)) {
+ if (!path || !out_index || path_index >= lttng_dynamic_array_get_count(&path->indexes)) {
status = LTTNG_ACTION_PATH_STATUS_INVALID;
goto end;
}
- *out_index = *((typeof(out_index)) lttng_dynamic_array_get_element(
- &path->indexes, path_index));
+ *out_index =
+ *((typeof(out_index)) lttng_dynamic_array_get_element(&path->indexes, path_index));
status = LTTNG_ACTION_PATH_STATUS_OK;
end:
return status;
return;
}
-int lttng_action_path_copy(const struct lttng_action_path *src,
- struct lttng_action_path **dst)
+int lttng_action_path_copy(const struct lttng_action_path *src, struct lttng_action_path **dst)
{
int ret;
struct lttng_action_path *new_path;
LTTNG_ASSERT(dst);
new_path = lttng_action_path_create(
- (uint64_t *) lttng_dynamic_array_get_element(
- &src->indexes, 0),
- lttng_dynamic_array_get_count(&src->indexes));
+ (uint64_t *) lttng_dynamic_array_get_element(&src->indexes, 0),
+ lttng_dynamic_array_get_count(&src->indexes));
if (!new_path) {
ret = -1;
} else {
return ret;
}
-ssize_t lttng_action_path_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action_path **_action_path)
+ssize_t lttng_action_path_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action_path **_action_path)
{
ssize_t consumed_size = 0, ret = -1;
const struct lttng_action_path_comm *header;
struct lttng_action_path *action_path = NULL;
const struct lttng_payload_view header_view =
- lttng_payload_view_from_view(view, 0, sizeof(*header));
+ lttng_payload_view_from_view(view, 0, sizeof(*header));
if (!lttng_payload_view_is_valid(&header_view)) {
goto end;
* single non-list action. Handle it differently since a payload view of
* size 0 is considered invalid.
*/
- if (header->index_count != 0)
- {
- const struct lttng_payload_view indexes_view =
- lttng_payload_view_from_view(view,
- consumed_size,
- header->index_count *
- sizeof(uint64_t));
+ if (header->index_count != 0) {
+ const struct lttng_payload_view indexes_view = lttng_payload_view_from_view(
+ view, consumed_size, header->index_count * sizeof(uint64_t));
if (!lttng_payload_view_is_valid(&indexes_view)) {
goto end;
}
consumed_size += indexes_view.buffer.size;
- action_path = lttng_action_path_create(
- (const uint64_t *) indexes_view.buffer.data,
- header->index_count);
+ action_path = lttng_action_path_create((const uint64_t *) indexes_view.buffer.data,
+ header->index_count);
if (!action_path) {
goto end;
}
}
int lttng_action_path_serialize(const struct lttng_action_path *action_path,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
size_t index_count, i;
}
comm.index_count = (uint32_t) index_count;
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &comm,
- sizeof(struct lttng_action_path_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &comm, sizeof(struct lttng_action_path_comm));
for (i = 0; i < index_count; i++) {
uint64_t path_index;
- status = lttng_action_path_get_index_at_index(
- action_path, i, &path_index);
+ status = lttng_action_path_get_index_at_index(action_path, i, &path_index);
if (status != LTTNG_ACTION_PATH_STATUS_OK) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, &path_index,
- sizeof(path_index));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &path_index, sizeof(path_index));
if (ret) {
goto end;
}
#include <common/mi-lttng.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
-#include <limits.h>
+
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
+
+#include <limits.h>
#include <stdbool.h>
#include <sys/types.h>
#define IS_EVERY_N_RATE_POLICY(policy) \
(lttng_rate_policy_get_type(policy) == LTTNG_RATE_POLICY_TYPE_EVERY_N)
-#define IS_ONCE_AFTER_N_RATE_POLICY(policy) \
- (lttng_rate_policy_get_type(policy) == \
- LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N)
+#define IS_ONCE_AFTER_N_RATE_POLICY(policy) \
+ (lttng_rate_policy_get_type(policy) == LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N)
typedef void (*rate_policy_destroy_cb)(struct lttng_rate_policy *rate_policy);
typedef int (*rate_policy_serialize_cb)(struct lttng_rate_policy *rate_policy,
- struct lttng_payload *payload);
+ struct lttng_payload *payload);
typedef bool (*rate_policy_equal_cb)(const struct lttng_rate_policy *a,
- const struct lttng_rate_policy *b);
-typedef ssize_t (*rate_policy_create_from_payload_cb)(
- struct lttng_payload_view *view,
- struct lttng_rate_policy **rate_policy);
-typedef struct lttng_rate_policy *(*rate_policy_copy_cb)(
- const struct lttng_rate_policy *source);
+ const struct lttng_rate_policy *b);
+typedef ssize_t (*rate_policy_create_from_payload_cb)(struct lttng_payload_view *view,
+ struct lttng_rate_policy **rate_policy);
+typedef struct lttng_rate_policy *(*rate_policy_copy_cb)(const struct lttng_rate_policy *source);
typedef enum lttng_error_code (*rate_policy_mi_serialize_cb)(
- const struct lttng_rate_policy *rate_policy,
- struct mi_writer *writer);
+ const struct lttng_rate_policy *rate_policy, struct mi_writer *writer);
struct lttng_rate_policy {
enum lttng_rate_policy_type type;
/* Forward declaration. */
static void lttng_rate_policy_init(struct lttng_rate_policy *rate_policy,
- enum lttng_rate_policy_type type,
- rate_policy_serialize_cb serialize,
- rate_policy_equal_cb equal,
- rate_policy_destroy_cb destroy,
- rate_policy_copy_cb copy,
- rate_policy_mi_serialize_cb mi);
+ enum lttng_rate_policy_type type,
+ rate_policy_serialize_cb serialize,
+ rate_policy_equal_cb equal,
+ rate_policy_destroy_cb destroy,
+ rate_policy_copy_cb copy,
+ rate_policy_mi_serialize_cb mi);
/* Forward declaration. Every n */
-static bool lttng_rate_policy_every_n_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter);
+static bool lttng_rate_policy_every_n_should_execute(const struct lttng_rate_policy *policy,
+ uint64_t counter);
/* Forward declaration. Once after N */
-static bool lttng_rate_policy_once_after_n_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter);
+static bool lttng_rate_policy_once_after_n_should_execute(const struct lttng_rate_policy *policy,
+ uint64_t counter);
-const char *lttng_rate_policy_type_string(
- enum lttng_rate_policy_type rate_policy_type)
+const char *lttng_rate_policy_type_string(enum lttng_rate_policy_type rate_policy_type)
{
switch (rate_policy_type) {
case LTTNG_RATE_POLICY_TYPE_EVERY_N:
}
}
-enum lttng_rate_policy_type lttng_rate_policy_get_type(
- const struct lttng_rate_policy *policy)
+enum lttng_rate_policy_type lttng_rate_policy_get_type(const struct lttng_rate_policy *policy)
{
return policy ? policy->type : LTTNG_RATE_POLICY_TYPE_UNKNOWN;
}
void lttng_rate_policy_init(struct lttng_rate_policy *rate_policy,
- enum lttng_rate_policy_type type,
- rate_policy_serialize_cb serialize,
- rate_policy_equal_cb equal,
- rate_policy_destroy_cb destroy,
- rate_policy_copy_cb copy,
- rate_policy_mi_serialize_cb mi)
+ enum lttng_rate_policy_type type,
+ rate_policy_serialize_cb serialize,
+ rate_policy_equal_cb equal,
+ rate_policy_destroy_cb destroy,
+ rate_policy_copy_cb copy,
+ rate_policy_mi_serialize_cb mi)
{
rate_policy->type = type;
rate_policy->serialize = serialize;
}
int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_rate_policy_comm rate_policy_comm = {
- .rate_policy_type = (int8_t) rate_policy->type,
+ .rate_policy_type = (int8_t) rate_policy->type,
};
- ret = lttng_dynamic_buffer_append(&payload->buffer, &rate_policy_comm,
- sizeof(rate_policy_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &rate_policy_comm, sizeof(rate_policy_comm));
if (ret) {
goto end;
}
return ret;
}
-static ssize_t lttng_rate_policy_once_after_n_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_rate_policy **rate_policy)
+static ssize_t
+lttng_rate_policy_once_after_n_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_rate_policy **rate_policy)
{
ssize_t consumed_len = -1;
struct lttng_rate_policy *policy = NULL;
const struct lttng_rate_policy_once_after_n_comm *comm;
const struct lttng_payload_view comm_view =
- lttng_payload_view_from_view(view, 0, sizeof(*comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*comm));
if (!view || !rate_policy) {
consumed_len = -1;
goto end;
}
- comm = (const struct lttng_rate_policy_once_after_n_comm *)
- comm_view.buffer.data;
+ comm = (const struct lttng_rate_policy_once_after_n_comm *) comm_view.buffer.data;
policy = lttng_rate_policy_once_after_n_create(comm->threshold);
if (policy == NULL) {
return consumed_len;
}
-static ssize_t lttng_rate_policy_every_n_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_rate_policy **rate_policy)
+static ssize_t lttng_rate_policy_every_n_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_rate_policy **rate_policy)
{
ssize_t consumed_len = -1;
struct lttng_rate_policy *policy = NULL;
const struct lttng_rate_policy_every_n_comm *comm;
const struct lttng_payload_view comm_view =
- lttng_payload_view_from_view(view, 0, sizeof(*comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*comm));
if (!view || !rate_policy) {
consumed_len = -1;
goto end;
}
- comm = (const struct lttng_rate_policy_every_n_comm *)
- comm_view.buffer.data;
+ comm = (const struct lttng_rate_policy_every_n_comm *) comm_view.buffer.data;
policy = lttng_rate_policy_every_n_create(comm->interval);
if (policy == NULL) {
}
ssize_t lttng_rate_policy_create_from_payload(struct lttng_payload_view *view,
- struct lttng_rate_policy **rate_policy)
+ struct lttng_rate_policy **rate_policy)
{
ssize_t consumed_len, specific_rate_policy_consumed_len;
rate_policy_create_from_payload_cb create_from_payload_cb;
const struct lttng_rate_policy_comm *rate_policy_comm;
const struct lttng_payload_view rate_policy_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*rate_policy_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*rate_policy_comm));
if (!view || !rate_policy) {
consumed_len = -1;
goto end;
}
- rate_policy_comm = (const struct lttng_rate_policy_comm *)
- rate_policy_comm_view.buffer.data;
+ rate_policy_comm =
+ (const struct lttng_rate_policy_comm *) rate_policy_comm_view.buffer.data;
DBG("Create rate_policy from payload: rate-policy-type=%s",
- lttng_rate_policy_type_string(
- (lttng_rate_policy_type) rate_policy_comm->rate_policy_type));
+ lttng_rate_policy_type_string(
+ (lttng_rate_policy_type) rate_policy_comm->rate_policy_type));
switch (rate_policy_comm->rate_policy_type) {
case LTTNG_RATE_POLICY_TYPE_EVERY_N:
- create_from_payload_cb =
- lttng_rate_policy_every_n_create_from_payload;
+ create_from_payload_cb = lttng_rate_policy_every_n_create_from_payload;
break;
case LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N:
- create_from_payload_cb =
- lttng_rate_policy_once_after_n_create_from_payload;
+ create_from_payload_cb = lttng_rate_policy_once_after_n_create_from_payload;
break;
default:
ERR("Failed to create rate-policy from payload, unhandled rate-policy type: rate-policy-type=%u (%s)",
- rate_policy_comm->rate_policy_type,
- lttng_rate_policy_type_string(
- (lttng_rate_policy_type) rate_policy_comm->rate_policy_type));
+ rate_policy_comm->rate_policy_type,
+ lttng_rate_policy_type_string(
+ (lttng_rate_policy_type) rate_policy_comm->rate_policy_type));
consumed_len = -1;
goto end;
}
{
/* Create buffer view for the rate_policy-type-specific data.
*/
- struct lttng_payload_view specific_rate_policy_view =
- lttng_payload_view_from_view(view,
- sizeof(struct lttng_rate_policy_comm),
- -1);
+ struct lttng_payload_view specific_rate_policy_view = lttng_payload_view_from_view(
+ view, sizeof(struct lttng_rate_policy_comm), -1);
- specific_rate_policy_consumed_len = create_from_payload_cb(
- &specific_rate_policy_view, rate_policy);
+ specific_rate_policy_consumed_len =
+ create_from_payload_cb(&specific_rate_policy_view, rate_policy);
}
if (specific_rate_policy_consumed_len < 0) {
ERR("Failed to create specific rate_policy from buffer.");
LTTNG_ASSERT(*rate_policy);
- consumed_len = sizeof(struct lttng_rate_policy_comm) +
- specific_rate_policy_consumed_len;
+ consumed_len = sizeof(struct lttng_rate_policy_comm) + specific_rate_policy_consumed_len;
end:
return consumed_len;
}
bool lttng_rate_policy_is_equal(const struct lttng_rate_policy *a,
- const struct lttng_rate_policy *b)
+ const struct lttng_rate_policy *b)
{
bool is_equal = false;
return is_equal;
}
-bool lttng_rate_policy_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter)
+bool lttng_rate_policy_should_execute(const struct lttng_rate_policy *policy, uint64_t counter)
{
switch (policy->type) {
case LTTNG_RATE_POLICY_TYPE_EVERY_N:
- return lttng_rate_policy_every_n_should_execute(
- policy, counter);
+ return lttng_rate_policy_every_n_should_execute(policy, counter);
case LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N:
- return lttng_rate_policy_once_after_n_should_execute(
- policy, counter);
+ return lttng_rate_policy_once_after_n_should_execute(policy, counter);
default:
abort();
break;
}
/* Every N */
-static struct lttng_rate_policy_every_n *rate_policy_every_n_from_rate_policy(
- struct lttng_rate_policy *policy)
+static struct lttng_rate_policy_every_n *
+rate_policy_every_n_from_rate_policy(struct lttng_rate_policy *policy)
{
LTTNG_ASSERT(policy);
}
static const struct lttng_rate_policy_every_n *
-rate_policy_every_n_from_rate_policy_const(
- const struct lttng_rate_policy *policy)
+rate_policy_every_n_from_rate_policy_const(const struct lttng_rate_policy *policy)
{
LTTNG_ASSERT(policy);
return lttng::utils::container_of(policy, <tng_rate_policy_every_n::parent);
}
-static int lttng_rate_policy_every_n_serialize(
- struct lttng_rate_policy *policy, struct lttng_payload *payload)
+static int lttng_rate_policy_every_n_serialize(struct lttng_rate_policy *policy,
+ struct lttng_payload *payload)
{
int ret;
every_n_policy = rate_policy_every_n_from_rate_policy(policy);
comm.interval = every_n_policy->interval;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
return ret;
}
-static bool lttng_rate_policy_every_n_is_equal(
- const struct lttng_rate_policy *_a,
- const struct lttng_rate_policy *_b)
+static bool lttng_rate_policy_every_n_is_equal(const struct lttng_rate_policy *_a,
+ const struct lttng_rate_policy *_b)
{
bool is_equal = false;
const struct lttng_rate_policy_every_n *a, *b;
return;
}
-static struct lttng_rate_policy *lttng_rate_policy_every_n_copy(
- const struct lttng_rate_policy *source)
+static struct lttng_rate_policy *
+lttng_rate_policy_every_n_copy(const struct lttng_rate_policy *source)
{
struct lttng_rate_policy *copy = NULL;
const struct lttng_rate_policy_every_n *every_n_policy;
return copy;
}
-static enum lttng_error_code lttng_rate_policy_every_n_mi_serialize(
- const struct lttng_rate_policy *rate_policy,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_rate_policy_every_n_mi_serialize(const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(IS_EVERY_N_RATE_POLICY(rate_policy));
LTTNG_ASSERT(writer);
- every_n_policy = rate_policy_every_n_from_rate_policy_const(
- rate_policy);
+ every_n_policy = rate_policy_every_n_from_rate_policy_const(rate_policy);
/* Open rate_policy_every_n element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_rate_policy_every_n);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rate_policy_every_n);
if (ret) {
goto mi_error;
}
/* Interval. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_rate_policy_every_n_interval,
- every_n_policy->interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_rate_policy_every_n_interval, every_n_policy->interval);
if (ret) {
goto mi_error;
}
goto end;
}
- lttng_rate_policy_init(&policy->parent, LTTNG_RATE_POLICY_TYPE_EVERY_N,
- lttng_rate_policy_every_n_serialize,
- lttng_rate_policy_every_n_is_equal,
- lttng_rate_policy_every_n_destroy,
- lttng_rate_policy_every_n_copy,
- lttng_rate_policy_every_n_mi_serialize);
+ lttng_rate_policy_init(&policy->parent,
+ LTTNG_RATE_POLICY_TYPE_EVERY_N,
+ lttng_rate_policy_every_n_serialize,
+ lttng_rate_policy_every_n_is_equal,
+ lttng_rate_policy_every_n_destroy,
+ lttng_rate_policy_every_n_copy,
+ lttng_rate_policy_every_n_mi_serialize);
policy->interval = interval;
return _policy;
}
-enum lttng_rate_policy_status lttng_rate_policy_every_n_get_interval(
- const struct lttng_rate_policy *policy, uint64_t *interval)
+enum lttng_rate_policy_status
+lttng_rate_policy_every_n_get_interval(const struct lttng_rate_policy *policy, uint64_t *interval)
{
const struct lttng_rate_policy_every_n *every_n_policy;
enum lttng_rate_policy_status status;
return status;
}
-static bool lttng_rate_policy_every_n_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter)
+static bool lttng_rate_policy_every_n_should_execute(const struct lttng_rate_policy *policy,
+ uint64_t counter)
{
const struct lttng_rate_policy_every_n *every_n_policy;
LTTNG_ASSERT(policy);
execute = (counter % every_n_policy->interval) == 0;
- DBG("Policy every N = %" PRIu64
- ": execution %s. Execution count: %" PRIu64,
- every_n_policy->interval,
- execute ? "accepted" : "denied", counter);
+ DBG("Policy every N = %" PRIu64 ": execution %s. Execution count: %" PRIu64,
+ every_n_policy->interval,
+ execute ? "accepted" : "denied",
+ counter);
return execute;
}
{
LTTNG_ASSERT(policy);
- return lttng::utils::container_of(
- policy, <tng_rate_policy_once_after_n::parent);
+ return lttng::utils::container_of(policy, <tng_rate_policy_once_after_n::parent);
}
static const struct lttng_rate_policy_once_after_n *
-rate_policy_once_after_n_from_rate_policy_const(
- const struct lttng_rate_policy *policy)
+rate_policy_once_after_n_from_rate_policy_const(const struct lttng_rate_policy *policy)
{
LTTNG_ASSERT(policy);
- return lttng::utils::container_of(
- policy, <tng_rate_policy_once_after_n::parent);
+ return lttng::utils::container_of(policy, <tng_rate_policy_once_after_n::parent);
}
-static int lttng_rate_policy_once_after_n_serialize(
- struct lttng_rate_policy *policy, struct lttng_payload *payload)
+static int lttng_rate_policy_once_after_n_serialize(struct lttng_rate_policy *policy,
+ struct lttng_payload *payload)
{
int ret;
once_after_n_policy = rate_policy_once_after_n_from_rate_policy(policy);
comm.threshold = once_after_n_policy->threshold;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
return ret;
}
-static bool lttng_rate_policy_once_after_n_is_equal(
- const struct lttng_rate_policy *_a,
- const struct lttng_rate_policy *_b)
+static bool lttng_rate_policy_once_after_n_is_equal(const struct lttng_rate_policy *_a,
+ const struct lttng_rate_policy *_b)
{
bool is_equal = false;
const struct lttng_rate_policy_once_after_n *a, *b;
return is_equal;
}
-static void lttng_rate_policy_once_after_n_destroy(
- struct lttng_rate_policy *policy)
+static void lttng_rate_policy_once_after_n_destroy(struct lttng_rate_policy *policy)
{
struct lttng_rate_policy_once_after_n *once_after_n_policy;
return;
}
-static struct lttng_rate_policy *lttng_rate_policy_once_after_n_copy(
- const struct lttng_rate_policy *source)
+static struct lttng_rate_policy *
+lttng_rate_policy_once_after_n_copy(const struct lttng_rate_policy *source)
{
struct lttng_rate_policy *copy = NULL;
const struct lttng_rate_policy_once_after_n *once_after_n_policy;
goto end;
}
- once_after_n_policy =
- rate_policy_once_after_n_from_rate_policy_const(source);
- copy = lttng_rate_policy_once_after_n_create(
- once_after_n_policy->threshold);
+ once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(source);
+ copy = lttng_rate_policy_once_after_n_create(once_after_n_policy->threshold);
end:
return copy;
}
-static enum lttng_error_code lttng_rate_policy_once_after_n_mi_serialize(
- const struct lttng_rate_policy *rate_policy,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_rate_policy_once_after_n_mi_serialize(const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
LTTNG_ASSERT(writer);
- once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(
- rate_policy);
+ once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(rate_policy);
/* Open rate_policy_once_after_n. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_rate_policy_once_after_n);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rate_policy_once_after_n);
if (ret) {
goto mi_error;
}
/* Threshold. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_rate_policy_once_after_n_threshold,
- once_after_n_policy->threshold);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer,
+ mi_lttng_element_rate_policy_once_after_n_threshold,
+ once_after_n_policy->threshold);
if (ret) {
goto mi_error;
}
return ret_code;
}
-struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(
- uint64_t threshold)
+struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(uint64_t threshold)
{
struct lttng_rate_policy_once_after_n *policy = NULL;
struct lttng_rate_policy *_policy = NULL;
}
lttng_rate_policy_init(&policy->parent,
- LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N,
- lttng_rate_policy_once_after_n_serialize,
- lttng_rate_policy_once_after_n_is_equal,
- lttng_rate_policy_once_after_n_destroy,
- lttng_rate_policy_once_after_n_copy,
- lttng_rate_policy_once_after_n_mi_serialize);
+ LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N,
+ lttng_rate_policy_once_after_n_serialize,
+ lttng_rate_policy_once_after_n_is_equal,
+ lttng_rate_policy_once_after_n_destroy,
+ lttng_rate_policy_once_after_n_copy,
+ lttng_rate_policy_once_after_n_mi_serialize);
policy->threshold = threshold;
return _policy;
}
-enum lttng_rate_policy_status lttng_rate_policy_once_after_n_get_threshold(
- const struct lttng_rate_policy *policy, uint64_t *threshold)
+enum lttng_rate_policy_status
+lttng_rate_policy_once_after_n_get_threshold(const struct lttng_rate_policy *policy,
+ uint64_t *threshold)
{
const struct lttng_rate_policy_once_after_n *once_after_n_policy;
enum lttng_rate_policy_status status;
goto end;
}
- once_after_n_policy =
- rate_policy_once_after_n_from_rate_policy_const(policy);
+ once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(policy);
*threshold = once_after_n_policy->threshold;
status = LTTNG_RATE_POLICY_STATUS_OK;
end:
return status;
}
-struct lttng_rate_policy *lttng_rate_policy_copy(
- const struct lttng_rate_policy *source)
+struct lttng_rate_policy *lttng_rate_policy_copy(const struct lttng_rate_policy *source)
{
LTTNG_ASSERT(source->copy);
return source->copy(source);
}
-static bool lttng_rate_policy_once_after_n_should_execute(
- const struct lttng_rate_policy *policy, uint64_t counter)
+static bool lttng_rate_policy_once_after_n_should_execute(const struct lttng_rate_policy *policy,
+ uint64_t counter)
{
const struct lttng_rate_policy_once_after_n *once_after_n_policy;
bool execute = false;
LTTNG_ASSERT(policy);
- once_after_n_policy =
- rate_policy_once_after_n_from_rate_policy_const(policy);
+ once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(policy);
execute = counter == once_after_n_policy->threshold;
- DBG("Policy once after N = %" PRIu64
- ": execution %s. Execution count: %" PRIu64,
- once_after_n_policy->threshold,
- execute ? "accepted" : "denied", counter);
+ DBG("Policy once after N = %" PRIu64 ": execution %s. Execution count: %" PRIu64,
+ once_after_n_policy->threshold,
+ execute ? "accepted" : "denied",
+ counter);
return counter == once_after_n_policy->threshold;
}
-enum lttng_error_code lttng_rate_policy_mi_serialize(
- const struct lttng_rate_policy *rate_policy,
- struct mi_writer *writer)
+enum lttng_error_code lttng_rate_policy_mi_serialize(const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rate_policy->mi_serialize);
/* Open rate policy element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_rate_policy);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rate_policy);
if (ret) {
goto mi_error;
}
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
} /* namespace */
static const struct lttng_rate_policy *
-lttng_action_rotate_session_internal_get_rate_policy(
- const struct lttng_action *action);
+lttng_action_rotate_session_internal_get_rate_policy(const struct lttng_action *action);
-static struct lttng_action_rotate_session *action_rotate_session_from_action(
- struct lttng_action *action)
+static struct lttng_action_rotate_session *
+action_rotate_session_from_action(struct lttng_action *action)
{
LTTNG_ASSERT(action);
/* A non-empty session name is mandatory. */
if (!action_rotate_session->session_name ||
- strlen(action_rotate_session->session_name) == 0) {
+ strlen(action_rotate_session->session_name) == 0) {
valid = false;
goto end;
}
return valid;
}
-static bool lttng_action_rotate_session_is_equal(
- const struct lttng_action *_a, const struct lttng_action *_b)
+static bool lttng_action_rotate_session_is_equal(const struct lttng_action *_a,
+ const struct lttng_action *_b)
{
bool is_equal = false;
const struct lttng_action_rotate_session *a, *b;
end:
return is_equal;
}
-static int lttng_action_rotate_session_serialize(
- struct lttng_action *action, struct lttng_payload *payload)
+static int lttng_action_rotate_session_serialize(struct lttng_action *action,
+ struct lttng_payload *payload)
{
struct lttng_action_rotate_session *action_rotate_session;
struct lttng_action_rotate_session_comm comm;
LTTNG_ASSERT(action_rotate_session->session_name);
DBG("Serializing rotate session action: session-name: %s",
- action_rotate_session->session_name);
+ action_rotate_session->session_name);
session_name_len = strlen(action_rotate_session->session_name) + 1;
comm.session_name_len = session_name_len;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- action_rotate_session->session_name, session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, action_rotate_session->session_name, session_name_len);
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_rate_policy_serialize(
- action_rotate_session->policy, payload);
+ ret = lttng_rate_policy_serialize(action_rotate_session->policy, payload);
if (ret) {
ret = -1;
goto end;
return;
}
-ssize_t lttng_action_rotate_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **p_action)
+ssize_t lttng_action_rotate_session_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **p_action)
{
ssize_t consumed_len, ret;
const struct lttng_action_rotate_session_comm *comm;
session_name = (const char *) &comm->data;
if (!lttng_buffer_view_contains_string(
- &view->buffer, session_name, comm->session_name_len)) {
+ &view->buffer, session_name, comm->session_name_len)) {
consumed_len = -1;
goto end;
}
/* Rate policy. */
{
struct lttng_payload_view policy_view =
- lttng_payload_view_from_view(
- view, consumed_len, -1);
- ret = lttng_rate_policy_create_from_payload(
- &policy_view, &policy);
+ lttng_payload_view_from_view(view, consumed_len, -1);
+ ret = lttng_rate_policy_create_from_payload(&policy_view, &policy);
if (ret < 0) {
consumed_len = -1;
goto end;
consumed_len += ret;
}
- status = lttng_action_rotate_session_set_session_name(
- action, session_name);
+ status = lttng_action_rotate_session_set_session_name(action, session_name);
if (status != LTTNG_ACTION_STATUS_OK) {
consumed_len = -1;
goto end;
return consumed_len;
}
-static enum lttng_error_code lttng_action_rotate_session_mi_serialize(
- const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_action_rotate_session_mi_serialize(const struct lttng_action *action,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_ROTATE_SESSION_ACTION(action));
- status = lttng_action_rotate_session_get_session_name(
- action, &session_name);
+ status = lttng_action_rotate_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
LTTNG_ASSERT(session_name != NULL);
LTTNG_ASSERT(policy != NULL);
/* Open action rotate session element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_rotate_session);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_rotate_session);
if (ret) {
goto mi_error;
}
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
}
lttng_action_init(&action_rotate->parent,
- LTTNG_ACTION_TYPE_ROTATE_SESSION,
- lttng_action_rotate_session_validate,
- lttng_action_rotate_session_serialize,
- lttng_action_rotate_session_is_equal,
- lttng_action_rotate_session_destroy,
- lttng_action_rotate_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results,
- lttng_action_rotate_session_mi_serialize);
-
- status = lttng_action_rotate_session_set_rate_policy(
- &action_rotate->parent, policy);
+ LTTNG_ACTION_TYPE_ROTATE_SESSION,
+ lttng_action_rotate_session_validate,
+ lttng_action_rotate_session_serialize,
+ lttng_action_rotate_session_is_equal,
+ lttng_action_rotate_session_destroy,
+ lttng_action_rotate_session_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_rotate_session_mi_serialize);
+
+ status = lttng_action_rotate_session_set_rate_policy(&action_rotate->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_rotate->parent);
action_rotate = NULL;
return action_rotate ? &action_rotate->parent : nullptr;
}
-enum lttng_action_status lttng_action_rotate_session_set_session_name(
- struct lttng_action *action, const char *session_name)
+enum lttng_action_status lttng_action_rotate_session_set_session_name(struct lttng_action *action,
+ const char *session_name)
{
struct lttng_action_rotate_session *action_rotate_session;
enum lttng_action_status status;
if (!action || !IS_ROTATE_SESSION_ACTION(action) || !session_name ||
- strlen(session_name) == 0) {
+ strlen(session_name) == 0) {
status = LTTNG_ACTION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_action_status lttng_action_rotate_session_get_session_name(
- const struct lttng_action *action, const char **session_name)
+enum lttng_action_status
+lttng_action_rotate_session_get_session_name(const struct lttng_action *action,
+ const char **session_name)
{
const struct lttng_action_rotate_session *action_rotate_session;
enum lttng_action_status status;
return status;
}
-enum lttng_action_status lttng_action_rotate_session_set_rate_policy(
- struct lttng_action *action,
- const struct lttng_rate_policy *policy)
+enum lttng_action_status
+lttng_action_rotate_session_set_rate_policy(struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
{
enum lttng_action_status status;
struct lttng_action_rotate_session *rotate_session_action;
return status;
}
-enum lttng_action_status lttng_action_rotate_session_get_rate_policy(
- const struct lttng_action *action,
- const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_rotate_session_get_rate_policy(const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
{
enum lttng_action_status status;
const struct lttng_action_rotate_session *rotate_session_action;
}
static const struct lttng_rate_policy *
-lttng_action_rotate_session_internal_get_rate_policy(
- const struct lttng_action *action)
+lttng_action_rotate_session_internal_get_rate_policy(const struct lttng_action *action)
{
const struct lttng_action_rotate_session *_action;
_action = action_rotate_session_from_action_const(action);
#include <common/payload-view.hpp>
#include <common/payload.hpp>
#include <common/snapshot.hpp>
-#include <inttypes.h>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
#include <lttng/snapshot-internal.hpp>
#include <lttng/snapshot.h>
+#include <inttypes.h>
+
#define IS_SNAPSHOT_SESSION_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_SNAPSHOT_SESSION)
} /* namespace */
static const struct lttng_rate_policy *
-lttng_action_snapshot_session_internal_get_rate_policy(
- const struct lttng_action *action);
+lttng_action_snapshot_session_internal_get_rate_policy(const struct lttng_action *action);
static struct lttng_action_snapshot_session *
action_snapshot_session_from_action(struct lttng_action *action)
{
LTTNG_ASSERT(action);
- return lttng::utils::container_of(
- action, <tng_action_snapshot_session::parent);
+ return lttng::utils::container_of(action, <tng_action_snapshot_session::parent);
}
static const struct lttng_action_snapshot_session *
{
LTTNG_ASSERT(action);
- return lttng::utils::container_of(
- action, <tng_action_snapshot_session::parent);
+ return lttng::utils::container_of(action, <tng_action_snapshot_session::parent);
}
static bool lttng_action_snapshot_session_validate(struct lttng_action *action)
/* A non-empty session name is mandatory. */
if (!action_snapshot_session->session_name ||
- strlen(action_snapshot_session->session_name) == 0) {
+ strlen(action_snapshot_session->session_name) == 0) {
goto end;
}
if (action_snapshot_session->output &&
- !lttng_snapshot_output_validate(action_snapshot_session->output)) {
+ !lttng_snapshot_output_validate(action_snapshot_session->output)) {
goto end;
}
return valid;
}
-static bool lttng_action_snapshot_session_is_equal(
- const struct lttng_action *_a, const struct lttng_action *_b)
+static bool lttng_action_snapshot_session_is_equal(const struct lttng_action *_a,
+ const struct lttng_action *_b)
{
bool is_equal = false;
const struct lttng_action_snapshot_session *a, *b;
goto end;
}
- if (a->output && b->output &&
- !lttng_snapshot_output_is_equal(a->output, b->output)) {
+ if (a->output && b->output && !lttng_snapshot_output_is_equal(a->output, b->output)) {
goto end;
} else if (!!a->output != !!b->output) {
goto end;
return str ? strlen(str) + 1 : 0;
}
-static int lttng_action_snapshot_session_serialize(
- struct lttng_action *action, struct lttng_payload *payload)
+static int lttng_action_snapshot_session_serialize(struct lttng_action *action,
+ struct lttng_payload *payload)
{
struct lttng_action_snapshot_session *action_snapshot_session;
struct lttng_action_snapshot_session_comm comm = {};
size_before_comm = payload->buffer.size;
action_snapshot_session = action_snapshot_session_from_action(action);
- comm.session_name_len =
- serialize_strlen(action_snapshot_session->session_name);
+ comm.session_name_len = serialize_strlen(action_snapshot_session->session_name);
/* Add header. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
goto end;
}
LTTNG_ASSERT(action_snapshot_session->session_name);
DBG("Serializing snapshot session action: session-name: %s",
- action_snapshot_session->session_name);
+ action_snapshot_session->session_name);
/* Add session name. */
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- action_snapshot_session->session_name,
- comm.session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, action_snapshot_session->session_name, comm.session_name_len);
if (ret) {
goto end;
}
const size_t size_before_output = payload->buffer.size;
struct lttng_action_snapshot_session_comm *comm_in_payload;
- ret = lttng_snapshot_output_serialize(
- action_snapshot_session->output,
- payload);
+ ret = lttng_snapshot_output_serialize(action_snapshot_session->output, payload);
if (ret) {
goto end;
}
- comm_in_payload = (typeof(comm_in_payload))(
- payload->buffer.data + size_before_comm);
+ comm_in_payload =
+ (typeof(comm_in_payload)) (payload->buffer.data + size_before_comm);
/* Adjust action length in header. */
- comm_in_payload->snapshot_output_len =
- payload->buffer.size - size_before_output;
+ comm_in_payload->snapshot_output_len = payload->buffer.size - size_before_output;
}
/* Serialize the rate policy. */
const size_t size_before_output = payload->buffer.size;
struct lttng_action_snapshot_session_comm *comm_in_payload;
- ret = lttng_rate_policy_serialize(
- action_snapshot_session->policy, payload);
+ ret = lttng_rate_policy_serialize(action_snapshot_session->policy, payload);
if (ret) {
ret = -1;
goto end;
}
- comm_in_payload = (typeof(comm_in_payload))(
- payload->buffer.data + size_before_comm);
+ comm_in_payload =
+ (typeof(comm_in_payload)) (payload->buffer.data + size_before_comm);
/* Adjust rate policy length in header. */
- comm_in_payload->rate_policy_len =
- payload->buffer.size - size_before_output;
+ comm_in_payload->rate_policy_len = payload->buffer.size - size_before_output;
}
end:
return;
}
-ssize_t lttng_action_snapshot_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **p_action)
+ssize_t lttng_action_snapshot_session_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **p_action)
{
ssize_t consumed_len;
const char *variable_data;
struct lttng_rate_policy *policy = NULL;
const struct lttng_action_snapshot_session_comm *comm;
const struct lttng_payload_view snapshot_session_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*comm));
action = lttng_action_snapshot_session_create();
if (!action) {
consumed_len = sizeof(struct lttng_action_snapshot_session_comm);
if (!lttng_buffer_view_contains_string(
- &view->buffer, variable_data, comm->session_name_len)) {
+ &view->buffer, variable_data, comm->session_name_len)) {
goto error;
}
- status = lttng_action_snapshot_session_set_session_name(
- action, variable_data);
+ status = lttng_action_snapshot_session_set_session_name(action, variable_data);
if (status != LTTNG_ACTION_STATUS_OK) {
goto error;
}
ssize_t snapshot_output_consumed_len;
enum lttng_action_status action_status;
struct lttng_payload_view snapshot_output_buffer_view =
- lttng_payload_view_from_view(view, consumed_len,
- comm->snapshot_output_len);
+ lttng_payload_view_from_view(view, consumed_len, comm->snapshot_output_len);
if (!lttng_payload_view_is_valid(&snapshot_output_buffer_view)) {
ERR("Failed to create buffer view for snapshot output.");
goto error;
}
- snapshot_output_consumed_len =
- lttng_snapshot_output_create_from_payload(
- &snapshot_output_buffer_view,
- &snapshot_output);
+ snapshot_output_consumed_len = lttng_snapshot_output_create_from_payload(
+ &snapshot_output_buffer_view, &snapshot_output);
if (snapshot_output_consumed_len != comm->snapshot_output_len) {
ERR("Failed to deserialize snapshot output object: "
- "consumed-len: %zd, expected-len: %" PRIu32,
- snapshot_output_consumed_len,
- comm->snapshot_output_len);
+ "consumed-len: %zd, expected-len: %" PRIu32,
+ snapshot_output_consumed_len,
+ comm->snapshot_output_len);
goto error;
}
- action_status = lttng_action_snapshot_session_set_output(
- action, snapshot_output);
+ action_status = lttng_action_snapshot_session_set_output(action, snapshot_output);
if (action_status != LTTNG_ACTION_STATUS_OK) {
goto error;
}
{
ssize_t rate_policy_consumed_len;
struct lttng_payload_view policy_view =
- lttng_payload_view_from_view(view, consumed_len,
- comm->rate_policy_len);
+ lttng_payload_view_from_view(view, consumed_len, comm->rate_policy_len);
if (!lttng_payload_view_is_valid(&policy_view)) {
ERR("Failed to create buffer view for rate policy.");
}
rate_policy_consumed_len =
- lttng_rate_policy_create_from_payload(
- &policy_view, &policy);
+ lttng_rate_policy_create_from_payload(&policy_view, &policy);
if (rate_policy_consumed_len < 0) {
goto error;
}
if (rate_policy_consumed_len != comm->rate_policy_len) {
ERR("Failed to deserialize rate policy object: "
"consumed-len: %zd, expected-len: %" PRIu32,
- rate_policy_consumed_len,
- comm->rate_policy_len);
+ rate_policy_consumed_len,
+ comm->rate_policy_len);
goto error;
}
- status = lttng_action_snapshot_session_set_rate_policy(
- action, policy);
+ status = lttng_action_snapshot_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
goto error;
}
return consumed_len;
}
-static enum lttng_error_code lttng_action_snapshot_session_mi_serialize(
- const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_action_snapshot_session_mi_serialize(const struct lttng_action *action,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_SNAPSHOT_SESSION_ACTION(action));
- status = lttng_action_snapshot_session_get_session_name(
- action, &session_name);
+ status = lttng_action_snapshot_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
LTTNG_ASSERT(session_name != NULL);
LTTNG_ASSERT(policy != NULL);
/* Open action snapshot session element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_snapshot_session);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_snapshot_session);
if (ret) {
goto mi_error;
}
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
}
lttng_action_init(&action_snapshot->parent,
- LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
- lttng_action_snapshot_session_validate,
- lttng_action_snapshot_session_serialize,
- lttng_action_snapshot_session_is_equal,
- lttng_action_snapshot_session_destroy,
- lttng_action_snapshot_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results,
- lttng_action_snapshot_session_mi_serialize);
-
- status = lttng_action_snapshot_session_set_rate_policy(
- &action_snapshot->parent, policy);
+ LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
+ lttng_action_snapshot_session_validate,
+ lttng_action_snapshot_session_serialize,
+ lttng_action_snapshot_session_is_equal,
+ lttng_action_snapshot_session_destroy,
+ lttng_action_snapshot_session_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_snapshot_session_mi_serialize);
+
+ status = lttng_action_snapshot_session_set_rate_policy(&action_snapshot->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_snapshot->parent);
action_snapshot = NULL;
return action_snapshot ? &action_snapshot->parent : nullptr;
}
-enum lttng_action_status lttng_action_snapshot_session_set_session_name(
- struct lttng_action *action, const char *session_name)
+enum lttng_action_status lttng_action_snapshot_session_set_session_name(struct lttng_action *action,
+ const char *session_name)
{
struct lttng_action_snapshot_session *action_snapshot_session;
enum lttng_action_status status;
if (!action || !IS_SNAPSHOT_SESSION_ACTION(action) || !session_name ||
- strlen(session_name) == 0) {
+ strlen(session_name) == 0) {
status = LTTNG_ACTION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_action_status lttng_action_snapshot_session_get_session_name(
- const struct lttng_action *action, const char **session_name)
+enum lttng_action_status
+lttng_action_snapshot_session_get_session_name(const struct lttng_action *action,
+ const char **session_name)
{
const struct lttng_action_snapshot_session *action_snapshot_session;
enum lttng_action_status status;
return status;
}
-enum lttng_action_status lttng_action_snapshot_session_set_output(
- struct lttng_action *action,
- struct lttng_snapshot_output *output)
+enum lttng_action_status
+lttng_action_snapshot_session_set_output(struct lttng_action *action,
+ struct lttng_snapshot_output *output)
{
struct lttng_action_snapshot_session *action_snapshot_session;
enum lttng_action_status status;
return status;
}
-enum lttng_action_status lttng_action_snapshot_session_get_output(
- const struct lttng_action *action,
- const struct lttng_snapshot_output **output)
+enum lttng_action_status
+lttng_action_snapshot_session_get_output(const struct lttng_action *action,
+ const struct lttng_snapshot_output **output)
{
const struct lttng_action_snapshot_session *action_snapshot_session;
enum lttng_action_status status;
- if (!action || !IS_SNAPSHOT_SESSION_ACTION(action)|| !output) {
+ if (!action || !IS_SNAPSHOT_SESSION_ACTION(action) || !output) {
status = LTTNG_ACTION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_action_status lttng_action_snapshot_session_set_rate_policy(
- struct lttng_action *action,
- const struct lttng_rate_policy *policy)
+enum lttng_action_status
+lttng_action_snapshot_session_set_rate_policy(struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
{
enum lttng_action_status status;
struct lttng_action_snapshot_session *snapshot_session_action;
return status;
}
-enum lttng_action_status lttng_action_snapshot_session_get_rate_policy(
- const struct lttng_action *action,
- const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_snapshot_session_get_rate_policy(const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
{
enum lttng_action_status status;
const struct lttng_action_snapshot_session *snapshot_session_action;
goto end;
}
- snapshot_session_action =
- action_snapshot_session_from_action_const(action);
+ snapshot_session_action = action_snapshot_session_from_action_const(action);
*policy = snapshot_session_action->policy;
status = LTTNG_ACTION_STATUS_OK;
}
static const struct lttng_rate_policy *
-lttng_action_snapshot_session_internal_get_rate_policy(
- const struct lttng_action *action)
+lttng_action_snapshot_session_internal_get_rate_policy(const struct lttng_action *action)
{
const struct lttng_action_snapshot_session *_action;
_action = action_snapshot_session_from_action_const(action);
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
} /* namespace */
static const struct lttng_rate_policy *
-lttng_action_start_session_internal_get_rate_policy(
- const struct lttng_action *action);
+lttng_action_start_session_internal_get_rate_policy(const struct lttng_action *action);
-static struct lttng_action_start_session *action_start_session_from_action(
- struct lttng_action *action)
+static struct lttng_action_start_session *
+action_start_session_from_action(struct lttng_action *action)
{
LTTNG_ASSERT(action);
/* A non-empty session name is mandatory. */
if (!action_start_session->session_name ||
- strlen(action_start_session->session_name) == 0) {
+ strlen(action_start_session->session_name) == 0) {
valid = false;
goto end;
}
return valid;
}
-static bool lttng_action_start_session_is_equal(
- const struct lttng_action *_a, const struct lttng_action *_b)
+static bool lttng_action_start_session_is_equal(const struct lttng_action *_a,
+ const struct lttng_action *_b)
{
bool is_equal = false;
struct lttng_action_start_session *a, *b;
return is_equal;
}
-static int lttng_action_start_session_serialize(
- struct lttng_action *action, struct lttng_payload *payload)
+static int lttng_action_start_session_serialize(struct lttng_action *action,
+ struct lttng_payload *payload)
{
struct lttng_action_start_session *action_start_session;
struct lttng_action_start_session_comm comm;
LTTNG_ASSERT(action_start_session->session_name);
DBG("Serializing start session action: session-name: %s",
- action_start_session->session_name);
+ action_start_session->session_name);
session_name_len = strlen(action_start_session->session_name) + 1;
comm.session_name_len = session_name_len;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- action_start_session->session_name, session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, action_start_session->session_name, session_name_len);
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_rate_policy_serialize(
- action_start_session->policy, payload);
+ ret = lttng_rate_policy_serialize(action_start_session->policy, payload);
if (ret) {
ret = -1;
goto end;
return;
}
-ssize_t lttng_action_start_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **p_action)
+ssize_t lttng_action_start_session_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **p_action)
{
ssize_t consumed_len, ret;
const struct lttng_action_start_session_comm *comm;
session_name = (const char *) &comm->data;
/* Session name */
- if (!lttng_buffer_view_contains_string(&view->buffer, session_name,
- comm->session_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, session_name, comm->session_name_len)) {
consumed_len = -1;
goto end;
}
/* Rate policy. */
{
struct lttng_payload_view policy_view =
- lttng_payload_view_from_view(
- view, consumed_len, -1);
- ret = lttng_rate_policy_create_from_payload(
- &policy_view, &policy);
+ lttng_payload_view_from_view(view, consumed_len, -1);
+ ret = lttng_rate_policy_create_from_payload(&policy_view, &policy);
if (ret < 0) {
consumed_len = -1;
goto end;
goto end;
}
- status = lttng_action_start_session_set_session_name(
- action, session_name);
+ status = lttng_action_start_session_set_session_name(action, session_name);
if (status != LTTNG_ACTION_STATUS_OK) {
consumed_len = -1;
goto end;
return consumed_len;
}
-static enum lttng_error_code lttng_action_start_session_mi_serialize(
- const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_action_start_session_mi_serialize(const struct lttng_action *action, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_START_SESSION_ACTION(action));
- status = lttng_action_start_session_get_session_name(
- action, &session_name);
+ status = lttng_action_start_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
LTTNG_ASSERT(session_name != NULL);
LTTNG_ASSERT(policy != NULL);
/* Open action start session element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_start_session);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_start_session);
if (ret) {
goto mi_error;
}
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
}
lttng_action_init(&action_start->parent,
- LTTNG_ACTION_TYPE_START_SESSION,
- lttng_action_start_session_validate,
- lttng_action_start_session_serialize,
- lttng_action_start_session_is_equal,
- lttng_action_start_session_destroy,
- lttng_action_start_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results,
- lttng_action_start_session_mi_serialize);
-
- status = lttng_action_start_session_set_rate_policy(
- &action_start->parent, policy);
+ LTTNG_ACTION_TYPE_START_SESSION,
+ lttng_action_start_session_validate,
+ lttng_action_start_session_serialize,
+ lttng_action_start_session_is_equal,
+ lttng_action_start_session_destroy,
+ lttng_action_start_session_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_start_session_mi_serialize);
+
+ status = lttng_action_start_session_set_rate_policy(&action_start->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_start->parent);
action_start = NULL;
return &action_start->parent;
}
-enum lttng_action_status lttng_action_start_session_set_session_name(
- struct lttng_action *action, const char *session_name)
+enum lttng_action_status lttng_action_start_session_set_session_name(struct lttng_action *action,
+ const char *session_name)
{
struct lttng_action_start_session *action_start_session;
enum lttng_action_status status;
if (!action || !IS_START_SESSION_ACTION(action) || !session_name ||
- strlen(session_name) == 0) {
+ strlen(session_name) == 0) {
status = LTTNG_ACTION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_action_status lttng_action_start_session_get_session_name(
- const struct lttng_action *action, const char **session_name)
+enum lttng_action_status
+lttng_action_start_session_get_session_name(const struct lttng_action *action,
+ const char **session_name)
{
const struct lttng_action_start_session *action_start_session;
enum lttng_action_status status;
return status;
}
-enum lttng_action_status lttng_action_start_session_set_rate_policy(
- struct lttng_action *action,
- const struct lttng_rate_policy *policy)
+enum lttng_action_status
+lttng_action_start_session_set_rate_policy(struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
{
enum lttng_action_status status;
struct lttng_action_start_session *start_session_action;
return status;
}
-enum lttng_action_status lttng_action_start_session_get_rate_policy(
- const struct lttng_action *action,
- const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_start_session_get_rate_policy(const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
{
enum lttng_action_status status;
const struct lttng_action_start_session *start_session_action;
}
static const struct lttng_rate_policy *
-lttng_action_start_session_internal_get_rate_policy(
- const struct lttng_action *action)
+lttng_action_start_session_internal_get_rate_policy(const struct lttng_action *action)
{
const struct lttng_action_start_session *_action;
_action = action_start_session_from_action_const(action);
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
} /* namespace */
static const struct lttng_rate_policy *
-lttng_action_stop_session_internal_get_rate_policy(
- const struct lttng_action *action);
+lttng_action_stop_session_internal_get_rate_policy(const struct lttng_action *action);
-static struct lttng_action_stop_session *action_stop_session_from_action(
- struct lttng_action *action)
+static struct lttng_action_stop_session *
+action_stop_session_from_action(struct lttng_action *action)
{
LTTNG_ASSERT(action);
action_stop_session = action_stop_session_from_action(action);
/* A non-empty session name is mandatory. */
- if (!action_stop_session->session_name ||
- strlen(action_stop_session->session_name) == 0) {
+ if (!action_stop_session->session_name || strlen(action_stop_session->session_name) == 0) {
valid = false;
goto end;
}
return valid;
}
-static bool lttng_action_stop_session_is_equal(
- const struct lttng_action *_a, const struct lttng_action *_b)
+static bool lttng_action_stop_session_is_equal(const struct lttng_action *_a,
+ const struct lttng_action *_b)
{
bool is_equal = false;
const struct lttng_action_stop_session *a, *b;
return is_equal;
}
-static int lttng_action_stop_session_serialize(
- struct lttng_action *action, struct lttng_payload *payload)
+static int lttng_action_stop_session_serialize(struct lttng_action *action,
+ struct lttng_payload *payload)
{
struct lttng_action_stop_session *action_stop_session;
struct lttng_action_stop_session_comm comm;
LTTNG_ASSERT(action_stop_session->session_name);
- DBG("Serializing stop session action: session-name: %s",
- action_stop_session->session_name);
+ DBG("Serializing stop session action: session-name: %s", action_stop_session->session_name);
session_name_len = strlen(action_stop_session->session_name) + 1;
comm.session_name_len = session_name_len;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- action_stop_session->session_name, session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, action_stop_session->session_name, session_name_len);
if (ret) {
ret = -1;
goto end;
return;
}
-ssize_t lttng_action_stop_session_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_action **p_action)
+ssize_t lttng_action_stop_session_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_action **p_action)
{
ssize_t consumed_len, ret;
const struct lttng_action_stop_session_comm *comm;
/* Session name. */
if (!lttng_buffer_view_contains_string(
- &view->buffer, session_name, comm->session_name_len)) {
+ &view->buffer, session_name, comm->session_name_len)) {
consumed_len = -1;
goto end;
}
/* Rate policy. */
{
struct lttng_payload_view policy_view =
- lttng_payload_view_from_view(
- view, consumed_len, -1);
- ret = lttng_rate_policy_create_from_payload(
- &policy_view, &policy);
+ lttng_payload_view_from_view(view, consumed_len, -1);
+ ret = lttng_rate_policy_create_from_payload(&policy_view, &policy);
if (ret < 0) {
consumed_len = -1;
goto end;
goto end;
}
- status = lttng_action_stop_session_set_session_name(
- action, session_name);
+ status = lttng_action_stop_session_set_session_name(action, session_name);
if (status != LTTNG_ACTION_STATUS_OK) {
consumed_len = -1;
goto end;
return consumed_len;
}
-static enum lttng_error_code lttng_action_stop_session_mi_serialize(
- const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_action_stop_session_mi_serialize(const struct lttng_action *action, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(action);
LTTNG_ASSERT(IS_STOP_SESSION_ACTION(action));
- status = lttng_action_stop_session_get_session_name(
- action, &session_name);
+ status = lttng_action_stop_session_get_session_name(action, &session_name);
LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
LTTNG_ASSERT(session_name != NULL);
LTTNG_ASSERT(policy != NULL);
/* Open action stop session. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_action_start_session);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_start_session);
if (ret) {
goto mi_error;
}
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
goto end;
}
- lttng_action_init(&action_stop->parent, LTTNG_ACTION_TYPE_STOP_SESSION,
- lttng_action_stop_session_validate,
- lttng_action_stop_session_serialize,
- lttng_action_stop_session_is_equal,
- lttng_action_stop_session_destroy,
- lttng_action_stop_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results,
- lttng_action_stop_session_mi_serialize);
-
- status = lttng_action_stop_session_set_rate_policy(
- &action_stop->parent, policy);
+ lttng_action_init(&action_stop->parent,
+ LTTNG_ACTION_TYPE_STOP_SESSION,
+ lttng_action_stop_session_validate,
+ lttng_action_stop_session_serialize,
+ lttng_action_stop_session_is_equal,
+ lttng_action_stop_session_destroy,
+ lttng_action_stop_session_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_stop_session_mi_serialize);
+
+ status = lttng_action_stop_session_set_rate_policy(&action_stop->parent, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
lttng_action_destroy(&action_stop->parent);
action_stop = NULL;
return &action_stop->parent;
}
-enum lttng_action_status lttng_action_stop_session_set_session_name(
- struct lttng_action *action, const char *session_name)
+enum lttng_action_status lttng_action_stop_session_set_session_name(struct lttng_action *action,
+ const char *session_name)
{
struct lttng_action_stop_session *action_stop_session;
enum lttng_action_status status;
if (!action || !IS_STOP_SESSION_ACTION(action) || !session_name ||
- strlen(session_name) == 0) {
+ strlen(session_name) == 0) {
status = LTTNG_ACTION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_action_status lttng_action_stop_session_get_session_name(
- const struct lttng_action *action, const char **session_name)
+enum lttng_action_status
+lttng_action_stop_session_get_session_name(const struct lttng_action *action,
+ const char **session_name)
{
const struct lttng_action_stop_session *action_stop_session;
enum lttng_action_status status;
return status;
}
-enum lttng_action_status lttng_action_stop_session_set_rate_policy(
- struct lttng_action *action,
- const struct lttng_rate_policy *policy)
+enum lttng_action_status
+lttng_action_stop_session_set_rate_policy(struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
{
enum lttng_action_status status;
struct lttng_action_stop_session *stop_session_action;
return status;
}
-enum lttng_action_status lttng_action_stop_session_get_rate_policy(
- const struct lttng_action *action,
- const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_stop_session_get_rate_policy(const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
{
enum lttng_action_status status;
const struct lttng_action_stop_session *stop_session_action;
}
static const struct lttng_rate_policy *
-lttng_action_stop_session_internal_get_rate_policy(
- const struct lttng_action *action)
+lttng_action_stop_session_internal_get_rate_policy(const struct lttng_action *action)
{
const struct lttng_action_stop_session *_action;
_action = action_stop_session_from_action_const(action);
#include "argpar-utils.hpp"
-#include <stdio.h>
-
#include <common/error.hpp>
#include <common/string-utils/string-utils.hpp>
+#include <stdio.h>
+
/*
* Given argpar error status `status` and error `error`, return a formatted
* error message describing the error.
*
* The returned string must be freed by the caller.
*/
-static ATTR_FORMAT_PRINTF(4, 0)
-char *format_arg_error_v(const struct argpar_error *error, int argc_offset,
- const char **argv, const char *context_fmt, va_list args)
+static ATTR_FORMAT_PRINTF(4, 0) char *format_arg_error_v(const struct argpar_error *error,
+ int argc_offset,
+ const char **argv,
+ const char *context_fmt,
+ va_list args)
{
char *str = NULL;
char *str_ret = NULL;
}
}
- switch (argpar_error_type(error))
- {
+ switch (argpar_error_type(error)) {
case ARGPAR_ERROR_TYPE_MISSING_OPT_ARG:
{
const int orig_index = argpar_error_orig_index(error);
const char *arg = argv[orig_index];
ret = strutils_appendf(&str,
- WHILE_PARSING_ARG_N_ARG_FMT "Missing required argument for option `%s`",
- orig_index + 1 + argc_offset, argv[orig_index], arg);
+ WHILE_PARSING_ARG_N_ARG_FMT
+ "Missing required argument for option `%s`",
+ orig_index + 1 + argc_offset,
+ argv[orig_index],
+ arg);
if (ret < 0) {
goto end;
}
case ARGPAR_ERROR_TYPE_UNEXPECTED_OPT_ARG:
{
bool is_short;
- const struct argpar_opt_descr *descr =
- argpar_error_opt_descr(error, &is_short);
+ const struct argpar_opt_descr *descr = argpar_error_opt_descr(error, &is_short);
int orig_index = argpar_error_orig_index(error);
const char *arg = argv[orig_index];
if (is_short) {
ret = strutils_appendf(&str,
- WHILE_PARSING_ARG_N_ARG_FMT "Unexpected argument for option `-%c`",
- orig_index + 1 + argc_offset, arg, descr->short_name);
+ WHILE_PARSING_ARG_N_ARG_FMT
+ "Unexpected argument for option `-%c`",
+ orig_index + 1 + argc_offset,
+ arg,
+ descr->short_name);
} else {
ret = strutils_appendf(&str,
- WHILE_PARSING_ARG_N_ARG_FMT "Unexpected argument for option `--%s`",
- orig_index + 1 + argc_offset, arg, descr->long_name);
+ WHILE_PARSING_ARG_N_ARG_FMT
+ "Unexpected argument for option `--%s`",
+ orig_index + 1 + argc_offset,
+ arg,
+ descr->long_name);
}
if (ret < 0) {
const char *unknown_opt = argpar_error_unknown_opt_name(error);
ret = strutils_appendf(&str,
- WHILE_PARSING_ARG_N_ARG_FMT "Unknown option `%s`",
- orig_index + 1 + argc_offset, argv[orig_index], unknown_opt);
+ WHILE_PARSING_ARG_N_ARG_FMT "Unknown option `%s`",
+ orig_index + 1 + argc_offset,
+ argv[orig_index],
+ unknown_opt);
if (ret < 0) {
goto end;
break;
}
default:
- abort ();
+ abort();
}
str_ret = str;
}
enum parse_next_item_status parse_next_item(struct argpar_iter *iter,
- const struct argpar_item **item, int argc_offset,
- const char **argv, bool unknown_opt_is_error,
- const struct argpar_error **error_out,
- const char *context_fmt, ...)
+ const struct argpar_item **item,
+ int argc_offset,
+ const char **argv,
+ bool unknown_opt_is_error,
+ const struct argpar_error **error_out,
+ const char *context_fmt,
+ ...)
{
enum argpar_iter_next_status status;
const struct argpar_error *error = NULL;
char *err_str;
if (argpar_error_type(error) == ARGPAR_ERROR_TYPE_UNKNOWN_OPT &&
- !unknown_opt_is_error) {
+ !unknown_opt_is_error) {
ret = PARSE_NEXT_ITEM_STATUS_END;
break;
}
va_start(args, context_fmt);
- err_str = format_arg_error_v(error, argc_offset, argv,
- context_fmt, args);
+ err_str = format_arg_error_v(error, argc_offset, argv, context_fmt, args);
va_end(args);
if (err_str) {
#include <common/dynamic-buffer.hpp>
#include <common/error.hpp>
-struct lttng_buffer_view lttng_buffer_view_init(
- const char *src, size_t offset, ptrdiff_t len)
+struct lttng_buffer_view lttng_buffer_view_init(const char *src, size_t offset, ptrdiff_t len)
{
struct lttng_buffer_view view = { .data = src + offset, .size = (size_t) len };
return view;
return view && view->data && view->size > 0;
}
-struct lttng_buffer_view lttng_buffer_view_from_view(
- const struct lttng_buffer_view *src, size_t offset,
- ptrdiff_t len)
+struct lttng_buffer_view
+lttng_buffer_view_from_view(const struct lttng_buffer_view *src, size_t offset, ptrdiff_t len)
{
struct lttng_buffer_view view = { .data = NULL, .size = 0 };
if (offset > src->size) {
ERR("Attempt to create buffer view from another view with invalid offset (offset > source size): source size = %zu, offset in source = %zu, length = %zd",
- src->size, offset, len);
+ src->size,
+ offset,
+ len);
goto end;
}
if (len != -1 && len > (src->size - offset)) {
ERR("Attempt to create buffer view from another view with invalid length (length > space left after offset in source): source size = %zu, offset in source = %zu, length = %zd",
- src->size, offset, len);
+ src->size,
+ offset,
+ len);
goto end;
}
}
struct lttng_buffer_view lttng_buffer_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *src, size_t offset,
- ptrdiff_t len)
+ const struct lttng_dynamic_buffer *src, size_t offset, ptrdiff_t len)
{
struct lttng_buffer_view view = { .data = NULL, .size = 0 };
if (offset > src->size) {
ERR("Attempt to create buffer view from a dynamic buffer with invalid offset (offset > source size): source size = %zu, offset in source = %zu, length = %zd",
- src->size, offset, len);
+ src->size,
+ offset,
+ len);
goto end;
}
if (len != -1 && len > (src->size - offset)) {
ERR("Attempt to create buffer view from a dynamic buffer with invalid length (length > space left after offset in source): source size = %zu, offset in source = %zu, length = %zd",
- src->size, offset, len);
+ src->size,
+ offset,
+ len);
goto end;
}
}
bool lttng_buffer_view_contains_string(const struct lttng_buffer_view *buf,
- const char *str,
- size_t len_with_null_terminator)
+ const char *str,
+ size_t len_with_null_terminator)
{
const char *past_buf_end;
size_t max_str_len_with_null_terminator;
*/
#include "bytecode.hpp"
+#include "common/align.hpp"
-#include <errno.h>
#include <algorithm>
-
-#include "common/align.hpp"
+#include <errno.h>
#define INIT_ALLOC_SIZE 4
-static inline
-int get_count_order(unsigned int count)
+static inline int get_count_order(unsigned int count)
{
int order;
}
}
-static
-int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len)
+static int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len)
{
int32_t ret;
uint32_t padding = lttng_offset_align((*fb)->b.len, align);
if (new_alloc_len > old_alloc_len) {
struct lttng_bytecode_alloc *newptr;
- new_alloc_len =
- std::max(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
+ new_alloc_len = std::max(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
newptr = (lttng_bytecode_alloc *) realloc(*fb, new_alloc_len);
if (!newptr)
return -ENOMEM;
return ret;
}
-int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data,
- uint32_t align, uint32_t len)
+int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data, uint32_t align, uint32_t len)
{
int32_t offset;
}
int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
- struct logical_op *data,
- uint32_t align, uint32_t len,
- uint16_t *skip_offset)
+ struct logical_op *data,
+ uint32_t align,
+ uint32_t len,
+ uint16_t *skip_offset)
{
int32_t offset;
if (offset < 0)
return offset;
memcpy(&(*fb)->b.data[offset], data, len);
- *skip_offset =
- (char *) &((struct logical_op *) &(*fb)->b.data[offset])->skip_offset
- - (char *) &(*fb)->b.data[0];
+ *skip_offset = (char *) &((struct logical_op *) &(*fb)->b.data[offset])->skip_offset -
+ (char *) &(*fb)->b.data[0];
return 0;
}
return ret;
}
-int bytecode_push_get_index_u64(struct lttng_bytecode_alloc **bytecode,
- uint64_t index)
+int bytecode_push_get_index_u64(struct lttng_bytecode_alloc **bytecode, uint64_t index)
{
int ret;
struct load_op *insn;
struct get_index_u64 index_op_data;
- const uint32_t insn_len =
- sizeof(struct load_op) + sizeof(struct get_index_u64);
+ const uint32_t insn_len = sizeof(struct load_op) + sizeof(struct get_index_u64);
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
}
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
- struct lttng_bytecode_alloc **bytecode_reloc,
- const char *symbol)
+ struct lttng_bytecode_alloc **bytecode_reloc,
+ const char *symbol)
{
int ret;
struct load_op *insn;
uint32_t reloc_offset_u32;
uint16_t reloc_offset;
uint32_t bytecode_reloc_offset_u32;
- const uint32_t insn_len =
- sizeof(struct load_op) + sizeof(struct get_symbol);
+ const uint32_t insn_len = sizeof(struct load_op) + sizeof(struct get_symbol);
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
* Get offset in the reloc portion at which the symbol name
* will end up at (GET_SYMBOL's operand points there).
*/
- bytecode_reloc_offset_u32 = bytecode_get_len(&(*bytecode_reloc)->b) +
- sizeof(reloc_offset);
+ bytecode_reloc_offset_u32 = bytecode_get_len(&(*bytecode_reloc)->b) + sizeof(reloc_offset);
symbol_offset.offset = (uint16_t) bytecode_reloc_offset_u32;
memcpy(insn->data, &symbol_offset, sizeof(symbol_offset));
}
/* Append reloc offset. */
- ret = bytecode_push(bytecode_reloc, &reloc_offset,
- 1, sizeof(reloc_offset));
+ ret = bytecode_push(bytecode_reloc, &reloc_offset, 1, sizeof(reloc_offset));
if (ret) {
goto end;
}
*
* Return allocated bytecode or NULL on error.
*/
-struct lttng_bytecode *lttng_bytecode_copy(
- const struct lttng_bytecode *orig_f)
+struct lttng_bytecode *lttng_bytecode_copy(const struct lttng_bytecode *orig_f)
{
- lttng_bytecode *bytecode
- = zmalloc<lttng_bytecode>(sizeof(*bytecode) + orig_f->len);
+ lttng_bytecode *bytecode = zmalloc<lttng_bytecode>(sizeof(*bytecode) + orig_f->len);
if (!bytecode) {
goto error;
}
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <lttng/channel-internal.hpp>
#include <lttng/channel.h>
#include <lttng/constant.h>
#include <lttng/userspace-probe-internal.hpp>
-static enum lttng_error_code flatten_lttng_channels(
- struct lttng_dynamic_pointer_array *channels,
- struct lttng_channel **flattened_channels);
+static enum lttng_error_code flatten_lttng_channels(struct lttng_dynamic_pointer_array *channels,
+ struct lttng_channel **flattened_channels);
-static enum lttng_error_code channel_list_create_from_buffer(
- const struct lttng_buffer_view *buffer,
- uint32_t count,
- struct lttng_dynamic_pointer_array *channel_list);
+static enum lttng_error_code
+channel_list_create_from_buffer(const struct lttng_buffer_view *buffer,
+ uint32_t count,
+ struct lttng_dynamic_pointer_array *channel_list);
static void channel_list_destructor(void *ptr)
{
}
ssize_t lttng_channel_create_from_buffer(const struct lttng_buffer_view *view,
- struct lttng_channel **channel)
+ struct lttng_channel **channel)
{
ssize_t ret, offset = 0;
struct lttng_channel *local_channel = nullptr;
/* lttng_trigger_comm header */
{
const struct lttng_buffer_view comm_view =
- lttng_buffer_view_from_view(view, offset,
- sizeof(*channel_comm));
+ lttng_buffer_view_from_view(view, offset, sizeof(*channel_comm));
if (!lttng_buffer_view_is_valid(&comm_view)) {
ret = -1;
goto end;
}
- channel_comm = (const struct lttng_channel_comm *)
- comm_view.data;
+ channel_comm = (const struct lttng_channel_comm *) comm_view.data;
offset += sizeof(*channel_comm);
}
{
const char *name;
const struct lttng_buffer_view name_view =
- lttng_buffer_view_from_view(view, offset,
- channel_comm->name_len);
+ lttng_buffer_view_from_view(view, offset, channel_comm->name_len);
name = name_view.data;
- if (!lttng_buffer_view_contains_string(
- &name_view, name, channel_comm->name_len)) {
+ if (!lttng_buffer_view_contains_string(&name_view, name, channel_comm->name_len)) {
ret = -1;
goto end;
}
- ret = lttng_strncpy(local_channel->name, name,
- sizeof(local_channel->name));
+ ret = lttng_strncpy(local_channel->name, name, sizeof(local_channel->name));
if (ret) {
goto end;
}
local_channel->attr.overwrite = channel_comm->overwrite;
local_channel->attr.subbuf_size = channel_comm->subbuf_size;
local_channel->attr.num_subbuf = channel_comm->num_subbuf;
- local_channel->attr.switch_timer_interval =
- channel_comm->switch_timer_interval;
- local_channel->attr.read_timer_interval =
- channel_comm->read_timer_interval;
+ local_channel->attr.switch_timer_interval = channel_comm->switch_timer_interval;
+ local_channel->attr.read_timer_interval = channel_comm->read_timer_interval;
local_channel->attr.output = (enum lttng_event_output) channel_comm->output;
local_channel->attr.tracefile_size = channel_comm->tracefile_size;
local_channel->attr.tracefile_count = channel_comm->tracefile_count;
- local_channel->attr.live_timer_interval =
- channel_comm->live_timer_interval;
+ local_channel->attr.live_timer_interval = channel_comm->live_timer_interval;
extended->discarded_events = channel_comm->discarded_events;
extended->lost_packets = channel_comm->lost_packets;
return ret;
}
-int lttng_channel_serialize(
- struct lttng_channel *channel, struct lttng_dynamic_buffer *buf)
+int lttng_channel_serialize(struct lttng_channel *channel, struct lttng_dynamic_buffer *buf)
{
int ret;
size_t name_len;
channel_comm.overwrite = channel->attr.overwrite;
channel_comm.subbuf_size = channel->attr.subbuf_size;
channel_comm.num_subbuf = channel->attr.num_subbuf;
- channel_comm.switch_timer_interval =
- channel->attr.switch_timer_interval;
+ channel_comm.switch_timer_interval = channel->attr.switch_timer_interval;
channel_comm.read_timer_interval = channel->attr.read_timer_interval;
channel_comm.output = channel->attr.output;
channel_comm.tracefile_size = channel->attr.tracefile_size;
channel_comm.blocking_timeout = extended->blocking_timeout;
/* Header */
- ret = lttng_dynamic_buffer_append(
- buf, &channel_comm, sizeof(channel_comm));
+ ret = lttng_dynamic_buffer_append(buf, &channel_comm, sizeof(channel_comm));
if (ret) {
goto end;
}
}
void lttng_channel_set_default_extended_attr(struct lttng_domain *domain,
- struct lttng_channel_extended *extended_attr)
+ struct lttng_channel_extended *extended_attr)
{
assert(domain);
assert(extended_attr);
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
- extended_attr->monitor_timer_interval =
- DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
- extended_attr->blocking_timeout =
- DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
+ extended_attr->monitor_timer_interval = DEFAULT_KERNEL_CHANNEL_MONITOR_TIMER;
+ extended_attr->blocking_timeout = DEFAULT_KERNEL_CHANNEL_BLOCKING_TIMEOUT;
break;
case LTTNG_DOMAIN_UST:
switch (domain->buf_type) {
case LTTNG_BUFFER_PER_UID:
extended_attr->monitor_timer_interval =
- DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
- extended_attr->blocking_timeout =
- DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
+ DEFAULT_UST_UID_CHANNEL_MONITOR_TIMER;
+ extended_attr->blocking_timeout = DEFAULT_UST_UID_CHANNEL_BLOCKING_TIMEOUT;
break;
case LTTNG_BUFFER_PER_PID:
default:
if (extended_attr) {
extended_attr->monitor_timer_interval =
- DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
+ DEFAULT_UST_PID_CHANNEL_MONITOR_TIMER;
extended_attr->blocking_timeout =
- DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
+ DEFAULT_UST_PID_CHANNEL_BLOCKING_TIMEOUT;
}
break;
}
}
}
-static enum lttng_error_code channel_list_create_from_buffer(
- const struct lttng_buffer_view *view,
- unsigned int count,
- struct lttng_dynamic_pointer_array *channel_list)
+static enum lttng_error_code
+channel_list_create_from_buffer(const struct lttng_buffer_view *view,
+ unsigned int count,
+ struct lttng_dynamic_pointer_array *channel_list)
{
enum lttng_error_code ret_code;
int ret, i;
ssize_t channel_size;
struct lttng_channel *channel = nullptr;
const struct lttng_buffer_view channel_view =
- lttng_buffer_view_from_view(view, offset, -1);
+ lttng_buffer_view_from_view(view, offset, -1);
- channel_size = lttng_channel_create_from_buffer(
- &channel_view, &channel);
+ channel_size = lttng_channel_create_from_buffer(&channel_view, &channel);
if (channel_size < 0) {
ret_code = LTTNG_ERR_INVALID;
goto end;
}
static enum lttng_error_code flatten_lttng_channels(struct lttng_dynamic_pointer_array *channels,
- struct lttng_channel **flattened_channels)
+ struct lttng_channel **flattened_channels)
{
enum lttng_error_code ret_code;
int ret, i;
* We must ensure that "local_flattened_channels" is never resized so as
* to preserve the validity of the flattened objects.
*/
- ret = lttng_dynamic_buffer_set_capacity(
- &local_flattened_channels, storage_req);
+ ret = lttng_dynamic_buffer_set_capacity(&local_flattened_channels, storage_req);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Start by laying the struct lttng_channel */
for (i = 0; i < nb_channels; i++) {
- const auto *element = (const struct lttng_channel *)
- lttng_dynamic_pointer_array_get_pointer(
- channels, i);
+ const auto *element =
+ (const struct lttng_channel *) lttng_dynamic_pointer_array_get_pointer(
+ channels, i);
if (!element) {
ret_code = LTTNG_ERR_FATAL;
goto end;
}
- ret = lttng_dynamic_buffer_append(&local_flattened_channels,
- element, sizeof(struct lttng_channel));
+ ret = lttng_dynamic_buffer_append(
+ &local_flattened_channels, element, sizeof(struct lttng_channel));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Flatten the extended data */
for (i = 0; i < nb_channels; i++) {
- const auto *element = (const struct lttng_channel *)
- lttng_dynamic_pointer_array_get_pointer(
- channels, i);
+ const auto *element =
+ (const struct lttng_channel *) lttng_dynamic_pointer_array_get_pointer(
+ channels, i);
/*
* Sample the location of the flattened channel we are about
* to modify.
*/
- auto *channel = (struct lttng_channel *)
- (local_flattened_channels.data + (sizeof(struct lttng_channel) * i));
+ auto *channel = (struct lttng_channel *) (local_flattened_channels.data +
+ (sizeof(struct lttng_channel) * i));
/*
* Sample the location of the extended attributes we are about
* to add.
*/
- const auto *channel_extended = (struct lttng_channel_extended *)
- (local_flattened_channels.data + local_flattened_channels.size);
+ const auto *channel_extended =
+ (struct lttng_channel_extended *) (local_flattened_channels.data +
+ local_flattened_channels.size);
if (!element) {
ret_code = LTTNG_ERR_FATAL;
}
ret = lttng_dynamic_buffer_append(&local_flattened_channels,
- element->attr.extended.ptr,
- sizeof(struct lttng_channel_extended));
+ element->attr.extended.ptr,
+ sizeof(struct lttng_channel_extended));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
enum lttng_error_code lttng_channels_create_and_flatten_from_buffer(
- const struct lttng_buffer_view *view,
- uint32_t count,
- struct lttng_channel **channels)
+ const struct lttng_buffer_view *view, uint32_t count, struct lttng_channel **channels)
{
enum lttng_error_code ret_code;
struct lttng_dynamic_pointer_array local_channels;
/* Deserialize the channels */
{
const struct lttng_buffer_view channels_view =
- lttng_buffer_view_from_view(view, 0, -1);
+ lttng_buffer_view_from_view(view, 0, -1);
- ret_code = channel_list_create_from_buffer(
- &channels_view, count, &local_channels);
+ ret_code = channel_list_create_from_buffer(&channels_view, count, &local_channels);
if (ret_code != LTTNG_OK) {
goto end;
}
#define _LGPL_SOURCE
#include <common/compat/fcntl.hpp>
#include <common/macros.hpp>
+
#include <unistd.h>
#ifdef __linux__
-int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
- unsigned int flags)
+int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
{
#ifdef HAVE_SYNC_FILE_RANGE
return sync_file_range(fd, offset, nbytes, flags);
*/
#include <common/compat/directory-handle.hpp>
+#include <common/credentials.hpp>
+#include <common/dynamic-array.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/runas.hpp>
-#include <common/credentials.hpp>
+
#include <lttng/constant.h>
-#include <common/dynamic-array.hpp>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <dirent.h>
#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <dirent.h>
/*
* This compatibility layer shares a common "base" that is implemented
* in terms of an internal API. This file contains two implementations
* of the internal API below.
*/
-static
-int lttng_directory_handle_mkdir(
- const struct lttng_directory_handle *handle,
- const char *path, mode_t mode);
-static
-int _run_as_mkdir(const struct lttng_directory_handle *handle, const char *path,
- mode_t mode, uid_t uid, gid_t gid);
-static
-int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode, uid_t uid, gid_t gid);
-static
-int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
- const char *filename, int flags, mode_t mode);
-static
-int _run_as_open(const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode, uid_t uid, gid_t gid);
-static
-int lttng_directory_handle_unlink(
- const struct lttng_directory_handle *handle,
- const char *filename);
-static
-int _run_as_unlink(const struct lttng_directory_handle *handle,
- const char *filename, uid_t uid, gid_t gid);
-static
-int _lttng_directory_handle_rename(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name);
-static
-int _run_as_rename(const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name, uid_t uid, gid_t gid);
-static
-DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
- const char *path);
-static
-int lttng_directory_handle_rmdir(
- const struct lttng_directory_handle *handle, const char *name);
-static
-int _run_as_rmdir(const struct lttng_directory_handle *handle,
- const char *name, uid_t uid, gid_t gid);
-static
-int _run_as_rmdir_recursive(
- const struct lttng_directory_handle *handle, const char *name,
- uid_t uid, gid_t gid, int flags);
-static
-void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle);
-static
-void lttng_directory_handle_release(struct urcu_ref *ref);
+static int lttng_directory_handle_mkdir(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode);
+static int _run_as_mkdir(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid);
+static int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid);
+static int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode);
+static int _run_as_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid);
+static int lttng_directory_handle_unlink(const struct lttng_directory_handle *handle,
+ const char *filename);
+static int _run_as_unlink(const struct lttng_directory_handle *handle,
+ const char *filename,
+ uid_t uid,
+ gid_t gid);
+static int _lttng_directory_handle_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name);
+static int _run_as_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name,
+ uid_t uid,
+ gid_t gid);
+static DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
+ const char *path);
+static int lttng_directory_handle_rmdir(const struct lttng_directory_handle *handle,
+ const char *name);
+static int
+_run_as_rmdir(const struct lttng_directory_handle *handle, const char *name, uid_t uid, gid_t gid);
+static int _run_as_rmdir_recursive(const struct lttng_directory_handle *handle,
+ const char *name,
+ uid_t uid,
+ gid_t gid,
+ int flags);
+static void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle);
+static void lttng_directory_handle_release(struct urcu_ref *ref);
#ifdef HAVE_DIRFD
struct lttng_directory_handle *lttng_directory_handle_create(const char *path)
{
- lttng_directory_handle cwd_handle {};
+ lttng_directory_handle cwd_handle{};
cwd_handle.dirfd = AT_FDCWD;
/* Open a handle to the CWD if NULL is passed. */
return lttng_directory_handle_create_from_handle(path, &cwd_handle);
}
-struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
- const char *path,
- const struct lttng_directory_handle *ref_handle)
+struct lttng_directory_handle *
+lttng_directory_handle_create_from_handle(const char *path,
+ const struct lttng_directory_handle *ref_handle)
{
int dirfd;
struct lttng_directory_handle *handle = NULL;
return NULL;
}
-struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
- int dirfd)
+struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(int dirfd)
{
int ret;
struct lttng_directory_handle *handle = zmalloc<lttng_directory_handle>();
return handle;
}
-static
-void lttng_directory_handle_release(struct urcu_ref *ref)
+static void lttng_directory_handle_release(struct urcu_ref *ref)
{
int ret;
struct lttng_directory_handle *handle =
- lttng::utils::container_of(ref, <tng_directory_handle::ref);
+ lttng::utils::container_of(ref, <tng_directory_handle::ref);
if (handle->destroy_cb) {
handle->destroy_cb(handle, handle->destroy_cb_data);
free(handle);
}
-struct lttng_directory_handle *lttng_directory_handle_copy(
- const struct lttng_directory_handle *handle)
+struct lttng_directory_handle *
+lttng_directory_handle_copy(const struct lttng_directory_handle *handle)
{
struct lttng_directory_handle *new_handle = NULL;
PERROR("Failed to duplicate directory file descriptor of directory handle");
goto end;
}
- new_handle = lttng_directory_handle_create_from_dirfd(
- new_dirfd);
+ new_handle = lttng_directory_handle_create_from_dirfd(new_dirfd);
if (!new_handle && close(new_dirfd)) {
PERROR("Failed to close directory file descriptor of directory handle");
}
}
bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
- const struct lttng_directory_handle *rhs)
+ const struct lttng_directory_handle *rhs)
{
return lhs->directory_inode == rhs->directory_inode;
}
-static
-void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle)
+static void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle)
{
handle->dirfd = -1;
}
int lttng_directory_handle_stat(const struct lttng_directory_handle *handle,
- const char *path, struct stat *st)
+ const char *path,
+ struct stat *st)
{
return fstatat(handle->dirfd, path, st, 0);
}
-bool lttng_directory_handle_uses_fd(
- const struct lttng_directory_handle *handle)
+bool lttng_directory_handle_uses_fd(const struct lttng_directory_handle *handle)
{
return handle->dirfd != AT_FDCWD;
}
-static
-int lttng_directory_handle_mkdir(
- const struct lttng_directory_handle *handle,
- const char *path, mode_t mode)
+static int lttng_directory_handle_mkdir(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode)
{
return mkdirat(handle->dirfd, path, mode);
}
-static
-int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
- const char *filename, int flags, mode_t mode)
+static int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode)
{
return openat(handle->dirfd, filename, flags, mode);
}
-static
-int _run_as_open(const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
return run_as_openat(handle->dirfd, filename, flags, mode, uid, gid);
}
-static
-int _run_as_unlink(const struct lttng_directory_handle *handle,
- const char *filename, uid_t uid, gid_t gid)
+static int _run_as_unlink(const struct lttng_directory_handle *handle,
+ const char *filename,
+ uid_t uid,
+ gid_t gid)
{
return run_as_unlinkat(handle->dirfd, filename, uid, gid);
}
-static
-int lttng_directory_handle_unlink(
- const struct lttng_directory_handle *handle,
- const char *filename)
+static int lttng_directory_handle_unlink(const struct lttng_directory_handle *handle,
+ const char *filename)
{
return unlinkat(handle->dirfd, filename, 0);
}
-static
-int _run_as_mkdir(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_mkdir(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
return run_as_mkdirat(handle->dirfd, path, mode, uid, gid);
}
-static
-int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
return run_as_mkdirat_recursive(handle->dirfd, path, mode, uid, gid);
}
-static
-int _lttng_directory_handle_rename(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name)
+static int _lttng_directory_handle_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name)
{
- return renameat(old_handle->dirfd, old_name,
- new_handle->dirfd, new_name);
+ return renameat(old_handle->dirfd, old_name, new_handle->dirfd, new_name);
}
-static
-int _run_as_rename(const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name, uid_t uid, gid_t gid)
+static int _run_as_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name,
+ uid_t uid,
+ gid_t gid)
{
- return run_as_renameat(old_handle->dirfd, old_name, new_handle->dirfd,
- new_name, uid, gid);
+ return run_as_renameat(old_handle->dirfd, old_name, new_handle->dirfd, new_name, uid, gid);
}
-static
-DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
- const char *path)
+static DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
+ const char *path)
{
DIR *dir_stream = NULL;
int fd = openat(handle->dirfd, path, O_RDONLY);
return dir_stream;
}
-static
-int lttng_directory_handle_rmdir(
- const struct lttng_directory_handle *handle, const char *name)
+static int lttng_directory_handle_rmdir(const struct lttng_directory_handle *handle,
+ const char *name)
{
int ret = unlinkat(handle->dirfd, name, AT_REMOVEDIR);
if (ret) {
return ret;
}
-static
-int _run_as_rmdir(const struct lttng_directory_handle *handle,
- const char *name, uid_t uid, gid_t gid)
+static int
+_run_as_rmdir(const struct lttng_directory_handle *handle, const char *name, uid_t uid, gid_t gid)
{
return run_as_rmdirat(handle->dirfd, name, uid, gid);
}
-static
-int _run_as_rmdir_recursive(
- const struct lttng_directory_handle *handle, const char *name,
- uid_t uid, gid_t gid, int flags)
+static int _run_as_rmdir_recursive(const struct lttng_directory_handle *handle,
+ const char *name,
+ uid_t uid,
+ gid_t gid,
+ int flags)
{
return run_as_rmdirat_recursive(handle->dirfd, name, uid, gid, flags);
}
#else /* HAVE_DIRFD */
-static
-int get_full_path(const struct lttng_directory_handle *handle,
- const char *subdirectory, char *fullpath, size_t size)
+static int get_full_path(const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ char *fullpath,
+ size_t size)
{
int ret;
- const bool subdirectory_is_absolute =
- subdirectory && *subdirectory == '/';
- const char * const base = subdirectory_is_absolute ?
- subdirectory : handle->base_path;
- const char * const end = subdirectory && !subdirectory_is_absolute ?
- subdirectory : NULL;
+ const bool subdirectory_is_absolute = subdirectory && *subdirectory == '/';
+ const char *const base = subdirectory_is_absolute ? subdirectory : handle->base_path;
+ const char *const end = subdirectory && !subdirectory_is_absolute ? subdirectory : NULL;
const size_t base_len = strlen(base);
const size_t end_len = end ? strlen(end) : 0;
const bool add_separator_slash = end && base[base_len - 1] != '/';
const bool add_trailing_slash = end && end[end_len - 1] != '/';
- ret = snprintf(fullpath, size, "%s%s%s%s",
- base,
- add_separator_slash ? "/" : "",
- end ? end : "",
- add_trailing_slash ? "/" : "");
+ ret = snprintf(fullpath,
+ size,
+ "%s%s%s%s",
+ base,
+ add_separator_slash ? "/" : "",
+ end ? end : "",
+ add_trailing_slash ? "/" : "");
if (ret == -1 || ret >= size) {
ERR("Failed to format subdirectory from directory handle");
ret = -1;
return ret;
}
-static
-struct lttng_directory_handle *_lttng_directory_handle_create(char *path)
+static struct lttng_directory_handle *_lttng_directory_handle_create(char *path)
{
struct lttng_directory_handle *handle = zmalloc<lttng_directory_handle>();
return handle;
}
-struct lttng_directory_handle *lttng_directory_handle_create(
- const char *path)
+struct lttng_directory_handle *lttng_directory_handle_create(const char *path)
{
int ret;
const char *cwd = "";
add_cwd_slash = cwd[cwd_len - 1] != '/';
}
- ret = snprintf(handle_buf, sizeof(handle_buf), "%s%s%s%s",
- cwd,
- add_cwd_slash ? "/" : "",
- path ? : "",
- add_trailing_slash ? "/" : "");
+ ret = snprintf(handle_buf,
+ sizeof(handle_buf),
+ "%s%s%s%s",
+ cwd,
+ add_cwd_slash ? "/" : "",
+ path ?: "",
+ add_trailing_slash ? "/" : "");
if (ret == -1 || ret >= LTTNG_PATH_MAX) {
ERR("Failed to initialize directory handle, failed to format directory path");
goto end;
return new_handle;
}
-struct lttng_directory_handle *lttng_directory_handle_create_from_handle(
- const char *path,
- const struct lttng_directory_handle *ref_handle)
+struct lttng_directory_handle *
+lttng_directory_handle_create_from_handle(const char *path,
+ const struct lttng_directory_handle *ref_handle)
{
int ret;
size_t path_len, handle_path_len;
char full_path[LTTNG_PATH_MAX];
/* Best effort for logging purposes. */
- ret = get_full_path(ref_handle, path, full_path,
- sizeof(full_path));
+ ret = get_full_path(ref_handle, path, full_path, sizeof(full_path));
if (ret) {
full_path[0] = '\0';
}
- ERR("Failed to initialize directory handle to \"%s\": not a directory",
- full_path);
+ ERR("Failed to initialize directory handle to \"%s\": not a directory", full_path);
goto end;
}
if (!path) {
add_trailing_slash = path[path_len - 1] != '/';
- handle_path_len = strlen(ref_handle->base_path) + path_len +
- !!add_trailing_slash;
+ handle_path_len = strlen(ref_handle->base_path) + path_len + !!add_trailing_slash;
if (handle_path_len >= LTTNG_PATH_MAX) {
ERR("Failed to initialize directory handle as the resulting path's length (%zu bytes) exceeds the maximal allowed length (%d bytes)",
- handle_path_len, LTTNG_PATH_MAX);
+ handle_path_len,
+ LTTNG_PATH_MAX);
goto end;
}
new_path = zmalloc<char>(handle_path_len);
goto end;
}
- ret = sprintf(new_handle->base_path, "%s%s%s",
- ref_handle->base_path,
- path,
- add_trailing_slash ? "/" : "");
+ ret = sprintf(new_handle->base_path,
+ "%s%s%s",
+ ref_handle->base_path,
+ path,
+ add_trailing_slash ? "/" : "");
if (ret == -1 || ret >= handle_path_len) {
ERR("Failed to initialize directory handle: path formatting failed");
goto end;
return new_handle;
}
-struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(
- int dirfd)
+struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd(int dirfd)
{
LTTNG_ASSERT(dirfd == AT_FDCWD);
return lttng_directory_handle_create(NULL);
}
-static
-void lttng_directory_handle_release(struct urcu_ref *ref)
+static void lttng_directory_handle_release(struct urcu_ref *ref)
{
struct lttng_directory_handle *handle =
- lttng::utils::container_of(ref, <tng_directory_handle::ref);
+ lttng::utils::container_of(ref, <tng_directory_handle::ref);
free(handle->base_path);
lttng_directory_handle_invalidate(handle);
free(handle);
}
-struct lttng_directory_handle *lttng_directory_handle_copy(
- const struct lttng_directory_handle *handle)
+struct lttng_directory_handle *
+lttng_directory_handle_copy(const struct lttng_directory_handle *handle)
{
struct lttng_directory_handle *new_handle = NULL;
char *new_path = NULL;
}
bool lttng_directory_handle_equals(const struct lttng_directory_handle *lhs,
- const struct lttng_directory_handle *rhs)
+ const struct lttng_directory_handle *rhs)
{
return strcmp(lhs->base_path, rhs->base_path) == 0;
}
-static
-void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle)
+static void lttng_directory_handle_invalidate(struct lttng_directory_handle *handle)
{
handle->base_path = NULL;
}
int lttng_directory_handle_stat(const struct lttng_directory_handle *handle,
- const char *subdirectory, struct stat *st)
+ const char *subdirectory,
+ struct stat *st)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-bool lttng_directory_handle_uses_fd(
- const struct lttng_directory_handle *handle)
+bool lttng_directory_handle_uses_fd(const struct lttng_directory_handle *handle)
{
return false;
}
-static
-int lttng_directory_handle_mkdir(const struct lttng_directory_handle *handle,
- const char *subdirectory, mode_t mode)
+static int lttng_directory_handle_mkdir(const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ mode_t mode)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
- const char *filename, int flags, mode_t mode)
+static int lttng_directory_handle_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int lttng_directory_handle_unlink(
- const struct lttng_directory_handle *handle,
- const char *filename)
+static int lttng_directory_handle_unlink(const struct lttng_directory_handle *handle,
+ const char *filename)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_mkdir(const struct lttng_directory_handle *handle, const char *path,
- mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_mkdir(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_open(const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_open(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_unlink(const struct lttng_directory_handle *handle,
- const char *filename, uid_t uid, gid_t gid)
+static int _run_as_unlink(const struct lttng_directory_handle *handle,
+ const char *filename,
+ uid_t uid,
+ gid_t gid)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode, uid_t uid, gid_t gid)
+static int _run_as_mkdir_recursive(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode,
+ uid_t uid,
+ gid_t gid)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _lttng_directory_handle_rename(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name)
+static int _lttng_directory_handle_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name)
{
int ret;
char old_fullpath[LTTNG_PATH_MAX];
char new_fullpath[LTTNG_PATH_MAX];
- ret = get_full_path(old_handle, old_name, old_fullpath,
- sizeof(old_fullpath));
+ ret = get_full_path(old_handle, old_name, old_fullpath, sizeof(old_fullpath));
if (ret) {
errno = ENOMEM;
goto end;
}
- ret = get_full_path(new_handle, new_name, new_fullpath,
- sizeof(new_fullpath));
+ ret = get_full_path(new_handle, new_name, new_fullpath, sizeof(new_fullpath));
if (ret) {
errno = ENOMEM;
goto end;
return ret;
}
-static
-int _run_as_rename(const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name, uid_t uid, gid_t gid)
+static int _run_as_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name,
+ uid_t uid,
+ gid_t gid)
{
int ret;
char old_fullpath[LTTNG_PATH_MAX];
char new_fullpath[LTTNG_PATH_MAX];
- ret = get_full_path(old_handle, old_name, old_fullpath,
- sizeof(old_fullpath));
+ ret = get_full_path(old_handle, old_name, old_fullpath, sizeof(old_fullpath));
if (ret) {
errno = ENOMEM;
goto end;
}
- ret = get_full_path(new_handle, new_name, new_fullpath,
- sizeof(new_fullpath));
+ ret = get_full_path(new_handle, new_name, new_fullpath, sizeof(new_fullpath));
if (ret) {
errno = ENOMEM;
goto end;
return ret;
}
-static
-DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
- const char *path)
+static DIR *lttng_directory_handle_opendir(const struct lttng_directory_handle *handle,
+ const char *path)
{
int ret;
DIR *dir_stream = NULL;
return dir_stream;
}
-static
-int lttng_directory_handle_rmdir(
- const struct lttng_directory_handle *handle, const char *name)
+static int lttng_directory_handle_rmdir(const struct lttng_directory_handle *handle,
+ const char *name)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_rmdir(const struct lttng_directory_handle *handle,
- const char *name, uid_t uid, gid_t gid)
+static int
+_run_as_rmdir(const struct lttng_directory_handle *handle, const char *name, uid_t uid, gid_t gid)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
return ret;
}
-static
-int _run_as_rmdir_recursive(
- const struct lttng_directory_handle *handle, const char *name,
- uid_t uid, gid_t gid, int flags)
+static int _run_as_rmdir_recursive(const struct lttng_directory_handle *handle,
+ const char *name,
+ uid_t uid,
+ gid_t gid,
+ int flags)
{
int ret;
char fullpath[LTTNG_PATH_MAX];
*
* Checking the path for existence allows us to work around this behaviour.
*/
-static
-int create_directory_check_exists(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode)
+static int create_directory_check_exists(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode)
{
int ret = 0;
struct stat st;
return ret;
}
-static
-int create_directory_recursive(const struct lttng_directory_handle *handle,
- const char *path, mode_t mode)
+static int create_directory_recursive(const struct lttng_directory_handle *handle,
+ const char *path,
+ mode_t mode)
{
char *p, tmp[LTTNG_PATH_MAX];
size_t len;
ret = lttng_strncpy(tmp, path, sizeof(tmp));
if (ret) {
ERR("Failed to create directory: provided path's length (%zu bytes) exceeds the maximal allowed length (%zu bytes)",
- strlen(path) + 1, sizeof(tmp));
+ strlen(path) + 1,
+ sizeof(tmp));
goto error;
}
for (p = tmp + 1; *p; p++) {
if (*p == '/') {
*p = 0;
- if (tmp[strlen(tmp) - 1] == '.' &&
- tmp[strlen(tmp) - 2] == '.' &&
- tmp[strlen(tmp) - 3] == '/') {
- ERR("Using '/../' is not permitted in the trace path (%s)",
- tmp);
+ if (tmp[strlen(tmp) - 1] == '.' && tmp[strlen(tmp) - 2] == '.' &&
+ tmp[strlen(tmp) - 3] == '/') {
+ ERR("Using '/../' is not permitted in the trace path (%s)", tmp);
ret = -1;
goto error;
}
ret = create_directory_check_exists(handle, tmp, mode);
if (ret < 0) {
if (errno != EACCES) {
- PERROR("Failed to create directory \"%s\"",
- path);
+ PERROR("Failed to create directory \"%s\"", path);
ret = -errno;
goto error;
}
urcu_ref_put(&handle->ref, lttng_directory_handle_release);
}
-int lttng_directory_handle_create_subdirectory_as_user(
- const struct lttng_directory_handle *handle,
- const char *subdirectory,
- mode_t mode, const struct lttng_credentials *creds)
+int lttng_directory_handle_create_subdirectory_as_user(const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ mode_t mode,
+ const struct lttng_credentials *creds)
{
int ret;
if (!creds) {
/* Run as current user. */
- ret = create_directory_check_exists(handle,
- subdirectory, mode);
+ ret = create_directory_check_exists(handle, subdirectory, mode);
} else {
- ret = _run_as_mkdir(handle, subdirectory, mode,
- lttng_credentials_get_uid(creds),
- lttng_credentials_get_gid(creds));
+ ret = _run_as_mkdir(handle,
+ subdirectory,
+ mode,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
int lttng_directory_handle_create_subdirectory_recursive_as_user(
- const struct lttng_directory_handle *handle,
- const char *subdirectory_path,
- mode_t mode, const struct lttng_credentials *creds)
+ const struct lttng_directory_handle *handle,
+ const char *subdirectory_path,
+ mode_t mode,
+ const struct lttng_credentials *creds)
{
int ret;
if (!creds) {
/* Run as current user. */
- ret = create_directory_recursive(handle,
- subdirectory_path, mode);
+ ret = create_directory_recursive(handle, subdirectory_path, mode);
} else {
- ret = _run_as_mkdir_recursive(handle, subdirectory_path,
- mode, lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds));
+ ret = _run_as_mkdir_recursive(handle,
+ subdirectory_path,
+ mode,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
-int lttng_directory_handle_create_subdirectory(
- const struct lttng_directory_handle *handle,
- const char *subdirectory,
- mode_t mode)
+int lttng_directory_handle_create_subdirectory(const struct lttng_directory_handle *handle,
+ const char *subdirectory,
+ mode_t mode)
{
- return lttng_directory_handle_create_subdirectory_as_user(
- handle, subdirectory, mode, NULL);
+ return lttng_directory_handle_create_subdirectory_as_user(handle, subdirectory, mode, NULL);
}
int lttng_directory_handle_create_subdirectory_recursive(
- const struct lttng_directory_handle *handle,
- const char *subdirectory_path,
- mode_t mode)
+ const struct lttng_directory_handle *handle, const char *subdirectory_path, mode_t mode)
{
return lttng_directory_handle_create_subdirectory_recursive_as_user(
- handle, subdirectory_path, mode, NULL);
+ handle, subdirectory_path, mode, NULL);
}
-int lttng_directory_handle_open_file_as_user(
- const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode,
- const struct lttng_credentials *creds)
+int lttng_directory_handle_open_file_as_user(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode,
+ const struct lttng_credentials *creds)
{
int ret;
if (!creds) {
/* Run as current user. */
- ret = lttng_directory_handle_open(handle, filename, flags,
- mode);
+ ret = lttng_directory_handle_open(handle, filename, flags, mode);
} else {
- ret = _run_as_open(handle, filename, flags, mode,
- lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds));
+ ret = _run_as_open(handle,
+ filename,
+ flags,
+ mode,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
-int lttng_directory_handle_open_file(
- const struct lttng_directory_handle *handle,
- const char *filename,
- int flags, mode_t mode)
+int lttng_directory_handle_open_file(const struct lttng_directory_handle *handle,
+ const char *filename,
+ int flags,
+ mode_t mode)
{
- return lttng_directory_handle_open_file_as_user(handle, filename, flags,
- mode, NULL);
+ return lttng_directory_handle_open_file_as_user(handle, filename, flags, mode, NULL);
}
-int lttng_directory_handle_unlink_file_as_user(
- const struct lttng_directory_handle *handle,
- const char *filename,
- const struct lttng_credentials *creds)
+int lttng_directory_handle_unlink_file_as_user(const struct lttng_directory_handle *handle,
+ const char *filename,
+ const struct lttng_credentials *creds)
{
int ret;
/* Run as current user. */
ret = lttng_directory_handle_unlink(handle, filename);
} else {
- ret = _run_as_unlink(handle, filename, lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds));
+ ret = _run_as_unlink(handle,
+ filename,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
-int lttng_directory_handle_unlink_file(
- const struct lttng_directory_handle *handle,
- const char *filename)
+int lttng_directory_handle_unlink_file(const struct lttng_directory_handle *handle,
+ const char *filename)
{
- return lttng_directory_handle_unlink_file_as_user(handle,
- filename, NULL);
+ return lttng_directory_handle_unlink_file_as_user(handle, filename, NULL);
}
-int lttng_directory_handle_rename(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name)
+int lttng_directory_handle_rename(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name)
{
- return lttng_directory_handle_rename_as_user(old_handle, old_name,
- new_handle, new_name, NULL);
+ return lttng_directory_handle_rename_as_user(
+ old_handle, old_name, new_handle, new_name, NULL);
}
-int lttng_directory_handle_rename_as_user(
- const struct lttng_directory_handle *old_handle,
- const char *old_name,
- const struct lttng_directory_handle *new_handle,
- const char *new_name,
- const struct lttng_credentials *creds)
+int lttng_directory_handle_rename_as_user(const struct lttng_directory_handle *old_handle,
+ const char *old_name,
+ const struct lttng_directory_handle *new_handle,
+ const char *new_name,
+ const struct lttng_credentials *creds)
{
int ret;
if (!creds) {
/* Run as current user. */
- ret = _lttng_directory_handle_rename(old_handle,
- old_name, new_handle, new_name);
+ ret = _lttng_directory_handle_rename(old_handle, old_name, new_handle, new_name);
} else {
- ret = _run_as_rename(old_handle, old_name, new_handle,
- new_name, lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds));
+ ret = _run_as_rename(old_handle,
+ old_name,
+ new_handle,
+ new_name,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
-int lttng_directory_handle_remove_subdirectory(
- const struct lttng_directory_handle *handle,
- const char *name)
+int lttng_directory_handle_remove_subdirectory(const struct lttng_directory_handle *handle,
+ const char *name)
{
- return lttng_directory_handle_remove_subdirectory_as_user(handle, name,
- NULL);
+ return lttng_directory_handle_remove_subdirectory_as_user(handle, name, NULL);
}
-int lttng_directory_handle_remove_subdirectory_as_user(
- const struct lttng_directory_handle *handle,
- const char *name,
- const struct lttng_credentials *creds)
+int lttng_directory_handle_remove_subdirectory_as_user(const struct lttng_directory_handle *handle,
+ const char *name,
+ const struct lttng_credentials *creds)
{
int ret;
/* Run as current user. */
ret = lttng_directory_handle_rmdir(handle, name);
} else {
- ret = _run_as_rmdir(handle, name, lttng_credentials_get_uid(creds), lttng_credentials_get_gid(creds));
+ ret = _run_as_rmdir(handle,
+ name,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds));
}
return ret;
}
};
} /* namespace */
-static
-void rmdir_frame_fini(void *data)
+static void rmdir_frame_fini(void *data)
{
int ret;
struct rmdir_frame *frame = (rmdir_frame *) data;
}
}
-static
-int remove_directory_recursive(const struct lttng_directory_handle *handle,
- const char *path, int flags)
+static int
+remove_directory_recursive(const struct lttng_directory_handle *handle, const char *path, int flags)
{
int ret;
struct lttng_dynamic_array frames;
const char separator = '/';
lttng_dynamic_buffer_init(¤t_path);
- lttng_dynamic_array_init(&frames, sizeof(struct rmdir_frame),
- rmdir_frame_fini);
+ lttng_dynamic_array_init(&frames, sizeof(struct rmdir_frame), rmdir_frame_fini);
- if (flags & ~(LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG |
- LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG)) {
+ if (flags &
+ ~(LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG |
+ LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG)) {
ERR("Unknown flags %d", flags);
ret = -1;
goto end;
}
if (!initial_frame.dir) {
- if (flags & LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG &&
- errno == ENOENT) {
+ if (flags & LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG && errno == ENOENT) {
DBG("Cannot rmdir \"%s\": root does not exist", path);
ret = 0;
goto end;
goto end;
}
- ret = lttng_dynamic_buffer_append(
- ¤t_path, path, initial_frame.path_size);
+ ret = lttng_dynamic_buffer_append(¤t_path, path, initial_frame.path_size);
if (ret) {
ERR("Failed to set initial path during recursive directory removal");
ret = -1;
while (lttng_dynamic_array_get_count(&frames) > 0) {
struct dirent *entry;
struct rmdir_frame *current_frame =
- (rmdir_frame *) lttng_dynamic_array_get_element(
- &frames, current_frame_idx);
+ (rmdir_frame *) lttng_dynamic_array_get_element(&frames, current_frame_idx);
LTTNG_ASSERT(current_frame->dir);
- ret = lttng_dynamic_buffer_set_size(
- ¤t_path, current_frame->path_size);
+ ret = lttng_dynamic_buffer_set_size(¤t_path, current_frame->path_size);
LTTNG_ASSERT(!ret);
current_path.data[current_path.size - 1] = '\0';
while ((entry = readdir(current_frame->dir))) {
struct stat st;
- if (!strcmp(entry->d_name, ".") ||
- !strcmp(entry->d_name, "..")) {
+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
/* Set current_path to the entry's path. */
- ret = lttng_dynamic_buffer_set_size(
- ¤t_path, current_path.size - 1);
+ ret = lttng_dynamic_buffer_set_size(¤t_path, current_path.size - 1);
LTTNG_ASSERT(!ret);
- ret = lttng_dynamic_buffer_append(¤t_path,
- &separator, sizeof(separator));
+ ret = lttng_dynamic_buffer_append(
+ ¤t_path, &separator, sizeof(separator));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(¤t_path,
- entry->d_name,
- strlen(entry->d_name) + 1);
+ ret = lttng_dynamic_buffer_append(
+ ¤t_path, entry->d_name, strlen(entry->d_name) + 1);
if (ret) {
goto end;
}
- if (lttng_directory_handle_stat(
- handle, current_path.data, &st)) {
+ if (lttng_directory_handle_stat(handle, current_path.data, &st)) {
if ((flags & LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG) &&
- errno == ENOENT) {
+ errno == ENOENT) {
break;
}
- PERROR("Failed to stat \"%s\"",
- current_path.data);
+ PERROR("Failed to stat \"%s\"", current_path.data);
ret = -1;
goto end;
}
} else {
/* Not empty, abort. */
DBG("Directory \"%s\" is not empty; refusing to remove directory",
- current_path.data);
+ current_path.data);
ret = -1;
goto end;
}
} else {
struct rmdir_frame new_frame = {
.parent_frame_idx = (ssize_t) current_frame_idx,
- .dir = lttng_directory_handle_opendir(
- handle,
- current_path.data),
+ .dir = lttng_directory_handle_opendir(handle,
+ current_path.data),
.empty = true,
.path_size = current_path.size,
};
if (!new_frame.dir) {
if (flags & LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG &&
- errno == ENOENT) {
+ errno == ENOENT) {
DBG("Non-existing directory stream during recursive directory removal");
break;
} else {
goto end;
}
}
- ret = lttng_dynamic_array_add_element(
- &frames, &new_frame);
+ ret = lttng_dynamic_array_add_element(&frames, &new_frame);
if (ret) {
ERR("Failed to push context frame during recursive directory removal");
rmdir_frame_fini(&new_frame);
/* Pop rmdir frame. */
if (current_frame->empty) {
- ret = lttng_directory_handle_rmdir(
- handle, current_path.data);
+ ret = lttng_directory_handle_rmdir(handle, current_path.data);
if (ret) {
if ((flags & LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG) ||
- errno != ENOENT) {
+ errno != ENOENT) {
PERROR("Failed to remove \"%s\" during recursive directory removal",
- current_path.data);
+ current_path.data);
goto end;
}
DBG("Non-existing directory stream during recursive directory removal");
} else if (current_frame->parent_frame_idx >= 0) {
struct rmdir_frame *parent_frame;
- parent_frame = (rmdir_frame *) lttng_dynamic_array_get_element(&frames,
- current_frame->parent_frame_idx);
+ parent_frame = (rmdir_frame *) lttng_dynamic_array_get_element(
+ &frames, current_frame->parent_frame_idx);
LTTNG_ASSERT(parent_frame);
parent_frame->empty = false;
}
- ret = lttng_dynamic_array_remove_element(
- &frames, current_frame_idx);
+ ret = lttng_dynamic_array_remove_element(&frames, current_frame_idx);
if (ret) {
ERR("Failed to pop context frame during recursive directory removal");
goto end;
}
int lttng_directory_handle_remove_subdirectory_recursive(
- const struct lttng_directory_handle *handle,
- const char *name,
- int flags)
+ const struct lttng_directory_handle *handle, const char *name, int flags)
{
return lttng_directory_handle_remove_subdirectory_recursive_as_user(
- handle, name, NULL, flags);
+ handle, name, NULL, flags);
}
int lttng_directory_handle_remove_subdirectory_recursive_as_user(
- const struct lttng_directory_handle *handle,
- const char *name,
- const struct lttng_credentials *creds,
- int flags)
+ const struct lttng_directory_handle *handle,
+ const char *name,
+ const struct lttng_credentials *creds,
+ int flags)
{
int ret;
/* Run as current user. */
ret = remove_directory_recursive(handle, name, flags);
} else {
- ret = _run_as_rmdir_recursive(handle, name, lttng_credentials_get_uid(creds),
- lttng_credentials_get_gid(creds), flags);
+ ret = _run_as_rmdir_recursive(handle,
+ name,
+ lttng_credentials_get_uid(creds),
+ lttng_credentials_get_gid(creds),
+ flags);
}
return ret;
}
*/
#define _LGPL_SOURCE
-#include <stdlib.h>
-#include <stdbool.h>
+#include "poll.hpp"
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/utils.hpp>
-#include "poll.hpp"
+#include <stdbool.h>
+#include <stdlib.h>
#ifdef HAVE_EPOLL
#include <fcntl.h>
#include <limits.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
/*
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
-static int resize_poll_event(struct lttng_poll_event *events,
- uint32_t new_size)
+static int resize_poll_event(struct lttng_poll_event *events, uint32_t new_size)
{
struct epoll_event *ptr;
}
if (new_size > events->alloc_size) {
/* Zero newly allocated memory */
- memset(ptr + events->alloc_size, 0,
- (new_size - events->alloc_size) * sizeof(*ptr));
+ memset(ptr + events->alloc_size, 0, (new_size - events->alloc_size) * sizeof(*ptr));
}
events->events = ptr;
events->alloc_size = new_size;
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
-int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible)
+int compat_epoll_wait(struct lttng_poll_event *events, int timeout, bool interruptible)
{
int ret;
uint32_t new_size;
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
-static int resize_poll_event(struct compat_poll_event_array *array,
- uint32_t new_size)
+static int resize_poll_event(struct compat_poll_event_array *array, uint32_t new_size)
{
struct pollfd *ptr;
}
if (new_size > array->alloc_size) {
/* Zero newly allocated memory */
- memset(ptr + array->alloc_size, 0,
- (new_size - array->alloc_size) * sizeof(*ptr));
+ memset(ptr + array->alloc_size, 0, (new_size - array->alloc_size) * sizeof(*ptr));
}
array->events = ptr;
array->alloc_size = new_size;
goto error;
}
}
- memcpy(wait->events, current->events,
- current->nb_fd * sizeof(*current->events));
+ memcpy(wait->events, current->events, current->nb_fd * sizeof(*current->events));
/* Update is done. */
events->need_update = 0;
/*
* Add fd to pollfd data structure with requested events.
*/
-int compat_poll_add(struct lttng_poll_event *events, int fd,
- uint32_t req_events)
+int compat_poll_add(struct lttng_poll_event *events, int fd, uint32_t req_events)
{
int new_size, ret, i;
struct compat_poll_event_array *current;
/*
* Modify an fd's events..
*/
-int compat_poll_mod(struct lttng_poll_event *events, int fd,
- uint32_t req_events)
+int compat_poll_mod(struct lttng_poll_event *events, int fd, uint32_t req_events)
{
int i;
struct compat_poll_event_array *current;
- if (events == NULL || events->current.nb_fd == 0 ||
- events->current.events == NULL || fd < 0) {
+ if (events == NULL || events->current.nb_fd == 0 || events->current.events == NULL ||
+ fd < 0) {
ERR("Bad compat poll mod arguments");
goto error;
}
uint32_t new_size;
struct compat_poll_event_array *current;
- if (events == NULL || events->current.nb_fd == 0 ||
- events->current.events == NULL || fd < 0) {
+ if (events == NULL || events->current.nb_fd == 0 || events->current.events == NULL ||
+ fd < 0) {
goto error;
}
/* Resize array if needed. */
new_size = 1U << utils_get_count_order_u32(current->nb_fd);
- if (new_size != current->alloc_size && new_size >= current->init_size
- && current->nb_fd != 0) {
+ if (new_size != current->alloc_size && new_size >= current->init_size &&
+ current->nb_fd != 0) {
ret = resize_poll_event(current, new_size);
if (ret < 0) {
goto error;
/*
* Wait on poll() with timeout. Blocking call.
*/
-int compat_poll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible)
+int compat_poll_wait(struct lttng_poll_event *events, int timeout, bool interruptible)
{
int ret, active_fd_count;
size_t pos = 0, consecutive_entries = 0, non_idle_pos;
non_idle_pos = pos;
/* Look for next non-idle entry. */
- while (events->wait.events[++non_idle_pos].revents == 0);
+ while (events->wait.events[++non_idle_pos].revents == 0)
+ ;
/* Swap idle and non-idle entries. */
idle_entry = *current;
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
-#include <float.h>
+
#include <lttng/condition/buffer-usage-internal.hpp>
#include <lttng/condition/condition-internal.hpp>
+
+#include <float.h>
#include <math.h>
#include <time.h>
-#define IS_USAGE_CONDITION(condition) ( \
- lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW || \
- lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH \
- )
+#define IS_USAGE_CONDITION(condition) \
+ (lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW || \
+ lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH)
-static
-bool is_usage_evaluation(const struct lttng_evaluation *evaluation)
+static bool is_usage_evaluation(const struct lttng_evaluation *evaluation)
{
enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
return type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW ||
- type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
+ type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH;
}
-static
-void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition)
+static void lttng_condition_buffer_usage_destroy(struct lttng_condition *condition)
{
struct lttng_condition_buffer_usage *usage;
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
free(usage->session_name);
free(usage->channel_name);
free(usage);
}
-static
-bool lttng_condition_buffer_usage_validate(
- const struct lttng_condition *condition)
+static bool lttng_condition_buffer_usage_validate(const struct lttng_condition *condition)
{
bool valid = false;
struct lttng_condition_buffer_usage *usage;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->session_name) {
ERR("Invalid buffer condition: a target session name must be set.");
goto end;
return valid;
}
-static
-int lttng_condition_buffer_usage_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload)
+static int lttng_condition_buffer_usage_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_condition_buffer_usage *usage;
}
DBG("Serializing buffer usage condition");
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
session_name_len = strlen(usage->session_name) + 1;
channel_name_len = strlen(usage->channel_name) + 1;
- if (session_name_len > LTTNG_NAME_MAX ||
- channel_name_len > LTTNG_NAME_MAX) {
+ if (session_name_len > LTTNG_NAME_MAX || channel_name_len > LTTNG_NAME_MAX) {
ret = -1;
goto end;
}
usage_comm.threshold_ratio = usage->threshold_ratio.value;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, &usage_comm,
- sizeof(usage_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &usage_comm, sizeof(usage_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, usage->session_name,
- session_name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, usage->session_name, session_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, usage->channel_name,
- channel_name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, usage->channel_name, channel_name_len);
if (ret) {
goto end;
}
return ret;
}
-static
-bool lttng_condition_buffer_usage_is_equal(const struct lttng_condition *_a,
- const struct lttng_condition *_b)
+static bool lttng_condition_buffer_usage_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b)
{
bool is_equal = false;
struct lttng_condition_buffer_usage *a, *b;
b = lttng::utils::container_of(_b, <tng_condition_buffer_usage::parent);
if ((a->threshold_ratio.set && !b->threshold_ratio.set) ||
- (a->threshold_bytes.set && !b->threshold_bytes.set)) {
+ (a->threshold_bytes.set && !b->threshold_bytes.set)) {
goto end;
}
return is_equal;
}
-static enum lttng_error_code lttng_condition_buffer_usage_mi_serialize(
- const struct lttng_condition *condition,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_condition_buffer_usage_mi_serialize(const struct lttng_condition *condition,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(condition);
LTTNG_ASSERT(IS_USAGE_CONDITION(condition));
- status = lttng_condition_buffer_usage_get_session_name(
- condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(condition, &session_name);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(session_name);
- status = lttng_condition_buffer_usage_get_channel_name(
- condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(condition, &channel_name);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(session_name);
- status = lttng_condition_buffer_usage_get_domain_type(
- condition, &domain_type);
+ status = lttng_condition_buffer_usage_get_domain_type(condition, &domain_type);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
- status = lttng_condition_buffer_usage_get_threshold(
- condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(condition, &threshold_bytes);
if (status == LTTNG_CONDITION_STATUS_OK) {
is_threshold_bytes = true;
} else if (status != LTTNG_CONDITION_STATUS_UNSET) {
}
if (!is_threshold_bytes) {
- status = lttng_condition_buffer_usage_get_threshold_ratio(
- condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(condition,
+ &threshold_ratio);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
}
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
- condition_type_str =
- mi_lttng_element_condition_buffer_usage_high;
+ condition_type_str = mi_lttng_element_condition_buffer_usage_high;
break;
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
- condition_type_str =
- mi_lttng_element_condition_buffer_usage_low;
+ condition_type_str = mi_lttng_element_condition_buffer_usage_low;
break;
default:
abort();
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
/* Channel name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_condition_channel_name, channel_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_condition_channel_name, channel_name);
if (ret) {
goto mi_error;
}
/* Domain. */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_domain,
- mi_lttng_domaintype_string(domain_type));
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_domain, mi_lttng_domaintype_string(domain_type));
if (ret) {
goto mi_error;
}
if (is_threshold_bytes) {
/* Usage in bytes. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_condition_threshold_bytes,
- threshold_bytes);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_condition_threshold_bytes, threshold_bytes);
if (ret) {
goto mi_error;
}
} else {
/* Ratio. */
- ret = mi_lttng_writer_write_element_double(writer,
- mi_lttng_element_condition_threshold_ratio,
- threshold_ratio);
+ ret = mi_lttng_writer_write_element_double(
+ writer, mi_lttng_element_condition_threshold_ratio, threshold_ratio);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-struct lttng_condition *lttng_condition_buffer_usage_create(
- enum lttng_condition_type type)
+static struct lttng_condition *lttng_condition_buffer_usage_create(enum lttng_condition_type type)
{
struct lttng_condition_buffer_usage *condition;
struct lttng_condition *lttng_condition_buffer_usage_low_create(void)
{
- return lttng_condition_buffer_usage_create(
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
+ return lttng_condition_buffer_usage_create(LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
}
struct lttng_condition *lttng_condition_buffer_usage_high_create(void)
{
- return lttng_condition_buffer_usage_create(
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
+ return lttng_condition_buffer_usage_create(LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
}
-static
-ssize_t init_condition_from_payload(struct lttng_condition *condition,
- struct lttng_payload_view *src_view)
+static ssize_t init_condition_from_payload(struct lttng_condition *condition,
+ struct lttng_payload_view *src_view)
{
ssize_t ret, condition_size;
enum lttng_condition_status status;
struct lttng_buffer_view names_view;
const struct lttng_condition_buffer_usage_comm *condition_comm;
const struct lttng_payload_view condition_comm_view =
- lttng_payload_view_from_view(
- src_view, 0, sizeof(*condition_comm));
+ lttng_payload_view_from_view(src_view, 0, sizeof(*condition_comm));
if (!lttng_payload_view_is_valid(&condition_comm_view)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain header");
}
condition_comm = (typeof(condition_comm)) condition_comm_view.buffer.data;
- names_view = lttng_buffer_view_from_view(&src_view->buffer,
- sizeof(*condition_comm), -1);
+ names_view = lttng_buffer_view_from_view(&src_view->buffer, sizeof(*condition_comm), -1);
if (condition_comm->session_name_len > LTTNG_NAME_MAX ||
- condition_comm->channel_name_len > LTTNG_NAME_MAX) {
+ condition_comm->channel_name_len > LTTNG_NAME_MAX) {
ERR("Failed to initialize from malformed condition buffer: name exceeds LTTNG_MAX_NAME");
ret = -1;
goto end;
}
if (names_view.size <
- (condition_comm->session_name_len +
- condition_comm->channel_name_len)) {
+ (condition_comm->session_name_len + condition_comm->channel_name_len)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain element names");
ret = -1;
goto end;
}
if (condition_comm->threshold_set_in_bytes) {
- status = lttng_condition_buffer_usage_set_threshold(condition,
- condition_comm->threshold_bytes);
+ status = lttng_condition_buffer_usage_set_threshold(
+ condition, condition_comm->threshold_bytes);
} else {
status = lttng_condition_buffer_usage_set_threshold_ratio(
- condition, condition_comm->threshold_ratio);
+ condition, condition_comm->threshold_ratio);
}
if (status != LTTNG_CONDITION_STATUS_OK) {
}
if (condition_comm->domain_type <= LTTNG_DOMAIN_NONE ||
- condition_comm->domain_type > LTTNG_DOMAIN_PYTHON) {
+ condition_comm->domain_type > LTTNG_DOMAIN_PYTHON) {
/* Invalid domain value. */
ERR("Invalid domain type value (%i) found in condition buffer",
- (int) condition_comm->domain_type);
+ (int) condition_comm->domain_type);
ret = -1;
goto end;
}
domain_type = (enum lttng_domain_type) condition_comm->domain_type;
- status = lttng_condition_buffer_usage_set_domain_type(condition,
- domain_type);
+ status = lttng_condition_buffer_usage_set_domain_type(condition, domain_type);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to set buffer usage condition domain");
ret = -1;
goto end;
}
- status = lttng_condition_buffer_usage_set_session_name(condition,
- session_name);
+ status = lttng_condition_buffer_usage_set_session_name(condition, session_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to set buffer usage session name");
ret = -1;
goto end;
}
- status = lttng_condition_buffer_usage_set_channel_name(condition,
- channel_name);
+ status = lttng_condition_buffer_usage_set_channel_name(condition, channel_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to set buffer usage channel name");
ret = -1;
goto end;
}
- condition_size = sizeof(*condition_comm) +
- (ssize_t) condition_comm->session_name_len +
- (ssize_t) condition_comm->channel_name_len;
+ condition_size = sizeof(*condition_comm) + (ssize_t) condition_comm->session_name_len +
+ (ssize_t) condition_comm->channel_name_len;
ret = condition_size;
end:
return ret;
}
-ssize_t lttng_condition_buffer_usage_low_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **_condition)
+ssize_t lttng_condition_buffer_usage_low_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **_condition)
{
ssize_t ret;
- struct lttng_condition *condition =
- lttng_condition_buffer_usage_low_create();
+ struct lttng_condition *condition = lttng_condition_buffer_usage_low_create();
if (!_condition || !condition) {
ret = -1;
return ret;
}
-ssize_t lttng_condition_buffer_usage_high_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **_condition)
+ssize_t lttng_condition_buffer_usage_high_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **_condition)
{
ssize_t ret;
- struct lttng_condition *condition =
- lttng_condition_buffer_usage_high_create();
+ struct lttng_condition *condition = lttng_condition_buffer_usage_high_create();
if (!_condition || !condition) {
ret = -1;
return ret;
}
-static
-struct lttng_evaluation *create_evaluation_from_payload(
- enum lttng_condition_type type,
- struct lttng_payload_view *view)
+static struct lttng_evaluation *create_evaluation_from_payload(enum lttng_condition_type type,
+ struct lttng_payload_view *view)
{
- const struct lttng_evaluation_buffer_usage_comm *comm =
- (typeof(comm)) view->buffer.data;
+ const struct lttng_evaluation_buffer_usage_comm *comm = (typeof(comm)) view->buffer.data;
struct lttng_evaluation *evaluation = NULL;
if (view->buffer.size < sizeof(*comm)) {
goto end;
}
- evaluation = lttng_evaluation_buffer_usage_create(type,
- comm->buffer_use, comm->buffer_capacity);
+ evaluation =
+ lttng_evaluation_buffer_usage_create(type, comm->buffer_use, comm->buffer_capacity);
end:
return evaluation;
}
-ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret;
struct lttng_evaluation *evaluation = NULL;
goto error;
}
- evaluation = create_evaluation_from_payload(
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW, view);
+ evaluation = create_evaluation_from_payload(LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW, view);
if (!evaluation) {
ret = -1;
goto error;
return ret;
}
-ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+ssize_t
+lttng_evaluation_buffer_usage_high_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret;
struct lttng_evaluation *evaluation = NULL;
goto error;
}
- evaluation = create_evaluation_from_payload(
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH, view);
+ evaluation = create_evaluation_from_payload(LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH, view);
if (!evaluation) {
ret = -1;
goto error;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_get_threshold_ratio(
- const struct lttng_condition *condition,
- double *threshold_ratio)
+lttng_condition_buffer_usage_get_threshold_ratio(const struct lttng_condition *condition,
+ double *threshold_ratio)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !IS_USAGE_CONDITION(condition) ||
- !threshold_ratio) {
+ if (!condition || !IS_USAGE_CONDITION(condition) || !threshold_ratio) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->threshold_ratio.set) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
/* threshold_ratio expressed as [0.0, 1.0]. */
enum lttng_condition_status
-lttng_condition_buffer_usage_set_threshold_ratio(
- struct lttng_condition *condition, double threshold_ratio)
+lttng_condition_buffer_usage_set_threshold_ratio(struct lttng_condition *condition,
+ double threshold_ratio)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !IS_USAGE_CONDITION(condition) ||
- threshold_ratio < 0.0 ||
- threshold_ratio > 1.0) {
+ if (!condition || !IS_USAGE_CONDITION(condition) || threshold_ratio < 0.0 ||
+ threshold_ratio > 1.0) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
usage->threshold_ratio.set = true;
usage->threshold_bytes.set = false;
usage->threshold_ratio.value = threshold_ratio;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_get_threshold(
- const struct lttng_condition *condition,
- uint64_t *threshold_bytes)
+lttng_condition_buffer_usage_get_threshold(const struct lttng_condition *condition,
+ uint64_t *threshold_bytes)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->threshold_bytes.set) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_set_threshold(
- struct lttng_condition *condition, uint64_t threshold_bytes)
+lttng_condition_buffer_usage_set_threshold(struct lttng_condition *condition,
+ uint64_t threshold_bytes)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
usage->threshold_ratio.set = false;
usage->threshold_bytes.set = true;
usage->threshold_bytes.value = threshold_bytes;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_get_session_name(
- const struct lttng_condition *condition,
- const char **session_name)
+lttng_condition_buffer_usage_get_session_name(const struct lttng_condition *condition,
+ const char **session_name)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->session_name) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_set_session_name(
- struct lttng_condition *condition, const char *session_name)
+lttng_condition_buffer_usage_set_session_name(struct lttng_condition *condition,
+ const char *session_name)
{
char *session_name_copy;
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
if (!condition || !IS_USAGE_CONDITION(condition) || !session_name ||
- strlen(session_name) == 0) {
+ strlen(session_name) == 0) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
session_name_copy = strdup(session_name);
if (!session_name_copy) {
status = LTTNG_CONDITION_STATUS_ERROR;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_get_channel_name(
- const struct lttng_condition *condition,
- const char **channel_name)
+lttng_condition_buffer_usage_get_channel_name(const struct lttng_condition *condition,
+ const char **channel_name)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->channel_name) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_set_channel_name(
- struct lttng_condition *condition, const char *channel_name)
+lttng_condition_buffer_usage_set_channel_name(struct lttng_condition *condition,
+ const char *channel_name)
{
char *channel_name_copy;
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
if (!condition || !IS_USAGE_CONDITION(condition) || !channel_name ||
- strlen(channel_name) == 0) {
+ strlen(channel_name) == 0) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
channel_name_copy = strdup(channel_name);
if (!channel_name_copy) {
status = LTTNG_CONDITION_STATUS_ERROR;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_get_domain_type(
- const struct lttng_condition *condition,
- enum lttng_domain_type *type)
+lttng_condition_buffer_usage_get_domain_type(const struct lttng_condition *condition,
+ enum lttng_domain_type *type)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
if (!usage->domain.set) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_buffer_usage_set_domain_type(
- struct lttng_condition *condition, enum lttng_domain_type type)
+lttng_condition_buffer_usage_set_domain_type(struct lttng_condition *condition,
+ enum lttng_domain_type type)
{
struct lttng_condition_buffer_usage *usage;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !IS_USAGE_CONDITION(condition) ||
- type == LTTNG_DOMAIN_NONE) {
+ if (!condition || !IS_USAGE_CONDITION(condition) || type == LTTNG_DOMAIN_NONE) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- usage = lttng::utils::container_of(condition,
- <tng_condition_buffer_usage::parent);
+ usage = lttng::utils::container_of(condition, <tng_condition_buffer_usage::parent);
usage->domain.set = true;
usage->domain.type = type;
end:
return status;
}
-static
-int lttng_evaluation_buffer_usage_serialize(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload)
+static int lttng_evaluation_buffer_usage_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload)
{
struct lttng_evaluation_buffer_usage *usage;
struct lttng_evaluation_buffer_usage_comm comm;
- usage = lttng::utils::container_of(evaluation,
- <tng_evaluation_buffer_usage::parent);
+ usage = lttng::utils::container_of(evaluation, <tng_evaluation_buffer_usage::parent);
comm.buffer_use = usage->buffer_use;
comm.buffer_capacity = usage->buffer_capacity;
- return lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ return lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
}
-static
-void lttng_evaluation_buffer_usage_destroy(
- struct lttng_evaluation *evaluation)
+static void lttng_evaluation_buffer_usage_destroy(struct lttng_evaluation *evaluation)
{
struct lttng_evaluation_buffer_usage *usage;
- usage = lttng::utils::container_of(evaluation,
- <tng_evaluation_buffer_usage::parent);
+ usage = lttng::utils::container_of(evaluation, <tng_evaluation_buffer_usage::parent);
free(usage);
}
-struct lttng_evaluation *lttng_evaluation_buffer_usage_create(
- enum lttng_condition_type type, uint64_t use, uint64_t capacity)
+struct lttng_evaluation *lttng_evaluation_buffer_usage_create(enum lttng_condition_type type,
+ uint64_t use,
+ uint64_t capacity)
{
struct lttng_evaluation_buffer_usage *usage;
* evaluate to "true".
*/
enum lttng_evaluation_status
-lttng_evaluation_buffer_usage_get_usage_ratio(
- const struct lttng_evaluation *evaluation, double *usage_ratio)
+lttng_evaluation_buffer_usage_get_usage_ratio(const struct lttng_evaluation *evaluation,
+ double *usage_ratio)
{
struct lttng_evaluation_buffer_usage *usage;
enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(evaluation,
- <tng_evaluation_buffer_usage::parent);
- *usage_ratio = (double) usage->buffer_use /
- (double) usage->buffer_capacity;
+ usage = lttng::utils::container_of(evaluation, <tng_evaluation_buffer_usage::parent);
+ *usage_ratio = (double) usage->buffer_use / (double) usage->buffer_capacity;
end:
return status;
}
enum lttng_evaluation_status
-lttng_evaluation_buffer_usage_get_usage(
- const struct lttng_evaluation *evaluation,
- uint64_t *usage_bytes)
+lttng_evaluation_buffer_usage_get_usage(const struct lttng_evaluation *evaluation,
+ uint64_t *usage_bytes)
{
struct lttng_evaluation_buffer_usage *usage;
enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
goto end;
}
- usage = lttng::utils::container_of(evaluation,
- <tng_evaluation_buffer_usage::parent);
+ usage = lttng::utils::container_of(evaluation, <tng_evaluation_buffer_usage::parent);
*usage_bytes = usage->buffer_use;
end:
return status;
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/condition/buffer-usage-internal.hpp>
#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/session-consumed-size-internal.hpp>
#include <lttng/condition/session-rotation-internal.hpp>
#include <lttng/error-query-internal.hpp>
+
#include <stdbool.h>
-enum lttng_condition_type lttng_condition_get_type(
- const struct lttng_condition *condition)
+enum lttng_condition_type lttng_condition_get_type(const struct lttng_condition *condition)
{
return condition ? condition->type : LTTNG_CONDITION_TYPE_UNKNOWN;
}
static void condition_destroy_ref(struct urcu_ref *ref)
{
- struct lttng_condition *condition =
- lttng::utils::container_of(ref, <tng_condition::ref);
+ struct lttng_condition *condition = lttng::utils::container_of(ref, <tng_condition::ref);
condition->destroy(condition);
}
urcu_ref_put(&condition->ref, condition_destroy_ref);
}
-
bool lttng_condition_validate(const struct lttng_condition *condition)
{
bool valid;
}
int lttng_condition_serialize(const struct lttng_condition *condition,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_condition_comm condition_comm = {};
condition_comm.condition_type = (int8_t) condition->type;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &condition_comm,
- sizeof(condition_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &condition_comm, sizeof(condition_comm));
if (ret) {
goto end;
}
return ret;
}
-bool lttng_condition_is_equal(const struct lttng_condition *a,
- const struct lttng_condition *b)
+bool lttng_condition_is_equal(const struct lttng_condition *a, const struct lttng_condition *b)
{
bool is_equal = false;
return is_equal;
}
-ssize_t lttng_condition_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition)
+ssize_t lttng_condition_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **condition)
{
ssize_t ret, condition_size = 0;
condition_create_from_payload_cb create_from_payload = NULL;
const struct lttng_condition_comm *condition_comm;
const struct lttng_payload_view condition_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*condition_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*condition_comm));
if (!view || !condition) {
ret = -1;
create_from_payload = lttng_condition_session_rotation_ongoing_create_from_payload;
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
- create_from_payload = lttng_condition_session_rotation_completed_create_from_payload;
+ create_from_payload =
+ lttng_condition_session_rotation_completed_create_from_payload;
break;
case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
- create_from_payload =
- lttng_condition_event_rule_matches_create_from_payload;
+ create_from_payload = lttng_condition_event_rule_matches_create_from_payload;
break;
default:
ERR("Attempted to create condition of unknown type (%i)",
- (int) condition_comm->condition_type);
+ (int) condition_comm->condition_type);
ret = -1;
goto end;
}
if (create_from_payload) {
struct lttng_payload_view condition_view =
- lttng_payload_view_from_view(view,
- sizeof(*condition_comm), -1);
+ lttng_payload_view_from_view(view, sizeof(*condition_comm), -1);
ret = create_from_payload(&condition_view, condition);
if (ret < 0) {
return ret;
}
-void lttng_condition_init(struct lttng_condition *condition,
- enum lttng_condition_type type)
+void lttng_condition_init(struct lttng_condition *condition, enum lttng_condition_type type)
{
condition->type = type;
urcu_ref_init(&condition->ref);
}
}
-enum lttng_error_code lttng_condition_mi_serialize(
- const struct lttng_trigger *trigger,
- const struct lttng_condition *condition,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks *error_query_callbacks)
+enum lttng_error_code
+lttng_condition_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_condition *condition,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks)
{
int ret;
enum lttng_error_code ret_code;
/* Serialize error query results for the action. */
if (error_query_callbacks && error_query_callbacks->action_cb) {
- ret_code = error_query_callbacks->condition_cb(
- trigger, &error_query_results);
+ ret_code = error_query_callbacks->condition_cb(trigger, &error_query_results);
if (ret_code != LTTNG_OK) {
goto end;
}
- ret_code = lttng_error_query_results_mi_serialize(
- error_query_results, writer);
+ ret_code = lttng_error_query_results_mi_serialize(error_query_results, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
-#include <inttypes.h>
-#include <limits.h>
+
#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
#include <lttng/event-field-value-internal.hpp>
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/lttng-error.h>
+
+#include <vendor/msgpack/msgpack.h>
+
+#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
-#include <vendor/msgpack/msgpack.h>
#define IS_EVENT_RULE_MATCHES_CONDITION(condition) \
- (lttng_condition_get_type(condition) == \
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES)
+ (lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES)
-static bool is_event_rule_matches_evaluation(
- const struct lttng_evaluation *evaluation)
+static bool is_event_rule_matches_evaluation(const struct lttng_evaluation *evaluation)
{
enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
return type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES;
}
-static bool lttng_condition_event_rule_matches_validate(
- const struct lttng_condition *condition);
-static int lttng_condition_event_rule_matches_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload);
-static bool lttng_condition_event_rule_matches_is_equal(
- const struct lttng_condition *_a,
- const struct lttng_condition *_b);
-static void lttng_condition_event_rule_matches_destroy(
- struct lttng_condition *condition);
-
-static bool lttng_condition_event_rule_matches_validate(
- const struct lttng_condition *condition)
+static bool lttng_condition_event_rule_matches_validate(const struct lttng_condition *condition);
+static int lttng_condition_event_rule_matches_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload);
+static bool lttng_condition_event_rule_matches_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b);
+static void lttng_condition_event_rule_matches_destroy(struct lttng_condition *condition);
+
+static bool lttng_condition_event_rule_matches_validate(const struct lttng_condition *condition)
{
bool valid = false;
struct lttng_condition_event_rule_matches *event_rule;
goto end;
}
- event_rule = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ event_rule =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
if (!event_rule->rule) {
ERR("Invalid on event condition: a rule must be set");
goto end;
* Encoding is the length of `str` plus one (for the null character),
* and then the string, including its null terminator.
*/
-static
-int serialize_cstr(const char *str, struct lttng_dynamic_buffer *buf)
+static int serialize_cstr(const char *str, struct lttng_dynamic_buffer *buf)
{
int ret;
const uint32_t len = strlen(str) + 1;
/* Serialize the length, including the null terminator. */
DBG("Serializing C string's length (including null terminator): "
- "%" PRIu32, len);
+ "%" PRIu32,
+ len);
ret = lttng_dynamic_buffer_append(buf, &len, sizeof(len));
if (ret) {
goto end;
/*
* Serializes the event expression `expr` into `buf`.
*/
-static
-int serialize_event_expr(const struct lttng_event_expr *expr,
- struct lttng_payload *payload)
+static int serialize_event_expr(const struct lttng_event_expr *expr, struct lttng_payload *payload)
{
const uint8_t type = expr->type;
int ret;
case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
{
const struct lttng_event_expr_field *field_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_field::parent);
+ lttng::utils::container_of(expr, <tng_event_expr_field::parent);
/* Serialize the field name. */
- DBG("Serializing field event expression's field name: '%s'",
- field_expr->name);
+ DBG("Serializing field event expression's field name: '%s'", field_expr->name);
ret = serialize_cstr(field_expr->name, &payload->buffer);
if (ret) {
goto end;
case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
{
const struct lttng_event_expr_app_specific_context_field *field_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_app_specific_context_field::parent);
+ lttng::utils::container_of(
+ expr, <tng_event_expr_app_specific_context_field::parent);
/* Serialize the provider name. */
DBG("Serializing app-specific context field event expression's "
- "provider name: '%s'",
- field_expr->provider_name);
+ "provider name: '%s'",
+ field_expr->provider_name);
ret = serialize_cstr(field_expr->provider_name, &payload->buffer);
if (ret) {
goto end;
/* Serialize the type name. */
DBG("Serializing app-specific context field event expression's "
- "type name: '%s'",
- field_expr->provider_name);
+ "type name: '%s'",
+ field_expr->provider_name);
ret = serialize_cstr(field_expr->type_name, &payload->buffer);
if (ret) {
goto end;
case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
{
const struct lttng_event_expr_array_field_element *elem_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_array_field_element::parent);
+ lttng::utils::container_of(expr,
+ <tng_event_expr_array_field_element::parent);
const uint32_t index = elem_expr->index;
/* Serialize the index. */
DBG("Serializing array field element event expression's "
- "index: %u", elem_expr->index);
+ "index: %u",
+ elem_expr->index);
ret = lttng_dynamic_buffer_append(&payload->buffer, &index, sizeof(index));
if (ret) {
goto end;
/* Serialize the parent array field expression. */
DBG("Serializing array field element event expression's "
- "parent array field event expression");
+ "parent array field event expression");
ret = serialize_event_expr(elem_expr->array_field_expr, payload);
if (ret) {
goto end;
static struct lttng_capture_descriptor *
lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
- const struct lttng_condition *condition, unsigned int index)
+ const struct lttng_condition *condition, unsigned int index)
{
- const struct lttng_condition_event_rule_matches
- *event_rule_matches_cond = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ const struct lttng_condition_event_rule_matches *event_rule_matches_cond =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
struct lttng_capture_descriptor *desc = NULL;
unsigned int count;
enum lttng_condition_status status;
goto end;
}
- status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &count);
+ status = lttng_condition_event_rule_matches_get_capture_descriptor_count(condition, &count);
if (status != LTTNG_CONDITION_STATUS_OK) {
goto end;
}
}
desc = (lttng_capture_descriptor *) lttng_dynamic_pointer_array_get_pointer(
- &event_rule_matches_cond->capture_descriptors, index);
+ &event_rule_matches_cond->capture_descriptors, index);
end:
return desc;
}
-static int lttng_condition_event_rule_matches_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload)
+static int lttng_condition_event_rule_matches_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_condition_event_rule_matches *event_rule_matches_condition;
}
DBG("Serializing on event condition");
- event_rule_matches_condition = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ event_rule_matches_condition =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
DBG("Serializing on event condition's event rule");
- ret = lttng_event_rule_serialize(
- event_rule_matches_condition->rule, payload);
+ ret = lttng_event_rule_serialize(event_rule_matches_condition->rule, payload);
if (ret) {
goto end;
}
status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &capture_descr_count);
+ condition, &capture_descr_count);
if (status != LTTNG_CONDITION_STATUS_OK) {
ret = -1;
goto end;
};
DBG("Serializing on event condition's capture descriptor count: %" PRIu32,
- capture_descr_count);
- ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_descr_count,
- sizeof(capture_descr_count));
+ capture_descr_count);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &capture_descr_count, sizeof(capture_descr_count));
if (ret) {
goto end;
}
for (i = 0; i < capture_descr_count; i++) {
const struct lttng_capture_descriptor *desc =
- lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
+ condition, i);
- DBG("Serializing on event condition's capture descriptor %" PRIu32,
- i);
+ DBG("Serializing on event condition's capture descriptor %" PRIu32, i);
ret = serialize_event_expr(desc->event_expression, payload);
if (ret) {
goto end;
return ret;
}
-static
-bool capture_descriptors_are_equal(
- const struct lttng_condition *condition_a,
- const struct lttng_condition *condition_b)
+static bool capture_descriptors_are_equal(const struct lttng_condition *condition_a,
+ const struct lttng_condition *condition_b)
{
bool is_equal = true;
unsigned int capture_descr_count_a;
enum lttng_condition_status status;
status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition_a, &capture_descr_count_a);
+ condition_a, &capture_descr_count_a);
if (status != LTTNG_CONDITION_STATUS_OK) {
goto not_equal;
}
status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition_b, &capture_descr_count_b);
+ condition_b, &capture_descr_count_b);
if (status != LTTNG_CONDITION_STATUS_OK) {
goto not_equal;
}
for (i = 0; i < capture_descr_count_a; i++) {
const struct lttng_event_expr *expr_a =
- lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- condition_a, i);
+ lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition_a, i);
const struct lttng_event_expr *expr_b =
- lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- condition_b, i);
+ lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition_b, i);
if (!lttng_event_expr_is_equal(expr_a, expr_b)) {
goto not_equal;
return is_equal;
}
-static bool lttng_condition_event_rule_matches_is_equal(
- const struct lttng_condition *_a,
- const struct lttng_condition *_b)
+static bool lttng_condition_event_rule_matches_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b)
{
bool is_equal = false;
struct lttng_condition_event_rule_matches *a, *b;
return is_equal;
}
-static void lttng_condition_event_rule_matches_destroy(
- struct lttng_condition *condition)
+static void lttng_condition_event_rule_matches_destroy(struct lttng_condition *condition)
{
struct lttng_condition_event_rule_matches *event_rule_matches_condition;
- event_rule_matches_condition = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ event_rule_matches_condition =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
lttng_event_rule_put(event_rule_matches_condition->rule);
- lttng_dynamic_pointer_array_reset(
- &event_rule_matches_condition->capture_descriptors);
+ lttng_dynamic_pointer_array_reset(&event_rule_matches_condition->capture_descriptors);
free(event_rule_matches_condition);
}
-static
-void destroy_capture_descriptor(void *ptr)
+static void destroy_capture_descriptor(void *ptr)
{
- struct lttng_capture_descriptor *desc =
- (struct lttng_capture_descriptor *) ptr;
+ struct lttng_capture_descriptor *desc = (struct lttng_capture_descriptor *) ptr;
lttng_event_expr_destroy(desc->event_expression);
free(desc->bytecode);
free(desc);
}
-static enum lttng_error_code lttng_condition_event_rule_matches_mi_serialize(
- const struct lttng_condition *condition,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_condition_event_rule_matches_mi_serialize(const struct lttng_condition *condition,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule != NULL);
status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &capture_descriptor_count);
+ condition, &capture_descriptor_count);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
/* Open condition event rule matches element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_condition_event_rule_matches);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_condition_event_rule_matches);
if (ret) {
goto mi_error;
}
}
/* Open the capture descriptors element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_capture_descriptors);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_capture_descriptors);
if (ret) {
goto mi_error;
}
const struct lttng_event_expr *descriptor = NULL;
descriptor = lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- condition, i);
+ condition, i);
LTTNG_ASSERT(descriptor);
ret_code = lttng_event_expr_mi_serialize(descriptor, writer);
return ret_code;
}
-struct lttng_condition *lttng_condition_event_rule_matches_create(
- struct lttng_event_rule *rule)
+struct lttng_condition *lttng_condition_event_rule_matches_create(struct lttng_event_rule *rule)
{
struct lttng_condition *parent = NULL;
struct lttng_condition_event_rule_matches *condition = NULL;
return NULL;
}
- lttng_condition_init(&condition->parent,
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
- condition->parent.validate =
- lttng_condition_event_rule_matches_validate,
- condition->parent.serialize =
- lttng_condition_event_rule_matches_serialize,
+ lttng_condition_init(&condition->parent, LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ condition->parent.validate = lttng_condition_event_rule_matches_validate,
+ condition->parent.serialize = lttng_condition_event_rule_matches_serialize,
condition->parent.equal = lttng_condition_event_rule_matches_is_equal,
condition->parent.destroy = lttng_condition_event_rule_matches_destroy,
condition->parent.mi_serialize = lttng_condition_event_rule_matches_mi_serialize,
rule = NULL;
lttng_dynamic_pointer_array_init(&condition->capture_descriptors,
- destroy_capture_descriptor);
+ destroy_capture_descriptor);
parent = &condition->parent;
end:
return parent;
}
-static
-uint64_t uint_from_buffer(const struct lttng_buffer_view *view, size_t size,
- size_t *offset)
+static uint64_t uint_from_buffer(const struct lttng_buffer_view *view, size_t size, size_t *offset)
{
uint64_t ret;
- const struct lttng_buffer_view uint_view =
- lttng_buffer_view_from_view(view, *offset, size);
+ const struct lttng_buffer_view uint_view = lttng_buffer_view_from_view(view, *offset, size);
if (!lttng_buffer_view_is_valid(&uint_view)) {
ret = UINT64_C(-1);
return ret;
}
-static
-const char *str_from_buffer(const struct lttng_buffer_view *view,
- size_t *offset)
+static const char *str_from_buffer(const struct lttng_buffer_view *view, size_t *offset)
{
uint64_t len;
const char *ret;
return ret;
}
-static
-struct lttng_event_expr *event_expr_from_payload(
- struct lttng_payload_view *view, size_t *offset)
+static struct lttng_event_expr *event_expr_from_payload(struct lttng_payload_view *view,
+ size_t *offset)
{
struct lttng_event_expr *expr = NULL;
const char *str;
goto error;
}
- expr = lttng_event_expr_app_specific_context_field_create(
- provider_name, type_name);
+ expr = lttng_event_expr_app_specific_context_field_create(provider_name, type_name);
break;
}
case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
{
struct lttng_event_expr *array_field_expr;
- const uint64_t index = uint_from_buffer(
- &view->buffer, sizeof(uint32_t), offset);
+ const uint64_t index = uint_from_buffer(&view->buffer, sizeof(uint32_t), offset);
if (index == UINT64_C(-1)) {
goto error;
}
/* Move ownership of `array_field_expr` to new expression. */
- expr = lttng_event_expr_array_field_element_create(
- array_field_expr, (unsigned int) index);
+ expr = lttng_event_expr_array_field_element_create(array_field_expr,
+ (unsigned int) index);
if (!expr) {
/* `array_field_expr` not moved: destroy it. */
lttng_event_expr_destroy(array_field_expr);
}
default:
ERR("Invalid event expression type encoutered while deserializing event expression: type = %" PRIu64,
- type);
+ type);
goto error;
}
return expr;
}
-ssize_t lttng_condition_event_rule_matches_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **_condition)
+ssize_t lttng_condition_event_rule_matches_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **_condition)
{
ssize_t consumed_length;
size_t offset = 0;
/* Struct lttng_event_rule. */
{
struct lttng_payload_view event_rule_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
- event_rule_length = lttng_event_rule_create_from_payload(
- &event_rule_view, &event_rule);
+ event_rule_length =
+ lttng_event_rule_create_from_payload(&event_rule_view, &event_rule);
}
if (event_rule_length < 0 || !event_rule) {
/* Capture descriptors. */
for (i = 0; i < capture_descr_count; i++) {
enum lttng_condition_status status;
- struct lttng_event_expr *expr = event_expr_from_payload(
- view, &offset);
+ struct lttng_event_expr *expr = event_expr_from_payload(view, &offset);
if (!expr) {
goto error;
}
/* Move ownership of `expr` to `condition`. */
- status = lttng_condition_event_rule_matches_append_capture_descriptor(
- condition, expr);
+ status = lttng_condition_event_rule_matches_append_capture_descriptor(condition,
+ expr);
if (status != LTTNG_CONDITION_STATUS_OK) {
/* `expr` not moved: destroy it. */
lttng_event_expr_destroy(expr);
}
enum lttng_condition_status
-lttng_condition_event_rule_matches_borrow_rule_mutable(
- const struct lttng_condition *condition,
- struct lttng_event_rule **rule)
+lttng_condition_event_rule_matches_borrow_rule_mutable(const struct lttng_condition *condition,
+ struct lttng_event_rule **rule)
{
struct lttng_condition_event_rule_matches *event_rule;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) ||
- !rule) {
+ if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || !rule) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- event_rule = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ event_rule =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
if (!event_rule->rule) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_condition_status lttng_condition_event_rule_matches_get_rule(
- const struct lttng_condition *condition,
- const struct lttng_event_rule **rule)
+enum lttng_condition_status
+lttng_condition_event_rule_matches_get_rule(const struct lttng_condition *condition,
+ const struct lttng_event_rule **rule)
{
struct lttng_event_rule *mutable_rule = NULL;
const enum lttng_condition_status status =
- lttng_condition_event_rule_matches_borrow_rule_mutable(
- condition, &mutable_rule);
+ lttng_condition_event_rule_matches_borrow_rule_mutable(condition, &mutable_rule);
*rule = mutable_rule;
return status;
}
-void lttng_condition_event_rule_matches_set_error_counter_index(
- struct lttng_condition *condition, uint64_t error_counter_index)
+void lttng_condition_event_rule_matches_set_error_counter_index(struct lttng_condition *condition,
+ uint64_t error_counter_index)
{
struct lttng_condition_event_rule_matches *event_rule_matches_cond =
- lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
- LTTNG_OPTIONAL_SET(&event_rule_matches_cond->error_counter_index,
- error_counter_index);
+ LTTNG_OPTIONAL_SET(&event_rule_matches_cond->error_counter_index, error_counter_index);
}
-uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
- const struct lttng_condition *condition)
+uint64_t
+lttng_condition_event_rule_matches_get_error_counter_index(const struct lttng_condition *condition)
{
- const struct lttng_condition_event_rule_matches
- *event_rule_matches_cond = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ const struct lttng_condition_event_rule_matches *event_rule_matches_cond =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
return LTTNG_OPTIONAL_GET(event_rule_matches_cond->error_counter_index);
}
enum lttng_condition_status
-lttng_condition_event_rule_matches_append_capture_descriptor(
- struct lttng_condition *condition,
- struct lttng_event_expr *expr)
+lttng_condition_event_rule_matches_append_capture_descriptor(struct lttng_condition *condition,
+ struct lttng_event_expr *expr)
{
int ret;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
struct lttng_condition_event_rule_matches *event_rule_matches_cond =
- lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
struct lttng_capture_descriptor *descriptor = NULL;
const struct lttng_event_rule *rule = NULL;
/* Only accept l-values. */
- if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) ||
- !expr || !lttng_event_expr_is_lvalue(expr)) {
+ if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || !expr ||
+ !lttng_event_expr_is_lvalue(expr)) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
goto end;
}
- switch(lttng_event_rule_get_type(rule)) {
+ switch (lttng_event_rule_get_type(rule)) {
case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT:
case LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT:
case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING:
descriptor->event_expression = expr;
descriptor->bytecode = NULL;
- ret = lttng_dynamic_pointer_array_add_pointer(
- &event_rule_matches_cond->capture_descriptors,
- descriptor);
+ ret = lttng_dynamic_pointer_array_add_pointer(&event_rule_matches_cond->capture_descriptors,
+ descriptor);
if (ret) {
status = LTTNG_CONDITION_STATUS_ERROR;
goto end;
return status;
}
-enum lttng_condition_status
-lttng_condition_event_rule_matches_get_capture_descriptor_count(
- const struct lttng_condition *condition, unsigned int *count)
+enum lttng_condition_status lttng_condition_event_rule_matches_get_capture_descriptor_count(
+ const struct lttng_condition *condition, unsigned int *count)
{
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- const struct lttng_condition_event_rule_matches
- *event_rule_matches_condition = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ const struct lttng_condition_event_rule_matches *event_rule_matches_condition =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
- if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) ||
- !count) {
+ if (!condition || !IS_EVENT_RULE_MATCHES_CONDITION(condition) || !count) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
*count = lttng_dynamic_pointer_array_get_count(
- &event_rule_matches_condition->capture_descriptors);
+ &event_rule_matches_condition->capture_descriptors);
end:
return status;
}
-const struct lttng_event_expr *
-lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
- const struct lttng_condition *condition, unsigned int index)
+const struct lttng_event_expr *lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ const struct lttng_condition *condition, unsigned int index)
{
const struct lttng_event_expr *expr = NULL;
const struct lttng_capture_descriptor *desc = NULL;
desc = lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
- condition, index);
+ condition, index);
if (desc == NULL) {
goto end;
}
}
ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
- const struct lttng_condition_event_rule_matches *condition,
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+ const struct lttng_condition_event_rule_matches *condition,
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret, offset = 0;
struct lttng_evaluation *evaluation = NULL;
{
const struct lttng_payload_view current_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
if (current_view.buffer.size < sizeof(capture_payload_size)) {
ret = -1;
goto error;
}
- memcpy(&capture_payload_size, current_view.buffer.data,
- sizeof(capture_payload_size));
+ memcpy(&capture_payload_size,
+ current_view.buffer.data,
+ sizeof(capture_payload_size));
}
offset += sizeof(capture_payload_size);
if (capture_payload_size > 0) {
const struct lttng_payload_view current_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
if (current_view.buffer.size < capture_payload_size) {
ret = -1;
}
evaluation = lttng_evaluation_event_rule_matches_create(
- condition, capture_payload, capture_payload_size, true);
+ condition, capture_payload, capture_payload_size, true);
if (!evaluation) {
ret = -1;
goto error;
return ret;
}
-static int lttng_evaluation_event_rule_matches_serialize(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload)
+static int lttng_evaluation_event_rule_matches_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload)
{
int ret = 0;
struct lttng_evaluation_event_rule_matches *hit;
uint32_t capture_payload_size;
- hit = lttng::utils::container_of(evaluation,
- <tng_evaluation_event_rule_matches::parent);
+ hit = lttng::utils::container_of(evaluation, <tng_evaluation_event_rule_matches::parent);
capture_payload_size = (uint32_t) hit->capture_payload.size;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_payload_size,
- sizeof(capture_payload_size));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &capture_payload_size, sizeof(capture_payload_size));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, hit->capture_payload.data,
- hit->capture_payload.size);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, hit->capture_payload.data, hit->capture_payload.size);
if (ret) {
goto end;
}
return ret;
}
-static
-bool msgpack_str_is_equal(const struct msgpack_object *obj, const char *str)
+static bool msgpack_str_is_equal(const struct msgpack_object *obj, const char *str)
{
bool is_equal = true;
return is_equal;
}
-static
-const msgpack_object *get_msgpack_map_obj(const struct msgpack_object *map_obj,
- const char *name)
+static const msgpack_object *get_msgpack_map_obj(const struct msgpack_object *map_obj,
+ const char *name)
{
const msgpack_object *ret = NULL;
size_t i;
return ret;
}
-static void lttng_evaluation_event_rule_matches_destroy(
- struct lttng_evaluation *evaluation)
+static void lttng_evaluation_event_rule_matches_destroy(struct lttng_evaluation *evaluation)
{
struct lttng_evaluation_event_rule_matches *hit;
- hit = lttng::utils::container_of(evaluation,
- <tng_evaluation_event_rule_matches::parent);
+ hit = lttng::utils::container_of(evaluation, <tng_evaluation_event_rule_matches::parent);
lttng_dynamic_buffer_reset(&hit->capture_payload);
lttng_event_field_value_destroy(hit->captured_values);
free(hit);
}
-static
-int event_field_value_from_obj(const msgpack_object *obj,
- struct lttng_event_field_value **field_val)
+static int event_field_value_from_obj(const msgpack_object *obj,
+ struct lttng_event_field_value **field_val)
{
int ret = 0;
*field_val = NULL;
goto end;
case MSGPACK_OBJECT_POSITIVE_INTEGER:
- *field_val = lttng_event_field_value_uint_create(
- obj->via.u64);
+ *field_val = lttng_event_field_value_uint_create(obj->via.u64);
break;
case MSGPACK_OBJECT_NEGATIVE_INTEGER:
- *field_val = lttng_event_field_value_int_create(
- obj->via.i64);
+ *field_val = lttng_event_field_value_int_create(obj->via.i64);
break;
case MSGPACK_OBJECT_FLOAT32:
case MSGPACK_OBJECT_FLOAT64:
- *field_val = lttng_event_field_value_real_create(
- obj->via.f64);
+ *field_val = lttng_event_field_value_real_create(obj->via.f64);
break;
case MSGPACK_OBJECT_STR:
- *field_val = lttng_event_field_value_string_create_with_size(
- obj->via.str.ptr, obj->via.str.size);
+ *field_val = lttng_event_field_value_string_create_with_size(obj->via.str.ptr,
+ obj->via.str.size);
break;
case MSGPACK_OBJECT_ARRAY:
{
const msgpack_object *elem_obj = &obj->via.array.ptr[i];
struct lttng_event_field_value *elem_field_val;
- ret = event_field_value_from_obj(elem_obj,
- &elem_field_val);
+ ret = event_field_value_from_obj(elem_obj, &elem_field_val);
if (ret) {
goto error;
}
if (elem_field_val) {
- ret = lttng_event_field_value_array_append(
- *field_val, elem_field_val);
+ ret = lttng_event_field_value_array_append(*field_val,
+ elem_field_val);
} else {
- ret = lttng_event_field_value_array_append_unavailable(
- *field_val);
+ ret = lttng_event_field_value_array_append_unavailable(*field_val);
}
if (ret) {
if (inner_obj->type != MSGPACK_OBJECT_STR) {
ERR("Map object's `type` entry is not a string: type = %s",
- msgpack_object_type_str(inner_obj->type));
+ msgpack_object_type_str(inner_obj->type));
goto error;
}
}
if (inner_obj->type == MSGPACK_OBJECT_POSITIVE_INTEGER) {
- *field_val = lttng_event_field_value_enum_uint_create(
- inner_obj->via.u64);
+ *field_val = lttng_event_field_value_enum_uint_create(inner_obj->via.u64);
} else if (inner_obj->type == MSGPACK_OBJECT_NEGATIVE_INTEGER) {
- *field_val = lttng_event_field_value_enum_int_create(
- inner_obj->via.i64);
+ *field_val = lttng_event_field_value_enum_int_create(inner_obj->via.i64);
} else {
ERR("Map object's `value` entry is not an integer: type = %s",
- msgpack_object_type_str(inner_obj->type));
+ msgpack_object_type_str(inner_obj->type));
goto error;
}
if (inner_obj->type != MSGPACK_OBJECT_ARRAY) {
ERR("Map object's `labels` entry is not an array: type = %s",
- msgpack_object_type_str(inner_obj->type));
+ msgpack_object_type_str(inner_obj->type));
goto error;
}
- for (label_i = 0; label_i < inner_obj->via.array.size;
- label_i++) {
+ for (label_i = 0; label_i < inner_obj->via.array.size; label_i++) {
int iret;
- const msgpack_object *elem_obj =
- &inner_obj->via.array.ptr[label_i];
+ const msgpack_object *elem_obj = &inner_obj->via.array.ptr[label_i];
if (elem_obj->type != MSGPACK_OBJECT_STR) {
ERR("Map object's `labels` entry's type is not a string: type = %s",
- msgpack_object_type_str(elem_obj->type));
+ msgpack_object_type_str(elem_obj->type));
goto error;
}
iret = lttng_event_field_value_enum_append_label_with_size(
- *field_val, elem_obj->via.str.ptr,
- elem_obj->via.str.size);
+ *field_val, elem_obj->via.str.ptr, elem_obj->via.str.size);
if (iret) {
goto error;
}
break;
}
default:
- ERR("Unexpected object type: type = %s",
- msgpack_object_type_str(obj->type));
+ ERR("Unexpected object type: type = %s", msgpack_object_type_str(obj->type));
goto error;
}
return ret;
}
-static struct lttng_event_field_value *event_field_value_from_capture_payload(
- const struct lttng_condition_event_rule_matches *condition,
- const char *capture_payload,
- size_t capture_payload_size)
+static struct lttng_event_field_value *
+event_field_value_from_capture_payload(const struct lttng_condition_event_rule_matches *condition,
+ const char *capture_payload,
+ size_t capture_payload_size)
{
struct lttng_event_field_value *ret = NULL;
msgpack_unpacked unpacked;
msgpack_unpacked_init(&unpacked);
/* Decode. */
- unpack_return = msgpack_unpack_next(&unpacked, capture_payload,
- capture_payload_size, NULL);
+ unpack_return = msgpack_unpack_next(&unpacked, capture_payload, capture_payload_size, NULL);
if (unpack_return != MSGPACK_UNPACK_SUCCESS) {
ERR("msgpack_unpack_next() failed to decode the "
- "MessagePack-encoded capture payload: "
- "size = %zu, ret = %d",
- capture_payload_size, unpack_return);
+ "MessagePack-encoded capture payload: "
+ "size = %zu, ret = %d",
+ capture_payload_size,
+ unpack_return);
goto error;
}
if (root_obj->type != MSGPACK_OBJECT_ARRAY) {
ERR("Expecting an array as the root object: type = %s",
- msgpack_object_type_str(root_obj->type));
+ msgpack_object_type_str(root_obj->type));
goto error;
}
*
* 3. Append it to `ret` (the root array event field value).
*/
- count = lttng_dynamic_pointer_array_get_count(
- &condition->capture_descriptors);
+ count = lttng_dynamic_pointer_array_get_count(&condition->capture_descriptors);
LTTNG_ASSERT(count > 0);
for (i = 0; i < count; i++) {
const struct lttng_capture_descriptor *capture_descriptor =
- lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
- &condition->parent, i);
+ lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
+ &condition->parent, i);
const msgpack_object *elem_obj;
struct lttng_event_field_value *elem_field_val;
int iret;
LTTNG_ASSERT(capture_descriptor);
elem_obj = &root_array_obj->ptr[i];
- iret = event_field_value_from_obj(elem_obj,
- &elem_field_val);
+ iret = event_field_value_from_obj(elem_obj, &elem_field_val);
if (iret) {
goto error;
}
if (elem_field_val) {
- iret = lttng_event_field_value_array_append(ret,
- elem_field_val);
+ iret = lttng_event_field_value_array_append(ret, elem_field_val);
} else {
- iret = lttng_event_field_value_array_append_unavailable(
- ret);
+ iret = lttng_event_field_value_array_append_unavailable(ret);
}
if (iret) {
}
struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
- const struct lttng_condition_event_rule_matches *condition,
- const char *capture_payload,
- size_t capture_payload_size,
- bool decode_capture_payload)
+ const struct lttng_condition_event_rule_matches *condition,
+ const char *capture_payload,
+ size_t capture_payload_size,
+ bool decode_capture_payload)
{
struct lttng_evaluation_event_rule_matches *hit;
struct lttng_evaluation *evaluation = NULL;
if (capture_payload) {
const int ret = lttng_dynamic_buffer_append(
- &hit->capture_payload, capture_payload,
- capture_payload_size);
+ &hit->capture_payload, capture_payload, capture_payload_size);
if (ret) {
ERR("Failed to initialize capture payload of event rule evaluation");
goto error;
}
if (decode_capture_payload) {
- hit->captured_values =
- event_field_value_from_capture_payload(
- condition,
- capture_payload,
- capture_payload_size);
+ hit->captured_values = event_field_value_from_capture_payload(
+ condition, capture_payload, capture_payload_size);
if (!hit->captured_values) {
ERR("Failed to decode the capture payload: size = %zu",
- capture_payload_size);
+ capture_payload_size);
goto error;
}
}
enum lttng_evaluation_event_rule_matches_status
lttng_evaluation_event_rule_matches_get_captured_values(
- const struct lttng_evaluation *evaluation,
- const struct lttng_event_field_value **field_val)
+ const struct lttng_evaluation *evaluation, const struct lttng_event_field_value **field_val)
{
struct lttng_evaluation_event_rule_matches *hit;
enum lttng_evaluation_event_rule_matches_status status =
- LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK;
+ LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK;
- if (!evaluation || !is_event_rule_matches_evaluation(evaluation) ||
- !field_val) {
+ if (!evaluation || !is_event_rule_matches_evaluation(evaluation) || !field_val) {
status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_INVALID;
goto end;
}
- hit = lttng::utils::container_of(evaluation,
- <tng_evaluation_event_rule_matches::parent);
+ hit = lttng::utils::container_of(evaluation, <tng_evaluation_event_rule_matches::parent);
if (!hit->captured_values) {
status = LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_NONE;
goto end;
return status;
}
-enum lttng_error_code
-lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
- struct lttng_condition *condition)
+enum lttng_error_code lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
+ struct lttng_condition *condition)
{
enum lttng_error_code ret;
enum lttng_condition_status status;
goto end;
}
- status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &capture_count);
+ status = lttng_condition_event_rule_matches_get_capture_descriptor_count(condition,
+ &capture_count);
if (status != LTTNG_CONDITION_STATUS_OK) {
ret = LTTNG_ERR_FATAL;
goto end;
for (i = 0; i < capture_count; i++) {
struct lttng_capture_descriptor *local_capture_desc =
- lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
- condition, i);
+ lttng_condition_event_rule_matches_get_internal_capture_descriptor_at_index(
+ condition, i);
int bytecode_ret;
if (local_capture_desc == NULL) {
}
/* Generate the bytecode. */
- bytecode_ret = lttng_event_expr_to_bytecode(
- local_capture_desc->event_expression,
- &local_capture_desc->bytecode);
+ bytecode_ret = lttng_event_expr_to_bytecode(local_capture_desc->event_expression,
+ &local_capture_desc->bytecode);
if (bytecode_ret < 0 || local_capture_desc->bytecode == NULL) {
ret = LTTNG_ERR_INVALID_CAPTURE_EXPRESSION;
goto end;
return ret;
}
-const struct lttng_bytecode *
-lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
- const struct lttng_condition *condition, unsigned int index)
+const struct lttng_bytecode *lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
+ const struct lttng_condition *condition, unsigned int index)
{
- const struct lttng_condition_event_rule_matches
- *event_rule_matches_cond = lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent);
+ const struct lttng_condition_event_rule_matches *event_rule_matches_cond =
+ lttng::utils::container_of(condition, <tng_condition_event_rule_matches::parent);
struct lttng_capture_descriptor *desc = NULL;
struct lttng_bytecode *bytecode = NULL;
unsigned int count;
goto end;
}
- status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
- condition, &count);
+ status = lttng_condition_event_rule_matches_get_capture_descriptor_count(condition, &count);
if (status != LTTNG_CONDITION_STATUS_OK) {
goto end;
}
}
desc = (lttng_capture_descriptor *) lttng_dynamic_pointer_array_get_pointer(
- &event_rule_matches_cond->capture_descriptors, index);
+ &event_rule_matches_cond->capture_descriptors, index);
if (desc == NULL) {
goto end;
}
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
-#include <float.h>
+
#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/session-consumed-size-internal.hpp>
#include <lttng/constant.h>
+
+#include <float.h>
#include <math.h>
#include <time.h>
-#define IS_CONSUMED_SIZE_CONDITION(condition) ( \
- lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE \
- )
+#define IS_CONSUMED_SIZE_CONDITION(condition) \
+ (lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE)
-#define IS_CONSUMED_SIZE_EVALUATION(evaluation) ( \
- lttng_evaluation_get_type(evaluation) == LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE \
- )
+#define IS_CONSUMED_SIZE_EVALUATION(evaluation) \
+ (lttng_evaluation_get_type(evaluation) == LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE)
-static
-void lttng_condition_session_consumed_size_destroy(struct lttng_condition *condition)
+static void lttng_condition_session_consumed_size_destroy(struct lttng_condition *condition)
{
struct lttng_condition_session_consumed_size *consumed_size;
consumed_size = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
free(consumed_size->session_name);
free(consumed_size);
}
-static
-bool lttng_condition_session_consumed_size_validate(
- const struct lttng_condition *condition)
+static bool lttng_condition_session_consumed_size_validate(const struct lttng_condition *condition)
{
bool valid = false;
struct lttng_condition_session_consumed_size *consumed;
}
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
if (!consumed->session_name) {
ERR("Invalid session consumed size condition: a target session name must be set.");
goto end;
return valid;
}
-static
-int lttng_condition_session_consumed_size_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload)
+static int lttng_condition_session_consumed_size_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload)
{
int ret;
size_t session_name_len;
DBG("Serializing session consumed size condition");
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
session_name_len = strlen(consumed->session_name) + 1;
if (session_name_len > LTTNG_NAME_MAX) {
goto end;
}
- consumed_comm.consumed_threshold_bytes =
- consumed->consumed_threshold_bytes.value;
+ consumed_comm.consumed_threshold_bytes = consumed->consumed_threshold_bytes.value;
consumed_comm.session_name_len = (uint32_t) session_name_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &consumed_comm,
- sizeof(consumed_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &consumed_comm, sizeof(consumed_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, consumed->session_name,
- session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, consumed->session_name, session_name_len);
if (ret) {
goto end;
}
return ret;
}
-static
-bool lttng_condition_session_consumed_size_is_equal(const struct lttng_condition *_a,
- const struct lttng_condition *_b)
+static bool lttng_condition_session_consumed_size_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b)
{
bool is_equal = false;
struct lttng_condition_session_consumed_size *a, *b;
return is_equal;
}
-static
-enum lttng_error_code lttng_condition_session_consumed_size_mi_serialize(
- const struct lttng_condition *condition,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_condition_session_consumed_size_mi_serialize(const struct lttng_condition *condition,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_CONSUMED_SIZE_CONDITION(condition));
- status = lttng_condition_session_consumed_size_get_session_name(
- condition, &session_name);
+ status = lttng_condition_session_consumed_size_get_session_name(condition, &session_name);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(session_name);
- status = lttng_condition_session_consumed_size_get_threshold(
- condition, &threshold_bytes);
+ status = lttng_condition_session_consumed_size_get_threshold(condition, &threshold_bytes);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
/* Open condition session consumed size element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_condition_session_consumed_size);
+ mi_lttng_element_condition_session_consumed_size);
if (ret) {
goto mi_error;
}
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
/* Threshold in bytes. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_condition_threshold_bytes,
- threshold_bytes);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_condition_threshold_bytes, threshold_bytes);
if (ret) {
goto mi_error;
}
return &condition->parent;
}
-static
-ssize_t init_condition_from_payload(struct lttng_condition *condition,
- struct lttng_payload_view *src_view)
+static ssize_t init_condition_from_payload(struct lttng_condition *condition,
+ struct lttng_payload_view *src_view)
{
ssize_t ret, condition_size;
enum lttng_condition_status status;
const char *session_name;
struct lttng_buffer_view session_name_view;
const struct lttng_condition_session_consumed_size_comm *condition_comm;
- struct lttng_payload_view condition_comm_view = lttng_payload_view_from_view(
- src_view, 0, sizeof(*condition_comm));
+ struct lttng_payload_view condition_comm_view =
+ lttng_payload_view_from_view(src_view, 0, sizeof(*condition_comm));
if (!lttng_payload_view_is_valid(&condition_comm_view)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain header");
}
condition_comm = (typeof(condition_comm)) condition_comm_view.buffer.data;
- session_name_view = lttng_buffer_view_from_view(&src_view->buffer,
- sizeof(*condition_comm), condition_comm->session_name_len);
+ session_name_view = lttng_buffer_view_from_view(
+ &src_view->buffer, sizeof(*condition_comm), condition_comm->session_name_len);
if (condition_comm->session_name_len > LTTNG_NAME_MAX) {
ERR("Failed to initialize from malformed condition buffer: name exceeds LTTNG_MAX_NAME");
goto end;
}
- status = lttng_condition_session_consumed_size_set_threshold(condition,
- condition_comm->consumed_threshold_bytes);
+ status = lttng_condition_session_consumed_size_set_threshold(
+ condition, condition_comm->consumed_threshold_bytes);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to initialize session consumed size condition threshold");
ret = -1;
goto end;
}
- status = lttng_condition_session_consumed_size_set_session_name(condition,
- session_name);
+ status = lttng_condition_session_consumed_size_set_session_name(condition, session_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to set session consumed size condition's session name");
ret = -1;
goto end;
}
- condition_size = sizeof(*condition_comm) +
- (ssize_t) condition_comm->session_name_len;
+ condition_size = sizeof(*condition_comm) + (ssize_t) condition_comm->session_name_len;
ret = condition_size;
end:
return ret;
}
-ssize_t lttng_condition_session_consumed_size_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **_condition)
+ssize_t
+lttng_condition_session_consumed_size_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **_condition)
{
ssize_t ret;
- struct lttng_condition *condition =
- lttng_condition_session_consumed_size_create();
+ struct lttng_condition *condition = lttng_condition_session_consumed_size_create();
if (!_condition || !condition) {
ret = -1;
return ret;
}
-static
-struct lttng_evaluation *create_evaluation_from_payload(
- const struct lttng_payload_view *view)
+static struct lttng_evaluation *
+create_evaluation_from_payload(const struct lttng_payload_view *view)
{
const struct lttng_evaluation_session_consumed_size_comm *comm =
- (typeof(comm)) view->buffer.data;
+ (typeof(comm)) view->buffer.data;
struct lttng_evaluation *evaluation = NULL;
if (view->buffer.size < sizeof(*comm)) {
goto end;
}
- evaluation = lttng_evaluation_session_consumed_size_create(
- comm->session_consumed);
+ evaluation = lttng_evaluation_session_consumed_size_create(comm->session_consumed);
end:
return evaluation;
}
-ssize_t lttng_evaluation_session_consumed_size_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+ssize_t
+lttng_evaluation_session_consumed_size_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret;
struct lttng_evaluation *evaluation = NULL;
}
enum lttng_condition_status
-lttng_condition_session_consumed_size_get_threshold(
- const struct lttng_condition *condition,
- uint64_t *consumed_threshold_bytes)
+lttng_condition_session_consumed_size_get_threshold(const struct lttng_condition *condition,
+ uint64_t *consumed_threshold_bytes)
{
struct lttng_condition_session_consumed_size *consumed;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
}
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
if (!consumed->consumed_threshold_bytes.set) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_session_consumed_size_set_threshold(
- struct lttng_condition *condition, uint64_t consumed_threshold_bytes)
+lttng_condition_session_consumed_size_set_threshold(struct lttng_condition *condition,
+ uint64_t consumed_threshold_bytes)
{
struct lttng_condition_session_consumed_size *consumed;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
}
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
consumed->consumed_threshold_bytes.set = true;
consumed->consumed_threshold_bytes.value = consumed_threshold_bytes;
end:
}
enum lttng_condition_status
-lttng_condition_session_consumed_size_get_session_name(
- const struct lttng_condition *condition,
- const char **session_name)
+lttng_condition_session_consumed_size_get_session_name(const struct lttng_condition *condition,
+ const char **session_name)
{
struct lttng_condition_session_consumed_size *consumed;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
}
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
if (!consumed->session_name) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_session_consumed_size_set_session_name(
- struct lttng_condition *condition, const char *session_name)
+lttng_condition_session_consumed_size_set_session_name(struct lttng_condition *condition,
+ const char *session_name)
{
char *session_name_copy;
struct lttng_condition_session_consumed_size *consumed;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !IS_CONSUMED_SIZE_CONDITION(condition) ||
- !session_name || strlen(session_name) == 0) {
+ if (!condition || !IS_CONSUMED_SIZE_CONDITION(condition) || !session_name ||
+ strlen(session_name) == 0) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
consumed = lttng::utils::container_of(condition,
- <tng_condition_session_consumed_size::parent);
+ <tng_condition_session_consumed_size::parent);
session_name_copy = strdup(session_name);
if (!session_name_copy) {
status = LTTNG_CONDITION_STATUS_ERROR;
return status;
}
-static
-int lttng_evaluation_session_consumed_size_serialize(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload)
+static int
+lttng_evaluation_session_consumed_size_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload)
{
struct lttng_evaluation_session_consumed_size *consumed;
struct lttng_evaluation_session_consumed_size_comm comm;
consumed = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_consumed_size::parent);
+ <tng_evaluation_session_consumed_size::parent);
comm.session_consumed = consumed->session_consumed;
- return lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ return lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
}
-static
-void lttng_evaluation_session_consumed_size_destroy(
- struct lttng_evaluation *evaluation)
+static void lttng_evaluation_session_consumed_size_destroy(struct lttng_evaluation *evaluation)
{
struct lttng_evaluation_session_consumed_size *consumed;
consumed = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_consumed_size::parent);
+ <tng_evaluation_session_consumed_size::parent);
free(consumed);
}
-struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(
- uint64_t consumed)
+struct lttng_evaluation *lttng_evaluation_session_consumed_size_create(uint64_t consumed)
{
struct lttng_evaluation_session_consumed_size *consumed_eval;
}
enum lttng_evaluation_status
-lttng_evaluation_session_consumed_size_get_consumed_size(
- const struct lttng_evaluation *evaluation,
- uint64_t *session_consumed)
+lttng_evaluation_session_consumed_size_get_consumed_size(const struct lttng_evaluation *evaluation,
+ uint64_t *session_consumed)
{
struct lttng_evaluation_session_consumed_size *consumed;
enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
- if (!evaluation || !IS_CONSUMED_SIZE_EVALUATION(evaluation) ||
- !session_consumed) {
+ if (!evaluation || !IS_CONSUMED_SIZE_EVALUATION(evaluation) || !session_consumed) {
status = LTTNG_EVALUATION_STATUS_INVALID;
goto end;
}
consumed = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_consumed_size::parent);
+ <tng_evaluation_session_consumed_size::parent);
*session_consumed = consumed->session_consumed;
end:
return status;
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/session-rotation-internal.hpp>
#include <lttng/location-internal.hpp>
+
#include <stdbool.h>
-static
-bool lttng_condition_session_rotation_validate(
- const struct lttng_condition *condition);
-static
-int lttng_condition_session_rotation_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload);
-static
-bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a,
- const struct lttng_condition *_b);
-static
-void lttng_condition_session_rotation_destroy(
- struct lttng_condition *condition);
-
-static
-enum lttng_error_code lttng_condition_session_rotation_mi_serialize(
- const struct lttng_condition *condition,
- struct mi_writer *writer);
-
-static const
-struct lttng_condition rotation_condition_template = {
+static bool lttng_condition_session_rotation_validate(const struct lttng_condition *condition);
+static int lttng_condition_session_rotation_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload);
+static bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b);
+static void lttng_condition_session_rotation_destroy(struct lttng_condition *condition);
+
+static enum lttng_error_code
+lttng_condition_session_rotation_mi_serialize(const struct lttng_condition *condition,
+ struct mi_writer *writer);
+
+static const struct lttng_condition rotation_condition_template = {
{},
LTTNG_CONDITION_TYPE_UNKNOWN, /* type unset, shall be set on creation. */
lttng_condition_session_rotation_validate,
lttng_condition_session_rotation_mi_serialize,
};
-static
-int lttng_evaluation_session_rotation_serialize(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload);
-static
-void lttng_evaluation_session_rotation_destroy(
- struct lttng_evaluation *evaluation);
+static int lttng_evaluation_session_rotation_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload);
+static void lttng_evaluation_session_rotation_destroy(struct lttng_evaluation *evaluation);
-static const
-struct lttng_evaluation rotation_evaluation_template = {
+static const struct lttng_evaluation rotation_evaluation_template = {
LTTNG_CONDITION_TYPE_UNKNOWN, /* type unset, shall be set on creation. */
lttng_evaluation_session_rotation_serialize,
lttng_evaluation_session_rotation_destroy,
};
-static
-bool is_rotation_condition(const struct lttng_condition *condition)
+static bool is_rotation_condition(const struct lttng_condition *condition)
{
enum lttng_condition_type type = lttng_condition_get_type(condition);
return type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING ||
- type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED;
+ type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED;
}
-static
-bool is_rotation_evaluation(const struct lttng_evaluation *evaluation)
+static bool is_rotation_evaluation(const struct lttng_evaluation *evaluation)
{
enum lttng_condition_type type = lttng_evaluation_get_type(evaluation);
return type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING ||
- type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED;
+ type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED;
}
-static
-bool lttng_condition_session_rotation_validate(
- const struct lttng_condition *condition)
+static bool lttng_condition_session_rotation_validate(const struct lttng_condition *condition)
{
bool valid = false;
struct lttng_condition_session_rotation *rotation;
goto end;
}
- rotation = lttng::utils::container_of(condition,
- <tng_condition_session_rotation::parent);
+ rotation = lttng::utils::container_of(condition, <tng_condition_session_rotation::parent);
if (!rotation->session_name) {
ERR("Invalid session rotation condition: a target session name must be set.");
goto end;
return valid;
}
-static
-int lttng_condition_session_rotation_serialize(
- const struct lttng_condition *condition,
- struct lttng_payload *payload)
+static int lttng_condition_session_rotation_serialize(const struct lttng_condition *condition,
+ struct lttng_payload *payload)
{
int ret;
size_t session_name_len;
}
DBG("Serializing session rotation condition");
- rotation = lttng::utils::container_of(condition,
- <tng_condition_session_rotation::parent);
+ rotation = lttng::utils::container_of(condition, <tng_condition_session_rotation::parent);
session_name_len = strlen(rotation->session_name) + 1;
if (session_name_len > LTTNG_NAME_MAX) {
}
rotation_comm.session_name_len = session_name_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &rotation_comm,
- sizeof(rotation_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &rotation_comm, sizeof(rotation_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- rotation->session_name, session_name_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, rotation->session_name, session_name_len);
if (ret) {
goto end;
}
return ret;
}
-static
-bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a,
- const struct lttng_condition *_b)
+static bool lttng_condition_session_rotation_is_equal(const struct lttng_condition *_a,
+ const struct lttng_condition *_b)
{
bool is_equal = false;
struct lttng_condition_session_rotation *a, *b;
b = lttng::utils::container_of(_b, <tng_condition_session_rotation::parent);
/* Both session names must be set or both must be unset. */
- if ((a->session_name && !b->session_name) ||
- (!a->session_name && b->session_name)) {
+ if ((a->session_name && !b->session_name) || (!a->session_name && b->session_name)) {
WARN("Comparing session rotation conditions with uninitialized session names.");
goto end;
}
- if (a->session_name && b->session_name &&
- strcmp(a->session_name, b->session_name)) {
+ if (a->session_name && b->session_name && strcmp(a->session_name, b->session_name)) {
goto end;
}
return is_equal;
}
-static
-void lttng_condition_session_rotation_destroy(
- struct lttng_condition *condition)
+static void lttng_condition_session_rotation_destroy(struct lttng_condition *condition)
{
struct lttng_condition_session_rotation *rotation;
- rotation = lttng::utils::container_of(condition,
- <tng_condition_session_rotation::parent);
+ rotation = lttng::utils::container_of(condition, <tng_condition_session_rotation::parent);
free(rotation->session_name);
free(rotation);
}
-static
-struct lttng_condition *lttng_condition_session_rotation_create(
- enum lttng_condition_type type)
+static struct lttng_condition *
+lttng_condition_session_rotation_create(enum lttng_condition_type type)
{
struct lttng_condition_session_rotation *condition;
return NULL;
}
- memcpy(&condition->parent, &rotation_condition_template,
- sizeof(condition->parent));
+ memcpy(&condition->parent, &rotation_condition_template, sizeof(condition->parent));
lttng_condition_init(&condition->parent, type);
return &condition->parent;
}
struct lttng_condition *lttng_condition_session_rotation_ongoing_create(void)
{
return lttng_condition_session_rotation_create(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING);
}
struct lttng_condition *lttng_condition_session_rotation_completed_create(void)
{
return lttng_condition_session_rotation_create(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED);
}
-static
-ssize_t init_condition_from_payload(struct lttng_condition *condition,
- struct lttng_payload_view *src_view)
+static ssize_t init_condition_from_payload(struct lttng_condition *condition,
+ struct lttng_payload_view *src_view)
{
ssize_t ret, condition_size;
enum lttng_condition_status status;
struct lttng_buffer_view name_view;
const struct lttng_condition_session_rotation_comm *condition_comm;
struct lttng_payload_view condition_comm_view =
- lttng_payload_view_from_view(
- src_view, 0, sizeof(*condition_comm));
+ lttng_payload_view_from_view(src_view, 0, sizeof(*condition_comm));
if (!lttng_payload_view_is_valid(&condition_comm_view)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain header");
}
condition_comm = (typeof(condition_comm)) src_view->buffer.data;
- name_view = lttng_buffer_view_from_view(&src_view->buffer,
- sizeof(*condition_comm), condition_comm->session_name_len);
+ name_view = lttng_buffer_view_from_view(
+ &src_view->buffer, sizeof(*condition_comm), condition_comm->session_name_len);
if (!lttng_buffer_view_is_valid(&name_view)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain session name");
goto end;
}
- status = lttng_condition_session_rotation_set_session_name(condition,
- session_name);
+ status = lttng_condition_session_rotation_set_session_name(condition, session_name);
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to set buffer consumed session name");
ret = -1;
goto end;
}
- condition_size = sizeof(*condition_comm) +
- (ssize_t) condition_comm->session_name_len;
+ condition_size = sizeof(*condition_comm) + (ssize_t) condition_comm->session_name_len;
ret = condition_size;
end:
return ret;
}
-static
-ssize_t lttng_condition_session_rotation_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **_condition,
- enum lttng_condition_type type)
+static ssize_t
+lttng_condition_session_rotation_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **_condition,
+ enum lttng_condition_type type)
{
ssize_t ret;
struct lttng_condition *condition = NULL;
return ret;
}
-ssize_t lttng_condition_session_rotation_ongoing_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition)
+ssize_t
+lttng_condition_session_rotation_ongoing_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **condition)
{
- return lttng_condition_session_rotation_create_from_payload(view,
- condition,
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING);
+ return lttng_condition_session_rotation_create_from_payload(
+ view, condition, LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING);
}
-ssize_t lttng_condition_session_rotation_completed_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_condition **condition)
+ssize_t
+lttng_condition_session_rotation_completed_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_condition **condition)
{
- return lttng_condition_session_rotation_create_from_payload(view,
- condition,
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED);
+ return lttng_condition_session_rotation_create_from_payload(
+ view, condition, LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED);
}
-static
-struct lttng_evaluation *lttng_evaluation_session_rotation_create(
- enum lttng_condition_type type, uint64_t id,
- struct lttng_trace_archive_location *location)
+static struct lttng_evaluation *lttng_evaluation_session_rotation_create(
+ enum lttng_condition_type type, uint64_t id, struct lttng_trace_archive_location *location)
{
struct lttng_evaluation_session_rotation *evaluation;
return NULL;
}
- memcpy(&evaluation->parent, &rotation_evaluation_template,
- sizeof(evaluation->parent));
+ memcpy(&evaluation->parent, &rotation_evaluation_template, sizeof(evaluation->parent));
lttng_evaluation_init(&evaluation->parent, type);
evaluation->id = id;
if (location) {
return &evaluation->parent;
}
-static
-ssize_t create_evaluation_from_payload(
- enum lttng_condition_type type,
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+static ssize_t create_evaluation_from_payload(enum lttng_condition_type type,
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret, size;
struct lttng_evaluation *evaluation = NULL;
struct lttng_trace_archive_location *location = NULL;
const struct lttng_evaluation_session_rotation_comm *comm;
- struct lttng_payload_view comm_view = lttng_payload_view_from_view(
- view, 0, sizeof(*comm));
+ struct lttng_payload_view comm_view = lttng_payload_view_from_view(view, 0, sizeof(*comm));
if (!lttng_payload_view_is_valid(&comm_view)) {
goto error;
size = sizeof(*comm);
if (comm->has_location) {
const struct lttng_buffer_view location_view =
- lttng_buffer_view_from_view(
- &view->buffer, sizeof(*comm), -1);
+ lttng_buffer_view_from_view(&view->buffer, sizeof(*comm), -1);
if (!lttng_buffer_view_is_valid(&location_view)) {
goto error;
}
- ret = lttng_trace_archive_location_create_from_buffer(
- &location_view, &location);
+ ret = lttng_trace_archive_location_create_from_buffer(&location_view, &location);
if (ret < 0) {
goto error;
}
size += ret;
}
- evaluation = lttng_evaluation_session_rotation_create(type, comm->id,
- location);
+ evaluation = lttng_evaluation_session_rotation_create(type, comm->id, location);
if (!evaluation) {
goto error;
}
return -1;
}
-static
-ssize_t lttng_evaluation_session_rotation_create_from_payload(
- enum lttng_condition_type type,
- struct lttng_payload_view *view,
- struct lttng_evaluation **_evaluation)
+static ssize_t
+lttng_evaluation_session_rotation_create_from_payload(enum lttng_condition_type type,
+ struct lttng_payload_view *view,
+ struct lttng_evaluation **_evaluation)
{
ssize_t ret;
struct lttng_evaluation *evaluation = NULL;
return ret;
}
-ssize_t lttng_evaluation_session_rotation_ongoing_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation)
+ssize_t
+lttng_evaluation_session_rotation_ongoing_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_evaluation **evaluation)
{
return lttng_evaluation_session_rotation_create_from_payload(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING,
- view, evaluation);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING, view, evaluation);
}
ssize_t lttng_evaluation_session_rotation_completed_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_evaluation **evaluation)
+ struct lttng_payload_view *view, struct lttng_evaluation **evaluation)
{
return lttng_evaluation_session_rotation_create_from_payload(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED,
- view, evaluation);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED, view, evaluation);
}
-struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(
- uint64_t id)
+struct lttng_evaluation *lttng_evaluation_session_rotation_ongoing_create(uint64_t id)
{
return lttng_evaluation_session_rotation_create(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING, id,
- NULL);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING, id, NULL);
}
-struct lttng_evaluation *lttng_evaluation_session_rotation_completed_create(
- uint64_t id, struct lttng_trace_archive_location *location)
+struct lttng_evaluation *
+lttng_evaluation_session_rotation_completed_create(uint64_t id,
+ struct lttng_trace_archive_location *location)
{
return lttng_evaluation_session_rotation_create(
- LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED, id,
- location);
+ LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED, id, location);
}
enum lttng_condition_status
-lttng_condition_session_rotation_get_session_name(
- const struct lttng_condition *condition,
- const char **session_name)
+lttng_condition_session_rotation_get_session_name(const struct lttng_condition *condition,
+ const char **session_name)
{
struct lttng_condition_session_rotation *rotation;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
goto end;
}
- rotation = lttng::utils::container_of(condition,
- <tng_condition_session_rotation::parent);
+ rotation = lttng::utils::container_of(condition, <tng_condition_session_rotation::parent);
if (!rotation->session_name) {
status = LTTNG_CONDITION_STATUS_UNSET;
goto end;
}
enum lttng_condition_status
-lttng_condition_session_rotation_set_session_name(
- struct lttng_condition *condition, const char *session_name)
+lttng_condition_session_rotation_set_session_name(struct lttng_condition *condition,
+ const char *session_name)
{
char *session_name_copy;
struct lttng_condition_session_rotation *rotation;
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
- if (!condition || !is_rotation_condition(condition) ||
- !session_name || strlen(session_name) == 0) {
+ if (!condition || !is_rotation_condition(condition) || !session_name ||
+ strlen(session_name) == 0) {
status = LTTNG_CONDITION_STATUS_INVALID;
goto end;
}
- rotation = lttng::utils::container_of(condition,
- <tng_condition_session_rotation::parent);
+ rotation = lttng::utils::container_of(condition, <tng_condition_session_rotation::parent);
session_name_copy = strdup(session_name);
if (!session_name_copy) {
status = LTTNG_CONDITION_STATUS_ERROR;
return status;
}
-static
-int lttng_evaluation_session_rotation_serialize(
- const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload)
+static int lttng_evaluation_session_rotation_serialize(const struct lttng_evaluation *evaluation,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_evaluation_session_rotation *rotation;
struct lttng_evaluation_session_rotation_comm comm = {};
- rotation = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_rotation::parent);
+ rotation =
+ lttng::utils::container_of(evaluation, <tng_evaluation_session_rotation::parent);
comm.id = rotation->id;
comm.has_location = !!rotation->location;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
goto end;
}
if (!rotation->location) {
goto end;
}
- ret = lttng_trace_archive_location_serialize(rotation->location,
- &payload->buffer);
+ ret = lttng_trace_archive_location_serialize(rotation->location, &payload->buffer);
end:
return ret;
}
-static
-void lttng_evaluation_session_rotation_destroy(
- struct lttng_evaluation *evaluation)
+static void lttng_evaluation_session_rotation_destroy(struct lttng_evaluation *evaluation)
{
struct lttng_evaluation_session_rotation *rotation;
- rotation = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_rotation::parent);
+ rotation =
+ lttng::utils::container_of(evaluation, <tng_evaluation_session_rotation::parent);
lttng_trace_archive_location_put(rotation->location);
free(rotation);
}
enum lttng_evaluation_status
-lttng_evaluation_session_rotation_get_id(
- const struct lttng_evaluation *evaluation, uint64_t *id)
+lttng_evaluation_session_rotation_get_id(const struct lttng_evaluation *evaluation, uint64_t *id)
{
const struct lttng_evaluation_session_rotation *rotation;
enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
goto end;
}
- rotation = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_rotation::parent);
+ rotation =
+ lttng::utils::container_of(evaluation, <tng_evaluation_session_rotation::parent);
*id = rotation->id;
end:
return status;
* trace archive location. Hence, users of liblttng-ctl have no visibility of
* the reference counting of archive locations.
*/
-enum lttng_evaluation_status
-lttng_evaluation_session_rotation_completed_get_location(
- const struct lttng_evaluation *evaluation,
- const struct lttng_trace_archive_location **location)
+enum lttng_evaluation_status lttng_evaluation_session_rotation_completed_get_location(
+ const struct lttng_evaluation *evaluation,
+ const struct lttng_trace_archive_location **location)
{
const struct lttng_evaluation_session_rotation *rotation;
enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
if (!evaluation || !location ||
- evaluation->type != LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED) {
+ evaluation->type != LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED) {
status = LTTNG_EVALUATION_STATUS_INVALID;
goto end;
}
- rotation = lttng::utils::container_of(evaluation,
- <tng_evaluation_session_rotation::parent);
+ rotation =
+ lttng::utils::container_of(evaluation, <tng_evaluation_session_rotation::parent);
*location = rotation->location;
end:
return status;
}
-static
-enum lttng_error_code lttng_condition_session_rotation_mi_serialize(
- const struct lttng_condition *condition,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_condition_session_rotation_mi_serialize(const struct lttng_condition *condition,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
- type_element_str =
- mi_lttng_element_condition_session_rotation_completed;
+ type_element_str = mi_lttng_element_condition_session_rotation_completed;
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
- type_element_str =
- mi_lttng_element_condition_session_rotation_ongoing;
+ type_element_str = mi_lttng_element_condition_session_rotation_ongoing;
break;
default:
abort();
break;
}
- status = lttng_condition_session_rotation_get_session_name(
- condition, &session_name);
+ status = lttng_condition_session_rotation_get_session_name(condition, &session_name);
LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
LTTNG_ASSERT(session_name);
/* Session name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_session_name, session_name);
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto mi_error;
}
#include "lttng/tracker.h"
#define _LGPL_SOURCE
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdbool.h>
+#include "config-internal.hpp"
+#include "session-config.hpp"
+#include <common/compat/getenv.hpp>
#include <common/defaults.hpp>
+#include <common/dynamic-buffer.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/utils.hpp>
-#include <common/dynamic-buffer.hpp>
-#include <common/compat/getenv.hpp>
+
#include <lttng/lttng-error.h>
-#include <libxml/parser.h>
-#include <libxml/valid.h>
-#include <libxml/xmlschemas.h>
-#include <libxml/tree.h>
#include <lttng/lttng.h>
-#include <lttng/snapshot.h>
#include <lttng/rotation.h>
+#include <lttng/snapshot.h>
#include <lttng/userspace-probe.h>
-#include "session-config.hpp"
-#include "config-internal.hpp"
+#include <ctype.h>
+#include <dirent.h>
+#include <inttypes.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/valid.h>
+#include <libxml/xmlschemas.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#define CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN 7
};
} /* namespace */
-const char * const config_element_all = "all";
+const char *const config_element_all = "all";
LTTNG_EXPORT const char *config_xml_encoding = "UTF-8";
-LTTNG_EXPORT size_t config_xml_encoding_bytes_per_char = 2; /* Size of the encoding's largest character */
+LTTNG_EXPORT size_t config_xml_encoding_bytes_per_char = 2; /* Size of the encoding's largest
+ character */
LTTNG_EXPORT const char *config_xml_indent_string = "\t";
LTTNG_EXPORT const char *config_xml_true = "true";
LTTNG_EXPORT const char *config_xml_false = "false";
-const char * const config_element_channel = "channel";
-const char * const config_element_channels = "channels";
-const char * const config_element_domain = "domain";
-const char * const config_element_domains = "domains";
-const char * const config_element_event = "event";
-const char * const config_element_events = "events";
-const char * const config_element_context = "context";
-const char * const config_element_contexts = "contexts";
-const char * const config_element_attributes = "attributes";
-const char * const config_element_exclusion = "exclusion";
-const char * const config_element_exclusions = "exclusions";
-const char * const config_element_function_attributes = "function_attributes";
-const char * const config_element_probe_attributes = "probe_attributes";
-const char * const config_element_symbol_name = "symbol_name";
-const char * const config_element_address = "address";
-const char * const config_element_offset = "offset";
-
-const char * const config_element_userspace_probe_lookup = "lookup_method";
-const char * const config_element_userspace_probe_lookup_function_default = "DEFAULT";
-const char * const config_element_userspace_probe_lookup_function_elf = "ELF";
-const char * const config_element_userspace_probe_lookup_tracepoint_sdt = "SDT";
-const char * const config_element_userspace_probe_location_binary_path = "binary_path";
-const char * const config_element_userspace_probe_function_attributes = "userspace_probe_function_attributes";
-const char * const config_element_userspace_probe_function_location_function_name = "function_name";
-const char * const config_element_userspace_probe_tracepoint_attributes = "userspace_probe_tracepoint_attributes";
-const char * const config_element_userspace_probe_tracepoint_location_provider_name = "provider_name";
-const char * const config_element_userspace_probe_tracepoint_location_probe_name = "probe_name";
-
-const char * const config_element_name = "name";
-const char * const config_element_enabled = "enabled";
-const char * const config_element_overwrite_mode = "overwrite_mode";
-const char * const config_element_subbuf_size = "subbuffer_size";
-const char * const config_element_num_subbuf = "subbuffer_count";
-const char * const config_element_switch_timer_interval = "switch_timer_interval";
-const char * const config_element_read_timer_interval = "read_timer_interval";
-const char * const config_element_monitor_timer_interval = "monitor_timer_interval";
-const char * const config_element_blocking_timeout = "blocking_timeout";
-const char * const config_element_output = "output";
-const char * const config_element_output_type = "output_type";
-const char * const config_element_tracefile_size = "tracefile_size";
-const char * const config_element_tracefile_count = "tracefile_count";
-const char * const config_element_live_timer_interval = "live_timer_interval";
-const char * const config_element_discarded_events = "discarded_events";
-const char * const config_element_lost_packets = "lost_packets";
-const char * const config_element_type = "type";
-const char * const config_element_buffer_type = "buffer_type";
-const char * const config_element_session = "session";
-const char * const config_element_sessions = "sessions";
-const char * const config_element_context_perf = "perf";
-const char * const config_element_context_app = "app";
-const char * const config_element_context_app_provider_name = "provider_name";
-const char * const config_element_context_app_ctx_name = "ctx_name";
-const char * const config_element_config = "config";
-const char * const config_element_started = "started";
-const char * const config_element_snapshot_mode = "snapshot_mode";
-const char * const config_element_loglevel = "loglevel";
-const char * const config_element_loglevel_type = "loglevel_type";
-const char * const config_element_filter = "filter";
-const char * const config_element_filter_expression = "filter_expression";
-const char * const config_element_snapshot_outputs = "snapshot_outputs";
-const char * const config_element_consumer_output = "consumer_output";
-const char * const config_element_destination = "destination";
-const char * const config_element_path = "path";
-const char * const config_element_net_output = "net_output";
-const char * const config_element_control_uri = "control_uri";
-const char * const config_element_data_uri = "data_uri";
-const char * const config_element_max_size = "max_size";
-const char * const config_element_pid = "pid";
-const char * const config_element_pids = "pids";
-const char * const config_element_shared_memory_path = "shared_memory_path";
-
-const char * const config_element_process_attr_id = "id";
-const char * const config_element_process_attr_tracker_pid = "pid_process_attr_tracker";
-const char * const config_element_process_attr_tracker_vpid = "vpid_process_attr_tracker";
-const char * const config_element_process_attr_tracker_uid = "uid_process_attr_tracker";
-const char * const config_element_process_attr_tracker_vuid = "vuid_process_attr_tracker";
-const char * const config_element_process_attr_tracker_gid = "gid_process_attr_tracker";
-const char * const config_element_process_attr_tracker_vgid = "vgid_process_attr_tracker";
-const char * const config_element_process_attr_trackers = "process_attr_trackers";
-const char * const config_element_process_attr_values = "process_attr_values";
-const char * const config_element_process_attr_value_type = "process_attr_value_type";
-const char * const config_element_process_attr_pid_value = "pid";
-const char * const config_element_process_attr_vpid_value = "vpid";
-const char * const config_element_process_attr_uid_value = "uid";
-const char * const config_element_process_attr_vuid_value = "vuid";
-const char * const config_element_process_attr_gid_value = "gid";
-const char * const config_element_process_attr_vgid_value = "vgid";
-const char * const config_element_process_attr_tracker_type = "process_attr_tracker_type";
+const char *const config_element_channel = "channel";
+const char *const config_element_channels = "channels";
+const char *const config_element_domain = "domain";
+const char *const config_element_domains = "domains";
+const char *const config_element_event = "event";
+const char *const config_element_events = "events";
+const char *const config_element_context = "context";
+const char *const config_element_contexts = "contexts";
+const char *const config_element_attributes = "attributes";
+const char *const config_element_exclusion = "exclusion";
+const char *const config_element_exclusions = "exclusions";
+const char *const config_element_function_attributes = "function_attributes";
+const char *const config_element_probe_attributes = "probe_attributes";
+const char *const config_element_symbol_name = "symbol_name";
+const char *const config_element_address = "address";
+const char *const config_element_offset = "offset";
+
+const char *const config_element_userspace_probe_lookup = "lookup_method";
+const char *const config_element_userspace_probe_lookup_function_default = "DEFAULT";
+const char *const config_element_userspace_probe_lookup_function_elf = "ELF";
+const char *const config_element_userspace_probe_lookup_tracepoint_sdt = "SDT";
+const char *const config_element_userspace_probe_location_binary_path = "binary_path";
+const char *const config_element_userspace_probe_function_attributes =
+ "userspace_probe_function_attributes";
+const char *const config_element_userspace_probe_function_location_function_name = "function_name";
+const char *const config_element_userspace_probe_tracepoint_attributes =
+ "userspace_probe_tracepoint_attributes";
+const char *const config_element_userspace_probe_tracepoint_location_provider_name =
+ "provider_name";
+const char *const config_element_userspace_probe_tracepoint_location_probe_name = "probe_name";
+
+const char *const config_element_name = "name";
+const char *const config_element_enabled = "enabled";
+const char *const config_element_overwrite_mode = "overwrite_mode";
+const char *const config_element_subbuf_size = "subbuffer_size";
+const char *const config_element_num_subbuf = "subbuffer_count";
+const char *const config_element_switch_timer_interval = "switch_timer_interval";
+const char *const config_element_read_timer_interval = "read_timer_interval";
+const char *const config_element_monitor_timer_interval = "monitor_timer_interval";
+const char *const config_element_blocking_timeout = "blocking_timeout";
+const char *const config_element_output = "output";
+const char *const config_element_output_type = "output_type";
+const char *const config_element_tracefile_size = "tracefile_size";
+const char *const config_element_tracefile_count = "tracefile_count";
+const char *const config_element_live_timer_interval = "live_timer_interval";
+const char *const config_element_discarded_events = "discarded_events";
+const char *const config_element_lost_packets = "lost_packets";
+const char *const config_element_type = "type";
+const char *const config_element_buffer_type = "buffer_type";
+const char *const config_element_session = "session";
+const char *const config_element_sessions = "sessions";
+const char *const config_element_context_perf = "perf";
+const char *const config_element_context_app = "app";
+const char *const config_element_context_app_provider_name = "provider_name";
+const char *const config_element_context_app_ctx_name = "ctx_name";
+const char *const config_element_config = "config";
+const char *const config_element_started = "started";
+const char *const config_element_snapshot_mode = "snapshot_mode";
+const char *const config_element_loglevel = "loglevel";
+const char *const config_element_loglevel_type = "loglevel_type";
+const char *const config_element_filter = "filter";
+const char *const config_element_filter_expression = "filter_expression";
+const char *const config_element_snapshot_outputs = "snapshot_outputs";
+const char *const config_element_consumer_output = "consumer_output";
+const char *const config_element_destination = "destination";
+const char *const config_element_path = "path";
+const char *const config_element_net_output = "net_output";
+const char *const config_element_control_uri = "control_uri";
+const char *const config_element_data_uri = "data_uri";
+const char *const config_element_max_size = "max_size";
+const char *const config_element_pid = "pid";
+const char *const config_element_pids = "pids";
+const char *const config_element_shared_memory_path = "shared_memory_path";
+
+const char *const config_element_process_attr_id = "id";
+const char *const config_element_process_attr_tracker_pid = "pid_process_attr_tracker";
+const char *const config_element_process_attr_tracker_vpid = "vpid_process_attr_tracker";
+const char *const config_element_process_attr_tracker_uid = "uid_process_attr_tracker";
+const char *const config_element_process_attr_tracker_vuid = "vuid_process_attr_tracker";
+const char *const config_element_process_attr_tracker_gid = "gid_process_attr_tracker";
+const char *const config_element_process_attr_tracker_vgid = "vgid_process_attr_tracker";
+const char *const config_element_process_attr_trackers = "process_attr_trackers";
+const char *const config_element_process_attr_values = "process_attr_values";
+const char *const config_element_process_attr_value_type = "process_attr_value_type";
+const char *const config_element_process_attr_pid_value = "pid";
+const char *const config_element_process_attr_vpid_value = "vpid";
+const char *const config_element_process_attr_uid_value = "uid";
+const char *const config_element_process_attr_vuid_value = "vuid";
+const char *const config_element_process_attr_gid_value = "gid";
+const char *const config_element_process_attr_vgid_value = "vgid";
+const char *const config_element_process_attr_tracker_type = "process_attr_tracker_type";
/* Used for support of legacy tracker serialization (< 2.12). */
-const char * const config_element_trackers_legacy = "trackers";
-const char * const config_element_pid_tracker_legacy = "pid_tracker";
-const char * const config_element_tracker_targets_legacy = "targets";
-const char * const config_element_tracker_pid_legacy = "pid";
-
-const char * const config_element_rotation_schedules = "rotation_schedules";
-const char * const config_element_rotation_schedule_periodic = "periodic";
-const char * const config_element_rotation_schedule_periodic_time_us = "time_us";
-const char * const config_element_rotation_schedule_size_threshold = "size_threshold";
-const char * const config_element_rotation_schedule_size_threshold_bytes = "bytes";
-
-const char * const config_domain_type_kernel = "KERNEL";
-const char * const config_domain_type_ust = "UST";
-const char * const config_domain_type_jul = "JUL";
-const char * const config_domain_type_log4j = "LOG4J";
-const char * const config_domain_type_python = "PYTHON";
-
-const char * const config_buffer_type_per_pid = "PER_PID";
-const char * const config_buffer_type_per_uid = "PER_UID";
-const char * const config_buffer_type_global = "GLOBAL";
-
-const char * const config_overwrite_mode_discard = "DISCARD";
-const char * const config_overwrite_mode_overwrite = "OVERWRITE";
-
-const char * const config_output_type_splice = "SPLICE";
-const char * const config_output_type_mmap = "MMAP";
-
-const char * const config_loglevel_type_all = "ALL";
-const char * const config_loglevel_type_range = "RANGE";
-const char * const config_loglevel_type_single = "SINGLE";
-
-const char * const config_event_type_all = "ALL";
-const char * const config_event_type_tracepoint = "TRACEPOINT";
-const char * const config_event_type_probe = "PROBE";
-const char * const config_event_type_userspace_probe = "USERSPACE_PROBE";
-const char * const config_event_type_function = "FUNCTION";
-const char * const config_event_type_function_entry = "FUNCTION_ENTRY";
-const char * const config_event_type_noop = "NOOP";
-const char * const config_event_type_syscall = "SYSCALL";
-const char * const config_event_type_kprobe = "KPROBE";
-const char * const config_event_type_kretprobe = "KRETPROBE";
-
-const char * const config_event_context_pid = "PID";
-const char * const config_event_context_procname = "PROCNAME";
-const char * const config_event_context_prio = "PRIO";
-const char * const config_event_context_nice = "NICE";
-const char * const config_event_context_vpid = "VPID";
-const char * const config_event_context_tid = "TID";
-const char * const config_event_context_vtid = "VTID";
-const char * const config_event_context_ppid = "PPID";
-const char * const config_event_context_vppid = "VPPID";
-const char * const config_event_context_pthread_id = "PTHREAD_ID";
-const char * const config_event_context_hostname = "HOSTNAME";
-const char * const config_event_context_ip = "IP";
-const char * const config_event_context_perf_thread_counter = "PERF_THREAD_COUNTER";
-const char * const config_event_context_app = "APP";
-const char * const config_event_context_interruptible = "INTERRUPTIBLE";
-const char * const config_event_context_preemptible = "PREEMPTIBLE";
-const char * const config_event_context_need_reschedule = "NEED_RESCHEDULE";
-const char * const config_event_context_migratable = "MIGRATABLE";
-const char * const config_event_context_callstack_user= "CALLSTACK_USER";
-const char * const config_event_context_callstack_kernel = "CALLSTACK_KERNEL";
-const char * const config_event_context_cgroup_ns = "CGROUP_NS";
-const char * const config_event_context_ipc_ns = "IPC_NS";
-const char * const config_event_context_mnt_ns = "MNT_NS";
-const char * const config_event_context_net_ns = "NET_NS";
-const char * const config_event_context_pid_ns = "PID_NS";
-const char * const config_event_context_time_ns = "TIME_NS";
-const char * const config_event_context_user_ns = "USER_NS";
-const char * const config_event_context_uts_ns = "UTS_NS";
-const char * const config_event_context_uid = "UID";
-const char * const config_event_context_euid = "EUID";
-const char * const config_event_context_suid = "SUID";
-const char * const config_event_context_gid = "GID";
-const char * const config_event_context_egid = "EGID";
-const char * const config_event_context_sgid = "SGID";
-const char * const config_event_context_vuid = "VUID";
-const char * const config_event_context_veuid = "VEUID";
-const char * const config_event_context_vsuid = "VSUID";
-const char * const config_event_context_vgid = "VGID";
-const char * const config_event_context_vegid = "VEGID";
-const char * const config_event_context_vsgid = "VSGID";
+const char *const config_element_trackers_legacy = "trackers";
+const char *const config_element_pid_tracker_legacy = "pid_tracker";
+const char *const config_element_tracker_targets_legacy = "targets";
+const char *const config_element_tracker_pid_legacy = "pid";
+
+const char *const config_element_rotation_schedules = "rotation_schedules";
+const char *const config_element_rotation_schedule_periodic = "periodic";
+const char *const config_element_rotation_schedule_periodic_time_us = "time_us";
+const char *const config_element_rotation_schedule_size_threshold = "size_threshold";
+const char *const config_element_rotation_schedule_size_threshold_bytes = "bytes";
+
+const char *const config_domain_type_kernel = "KERNEL";
+const char *const config_domain_type_ust = "UST";
+const char *const config_domain_type_jul = "JUL";
+const char *const config_domain_type_log4j = "LOG4J";
+const char *const config_domain_type_python = "PYTHON";
+
+const char *const config_buffer_type_per_pid = "PER_PID";
+const char *const config_buffer_type_per_uid = "PER_UID";
+const char *const config_buffer_type_global = "GLOBAL";
+
+const char *const config_overwrite_mode_discard = "DISCARD";
+const char *const config_overwrite_mode_overwrite = "OVERWRITE";
+
+const char *const config_output_type_splice = "SPLICE";
+const char *const config_output_type_mmap = "MMAP";
+
+const char *const config_loglevel_type_all = "ALL";
+const char *const config_loglevel_type_range = "RANGE";
+const char *const config_loglevel_type_single = "SINGLE";
+
+const char *const config_event_type_all = "ALL";
+const char *const config_event_type_tracepoint = "TRACEPOINT";
+const char *const config_event_type_probe = "PROBE";
+const char *const config_event_type_userspace_probe = "USERSPACE_PROBE";
+const char *const config_event_type_function = "FUNCTION";
+const char *const config_event_type_function_entry = "FUNCTION_ENTRY";
+const char *const config_event_type_noop = "NOOP";
+const char *const config_event_type_syscall = "SYSCALL";
+const char *const config_event_type_kprobe = "KPROBE";
+const char *const config_event_type_kretprobe = "KRETPROBE";
+
+const char *const config_event_context_pid = "PID";
+const char *const config_event_context_procname = "PROCNAME";
+const char *const config_event_context_prio = "PRIO";
+const char *const config_event_context_nice = "NICE";
+const char *const config_event_context_vpid = "VPID";
+const char *const config_event_context_tid = "TID";
+const char *const config_event_context_vtid = "VTID";
+const char *const config_event_context_ppid = "PPID";
+const char *const config_event_context_vppid = "VPPID";
+const char *const config_event_context_pthread_id = "PTHREAD_ID";
+const char *const config_event_context_hostname = "HOSTNAME";
+const char *const config_event_context_ip = "IP";
+const char *const config_event_context_perf_thread_counter = "PERF_THREAD_COUNTER";
+const char *const config_event_context_app = "APP";
+const char *const config_event_context_interruptible = "INTERRUPTIBLE";
+const char *const config_event_context_preemptible = "PREEMPTIBLE";
+const char *const config_event_context_need_reschedule = "NEED_RESCHEDULE";
+const char *const config_event_context_migratable = "MIGRATABLE";
+const char *const config_event_context_callstack_user = "CALLSTACK_USER";
+const char *const config_event_context_callstack_kernel = "CALLSTACK_KERNEL";
+const char *const config_event_context_cgroup_ns = "CGROUP_NS";
+const char *const config_event_context_ipc_ns = "IPC_NS";
+const char *const config_event_context_mnt_ns = "MNT_NS";
+const char *const config_event_context_net_ns = "NET_NS";
+const char *const config_event_context_pid_ns = "PID_NS";
+const char *const config_event_context_time_ns = "TIME_NS";
+const char *const config_event_context_user_ns = "USER_NS";
+const char *const config_event_context_uts_ns = "UTS_NS";
+const char *const config_event_context_uid = "UID";
+const char *const config_event_context_euid = "EUID";
+const char *const config_event_context_suid = "SUID";
+const char *const config_event_context_gid = "GID";
+const char *const config_event_context_egid = "EGID";
+const char *const config_event_context_sgid = "SGID";
+const char *const config_event_context_vuid = "VUID";
+const char *const config_event_context_veuid = "VEUID";
+const char *const config_event_context_vsuid = "VSUID";
+const char *const config_event_context_vgid = "VGID";
+const char *const config_event_context_vegid = "VEGID";
+const char *const config_event_context_vsgid = "VSGID";
/* Deprecated symbols */
LTTNG_EXPORT const char *config_element_perf;
}
writer->writer = xmlNewTextWriter(buffer);
- ret = xmlTextWriterStartDocument(writer->writer, NULL,
- config_xml_encoding, NULL);
+ ret = xmlTextWriterStartDocument(writer->writer, NULL, config_xml_encoding, NULL);
if (ret < 0) {
goto error_destroy;
}
- ret = xmlTextWriterSetIndentString(writer->writer,
- BAD_CAST config_xml_indent_string);
+ ret = xmlTextWriterSetIndentString(writer->writer, BAD_CAST config_xml_indent_string);
if (ret) {
goto error_destroy;
}
return ret;
}
-int config_writer_open_element(struct config_writer *writer,
- const char *element_name)
+int config_writer_open_element(struct config_writer *writer, const char *element_name)
{
int ret;
xmlChar *encoded_element_name;
return ret >= 0 ? 0 : ret;
}
-int config_writer_write_attribute(struct config_writer *writer,
- const char *name, const char *value)
+int config_writer_write_attribute(struct config_writer *writer, const char *name, const char *value)
{
int ret;
xmlChar *encoded_name = NULL;
goto end;
}
- ret = xmlTextWriterWriteAttribute(writer->writer, encoded_name,
- encoded_value);
+ ret = xmlTextWriterWriteAttribute(writer->writer, encoded_name, encoded_value);
end:
xmlFree(encoded_name);
xmlFree(encoded_value);
}
int config_writer_write_element_unsigned_int(struct config_writer *writer,
- const char *element_name, uint64_t value)
+ const char *element_name,
+ uint64_t value)
{
int ret;
xmlChar *encoded_element_name;
goto end;
}
- ret = xmlTextWriterWriteFormatElement(writer->writer,
- encoded_element_name, "%" PRIu64, value);
+ ret = xmlTextWriterWriteFormatElement(
+ writer->writer, encoded_element_name, "%" PRIu64, value);
xmlFree(encoded_element_name);
end:
return ret >= 0 ? 0 : ret;
}
int config_writer_write_element_signed_int(struct config_writer *writer,
- const char *element_name, int64_t value)
+ const char *element_name,
+ int64_t value)
{
int ret;
xmlChar *encoded_element_name;
goto end;
}
- ret = xmlTextWriterWriteFormatElement(writer->writer,
- encoded_element_name, "%" PRIi64, value);
+ ret = xmlTextWriterWriteFormatElement(
+ writer->writer, encoded_element_name, "%" PRIi64, value);
xmlFree(encoded_element_name);
end:
return ret >= 0 ? 0 : ret;
}
int config_writer_write_element_bool(struct config_writer *writer,
- const char *element_name, int value)
+ const char *element_name,
+ int value)
{
- return config_writer_write_element_string(writer, element_name,
- value ? config_xml_true : config_xml_false);
+ return config_writer_write_element_string(
+ writer, element_name, value ? config_xml_true : config_xml_false);
}
int config_writer_write_element_double(struct config_writer *writer,
- const char *element_name,
- double value)
+ const char *element_name,
+ double value)
{
int ret;
xmlChar *encoded_element_name;
goto end;
}
- ret = xmlTextWriterWriteFormatElement(
- writer->writer, encoded_element_name, "%f", value);
+ ret = xmlTextWriterWriteFormatElement(writer->writer, encoded_element_name, "%f", value);
xmlFree(encoded_element_name);
end:
return ret >= 0 ? 0 : ret;
}
int config_writer_write_element_string(struct config_writer *writer,
- const char *element_name, const char *value)
+ const char *element_name,
+ const char *value)
{
int ret;
xmlChar *encoded_element_name = NULL;
xmlChar *encoded_value = NULL;
- if (!writer || !writer->writer || !element_name || !element_name[0] ||
- !value) {
+ if (!writer || !writer->writer || !element_name || !element_name[0] || !value) {
ret = -1;
goto end;
}
goto end;
}
- ret = xmlTextWriterWriteElement(writer->writer, encoded_element_name,
- encoded_value);
+ ret = xmlTextWriterWriteElement(writer->writer, encoded_element_name, encoded_value);
end:
xmlFree(encoded_element_name);
xmlFree(encoded_value);
return ret >= 0 ? 0 : ret;
}
-static ATTR_FORMAT_PRINTF(2, 3)
-void xml_error_handler(void *ctx __attribute__((unused)), const char *format, ...)
+static ATTR_FORMAT_PRINTF(2, 3) void xml_error_handler(void *ctx __attribute__((unused)),
+ const char *format,
+ ...)
{
char *errMsg;
va_list args;
free(errMsg);
}
-static
-void fini_session_config_validation_ctx(
- struct session_config_validation_ctx *ctx)
+static void fini_session_config_validation_ctx(struct session_config_validation_ctx *ctx)
{
if (ctx->parser_ctx) {
xmlSchemaFreeParserCtxt(ctx->parser_ctx);
memset(ctx, 0, sizeof(struct session_config_validation_ctx));
}
-static
-char *get_session_config_xsd_path(void)
+static char *get_session_config_xsd_path(void)
{
char *xsd_path;
const char *base_path = lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV);
}
base_path_len = strlen(base_path);
- max_path_len = base_path_len +
- sizeof(DEFAULT_SESSION_CONFIG_XSD_FILENAME) + 1;
+ max_path_len = base_path_len + sizeof(DEFAULT_SESSION_CONFIG_XSD_FILENAME) + 1;
xsd_path = zmalloc<char>(max_path_len);
if (!xsd_path) {
goto end;
return xsd_path;
}
-static
-int init_session_config_validation_ctx(
- struct session_config_validation_ctx *ctx)
+static int init_session_config_validation_ctx(struct session_config_validation_ctx *ctx)
{
int ret;
char *xsd_path = get_session_config_xsd_path();
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler,
- xml_error_handler, NULL);
+ xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, NULL);
ctx->schema = xmlSchemaParse(ctx->parser_ctx);
if (!ctx->schema) {
goto end;
}
- xmlSchemaSetValidErrors(ctx->schema_validation_ctx, xml_error_handler,
- xml_error_handler, NULL);
+ xmlSchemaSetValidErrors(
+ ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, NULL);
ret = 0;
end:
return ret;
}
-static
-int parse_uint(xmlChar *str, uint64_t *val)
+static int parse_uint(xmlChar *str, uint64_t *val)
{
int ret;
char *endptr;
return ret;
}
-static
-int parse_int(xmlChar *str, int64_t *val)
+static int parse_int(xmlChar *str, int64_t *val)
{
int ret;
char *endptr;
return ret;
}
-static
-int parse_bool(xmlChar *str, int *val)
+static int parse_bool(xmlChar *str, int *val)
{
int ret = 0;
goto end;
}
- if (!strcmp((const char *) str, config_xml_true) ||
- !strcmp((const char *) str, "1")) {
+ if (!strcmp((const char *) str, config_xml_true) || !strcmp((const char *) str, "1")) {
*val = 1;
} else if (!strcmp((const char *) str, config_xml_false) ||
- !strcmp((const char *) str, "0")) {
+ !strcmp((const char *) str, "0")) {
*val = 0;
} else {
- WARN("Invalid boolean value encountered (%s).",
- (const char *) str);
+ WARN("Invalid boolean value encountered (%s).", (const char *) str);
ret = -1;
}
end:
return ret;
}
-static
-int get_domain_type(xmlChar *domain)
+static int get_domain_type(xmlChar *domain)
{
int ret;
return -1;
}
-static
-int get_buffer_type(xmlChar *buffer_type)
+static int get_buffer_type(xmlChar *buffer_type)
{
int ret;
return -1;
}
-static
-int get_overwrite_mode(xmlChar *overwrite_mode)
+static int get_overwrite_mode(xmlChar *overwrite_mode)
{
int ret;
if (!strcmp((char *) overwrite_mode, config_overwrite_mode_overwrite)) {
ret = 1;
- } else if (!strcmp((char *) overwrite_mode,
- config_overwrite_mode_discard)) {
+ } else if (!strcmp((char *) overwrite_mode, config_overwrite_mode_discard)) {
ret = 0;
} else {
goto error;
return -1;
}
-static
-int get_output_type(xmlChar *output_type)
+static int get_output_type(xmlChar *output_type)
{
int ret;
return -1;
}
-static
-int get_event_type(xmlChar *event_type)
+static int get_event_type(xmlChar *event_type)
{
int ret;
ret = LTTNG_EVENT_TRACEPOINT;
} else if (!strcmp((char *) event_type, config_event_type_probe)) {
ret = LTTNG_EVENT_PROBE;
- } else if (!strcmp((char *) event_type,
- config_event_type_userspace_probe)) {
+ } else if (!strcmp((char *) event_type, config_event_type_userspace_probe)) {
ret = LTTNG_EVENT_USERSPACE_PROBE;
} else if (!strcmp((char *) event_type, config_event_type_function)) {
ret = LTTNG_EVENT_FUNCTION;
- } else if (!strcmp((char *) event_type,
- config_event_type_function_entry)) {
+ } else if (!strcmp((char *) event_type, config_event_type_function_entry)) {
ret = LTTNG_EVENT_FUNCTION_ENTRY;
} else if (!strcmp((char *) event_type, config_event_type_noop)) {
ret = LTTNG_EVENT_NOOP;
return -1;
}
-static
-int get_loglevel_type(xmlChar *loglevel_type)
+static int get_loglevel_type(xmlChar *loglevel_type)
{
int ret;
if (!strcmp((char *) loglevel_type, config_loglevel_type_all)) {
ret = LTTNG_EVENT_LOGLEVEL_ALL;
- } else if (!strcmp((char *) loglevel_type,
- config_loglevel_type_range)) {
+ } else if (!strcmp((char *) loglevel_type, config_loglevel_type_range)) {
ret = LTTNG_EVENT_LOGLEVEL_RANGE;
- } else if (!strcmp((char *) loglevel_type,
- config_loglevel_type_single)) {
+ } else if (!strcmp((char *) loglevel_type, config_loglevel_type_single)) {
ret = LTTNG_EVENT_LOGLEVEL_SINGLE;
} else {
goto error;
/*
* Return the context type or -1 on error.
*/
-static
-int get_context_type(xmlChar *context_type)
+static int get_context_type(xmlChar *context_type)
{
int ret;
if (!strcmp((char *) context_type, config_event_context_pid)) {
ret = LTTNG_EVENT_CONTEXT_PID;
- } else if (!strcmp((char *) context_type,
- config_event_context_procname)) {
+ } else if (!strcmp((char *) context_type, config_event_context_procname)) {
ret = LTTNG_EVENT_CONTEXT_PROCNAME;
- } else if (!strcmp((char *) context_type,
- config_event_context_prio)) {
+ } else if (!strcmp((char *) context_type, config_event_context_prio)) {
ret = LTTNG_EVENT_CONTEXT_PRIO;
- } else if (!strcmp((char *) context_type,
- config_event_context_nice)) {
+ } else if (!strcmp((char *) context_type, config_event_context_nice)) {
ret = LTTNG_EVENT_CONTEXT_NICE;
- } else if (!strcmp((char *) context_type,
- config_event_context_vpid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vpid)) {
ret = LTTNG_EVENT_CONTEXT_VPID;
- } else if (!strcmp((char *) context_type,
- config_event_context_tid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_tid)) {
ret = LTTNG_EVENT_CONTEXT_TID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vtid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vtid)) {
ret = LTTNG_EVENT_CONTEXT_VTID;
- } else if (!strcmp((char *) context_type,
- config_event_context_ppid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_ppid)) {
ret = LTTNG_EVENT_CONTEXT_PPID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vppid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vppid)) {
ret = LTTNG_EVENT_CONTEXT_VPPID;
- } else if (!strcmp((char *) context_type,
- config_event_context_pthread_id)) {
+ } else if (!strcmp((char *) context_type, config_event_context_pthread_id)) {
ret = LTTNG_EVENT_CONTEXT_PTHREAD_ID;
- } else if (!strcmp((char *) context_type,
- config_event_context_hostname)) {
+ } else if (!strcmp((char *) context_type, config_event_context_hostname)) {
ret = LTTNG_EVENT_CONTEXT_HOSTNAME;
- } else if (!strcmp((char *) context_type,
- config_event_context_ip)) {
+ } else if (!strcmp((char *) context_type, config_event_context_ip)) {
ret = LTTNG_EVENT_CONTEXT_IP;
- } else if (!strcmp((char *) context_type,
- config_event_context_interruptible)) {
+ } else if (!strcmp((char *) context_type, config_event_context_interruptible)) {
ret = LTTNG_EVENT_CONTEXT_INTERRUPTIBLE;
- } else if (!strcmp((char *) context_type,
- config_event_context_preemptible)) {
+ } else if (!strcmp((char *) context_type, config_event_context_preemptible)) {
ret = LTTNG_EVENT_CONTEXT_PREEMPTIBLE;
- } else if (!strcmp((char *) context_type,
- config_event_context_need_reschedule)) {
+ } else if (!strcmp((char *) context_type, config_event_context_need_reschedule)) {
ret = LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE;
- } else if (!strcmp((char *) context_type,
- config_event_context_migratable)) {
+ } else if (!strcmp((char *) context_type, config_event_context_migratable)) {
ret = LTTNG_EVENT_CONTEXT_MIGRATABLE;
- } else if (!strcmp((char *) context_type,
- config_event_context_callstack_user)) {
+ } else if (!strcmp((char *) context_type, config_event_context_callstack_user)) {
ret = LTTNG_EVENT_CONTEXT_CALLSTACK_USER;
- } else if (!strcmp((char *) context_type,
- config_event_context_callstack_kernel)) {
+ } else if (!strcmp((char *) context_type, config_event_context_callstack_kernel)) {
ret = LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL;
- } else if (!strcmp((char *) context_type,
- config_event_context_cgroup_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_cgroup_ns)) {
ret = LTTNG_EVENT_CONTEXT_CGROUP_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_ipc_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_ipc_ns)) {
ret = LTTNG_EVENT_CONTEXT_IPC_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_mnt_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_mnt_ns)) {
ret = LTTNG_EVENT_CONTEXT_MNT_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_net_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_net_ns)) {
ret = LTTNG_EVENT_CONTEXT_NET_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_pid_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_pid_ns)) {
ret = LTTNG_EVENT_CONTEXT_PID_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_time_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_time_ns)) {
ret = LTTNG_EVENT_CONTEXT_TIME_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_user_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_user_ns)) {
ret = LTTNG_EVENT_CONTEXT_USER_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_uts_ns)) {
+ } else if (!strcmp((char *) context_type, config_event_context_uts_ns)) {
ret = LTTNG_EVENT_CONTEXT_UTS_NS;
- } else if (!strcmp((char *) context_type,
- config_event_context_uid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_uid)) {
ret = LTTNG_EVENT_CONTEXT_UID;
- } else if (!strcmp((char *) context_type,
- config_event_context_euid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_euid)) {
ret = LTTNG_EVENT_CONTEXT_EUID;
- } else if (!strcmp((char *) context_type,
- config_event_context_suid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_suid)) {
ret = LTTNG_EVENT_CONTEXT_SUID;
- } else if (!strcmp((char *) context_type,
- config_event_context_gid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_gid)) {
ret = LTTNG_EVENT_CONTEXT_GID;
- } else if (!strcmp((char *) context_type,
- config_event_context_egid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_egid)) {
ret = LTTNG_EVENT_CONTEXT_EGID;
- } else if (!strcmp((char *) context_type,
- config_event_context_sgid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_sgid)) {
ret = LTTNG_EVENT_CONTEXT_SGID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vuid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vuid)) {
ret = LTTNG_EVENT_CONTEXT_VUID;
- } else if (!strcmp((char *) context_type,
- config_event_context_veuid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_veuid)) {
ret = LTTNG_EVENT_CONTEXT_VEUID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vsuid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vsuid)) {
ret = LTTNG_EVENT_CONTEXT_VSUID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vgid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vgid)) {
ret = LTTNG_EVENT_CONTEXT_VGID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vegid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vegid)) {
ret = LTTNG_EVENT_CONTEXT_VEGID;
- } else if (!strcmp((char *) context_type,
- config_event_context_vsgid)) {
+ } else if (!strcmp((char *) context_type, config_event_context_vsgid)) {
ret = LTTNG_EVENT_CONTEXT_VSGID;
} else {
goto error;
return -1;
}
-static
-int init_domain(xmlNodePtr domain_node, struct lttng_domain *domain)
+static int init_domain(xmlNodePtr domain_node, struct lttng_domain *domain)
{
int ret;
xmlNodePtr node;
- for (node = xmlFirstElementChild(domain_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(domain_node); node; node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, config_element_type)) {
/* domain type */
xmlChar *node_content = xmlNodeGetContent(node);
}
domain->type = (lttng_domain_type) ret;
- } else if (!strcmp((const char *) node->name,
- config_element_buffer_type)) {
+ } else if (!strcmp((const char *) node->name, config_element_buffer_type)) {
/* buffer type */
xmlChar *node_content = xmlNodeGetContent(node);
if (!node_content) {
return ret;
}
-static
-int get_net_output_uris(xmlNodePtr net_output_node, char **control_uri,
- char **data_uri)
+static int get_net_output_uris(xmlNodePtr net_output_node, char **control_uri, char **data_uri)
{
xmlNodePtr node;
for (node = xmlFirstElementChild(net_output_node); node;
- node = xmlNextElementSibling(node)) {
+ node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, config_element_control_uri)) {
/* control_uri */
*control_uri = (char *) xmlNodeGetContent(node);
return *control_uri || *data_uri ? 0 : -LTTNG_ERR_LOAD_INVALID_CONFIG;
}
-static
-int process_consumer_output(xmlNodePtr consumer_output_node,
- struct consumer_output *output)
+static int process_consumer_output(xmlNodePtr consumer_output_node, struct consumer_output *output)
{
int ret;
xmlNodePtr node;
LTTNG_ASSERT(output);
for (node = xmlFirstElementChild(consumer_output_node); node;
- node = xmlNextElementSibling(node)) {
+ node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, config_element_enabled)) {
xmlChar *enabled_str = xmlNodeGetContent(node);
goto end;
}
- if (!strcmp((const char *) output_type_node->name,
- config_element_path)) {
+ if (!strcmp((const char *) output_type_node->name, config_element_path)) {
/* path */
output->path = (char *) xmlNodeGetContent(output_type_node);
if (!output->path) {
}
} else {
/* net_output */
- ret = get_net_output_uris(output_type_node,
- &output->control_uri, &output->data_uri);
+ ret = get_net_output_uris(
+ output_type_node, &output->control_uri, &output->data_uri);
if (ret) {
goto end;
}
return ret;
}
-static
-int create_snapshot_session(const char *session_name, xmlNodePtr output_node,
- const struct config_load_session_override_attr *overrides)
+static int create_snapshot_session(const char *session_name,
+ xmlNodePtr output_node,
+ const struct config_load_session_override_attr *overrides)
{
int ret;
enum lttng_error_code ret_code;
snapshot_output_list_node = xmlFirstElementChild(output_node);
/* Parse and create snapshot outputs */
- for (snapshot_output_node =
- xmlFirstElementChild(snapshot_output_list_node);
- snapshot_output_node; snapshot_output_node =
- xmlNextElementSibling(snapshot_output_node)) {
+ for (snapshot_output_node = xmlFirstElementChild(snapshot_output_list_node);
+ snapshot_output_node;
+ snapshot_output_node = xmlNextElementSibling(snapshot_output_node)) {
char *name = NULL;
uint64_t max_size = UINT64_MAX;
struct consumer_output output = {};
const char *path = NULL;
for (node = xmlFirstElementChild(snapshot_output_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_name)) {
+ node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_name)) {
/* name */
name = (char *) xmlNodeGetContent(node);
if (!name) {
ret = -LTTNG_ERR_NOMEM;
goto error_snapshot_output;
}
- } else if (!strcmp((const char *) node->name,
- config_element_max_size)) {
+ } else if (!strcmp((const char *) node->name, config_element_max_size)) {
xmlChar *content = xmlNodeGetContent(node);
/* max_size */
}
if (path) {
- ret = lttng_snapshot_output_set_ctrl_url(path,
- snapshot_output);
+ ret = lttng_snapshot_output_set_ctrl_url(path, snapshot_output);
if (ret) {
goto error_snapshot_output;
}
} else {
if (control_uri) {
ret = lttng_snapshot_output_set_ctrl_url(control_uri,
- snapshot_output);
+ snapshot_output);
if (ret) {
goto error_snapshot_output;
}
}
if (data_uri) {
- ret = lttng_snapshot_output_set_data_url(data_uri,
- snapshot_output);
+ ret = lttng_snapshot_output_set_data_url(data_uri, snapshot_output);
if (ret) {
goto error_snapshot_output;
}
}
ret = lttng_snapshot_add_output(session_name, snapshot_output);
-error_snapshot_output:
+ error_snapshot_output:
free(name);
free(output.path);
free(output.control_uri);
return ret;
}
-static
-int create_session(const char *name,
- xmlNodePtr output_node,
- uint64_t live_timer_interval,
- const struct config_load_session_override_attr *overrides)
+static int create_session(const char *name,
+ xmlNodePtr output_node,
+ uint64_t live_timer_interval,
+ const struct config_load_session_override_attr *overrides)
{
int ret = 0;
enum lttng_error_code ret_code;
}
if (strcmp((const char *) consumer_output_node->name,
- config_element_consumer_output)) {
+ config_element_consumer_output)) {
WARN("Invalid output type, expected %s node",
- config_element_consumer_output);
+ config_element_consumer_output);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
* NULL is passed here and will be set right after.
*/
session_descriptor = lttng_session_descriptor_live_network_create(
- name, control_uri, data_uri, live_timer_interval);
+ name, control_uri, data_uri, live_timer_interval);
} else {
session_descriptor = lttng_session_descriptor_network_create(
- name, control_uri, data_uri);
+ name, control_uri, data_uri);
}
} else if (path != nullptr) {
return ret;
}
-static
-struct lttng_userspace_probe_location *
-process_userspace_probe_function_attribute_node(
- xmlNodePtr attribute_node)
+static struct lttng_userspace_probe_location *
+process_userspace_probe_function_attribute_node(xmlNodePtr attribute_node)
{
xmlNodePtr function_attribute_node;
char *function_name = NULL, *binary_path = NULL;
* and check at the end if everything we need for this location type is
* there.
*/
- for (function_attribute_node =
- xmlFirstElementChild(attribute_node);
- function_attribute_node;
- function_attribute_node = xmlNextElementSibling(
- function_attribute_node)) {
+ for (function_attribute_node = xmlFirstElementChild(attribute_node);
+ function_attribute_node;
+ function_attribute_node = xmlNextElementSibling(function_attribute_node)) {
/* Handle function name, binary path and lookup method. */
if (!strcmp((const char *) function_attribute_node->name,
- config_element_userspace_probe_function_location_function_name)) {
+ config_element_userspace_probe_function_location_function_name)) {
function_name = (char *) xmlNodeGetContent(function_attribute_node);
if (!function_name) {
goto error;
}
} else if (!strcmp((const char *) function_attribute_node->name,
- config_element_userspace_probe_location_binary_path)) {
+ config_element_userspace_probe_location_binary_path)) {
binary_path = (char *) xmlNodeGetContent(function_attribute_node);
if (!binary_path) {
goto error;
}
} else if (!strcmp((const char *) function_attribute_node->name,
- config_element_userspace_probe_lookup)) {
+ config_element_userspace_probe_lookup)) {
char *lookup_method_name;
- lookup_method_name = (char *) xmlNodeGetContent(
- function_attribute_node);
+ lookup_method_name = (char *) xmlNodeGetContent(function_attribute_node);
if (!lookup_method_name) {
goto error;
}
* function_default lookup method defaults to
* function_elf lookup method at the moment.
*/
- if (!strcmp(lookup_method_name, config_element_userspace_probe_lookup_function_elf)
- || !strcmp(lookup_method_name, config_element_userspace_probe_lookup_function_default)) {
- lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create();
+ if (!strcmp(lookup_method_name,
+ config_element_userspace_probe_lookup_function_elf) ||
+ !strcmp(lookup_method_name,
+ config_element_userspace_probe_lookup_function_default)) {
+ lookup_method =
+ lttng_userspace_probe_location_lookup_method_function_elf_create();
if (!lookup_method) {
PERROR("Error creating function default/ELF lookup method");
}
/* Check if all the necessary fields were found. */
if (binary_path && function_name && lookup_method) {
/* Ownership of lookup_method is transferred. */
- location =
- lttng_userspace_probe_location_function_create(
- binary_path, function_name,
- lookup_method);
+ location = lttng_userspace_probe_location_function_create(
+ binary_path, function_name, lookup_method);
lookup_method = NULL;
goto error;
}
return location;
}
-static
-struct lttng_userspace_probe_location *
-process_userspace_probe_tracepoint_attribute_node(
- xmlNodePtr attribute_node)
+static struct lttng_userspace_probe_location *
+process_userspace_probe_tracepoint_attribute_node(xmlNodePtr attribute_node)
{
xmlNodePtr tracepoint_attribute_node;
char *probe_name = NULL, *provider_name = NULL, *binary_path = NULL;
* and check at the end if everything we need for this location type is
* there.
*/
- for (tracepoint_attribute_node =
- xmlFirstElementChild(attribute_node); tracepoint_attribute_node;
- tracepoint_attribute_node = xmlNextElementSibling(
- tracepoint_attribute_node)) {
+ for (tracepoint_attribute_node = xmlFirstElementChild(attribute_node);
+ tracepoint_attribute_node;
+ tracepoint_attribute_node = xmlNextElementSibling(tracepoint_attribute_node)) {
if (!strcmp((const char *) tracepoint_attribute_node->name,
- config_element_userspace_probe_tracepoint_location_probe_name)) {
+ config_element_userspace_probe_tracepoint_location_probe_name)) {
probe_name = (char *) xmlNodeGetContent(tracepoint_attribute_node);
if (!probe_name) {
goto error;
}
} else if (!strcmp((const char *) tracepoint_attribute_node->name,
- config_element_userspace_probe_tracepoint_location_provider_name)) {
+ config_element_userspace_probe_tracepoint_location_provider_name)) {
provider_name = (char *) xmlNodeGetContent(tracepoint_attribute_node);
if (!provider_name) {
goto error;
}
} else if (!strcmp((const char *) tracepoint_attribute_node->name,
- config_element_userspace_probe_location_binary_path)) {
+ config_element_userspace_probe_location_binary_path)) {
binary_path = (char *) xmlNodeGetContent(tracepoint_attribute_node);
if (!binary_path) {
goto error;
}
} else if (!strcmp((const char *) tracepoint_attribute_node->name,
- config_element_userspace_probe_lookup)) {
+ config_element_userspace_probe_lookup)) {
char *lookup_method_name;
- lookup_method_name = (char *) xmlNodeGetContent(
- tracepoint_attribute_node);
+ lookup_method_name = (char *) xmlNodeGetContent(tracepoint_attribute_node);
if (!lookup_method_name) {
goto error;
}
if (!strcmp(lookup_method_name,
- config_element_userspace_probe_lookup_tracepoint_sdt)) {
+ config_element_userspace_probe_lookup_tracepoint_sdt)) {
lookup_method =
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create();
if (!lookup_method) {
/* Check if all the necessary fields were found. */
if (binary_path && provider_name && probe_name && lookup_method) {
/* Ownership of lookup_method is transferred. */
- location =
- lttng_userspace_probe_location_tracepoint_create(
- binary_path, provider_name,
- probe_name, lookup_method);
+ location = lttng_userspace_probe_location_tracepoint_create(
+ binary_path, provider_name, probe_name, lookup_method);
lookup_method = NULL;
goto error;
}
return location;
}
-static
-int process_probe_attribute_node(xmlNodePtr probe_attribute_node,
- struct lttng_event_probe_attr *attr)
+static int process_probe_attribute_node(xmlNodePtr probe_attribute_node,
+ struct lttng_event_probe_attr *attr)
{
int ret;
LTTNG_ASSERT(probe_attribute_node);
LTTNG_ASSERT(attr);
- if (!strcmp((const char *) probe_attribute_node->name,
- config_element_address)) {
+ if (!strcmp((const char *) probe_attribute_node->name, config_element_address)) {
xmlChar *content;
uint64_t addr = 0;
}
attr->addr = addr;
- } else if (!strcmp((const char *) probe_attribute_node->name,
- config_element_offset)) {
+ } else if (!strcmp((const char *) probe_attribute_node->name, config_element_offset)) {
xmlChar *content;
uint64_t offset = 0;
}
attr->offset = offset;
- } else if (!strcmp((const char *) probe_attribute_node->name,
- config_element_symbol_name)) {
+ } else if (!strcmp((const char *) probe_attribute_node->name, config_element_symbol_name)) {
xmlChar *content;
/* symbol_name */
goto end;
}
- ret = lttng_strncpy(attr->symbol_name,
- (const char *) content,
- LTTNG_SYMBOL_NAME_LEN);
+ ret = lttng_strncpy(
+ attr->symbol_name, (const char *) content, LTTNG_SYMBOL_NAME_LEN);
if (ret == -1) {
- ERR("symbol name \"%s\"'s length (%zu) exceeds the maximal permitted length (%d) in session configuration",
- (const char *) content,
- strlen((const char *) content),
- LTTNG_SYMBOL_NAME_LEN);
+ ERR("symbol name \"%s\"'s length (%zu) exceeds the maximal permitted length (%d) in session configuration",
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
return ret;
}
-static
-int process_event_node(xmlNodePtr event_node, struct lttng_handle *handle,
- const char *channel_name, const enum process_event_node_phase phase)
+static int process_event_node(xmlNodePtr event_node,
+ struct lttng_handle *handle,
+ const char *channel_name,
+ const enum process_event_node_phase phase)
{
int ret = 0, i;
xmlNodePtr node;
}
/* Initialize default log level which varies by domain */
- switch (handle->domain.type)
- {
+ switch (handle->domain.type) {
case LTTNG_DOMAIN_JUL:
event->loglevel = LTTNG_LOGLEVEL_JUL_ALL;
break;
abort();
}
- for (node = xmlFirstElementChild(event_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(event_node); node; node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, config_element_name)) {
xmlChar *content;
goto end;
}
- ret = lttng_strncpy(event->name,
- (const char *) content,
- LTTNG_SYMBOL_NAME_LEN);
+ ret = lttng_strncpy(
+ event->name, (const char *) content, LTTNG_SYMBOL_NAME_LEN);
if (ret == -1) {
WARN("Event \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
- (const char *) content,
- strlen((const char *) content),
- LTTNG_SYMBOL_NAME_LEN);
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
free(content);
- } else if (!strcmp((const char *) node->name,
- config_element_enabled)) {
+ } else if (!strcmp((const char *) node->name, config_element_enabled)) {
xmlChar *content = xmlNodeGetContent(node);
/* enabled */
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) node->name,
- config_element_type)) {
+ } else if (!strcmp((const char *) node->name, config_element_type)) {
xmlChar *content = xmlNodeGetContent(node);
/* type */
}
event->type = (lttng_event_type) ret;
- } else if (!strcmp((const char *) node->name,
- config_element_loglevel_type)) {
+ } else if (!strcmp((const char *) node->name, config_element_loglevel_type)) {
xmlChar *content = xmlNodeGetContent(node);
/* loglevel_type */
}
event->loglevel_type = (lttng_loglevel_type) ret;
- } else if (!strcmp((const char *) node->name,
- config_element_loglevel)) {
+ } else if (!strcmp((const char *) node->name, config_element_loglevel)) {
xmlChar *content;
int64_t loglevel = 0;
}
event->loglevel = loglevel;
- } else if (!strcmp((const char *) node->name,
- config_element_filter)) {
- xmlChar *content =
- xmlNodeGetContent(node);
+ } else if (!strcmp((const char *) node->name, config_element_filter)) {
+ xmlChar *content = xmlNodeGetContent(node);
/* filter */
if (!content) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
- } else if (!strcmp((const char *) node->name,
- config_element_exclusions)) {
+ } else if (!strcmp((const char *) node->name, config_element_exclusions)) {
xmlNodePtr exclusion_node;
int exclusion_index = 0;
}
for (exclusion_node = xmlFirstElementChild(node); exclusion_node;
- exclusion_node = xmlNextElementSibling(exclusion_node)) {
- xmlChar *content =
- xmlNodeGetContent(exclusion_node);
+ exclusion_node = xmlNextElementSibling(exclusion_node)) {
+ xmlChar *content = xmlNodeGetContent(exclusion_node);
if (!content) {
ret = -LTTNG_ERR_NOMEM;
}
event->exclusion = 1;
- } else if (!strcmp((const char *) node->name,
- config_element_attributes)) {
+ } else if (!strcmp((const char *) node->name, config_element_attributes)) {
xmlNodePtr attribute_node = xmlFirstElementChild(node);
/* attributes */
}
if (!strcmp((const char *) attribute_node->name,
- config_element_probe_attributes)) {
+ config_element_probe_attributes)) {
xmlNodePtr probe_attribute_node;
/* probe_attributes */
- for (probe_attribute_node =
- xmlFirstElementChild(attribute_node); probe_attribute_node;
- probe_attribute_node = xmlNextElementSibling(
- probe_attribute_node)) {
-
+ for (probe_attribute_node = xmlFirstElementChild(attribute_node);
+ probe_attribute_node;
+ probe_attribute_node =
+ xmlNextElementSibling(probe_attribute_node)) {
ret = process_probe_attribute_node(probe_attribute_node,
- &event->attr.probe);
+ &event->attr.probe);
if (ret) {
goto end;
}
}
} else if (!strcmp((const char *) attribute_node->name,
- config_element_function_attributes)) {
+ config_element_function_attributes)) {
size_t sym_len;
xmlChar *content;
xmlNodePtr symbol_node = xmlFirstElementChild(attribute_node);
}
ret = lttng_strncpy(
- event->attr.ftrace.symbol_name,
- (char *) content, sym_len);
+ event->attr.ftrace.symbol_name, (char *) content, sym_len);
if (ret == -1) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
}
free(content);
} else if (!strcmp((const char *) attribute_node->name,
- config_element_userspace_probe_tracepoint_attributes)) {
+ config_element_userspace_probe_tracepoint_attributes)) {
struct lttng_userspace_probe_location *location;
- location = process_userspace_probe_tracepoint_attribute_node(attribute_node);
+ location = process_userspace_probe_tracepoint_attribute_node(
+ attribute_node);
if (!location) {
WARN("Error processing userspace probe tracepoint attribute");
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- ret = lttng_event_set_userspace_probe_location(
- event, location);
+ ret = lttng_event_set_userspace_probe_location(event, location);
if (ret) {
WARN("Error setting userspace probe location field");
- lttng_userspace_probe_location_destroy(
- location);
+ lttng_userspace_probe_location_destroy(location);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
} else if (!strcmp((const char *) attribute_node->name,
- config_element_userspace_probe_function_attributes)) {
+ config_element_userspace_probe_function_attributes)) {
struct lttng_userspace_probe_location *location;
- location =
- process_userspace_probe_function_attribute_node(
- attribute_node);
+ location = process_userspace_probe_function_attribute_node(
+ attribute_node);
if (!location) {
WARN("Error processing userspace probe function attribute");
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- ret = lttng_event_set_userspace_probe_location(
- event, location);
+ ret = lttng_event_set_userspace_probe_location(event, location);
if (ret) {
WARN("Error setting userspace probe location field");
- lttng_userspace_probe_location_destroy(
- location);
+ lttng_userspace_probe_location_destroy(location);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
}
if ((event->enabled && phase == ENABLE) || phase == CREATION) {
- ret = lttng_enable_event_with_exclusions(handle, event, channel_name,
- filter_expression, exclusion_count, exclusions);
+ ret = lttng_enable_event_with_exclusions(
+ handle, event, channel_name, filter_expression, exclusion_count, exclusions);
if (ret < 0) {
WARN("Enabling event (name:%s) on load failed.", event->name);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
return ret;
}
-static
-int process_events_node(xmlNodePtr events_node, struct lttng_handle *handle,
- const char *channel_name)
+static int
+process_events_node(xmlNodePtr events_node, struct lttng_handle *handle, const char *channel_name)
{
int ret = 0;
struct lttng_event event;
LTTNG_ASSERT(handle);
LTTNG_ASSERT(channel_name);
- for (node = xmlFirstElementChild(events_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(events_node); node; node = xmlNextElementSibling(node)) {
ret = process_event_node(node, handle, channel_name, CREATION);
if (ret) {
goto end;
goto end;
}
- for (node = xmlFirstElementChild(events_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(events_node); node; node = xmlNextElementSibling(node)) {
ret = process_event_node(node, handle, channel_name, ENABLE);
if (ret) {
goto end;
return ret;
}
-static
-int process_channel_attr_node(xmlNodePtr attr_node,
- struct lttng_channel *channel, xmlNodePtr *contexts_node,
- xmlNodePtr *events_node)
+static int process_channel_attr_node(xmlNodePtr attr_node,
+ struct lttng_channel *channel,
+ xmlNodePtr *contexts_node,
+ xmlNodePtr *events_node)
{
int ret;
goto end;
}
- ret = lttng_strncpy(channel->name,
- (const char *) content,
- LTTNG_SYMBOL_NAME_LEN);
+ ret = lttng_strncpy(channel->name, (const char *) content, LTTNG_SYMBOL_NAME_LEN);
if (ret == -1) {
WARN("Channel \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
- (const char *) content,
- strlen((const char *) content),
- LTTNG_SYMBOL_NAME_LEN);
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
free(content);
- } else if (!strcmp((const char *) attr_node->name,
- config_element_enabled)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_enabled)) {
xmlChar *content;
int enabled;
}
channel->enabled = enabled;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_overwrite_mode)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_overwrite_mode)) {
xmlChar *content;
/* overwrite_mode */
}
channel->attr.overwrite = ret;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_subbuf_size)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_subbuf_size)) {
xmlChar *content;
/* subbuffer_size */
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_num_subbuf)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_num_subbuf)) {
xmlChar *content;
/* subbuffer_count */
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_switch_timer_interval)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_switch_timer_interval)) {
xmlChar *content;
uint64_t switch_timer_interval = 0;
goto end;
}
- channel->attr.switch_timer_interval =
- switch_timer_interval;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_read_timer_interval)) {
+ channel->attr.switch_timer_interval = switch_timer_interval;
+ } else if (!strcmp((const char *) attr_node->name, config_element_read_timer_interval)) {
xmlChar *content;
uint64_t read_timer_interval = 0;
goto end;
}
- channel->attr.read_timer_interval =
- read_timer_interval;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_output_type)) {
+ channel->attr.read_timer_interval = read_timer_interval;
+ } else if (!strcmp((const char *) attr_node->name, config_element_output_type)) {
xmlChar *content;
/* output_type */
}
channel->attr.output = (lttng_event_output) ret;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_tracefile_size)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_tracefile_size)) {
xmlChar *content;
/* tracefile_size */
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_tracefile_count)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_tracefile_count)) {
xmlChar *content;
/* tracefile_count */
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_live_timer_interval)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_live_timer_interval)) {
xmlChar *content;
uint64_t live_timer_interval = 0;
goto end;
}
- channel->attr.live_timer_interval =
- live_timer_interval;
- } else if (!strcmp((const char *) attr_node->name,
- config_element_monitor_timer_interval)) {
+ channel->attr.live_timer_interval = live_timer_interval;
+ } else if (!strcmp((const char *) attr_node->name, config_element_monitor_timer_interval)) {
xmlChar *content;
uint64_t monitor_timer_interval = 0;
goto end;
}
- ret = lttng_channel_set_monitor_timer_interval(channel,
- monitor_timer_interval);
+ ret = lttng_channel_set_monitor_timer_interval(channel, monitor_timer_interval);
if (ret) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_blocking_timeout)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_blocking_timeout)) {
xmlChar *content;
int64_t blocking_timeout = 0;
goto end;
}
- ret = lttng_channel_set_blocking_timeout(channel,
- blocking_timeout);
+ ret = lttng_channel_set_blocking_timeout(channel, blocking_timeout);
if (ret) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- } else if (!strcmp((const char *) attr_node->name,
- config_element_events)) {
+ } else if (!strcmp((const char *) attr_node->name, config_element_events)) {
/* events */
*events_node = attr_node;
} else {
return ret;
}
-static
-int process_context_node(xmlNodePtr context_node,
- struct lttng_handle *handle, const char *channel_name)
+static int
+process_context_node(xmlNodePtr context_node, struct lttng_handle *handle, const char *channel_name)
{
int ret;
struct lttng_event_context context;
memset(&context, 0, sizeof(context));
- if (!strcmp((const char *) context_child_node->name,
- config_element_type)) {
+ if (!strcmp((const char *) context_child_node->name, config_element_type)) {
/* type */
xmlChar *content = xmlNodeGetContent(context_child_node);
}
context.ctx = (lttng_event_context_type) ret;
- } else if (!strcmp((const char *) context_child_node->name,
- config_element_context_perf)) {
+ } else if (!strcmp((const char *) context_child_node->name, config_element_context_perf)) {
/* perf */
xmlNodePtr perf_attr_node;
context.ctx = handle->domain.type == LTTNG_DOMAIN_KERNEL ?
LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER :
LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER;
- for (perf_attr_node = xmlFirstElementChild(context_child_node);
- perf_attr_node; perf_attr_node =
- xmlNextElementSibling(perf_attr_node)) {
- if (!strcmp((const char *) perf_attr_node->name,
- config_element_type)) {
+ for (perf_attr_node = xmlFirstElementChild(context_child_node); perf_attr_node;
+ perf_attr_node = xmlNextElementSibling(perf_attr_node)) {
+ if (!strcmp((const char *) perf_attr_node->name, config_element_type)) {
xmlChar *content;
uint64_t type = 0;
context.u.perf_counter.type = type;
} else if (!strcmp((const char *) perf_attr_node->name,
- config_element_config)) {
+ config_element_config)) {
xmlChar *content;
uint64_t config = 0;
context.u.perf_counter.config = config;
} else if (!strcmp((const char *) perf_attr_node->name,
- config_element_name)) {
+ config_element_name)) {
xmlChar *content;
/* name */
}
ret = lttng_strncpy(context.u.perf_counter.name,
- (const char *) content,
- LTTNG_SYMBOL_NAME_LEN);
+ (const char *) content,
+ LTTNG_SYMBOL_NAME_LEN);
if (ret == -1) {
WARN("Perf counter \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
- (const char *) content,
- strlen((const char *) content),
- LTTNG_SYMBOL_NAME_LEN);
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
free(content);
}
}
- } else if (!strcmp((const char *) context_child_node->name,
- config_element_context_app)) {
+ } else if (!strcmp((const char *) context_child_node->name, config_element_context_app)) {
/* application context */
xmlNodePtr app_ctx_node;
context.ctx = LTTNG_EVENT_CONTEXT_APP_CONTEXT;
- for (app_ctx_node = xmlFirstElementChild(context_child_node);
- app_ctx_node; app_ctx_node =
- xmlNextElementSibling(app_ctx_node)) {
+ for (app_ctx_node = xmlFirstElementChild(context_child_node); app_ctx_node;
+ app_ctx_node = xmlNextElementSibling(app_ctx_node)) {
xmlChar *content;
- char **target = strcmp(
- (const char *) app_ctx_node->name,
- config_element_context_app_provider_name) == 0 ?
- &context.u.app_ctx.provider_name :
- &context.u.app_ctx.ctx_name;
+ char **target = strcmp((const char *) app_ctx_node->name,
+ config_element_context_app_provider_name) == 0 ?
+ &context.u.app_ctx.provider_name :
+ &context.u.app_ctx.ctx_name;
content = xmlNodeGetContent(app_ctx_node);
if (!content) {
return ret;
}
-static
-int process_contexts_node(xmlNodePtr contexts_node,
- struct lttng_handle *handle, const char *channel_name)
+static int process_contexts_node(xmlNodePtr contexts_node,
+ struct lttng_handle *handle,
+ const char *channel_name)
{
int ret = 0;
xmlNodePtr context_node;
for (context_node = xmlFirstElementChild(contexts_node); context_node;
- context_node = xmlNextElementSibling(context_node)) {
+ context_node = xmlNextElementSibling(context_node)) {
ret = process_context_node(context_node, handle, channel_name);
if (ret) {
goto end;
}
static int get_tracker_elements(enum lttng_process_attr process_attr,
- const char **element_id_tracker,
- const char **element_value_type,
- const char **element_value,
- const char **element_value_alias,
- const char **element_name)
+ const char **element_id_tracker,
+ const char **element_value_type,
+ const char **element_value,
+ const char **element_value_alias,
+ const char **element_name)
{
int ret = 0;
return ret;
}
-static int process_legacy_pid_tracker_node(
- xmlNodePtr trackers_node, struct lttng_handle *handle)
+static int process_legacy_pid_tracker_node(xmlNodePtr trackers_node, struct lttng_handle *handle)
{
int ret = 0, child_count;
xmlNodePtr targets_node = NULL;
enum lttng_error_code tracker_handle_ret_code;
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
enum lttng_process_attr_tracker_handle_status status;
- const enum lttng_process_attr process_attr =
- handle->domain.type == LTTNG_DOMAIN_UST ?
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID :
- LTTNG_PROCESS_ATTR_PROCESS_ID;
+ const enum lttng_process_attr process_attr = handle->domain.type == LTTNG_DOMAIN_UST ?
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID :
+ LTTNG_PROCESS_ATTR_PROCESS_ID;
LTTNG_ASSERT(handle);
tracker_handle_ret_code = lttng_session_get_tracker_handle(
- handle->session_name, handle->domain.type,
- process_attr,
- &tracker_handle);
+ handle->session_name, handle->domain.type, process_attr, &tracker_handle);
if (tracker_handle_ret_code != LTTNG_OK) {
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = get_tracker_elements(process_attr, &element_id_tracker,
- &element_target_id, &element_id, &element_id_alias,
- &element_name);
+ ret = get_tracker_elements(process_attr,
+ &element_id_tracker,
+ &element_target_id,
+ &element_id,
+ &element_id_alias,
+ &element_name);
if (ret) {
goto end;
}
/* Get the targets node */
- for (node = xmlFirstElementChild(trackers_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_tracker_targets_legacy)) {
+ for (node = xmlFirstElementChild(trackers_node); node; node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_tracker_targets_legacy)) {
targets_node = node;
break;
}
/* Go through all id target node */
child_count = xmlChildElementCount(targets_node);
status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- child_count == 0 ? LTTNG_TRACKING_POLICY_EXCLUDE_ALL :
- LTTNG_TRACKING_POLICY_INCLUDE_SET);
+ tracker_handle,
+ child_count == 0 ? LTTNG_TRACKING_POLICY_EXCLUDE_ALL :
+ LTTNG_TRACKING_POLICY_INCLUDE_SET);
if (status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret = LTTNG_ERR_UNK;
goto end;
}
/* Add all tracked values. */
- for (node = xmlFirstElementChild(targets_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(targets_node); node; node = xmlNextElementSibling(node)) {
xmlNodePtr pid_target_node = node;
/* get pid_target node and track it */
for (node = xmlFirstElementChild(pid_target_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_tracker_pid_legacy)) {
+ node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_tracker_pid_legacy)) {
int64_t id;
xmlChar *content = xmlNodeGetContent(node);
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
- status = lttng_process_attr_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) id);
+ status =
+ lttng_process_attr_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) id);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
- status = lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) id);
+ status =
+ lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) id);
break;
default:
ret = LTTNG_ERR_INVALID;
end:
lttng_process_attr_tracker_handle_destroy(tracker_handle);
return ret;
- }
+}
static int process_id_tracker_node(xmlNodePtr id_tracker_node,
- struct lttng_handle *handle,
- enum lttng_process_attr process_attr)
+ struct lttng_handle *handle,
+ enum lttng_process_attr process_attr)
{
int ret = 0, child_count;
xmlNodePtr values_node = NULL;
LTTNG_ASSERT(id_tracker_node);
tracker_handle_ret_code = lttng_session_get_tracker_handle(
- handle->session_name, handle->domain.type, process_attr,
- &tracker_handle);
+ handle->session_name, handle->domain.type, process_attr, &tracker_handle);
if (tracker_handle_ret_code != LTTNG_OK) {
ret = LTTNG_ERR_INVALID;
goto end;
}
- ret = get_tracker_elements(process_attr, &element_id_tracker,
- &element_target_id, &element_id, &element_id_alias,
- &element_name);
+ ret = get_tracker_elements(process_attr,
+ &element_id_tracker,
+ &element_target_id,
+ &element_id,
+ &element_id_alias,
+ &element_name);
if (ret) {
goto end;
}
/* get the values node */
for (node = xmlFirstElementChild(id_tracker_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_process_attr_values)) {
+ node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_values)) {
values_node = node;
break;
}
/* Go through all id target node */
child_count = xmlChildElementCount(values_node);
status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- child_count == 0 ? LTTNG_TRACKING_POLICY_EXCLUDE_ALL :
- LTTNG_TRACKING_POLICY_INCLUDE_SET);
+ tracker_handle,
+ child_count == 0 ? LTTNG_TRACKING_POLICY_EXCLUDE_ALL :
+ LTTNG_TRACKING_POLICY_INCLUDE_SET);
if (status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret = LTTNG_ERR_UNK;
goto end;
}
/* Add all tracked values. */
- for (node = xmlFirstElementChild(values_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(values_node); node; node = xmlNextElementSibling(node)) {
xmlNodePtr id_target_node = node;
/* get id node and track it */
for (node = xmlFirstElementChild(id_target_node); node;
- node = xmlNextElementSibling(node)) {
+ node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, element_id) ||
- (element_id_alias &&
- !strcmp((const char *) node->name,
- element_id_alias))) {
+ (element_id_alias &&
+ !strcmp((const char *) node->name, element_id_alias))) {
int64_t id;
xmlChar *content = xmlNodeGetContent(node);
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
- status = lttng_process_attr_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) id);
+ status =
+ lttng_process_attr_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) id);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
- status = lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) id);
+ status =
+ lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
+ tracker_handle, (pid_t) id);
break;
case LTTNG_PROCESS_ATTR_USER_ID:
status = lttng_process_attr_user_id_tracker_handle_add_uid(
- tracker_handle,
- (uid_t) id);
+ tracker_handle, (uid_t) id);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
- status = lttng_process_attr_virtual_user_id_tracker_handle_add_uid(
- tracker_handle,
- (uid_t) id);
+ status =
+ lttng_process_attr_virtual_user_id_tracker_handle_add_uid(
+ tracker_handle, (uid_t) id);
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
status = lttng_process_attr_group_id_tracker_handle_add_gid(
- tracker_handle,
- (gid_t) id);
+ tracker_handle, (gid_t) id);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
- status = lttng_process_attr_virtual_group_id_tracker_handle_add_gid(
- tracker_handle,
- (gid_t) id);
+ status =
+ lttng_process_attr_virtual_group_id_tracker_handle_add_gid(
+ tracker_handle, (gid_t) id);
break;
default:
ret = LTTNG_ERR_INVALID;
goto end;
}
} else if (element_name &&
- !strcmp((const char *) node->name,
- element_name)) {
+ !strcmp((const char *) node->name, element_name)) {
xmlChar *content = xmlNodeGetContent(node);
if (!content) {
switch (process_attr) {
case LTTNG_PROCESS_ATTR_USER_ID:
- status = lttng_process_attr_user_id_tracker_handle_add_user_name(
- tracker_handle,
- (const char *) content);
+ status =
+ lttng_process_attr_user_id_tracker_handle_add_user_name(
+ tracker_handle, (const char *) content);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
- status = lttng_process_attr_virtual_user_id_tracker_handle_add_user_name(
- tracker_handle,
- (const char *) content);
+ status =
+ lttng_process_attr_virtual_user_id_tracker_handle_add_user_name(
+ tracker_handle, (const char *) content);
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
- status = lttng_process_attr_group_id_tracker_handle_add_group_name(
- tracker_handle,
- (const char *) content);
+ status =
+ lttng_process_attr_group_id_tracker_handle_add_group_name(
+ tracker_handle, (const char *) content);
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
- status = lttng_process_attr_virtual_group_id_tracker_handle_add_group_name(
- tracker_handle,
- (const char *) content);
+ status =
+ lttng_process_attr_virtual_group_id_tracker_handle_add_group_name(
+ tracker_handle, (const char *) content);
break;
default:
free(content);
return ret;
}
-static
-int process_domain_node(xmlNodePtr domain_node, const char *session_name)
+static int process_domain_node(xmlNodePtr domain_node, const char *session_name)
{
int ret;
struct lttng_domain domain {};
}
/* get the channels node */
- for (node = xmlFirstElementChild(domain_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_channels)) {
+ for (node = xmlFirstElementChild(domain_node); node; node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_channels)) {
channels_node = node;
break;
}
}
/* create all channels */
- for (node = xmlFirstElementChild(channels_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(channels_node); node; node = xmlNextElementSibling(node)) {
const enum lttng_domain_type original_domain = domain.type;
xmlNodePtr contexts_node = NULL;
xmlNodePtr events_node = NULL;
goto end;
}
- for (channel_attr_node = xmlFirstElementChild(node);
- channel_attr_node; channel_attr_node =
- xmlNextElementSibling(channel_attr_node)) {
- ret = process_channel_attr_node(channel_attr_node,
- channel, &contexts_node, &events_node);
+ for (channel_attr_node = xmlFirstElementChild(node); channel_attr_node;
+ channel_attr_node = xmlNextElementSibling(channel_attr_node)) {
+ ret = process_channel_attr_node(
+ channel_attr_node, channel, &contexts_node, &events_node);
if (ret) {
goto end;
}
goto end;
}
- ret = process_contexts_node(contexts_node, handle,
- channel->name);
+ ret = process_contexts_node(contexts_node, handle, channel->name);
if (ret) {
goto end;
}
channel = NULL;
/* get the trackers node */
- for (node = xmlFirstElementChild(domain_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_process_attr_trackers) ||
- !strcmp((const char *) node->name,
- config_element_trackers_legacy)) {
+ for (node = xmlFirstElementChild(domain_node); node; node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_trackers) ||
+ !strcmp((const char *) node->name, config_element_trackers_legacy)) {
if (trackers_node) {
ERR("Only one instance of `%s` or `%s` is allowed in a session configuration",
- config_element_process_attr_trackers,
- config_element_trackers_legacy);
+ config_element_process_attr_trackers,
+ config_element_trackers_legacy);
ret = -1;
goto end;
}
goto end;
}
- for (node = xmlFirstElementChild(trackers_node); node;
- node = xmlNextElementSibling(node)) {
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_pid)) {
+ for (node = xmlFirstElementChild(trackers_node); node; node = xmlNextElementSibling(node)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_pid)) {
pid_tracker_node = node;
- ret = process_id_tracker_node(pid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_PROCESS_ID);
+ ret = process_id_tracker_node(
+ pid_tracker_node, handle, LTTNG_PROCESS_ATTR_PROCESS_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_vpid)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_vpid)) {
vpid_tracker_node = node;
- ret = process_id_tracker_node(vpid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
+ ret = process_id_tracker_node(
+ vpid_tracker_node, handle, LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_uid)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_uid)) {
uid_tracker_node = node;
- ret = process_id_tracker_node(uid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_USER_ID);
+ ret = process_id_tracker_node(
+ uid_tracker_node, handle, LTTNG_PROCESS_ATTR_USER_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_vuid)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_vuid)) {
vuid_tracker_node = node;
- ret = process_id_tracker_node(vuid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
+ ret = process_id_tracker_node(
+ vuid_tracker_node, handle, LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_gid)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_gid)) {
gid_tracker_node = node;
- ret = process_id_tracker_node(gid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_GROUP_ID);
+ ret = process_id_tracker_node(
+ gid_tracker_node, handle, LTTNG_PROCESS_ATTR_GROUP_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_process_attr_tracker_vgid)) {
+ if (!strcmp((const char *) node->name, config_element_process_attr_tracker_vgid)) {
vgid_tracker_node = node;
- ret = process_id_tracker_node(vgid_tracker_node, handle,
- LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
+ ret = process_id_tracker_node(
+ vgid_tracker_node, handle, LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID);
if (ret) {
goto end;
}
}
- if (!strcmp((const char *) node->name,
- config_element_pid_tracker_legacy)) {
+ if (!strcmp((const char *) node->name, config_element_pid_tracker_legacy)) {
ret = process_legacy_pid_tracker_node(node, handle);
if (ret) {
goto end;
return ret;
}
-static
-int add_periodic_rotation(const char *name, uint64_t time_us)
+static int add_periodic_rotation(const char *name, uint64_t time_us)
{
int ret;
enum lttng_rotation_status status;
- struct lttng_rotation_schedule *periodic =
- lttng_rotation_schedule_periodic_create();
+ struct lttng_rotation_schedule *periodic = lttng_rotation_schedule_periodic_create();
if (!periodic) {
ret = -LTTNG_ERR_NOMEM;
goto error;
}
- status = lttng_rotation_schedule_periodic_set_period(periodic,
- time_us);
+ status = lttng_rotation_schedule_periodic_set_period(periodic, time_us);
if (status != LTTNG_ROTATION_STATUS_OK) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-static
-int add_size_rotation(const char *name, uint64_t size_bytes)
+static int add_size_rotation(const char *name, uint64_t size_bytes)
{
int ret;
enum lttng_rotation_status status;
- struct lttng_rotation_schedule *size =
- lttng_rotation_schedule_size_threshold_create();
+ struct lttng_rotation_schedule *size = lttng_rotation_schedule_size_threshold_create();
if (!size) {
ret = -LTTNG_ERR_NOMEM;
goto error;
}
- status = lttng_rotation_schedule_size_threshold_set_threshold(size,
- size_bytes);
+ status = lttng_rotation_schedule_size_threshold_set_threshold(size, size_bytes);
if (status != LTTNG_ROTATION_STATUS_OK) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-static
-int process_session_rotation_schedules_node(
- xmlNodePtr schedules_node,
- uint64_t *rotation_timer_interval,
- uint64_t *rotation_size)
+static int process_session_rotation_schedules_node(xmlNodePtr schedules_node,
+ uint64_t *rotation_timer_interval,
+ uint64_t *rotation_size)
{
int ret = 0;
xmlNodePtr child;
- for (child = xmlFirstElementChild(schedules_node);
- child;
- child = xmlNextElementSibling(child)) {
+ for (child = xmlFirstElementChild(schedules_node); child;
+ child = xmlNextElementSibling(child)) {
if (!strcmp((const char *) child->name,
- config_element_rotation_schedule_periodic)) {
+ config_element_rotation_schedule_periodic)) {
xmlChar *content;
xmlNodePtr time_us_node;
/* periodic rotation schedule */
time_us_node = xmlFirstElementChild(child);
if (!time_us_node ||
- strcmp((const char *) time_us_node->name,
- config_element_rotation_schedule_periodic_time_us)) {
+ strcmp((const char *) time_us_node->name,
+ config_element_rotation_schedule_periodic_time_us)) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
goto end;
}
} else if (!strcmp((const char *) child->name,
- config_element_rotation_schedule_size_threshold)) {
+ config_element_rotation_schedule_size_threshold)) {
xmlChar *content;
xmlNodePtr bytes_node;
/* size_threshold rotation schedule */
bytes_node = xmlFirstElementChild(child);
if (!bytes_node ||
- strcmp((const char *) bytes_node->name,
- config_element_rotation_schedule_size_threshold_bytes)) {
+ strcmp((const char *) bytes_node->name,
+ config_element_rotation_schedule_size_threshold_bytes)) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
return ret;
}
-static
-int process_session_node(xmlNodePtr session_node, const char *session_name,
- int overwrite,
- const struct config_load_session_override_attr *overrides)
+static int process_session_node(xmlNodePtr session_node,
+ const char *session_name,
+ int overwrite,
+ const struct config_load_session_override_attr *overrides)
{
int ret, started = -1, snapshot_mode = -1;
- uint64_t live_timer_interval = UINT64_MAX,
- rotation_timer_interval = 0,
- rotation_size = 0;
+ uint64_t live_timer_interval = UINT64_MAX, rotation_timer_interval = 0, rotation_size = 0;
xmlChar *name = NULL;
xmlChar *shm_path = NULL;
xmlNodePtr domains_node = NULL;
struct lttng_domain *log4j_domain = NULL;
struct lttng_domain *python_domain = NULL;
- for (node = xmlFirstElementChild(session_node); node;
- node = xmlNextElementSibling(node)) {
- if (!name && !strcmp((const char *) node->name,
- config_element_name)) {
+ for (node = xmlFirstElementChild(session_node); node; node = xmlNextElementSibling(node)) {
+ if (!name && !strcmp((const char *) node->name, config_element_name)) {
/* name */
xmlChar *node_content = xmlNodeGetContent(node);
if (!node_content) {
}
name = node_content;
- } else if (!domains_node && !strcmp((const char *) node->name,
- config_element_domains)) {
+ } else if (!domains_node &&
+ !strcmp((const char *) node->name, config_element_domains)) {
/* domains */
domains_node = node;
- } else if (started == -1 && !strcmp((const char *) node->name,
- config_element_started)) {
+ } else if (started == -1 &&
+ !strcmp((const char *) node->name, config_element_started)) {
/* started */
xmlChar *node_content = xmlNodeGetContent(node);
if (!node_content) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto error;
}
- } else if (!output_node && !strcmp((const char *) node->name,
- config_element_output)) {
+ } else if (!output_node &&
+ !strcmp((const char *) node->name, config_element_output)) {
/* output */
output_node = node;
- } else if (!shm_path && !strcmp((const char *) node->name,
- config_element_shared_memory_path)) {
+ } else if (!shm_path &&
+ !strcmp((const char *) node->name, config_element_shared_memory_path)) {
/* shared memory path */
xmlChar *node_content = xmlNodeGetContent(node);
if (!node_content) {
* rotation_timer_interval.
*/
for (attributes_child = xmlFirstElementChild(node); attributes_child;
- attributes_child = xmlNextElementSibling(attributes_child)) {
+ attributes_child = xmlNextElementSibling(attributes_child)) {
if (!strcmp((const char *) attributes_child->name,
- config_element_snapshot_mode)) {
+ config_element_snapshot_mode)) {
/* snapshot_mode */
xmlChar *snapshot_mode_content =
xmlNodeGetContent(attributes_child);
goto error;
}
} else if (!strcmp((const char *) attributes_child->name,
- config_element_live_timer_interval)) {
+ config_element_live_timer_interval)) {
/* live_timer_interval */
xmlChar *timer_interval_content =
xmlNodeGetContent(attributes_child);
goto error;
}
- ret = parse_uint(timer_interval_content, &live_timer_interval);
+ ret = parse_uint(timer_interval_content,
+ &live_timer_interval);
free(timer_interval_content);
if (ret) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto error;
}
} else if (!strcmp((const char *) attributes_child->name,
- config_element_rotation_schedules)) {
+ config_element_rotation_schedules)) {
ret = process_session_rotation_schedules_node(
- attributes_child,
- &rotation_timer_interval,
- &rotation_size);
+ attributes_child,
+ &rotation_timer_interval,
+ &rotation_size);
if (ret) {
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto error;
}
-
}
}
}
}
/* Init domains to create the session handles */
- for (node = xmlFirstElementChild(domains_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(domains_node); node; node = xmlNextElementSibling(node)) {
lttng_domain *domain = zmalloc<lttng_domain>();
if (!domain) {
goto domain_init_error;
}
continue;
-domain_init_error:
+ domain_init_error:
free(domain);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto error;
/* Create session type depending on output type */
if (snapshot_mode && snapshot_mode != -1) {
- ret = create_snapshot_session((const char *) name, output_node,
- overrides);
- } else if (live_timer_interval &&
- live_timer_interval != UINT64_MAX) {
- ret = create_session((const char *) name,
- output_node, live_timer_interval, overrides);
+ ret = create_snapshot_session((const char *) name, output_node, overrides);
+ } else if (live_timer_interval && live_timer_interval != UINT64_MAX) {
+ ret = create_session(
+ (const char *) name, output_node, live_timer_interval, overrides);
} else {
/* regular session */
- ret = create_session((const char *) name,
- output_node, UINT64_MAX, overrides);
+ ret = create_session((const char *) name, output_node, UINT64_MAX, overrides);
}
if (ret) {
goto error;
}
if (shm_path) {
- ret = lttng_set_session_shm_path((const char *) name,
- (const char *) shm_path);
+ ret = lttng_set_session_shm_path((const char *) name, (const char *) shm_path);
if (ret) {
goto error;
}
}
- for (node = xmlFirstElementChild(domains_node); node;
- node = xmlNextElementSibling(node)) {
+ for (node = xmlFirstElementChild(domains_node); node; node = xmlNextElementSibling(node)) {
ret = process_domain_node(node, (const char *) name);
if (ret) {
goto end;
}
if (rotation_timer_interval) {
- ret = add_periodic_rotation((const char *) name,
- rotation_timer_interval);
+ ret = add_periodic_rotation((const char *) name, rotation_timer_interval);
if (ret < 0) {
goto error;
}
}
if (rotation_size) {
- ret = add_size_rotation((const char *) name,
- rotation_size);
+ ret = add_size_rotation((const char *) name, rotation_size);
if (ret < 0) {
goto error;
}
end:
if (ret < 0) {
- ERR("Failed to load session %s: %s", (const char *) name,
- lttng_strerror(ret));
+ ERR("Failed to load session %s: %s", (const char *) name, lttng_strerror(ret));
lttng_destroy_session((const char *) name);
}
return 1;
}
-static
-int load_session_from_file(const char *path, const char *session_name,
- struct session_config_validation_ctx *validation_ctx, int overwrite,
- const struct config_load_session_override_attr *overrides)
+static int load_session_from_file(const char *path,
+ const char *session_name,
+ struct session_config_validation_ctx *validation_ctx,
+ int overwrite,
+ const struct config_load_session_override_attr *overrides)
{
int ret, session_found = !session_name;
xmlDocPtr doc = NULL;
goto end;
}
- for (session_node = xmlFirstElementChild(sessions_node);
- session_node; session_node =
- xmlNextElementSibling(session_node)) {
- ret = process_session_node(session_node,
- session_name, overwrite, overrides);
+ for (session_node = xmlFirstElementChild(sessions_node); session_node;
+ session_node = xmlNextElementSibling(session_node)) {
+ ret = process_session_node(session_node, session_name, overwrite, overrides);
if (!session_name && ret) {
/* Loading error occurred. */
goto end;
return ret;
}
-static
-int load_session_from_path(const char *path, const char *session_name,
- struct session_config_validation_ctx *validation_ctx, int overwrite,
- const struct config_load_session_override_attr *overrides)
+static int load_session_from_path(const char *path,
+ const char *session_name,
+ struct session_config_validation_ctx *validation_ctx,
+ int overwrite,
+ const struct config_load_session_override_attr *overrides)
{
int ret, session_found = !session_name;
DIR *directory = NULL;
lttng_dynamic_buffer_init(&file_path);
if (path_len >= LTTNG_PATH_MAX) {
ERR("Session configuration load path \"%s\" length (%zu) exceeds the maximal length allowed (%d)",
- path, path_len, LTTNG_PATH_MAX);
+ path,
+ path_len,
+ LTTNG_PATH_MAX);
ret = -LTTNG_ERR_INVALID;
goto end;
}
if (directory) {
size_t file_path_root_len;
- ret = lttng_dynamic_buffer_set_capacity(&file_path,
- LTTNG_PATH_MAX);
+ ret = lttng_dynamic_buffer_set_capacity(&file_path, LTTNG_PATH_MAX);
if (ret) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
- ret = lttng_dynamic_buffer_append(&file_path, path, path_len);
+ ret = lttng_dynamic_buffer_append(&file_path, path, path_len);
if (ret) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
if (file_path.data[file_path.size - 1] != '/') {
- ret = lttng_dynamic_buffer_append(&file_path, "/", 1);
+ ret = lttng_dynamic_buffer_append(&file_path, "/", 1);
if (ret) {
ret = -LTTNG_ERR_NOMEM;
goto end;
/* Reached end of dir stream or error out. */
if (!result) {
if (errno) {
- PERROR("Failed to enumerate the contents of path \"%s\" while loading session, readdir returned", path);
+ PERROR("Failed to enumerate the contents of path \"%s\" while loading session, readdir returned",
+ path);
ret = -LTTNG_ERR_LOAD_IO_FAIL;
goto end;
}
file_name_len = strlen(result->d_name);
- if (file_name_len <=
- sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION)) {
+ if (file_name_len <= sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION)) {
continue;
}
if (file_path.size + file_name_len >= LTTNG_PATH_MAX) {
WARN("Ignoring file \"%s\" since the path's length (%zu) would exceed the maximal permitted size (%d)",
- result->d_name,
- /* +1 to account for NULL terminator. */
- file_path.size + file_name_len + 1,
- LTTNG_PATH_MAX);
+ result->d_name,
+ /* +1 to account for NULL terminator. */
+ file_path.size + file_name_len + 1,
+ LTTNG_PATH_MAX);
continue;
}
/* Does the file end with .lttng? */
if (strcmp(DEFAULT_SESSION_CONFIG_FILE_EXTENSION,
- result->d_name + file_name_len - sizeof(
- DEFAULT_SESSION_CONFIG_FILE_EXTENSION) + 1)) {
+ result->d_name + file_name_len -
+ sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION) + 1)) {
continue;
}
- ret = lttng_dynamic_buffer_append(&file_path, result->d_name,
- file_name_len + 1);
+ ret = lttng_dynamic_buffer_append(
+ &file_path, result->d_name, file_name_len + 1);
if (ret) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
- ret = load_session_from_file(file_path.data, session_name,
- validation_ctx, overwrite, overrides);
- if (session_name &&
- (!ret || ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) {
+ ret = load_session_from_file(
+ file_path.data, session_name, validation_ctx, overwrite, overrides);
+ if (session_name && (!ret || ret != -LTTNG_ERR_LOAD_SESSION_NOENT)) {
session_found = 1;
break;
}
* Reset the buffer's size to the location of the
* path's trailing '/'.
*/
- ret = lttng_dynamic_buffer_set_size(&file_path,
- file_path_root_len);
+ ret = lttng_dynamic_buffer_set_size(&file_path, file_path_root_len);
if (ret) {
ret = -LTTNG_ERR_UNK;
goto end;
}
}
} else {
- ret = load_session_from_file(path, session_name,
- validation_ctx, overwrite, overrides);
+ ret = load_session_from_file(
+ path, session_name, validation_ctx, overwrite, overrides);
if (ret) {
goto end;
}
return 0;
}
-int config_load_session(const char *path, const char *session_name,
- int overwrite, unsigned int autoload,
- const struct config_load_session_override_attr *overrides)
+int config_load_session(const char *path,
+ const char *session_name,
+ int overwrite,
+ unsigned int autoload,
+ const struct config_load_session_override_attr *overrides)
{
int ret;
bool session_loaded = false;
* continue loading the system wide sessions.
*/
if (autoload) {
- ret = snprintf(path_buf, sizeof(path_buf),
- DEFAULT_SESSION_HOME_CONFIGPATH
- "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
- home_path);
+ ret = snprintf(path_buf,
+ sizeof(path_buf),
+ DEFAULT_SESSION_HOME_CONFIGPATH
+ "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
+ home_path);
if (ret < 0) {
PERROR("snprintf session autoload home config path");
ret = -LTTNG_ERR_INVALID;
path_ptr = path_buf;
}
} else {
- ret = snprintf(path_buf, sizeof(path_buf),
- DEFAULT_SESSION_HOME_CONFIGPATH,
- home_path);
+ ret = snprintf(path_buf,
+ sizeof(path_buf),
+ DEFAULT_SESSION_HOME_CONFIGPATH,
+ home_path);
if (ret < 0) {
PERROR("snprintf session home config path");
ret = -LTTNG_ERR_INVALID;
path_ptr = path_buf;
}
if (path_ptr) {
- ret = load_session_from_path(path_ptr, session_name,
- &validation_ctx, overwrite, overrides);
+ ret = load_session_from_path(path_ptr,
+ session_name,
+ &validation_ctx,
+ overwrite,
+ overrides);
if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) {
goto end;
}
/* Try system wide configuration directory. */
if (autoload) {
- sys_path = DEFAULT_SESSION_SYSTEM_CONFIGPATH "/"
- DEFAULT_SESSION_CONFIG_AUTOLOAD;
+ sys_path = DEFAULT_SESSION_SYSTEM_CONFIGPATH
+ "/" DEFAULT_SESSION_CONFIG_AUTOLOAD;
ret = validate_path_creds(sys_path);
if (ret) {
path_ptr = sys_path;
}
if (path_ptr) {
- ret = load_session_from_path(path_ptr, session_name,
- &validation_ctx, overwrite, overrides);
+ ret = load_session_from_path(
+ path_ptr, session_name, &validation_ctx, overwrite, overrides);
if (!ret) {
session_loaded = true;
}
goto end;
}
- ret = load_session_from_path(path, session_name,
- &validation_ctx, overwrite, overrides);
+ ret = load_session_from_path(
+ path, session_name, &validation_ctx, overwrite, overrides);
}
end:
fini_session_config_validation_ctx(&validation_ctx);
return ret;
}
-static
-void __attribute__((destructor)) session_config_exit(void)
+static void __attribute__((destructor)) session_config_exit(void)
{
xmlCleanupParser();
}
*/
#define _LGPL_SOURCE
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <inttypes.h>
+#include "consumer-metadata-cache.hpp"
#include <common/common.hpp>
-#include <common/utils.hpp>
+#include <common/consumer/consumer.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/ust-consumer/ust-consumer.hpp>
-#include <common/consumer/consumer.hpp>
+#include <common/utils.hpp>
-#include "consumer-metadata-cache.hpp"
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
enum metadata_cache_update_version_status {
METADATA_CACHE_UPDATE_STATUS_VERSION_UPDATED,
/*
* Reset the metadata cache.
*/
-static
-void metadata_cache_reset(struct consumer_metadata_cache *cache)
+static void metadata_cache_reset(struct consumer_metadata_cache *cache)
{
const int ret = lttng_dynamic_buffer_set_size(&cache->contents, 0);
* If it did, reset the metadata cache.
* The metadata cache lock MUST be held.
*/
-static enum metadata_cache_update_version_status metadata_cache_update_version(
- struct consumer_metadata_cache *cache, uint64_t version)
+static enum metadata_cache_update_version_status
+metadata_cache_update_version(struct consumer_metadata_cache *cache, uint64_t version)
{
enum metadata_cache_update_version_status status;
*/
enum consumer_metadata_cache_write_status
consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
- unsigned int offset, unsigned int len, uint64_t version,
- const char *data)
+ unsigned int offset,
+ unsigned int len,
+ uint64_t version,
+ const char *data)
{
int ret = 0;
enum consumer_metadata_cache_write_status status;
original_size = cache->contents.size;
if (metadata_cache_update_version(cache, version) ==
- METADATA_CACHE_UPDATE_STATUS_VERSION_UPDATED) {
+ METADATA_CACHE_UPDATE_STATUS_VERSION_UPDATED) {
metadata_cache_reset(cache);
cache_is_invalidated = true;
}
DBG("Writing %u bytes from offset %u in metadata cache", len, offset);
if (offset + len > cache->contents.size) {
- ret = lttng_dynamic_buffer_set_size(
- &cache->contents, offset + len);
+ ret = lttng_dynamic_buffer_set_size(&cache->contents, offset + len);
if (ret) {
ERR("Extending metadata cache");
status = CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR;
}
lttng_dynamic_buffer_init(&channel->metadata_cache->contents);
- ret = lttng_dynamic_buffer_set_capacity(
- &channel->metadata_cache->contents,
- DEFAULT_METADATA_CACHE_SIZE);
+ ret = lttng_dynamic_buffer_set_capacity(&channel->metadata_cache->contents,
+ DEFAULT_METADATA_CACHE_SIZE);
if (ret) {
PERROR("Failed to pre-allocate metadata cache storage of %d bytes on creation",
- DEFAULT_METADATA_CACHE_SIZE);
+ DEFAULT_METADATA_CACHE_SIZE);
ret = -1;
goto end_free_mutex;
}
DBG("Allocated metadata cache: current capacity = %zu",
- lttng_dynamic_buffer_get_capacity_left(
- &channel->metadata_cache->contents));
+ lttng_dynamic_buffer_get_capacity_left(&channel->metadata_cache->contents));
ret = 0;
goto end;
* Return 0 if everything has been flushed, 1 if there is data not flushed.
*/
int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
- uint64_t offset, int timer)
+ uint64_t offset,
+ int timer)
{
int ret = 0;
struct lttng_consumer_stream *metadata_stream;
if (metadata_stream->ust_metadata_pushed >= offset) {
ret = 0;
- } else if (channel->metadata_stream->endpoint_status !=
- CONSUMER_ENDPOINT_ACTIVE) {
+ } else if (channel->metadata_stream->endpoint_status != CONSUMER_ENDPOINT_ACTIVE) {
/* An inactive endpoint means we don't have to flush anymore. */
ret = 0;
} else {
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <sys/mman.h>
-#include <unistd.h>
+#include "consumer-stream.hpp"
#include <common/common.hpp>
#include <common/consumer/consumer-timer.hpp>
-#include <common/consumer/consumer-timer.hpp>
-#include <common/consumer/consumer.hpp>
#include <common/consumer/consumer.hpp>
#include <common/consumer/metadata-bucket.hpp>
-#include <common/consumer/metadata-bucket.hpp>
#include <common/index/index.hpp>
#include <common/kernel-consumer/kernel-consumer.hpp>
#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/ust-consumer/ust-consumer.hpp>
#include <common/utils.hpp>
-#include "consumer-stream.hpp"
+#include <inttypes.h>
+#include <sys/mman.h>
+#include <unistd.h>
/*
* RCU call to free stream. MUST only be used with call_rcu().
*/
static void free_stream_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_u64 *node =
- lttng::utils::container_of(head, <tng_ht_node_u64::head);
+ struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head);
struct lttng_consumer_stream *stream =
lttng::utils::container_of(node, <tng_consumer_stream::node);
/* Only used for data streams. */
static int consumer_stream_update_stats(struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuf)
+ const struct stream_subbuffer *subbuf)
{
int ret = 0;
uint64_t sequence_number;
if (stream->last_sequence_number == -1ULL) {
stream->last_sequence_number = sequence_number;
} else if (sequence_number > stream->last_sequence_number) {
- stream->chan->lost_packets += sequence_number -
- stream->last_sequence_number - 1;
+ stream->chan->lost_packets += sequence_number - stream->last_sequence_number - 1;
} else {
/* seq <= last_sequence_number */
- ERR("Sequence number inconsistent : prev = %" PRIu64
- ", current = %" PRIu64,
- stream->last_sequence_number, sequence_number);
+ ERR("Sequence number inconsistent : prev = %" PRIu64 ", current = %" PRIu64,
+ stream->last_sequence_number,
+ sequence_number);
ret = -1;
goto end;
}
* Overflow has occurred. We assume only one wrap-around
* has occurred.
*/
- stream->chan->discarded_events +=
- (1ULL << (CAA_BITS_PER_LONG - 1)) -
- stream->last_discarded_events +
- discarded_events;
+ stream->chan->discarded_events += (1ULL << (CAA_BITS_PER_LONG - 1)) -
+ stream->last_discarded_events + discarded_events;
} else {
- stream->chan->discarded_events += discarded_events -
- stream->last_discarded_events;
+ stream->chan->discarded_events += discarded_events - stream->last_discarded_events;
}
stream->last_discarded_events = discarded_events;
ret = 0;
return ret;
}
-static
-void ctf_packet_index_populate(struct ctf_packet_index *index,
- off_t offset, const struct stream_subbuffer *subbuffer)
+static void ctf_packet_index_populate(struct ctf_packet_index *index,
+ off_t offset,
+ const struct stream_subbuffer *subbuffer)
{
*index = (typeof(*index)){
.offset = htobe64(offset),
.packet_size = htobe64(subbuffer->info.data.packet_size),
.content_size = htobe64(subbuffer->info.data.content_size),
- .timestamp_begin = htobe64(
- subbuffer->info.data.timestamp_begin),
- .timestamp_end = htobe64(
- subbuffer->info.data.timestamp_end),
- .events_discarded = htobe64(
- subbuffer->info.data.events_discarded),
+ .timestamp_begin = htobe64(subbuffer->info.data.timestamp_begin),
+ .timestamp_end = htobe64(subbuffer->info.data.timestamp_end),
+ .events_discarded = htobe64(subbuffer->info.data.events_discarded),
.stream_id = htobe64(subbuffer->info.data.stream_id),
- .stream_instance_id = htobe64(
- subbuffer->info.data.stream_instance_id.is_set ?
- subbuffer->info.data.stream_instance_id.value : -1ULL),
- .packet_seq_num = htobe64(
- subbuffer->info.data.sequence_number.is_set ?
- subbuffer->info.data.sequence_number.value : -1ULL),
+ .stream_instance_id =
+ htobe64(subbuffer->info.data.stream_instance_id.is_set ?
+ subbuffer->info.data.stream_instance_id.value :
+ -1ULL),
+ .packet_seq_num = htobe64(subbuffer->info.data.sequence_number.is_set ?
+ subbuffer->info.data.sequence_number.value :
+ -1ULL),
};
}
-static ssize_t consumer_stream_consume_mmap(
- struct lttng_consumer_local_data *ctx __attribute__((unused)),
- struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer)
+static ssize_t consumer_stream_consume_mmap(struct lttng_consumer_local_data *ctx
+ __attribute__((unused)),
+ struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer)
{
const unsigned long padding_size =
- subbuffer->info.data.padded_subbuf_size -
- subbuffer->info.data.subbuf_size;
+ subbuffer->info.data.padded_subbuf_size - subbuffer->info.data.subbuf_size;
const ssize_t written_bytes = lttng_consumer_on_read_subbuffer_mmap(
- stream, &subbuffer->buffer.buffer, padding_size);
+ stream, &subbuffer->buffer.buffer, padding_size);
if (stream->net_seq_idx == -1ULL) {
/*
*/
if (written_bytes != subbuffer->info.data.padded_subbuf_size) {
DBG("Failed to write the entire padded subbuffer on disk (written_bytes: %zd, padded subbuffer size %lu)",
- written_bytes,
- subbuffer->info.data.padded_subbuf_size);
+ written_bytes,
+ subbuffer->info.data.padded_subbuf_size);
}
} else {
/*
*/
if (written_bytes != subbuffer->info.data.subbuf_size) {
DBG("Failed to write only the subbuffer over the network (written_bytes: %zd, subbuffer size %lu)",
- written_bytes,
- subbuffer->info.data.subbuf_size);
+ written_bytes,
+ subbuffer->info.data.subbuf_size);
}
}
return written_bytes;
}
-static ssize_t consumer_stream_consume_splice(
- struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer)
+static ssize_t consumer_stream_consume_splice(struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer)
{
const ssize_t written_bytes = lttng_consumer_on_read_subbuffer_splice(
- ctx, stream, subbuffer->info.data.padded_subbuf_size, 0);
+ ctx, stream, subbuffer->info.data.padded_subbuf_size, 0);
if (written_bytes != subbuffer->info.data.padded_subbuf_size) {
DBG("Failed to write the entire padded subbuffer (written_bytes: %zd, padded subbuffer size %lu)",
- written_bytes,
- subbuffer->info.data.padded_subbuf_size);
+ written_bytes,
+ subbuffer->info.data.padded_subbuf_size);
}
/*
return written_bytes;
}
-static int consumer_stream_send_index(
- struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer,
- struct lttng_consumer_local_data *ctx __attribute__((unused)))
+static int consumer_stream_send_index(struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer,
+ struct lttng_consumer_local_data *ctx __attribute__((unused)))
{
off_t packet_offset = 0;
struct ctf_packet_index index = {};
* effect this sub-buffer from the offset.
*/
if (stream->net_seq_idx == (uint64_t) -1ULL) {
- packet_offset = stream->out_fd_offset -
- subbuffer->info.data.padded_subbuf_size;
+ packet_offset = stream->out_fd_offset - subbuffer->info.data.padded_subbuf_size;
}
ctf_packet_index_populate(&index, packet_offset, subbuffer);
* indicating that there is no metadata available for that stream.
*/
static int do_sync_metadata(struct lttng_consumer_stream *metadata,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret;
enum sync_metadata_status status;
*
* Return 0 on success or else a negative value.
*/
-int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
- uint64_t session_id)
+int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, uint64_t session_id)
{
int ret;
struct lttng_consumer_stream *stream = NULL;
/* Search the metadata associated with the session id of the given stream. */
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&session_id, lttng_ht_seed), ht->match_fct,
- &session_id, &iter.iter, stream, node_session_id.node) {
+ ht->hash_fct(&session_id, lttng_ht_seed),
+ ht->match_fct,
+ &session_id,
+ &iter.iter,
+ stream,
+ node_session_id.node)
+ {
if (!stream->metadata_flag) {
continue;
}
return ret;
}
-static int consumer_stream_sync_metadata_index(
- struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer,
- struct lttng_consumer_local_data *ctx)
+static int consumer_stream_sync_metadata_index(struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer,
+ struct lttng_consumer_local_data *ctx)
{
bool missed_metadata_flush;
int ret;
* of the metadata stream in the kernel. If it was updated, set the reset flag
* on the stream.
*/
-static
-int metadata_stream_check_version(struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer)
+static int metadata_stream_check_version(struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer)
{
if (stream->metadata_version == subbuffer->info.metadata.version) {
goto end;
}
DBG("New metadata version detected");
- consumer_stream_metadata_set_version(stream,
- subbuffer->info.metadata.version);
+ consumer_stream_metadata_set_version(stream, subbuffer->info.metadata.version);
if (stream->read_subbuffer_ops.reset_metadata) {
stream->read_subbuffer_ops.reset_metadata(stream);
return 0;
}
-static
-bool stream_is_rotating_to_null_chunk(
- const struct lttng_consumer_stream *stream)
+static bool stream_is_rotating_to_null_chunk(const struct lttng_consumer_stream *stream)
{
bool rotating_to_null_chunk = false;
goto end;
}
- if (stream->trace_chunk == stream->chan->trace_chunk ||
- !stream->chan->trace_chunk) {
+ if (stream->trace_chunk == stream->chan->trace_chunk || !stream->chan->trace_chunk) {
rotating_to_null_chunk = true;
}
end:
return rotating_to_null_chunk;
}
-enum consumer_stream_open_packet_status consumer_stream_open_packet(
- struct lttng_consumer_stream *stream)
+enum consumer_stream_open_packet_status
+consumer_stream_open_packet(struct lttng_consumer_stream *stream)
{
int ret;
enum consumer_stream_open_packet_status status;
ret = lttng_consumer_sample_snapshot_positions(stream);
if (ret < 0) {
ERR("Failed to snapshot positions before post-rotation empty packet flush: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
status = CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR;
goto end;
}
- ret = lttng_consumer_get_produced_snapshot(
- stream, &produced_pos_before);
+ ret = lttng_consumer_get_produced_snapshot(stream, &produced_pos_before);
if (ret < 0) {
ERR("Failed to read produced position before post-rotation empty packet flush: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
status = CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR;
goto end;
}
ret = consumer_stream_flush_buffer(stream, 0);
if (ret) {
ERR("Failed to flush an empty packet at rotation point: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
status = CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR;
goto end;
}
ret = lttng_consumer_sample_snapshot_positions(stream);
if (ret < 0) {
ERR("Failed to snapshot positions after post-rotation empty packet flush: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
status = CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR;
goto end;
}
ret = lttng_consumer_get_produced_snapshot(stream, &produced_pos_after);
if (ret < 0) {
ERR("Failed to read produced position after post-rotation empty packet flush: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
status = CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR;
goto end;
}
* positons before and after the flush.
*/
status = produced_pos_before != produced_pos_after ?
- CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED :
- CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE;
+ CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED :
+ CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE;
if (status == CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED) {
stream->opened_packet_in_current_trace_chunk = true;
}
* ring-buffer. In that case, a second attempt is performed after consuming
* a packet since that will have freed enough space in the ring-buffer.
*/
-static
-int post_consume_open_new_packet(struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer __attribute__((unused)),
- struct lttng_consumer_local_data *ctx __attribute__((unused)))
+static int post_consume_open_new_packet(struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer
+ __attribute__((unused)),
+ struct lttng_consumer_local_data *ctx
+ __attribute__((unused)))
{
int ret = 0;
- if (!stream->opened_packet_in_current_trace_chunk &&
- stream->trace_chunk &&
- !stream_is_rotating_to_null_chunk(stream)) {
+ if (!stream->opened_packet_in_current_trace_chunk && stream->trace_chunk &&
+ !stream_is_rotating_to_null_chunk(stream)) {
const enum consumer_stream_open_packet_status status =
- consumer_stream_open_packet(stream);
+ consumer_stream_open_packet(stream);
switch (status) {
case CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED:
DBG("Opened a packet after consuming a packet rotation: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
stream->opened_packet_in_current_trace_chunk = true;
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE:
* anyhow.
*/
DBG("No space left to open a packet after consuming a packet: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
stream->opened_packet_in_current_trace_chunk = true;
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR:
return ret;
}
-struct lttng_consumer_stream *consumer_stream_create(
- struct lttng_consumer_channel *channel,
- uint64_t channel_key,
- uint64_t stream_key,
- const char *channel_name,
- uint64_t relayd_id,
- uint64_t session_id,
- struct lttng_trace_chunk *trace_chunk,
- int cpu,
- int *alloc_ret,
- enum consumer_channel_type type,
- unsigned int monitor)
+struct lttng_consumer_stream *consumer_stream_create(struct lttng_consumer_channel *channel,
+ uint64_t channel_key,
+ uint64_t stream_key,
+ const char *channel_name,
+ uint64_t relayd_id,
+ uint64_t session_id,
+ struct lttng_trace_chunk *trace_chunk,
+ int cpu,
+ int *alloc_ret,
+ enum consumer_channel_type type,
+ unsigned int monitor)
{
int ret;
struct lttng_consumer_stream *stream;
pthread_mutex_init(&stream->metadata_rdv_lock, NULL);
} else {
/* Format stream name to <channel_name>_<cpu_number> */
- ret = snprintf(stream->name, sizeof(stream->name), "%s_%d",
- channel_name, cpu);
+ ret = snprintf(stream->name, sizeof(stream->name), "%s_%d", channel_name, cpu);
if (ret < 0) {
PERROR("snprintf stream name");
goto error;
/* Init session id node with the stream session id */
lttng_ht_node_init_u64(&stream->node_session_id, stream->session_id);
- DBG3("Allocated stream %s (key %" PRIu64 ", chan_key %" PRIu64
- " relayd_id %" PRIu64 ", session_id %" PRIu64,
- stream->name, stream->key, channel_key,
- stream->net_seq_idx, stream->session_id);
+ DBG3("Allocated stream %s (key %" PRIu64 ", chan_key %" PRIu64 " relayd_id %" PRIu64
+ ", session_id %" PRIu64,
+ stream->name,
+ stream->key,
+ channel_key,
+ stream->net_seq_idx,
+ stream->session_id);
rcu_read_unlock();
- lttng_dynamic_array_init(&stream->read_subbuffer_ops.post_consume_cbs,
- sizeof(post_consume_cb), NULL);
+ lttng_dynamic_array_init(
+ &stream->read_subbuffer_ops.post_consume_cbs, sizeof(post_consume_cb), NULL);
if (type == CONSUMER_CHANNEL_TYPE_METADATA) {
- stream->read_subbuffer_ops.lock =
- consumer_stream_metadata_lock_all;
- stream->read_subbuffer_ops.unlock =
- consumer_stream_metadata_unlock_all;
+ stream->read_subbuffer_ops.lock = consumer_stream_metadata_lock_all;
+ stream->read_subbuffer_ops.unlock = consumer_stream_metadata_unlock_all;
stream->read_subbuffer_ops.assert_locked =
- consumer_stream_metadata_assert_locked_all;
- stream->read_subbuffer_ops.pre_consume_subbuffer =
- metadata_stream_check_version;
+ consumer_stream_metadata_assert_locked_all;
+ stream->read_subbuffer_ops.pre_consume_subbuffer = metadata_stream_check_version;
} else {
const post_consume_cb post_consume_index_op = channel->is_live ?
- consumer_stream_sync_metadata_index :
- consumer_stream_send_index;
- const post_consume_cb post_consume_open_new_packet_ =
- post_consume_open_new_packet;
-
- ret = lttng_dynamic_array_add_element(
- &stream->read_subbuffer_ops.post_consume_cbs,
- &post_consume_index_op);
+ consumer_stream_sync_metadata_index :
+ consumer_stream_send_index;
+ const post_consume_cb post_consume_open_new_packet_ = post_consume_open_new_packet;
+
+ ret = lttng_dynamic_array_add_element(&stream->read_subbuffer_ops.post_consume_cbs,
+ &post_consume_index_op);
if (ret) {
PERROR("Failed to add `send index` callback to stream's post consumption callbacks");
goto error;
}
- ret = lttng_dynamic_array_add_element(
- &stream->read_subbuffer_ops.post_consume_cbs,
- &post_consume_open_new_packet_);
+ ret = lttng_dynamic_array_add_element(&stream->read_subbuffer_ops.post_consume_cbs,
+ &post_consume_open_new_packet_);
if (ret) {
PERROR("Failed to add `open new packet` callback to stream's post consumption callbacks");
goto error;
}
stream->read_subbuffer_ops.lock = consumer_stream_data_lock_all;
- stream->read_subbuffer_ops.unlock =
- consumer_stream_data_unlock_all;
- stream->read_subbuffer_ops.assert_locked =
- consumer_stream_data_assert_locked_all;
- stream->read_subbuffer_ops.pre_consume_subbuffer =
- consumer_stream_update_stats;
+ stream->read_subbuffer_ops.unlock = consumer_stream_data_unlock_all;
+ stream->read_subbuffer_ops.assert_locked = consumer_stream_data_assert_locked_all;
+ stream->read_subbuffer_ops.pre_consume_subbuffer = consumer_stream_update_stats;
}
if (channel->output == CONSUMER_CHANNEL_MMAP) {
- stream->read_subbuffer_ops.consume_subbuffer =
- consumer_stream_consume_mmap;
+ stream->read_subbuffer_ops.consume_subbuffer = consumer_stream_consume_mmap;
} else {
- stream->read_subbuffer_ops.consume_subbuffer =
- consumer_stream_consume_splice;
+ stream->read_subbuffer_ops.consume_subbuffer = consumer_stream_consume_splice;
}
return stream;
* a hash table before calling this.
*/
void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
- struct consumer_relayd_sock_pair *relayd)
+ struct consumer_relayd_sock_pair *relayd)
{
int ret;
/* Closing streams requires to lock the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_send_close_stream(&relayd->control_sock,
- stream->relayd_stream_id,
- stream->next_net_seq_num - 1);
+ ret = relayd_send_close_stream(
+ &relayd->control_sock, stream->relayd_stream_id, stream->next_net_seq_num - 1);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
- ERR("Relayd send close stream failed. Cleaning up relayd %" PRIu64 ".", relayd->net_seq_idx);
+ ERR("Relayd send close stream failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
}
/* Both conditions are met, we destroy the relayd. */
- if (uatomic_read(&relayd->refcount) == 0 &&
- uatomic_read(&relayd->destroy_flag)) {
+ if (uatomic_read(&relayd->refcount) == 0 && uatomic_read(&relayd->destroy_flag)) {
consumer_destroy_relayd(relayd);
}
stream->net_seq_idx = (uint64_t) -1ULL;
* The consumer data lock MUST be acquired.
* The stream lock MUST be acquired.
*/
-void consumer_stream_delete(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht)
+void consumer_stream_delete(struct lttng_consumer_stream *stream, struct lttng_ht *ht)
{
int ret;
struct lttng_ht_iter iter;
* Decrement the stream's channel refcount and if down to 0, return the channel
* pointer so it can be destroyed by the caller or NULL if not.
*/
-static struct lttng_consumer_channel *unref_channel(
- struct lttng_consumer_stream *stream)
+static struct lttng_consumer_channel *unref_channel(struct lttng_consumer_stream *stream)
{
struct lttng_consumer_channel *free_chan = NULL;
LTTNG_ASSERT(stream->chan);
/* Update refcount of channel and see if we need to destroy it. */
- if (!uatomic_sub_return(&stream->chan->refcount, 1)
- && !uatomic_read(&stream->chan->nb_init_stream_left)) {
+ if (!uatomic_sub_return(&stream->chan->refcount, 1) &&
+ !uatomic_read(&stream->chan->nb_init_stream_left)) {
free_chan = stream->chan;
}
* This MUST be called WITHOUT the consumer data and stream lock acquired if
* the stream is in _monitor_ mode else it does not matter.
*/
-void consumer_stream_destroy(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht)
+void consumer_stream_destroy(struct lttng_consumer_stream *stream, struct lttng_ht *ht)
{
LTTNG_ASSERT(stream);
/* Remove every reference of the stream in the consumer. */
consumer_stream_delete(stream, ht);
-
destroy_close_stream(stream);
/* Update channel's refcount of the stream. */
* Return 0 on success or else a negative value.
*/
int consumer_stream_write_index(struct lttng_consumer_stream *stream,
- struct ctf_packet_index *element)
+ struct ctf_packet_index *element)
{
int ret;
relayd = consumer_find_relayd(stream->net_seq_idx);
if (relayd) {
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_send_index(&relayd->control_sock, element,
- stream->relayd_stream_id, stream->next_net_seq_num - 1);
+ ret = relayd_send_index(&relayd->control_sock,
+ element,
+ stream->relayd_stream_id,
+ stream->next_net_seq_num - 1);
if (ret < 0) {
/*
* Communication error with lttng-relayd,
* perform cleanup now
*/
- ERR("Relayd send index failed. Cleaning up relayd %" PRIu64 ".", relayd->net_seq_idx);
+ ERR("Relayd send index failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
ret = -1;
}
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
} else {
ERR("Stream %" PRIu64 " relayd ID %" PRIu64 " unknown. Can't write index.",
- stream->key, stream->net_seq_idx);
+ stream->key,
+ stream->net_seq_idx);
ret = -1;
}
} else {
return ret;
}
-int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
- bool create_index)
+int consumer_stream_create_output_files(struct lttng_consumer_stream *stream, bool create_index)
{
int ret;
enum lttng_trace_chunk_status chunk_status;
ASSERT_LOCKED(stream->lock);
LTTNG_ASSERT(stream->trace_chunk);
- ret = utils_stream_file_path(stream->chan->pathname, stream->name,
- stream->chan->tracefile_size,
- stream->tracefile_count_current, NULL,
- stream_path, sizeof(stream_path));
+ ret = utils_stream_file_path(stream->chan->pathname,
+ stream->name,
+ stream->chan->tracefile_size,
+ stream->tracefile_count_current,
+ NULL,
+ stream_path,
+ sizeof(stream_path));
if (ret < 0) {
goto end;
}
if (stream->out_fd >= 0) {
ret = close(stream->out_fd);
if (ret < 0) {
- PERROR("Failed to close stream file \"%s\"",
- stream->name);
+ PERROR("Failed to close stream file \"%s\"", stream->name);
goto end;
}
stream->out_fd = -1;
}
DBG("Opening stream output file \"%s\"", stream_path);
- chunk_status = lttng_trace_chunk_open_file(stream->trace_chunk, stream_path,
- flags, mode, &stream->out_fd, false);
+ chunk_status = lttng_trace_chunk_open_file(
+ stream->trace_chunk, stream_path, flags, mode, &stream->out_fd, false);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to open stream file \"%s\"", stream->name);
ret = -1;
if (stream->index_file) {
lttng_index_file_put(stream->index_file);
}
- chunk_status = lttng_index_file_create_from_trace_chunk(
- stream->trace_chunk,
- stream->chan->pathname,
- stream->name,
- stream->chan->tracefile_size,
- stream->tracefile_count_current,
- CTF_INDEX_MAJOR, CTF_INDEX_MINOR,
- false, &stream->index_file);
+ chunk_status =
+ lttng_index_file_create_from_trace_chunk(stream->trace_chunk,
+ stream->chan->pathname,
+ stream->name,
+ stream->chan->tracefile_size,
+ stream->tracefile_count_current,
+ CTF_INDEX_MAJOR,
+ CTF_INDEX_MINOR,
+ false,
+ &stream->index_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
stream->tracefile_count_current++;
if (stream->chan->tracefile_count > 0) {
- stream->tracefile_count_current %=
- stream->chan->tracefile_count;
+ stream->tracefile_count_current %= stream->chan->tracefile_count;
}
DBG("Rotating output files of stream \"%s\"", stream->name);
return cds_lfht_is_node_deleted(&stream->node.node);
}
-static ssize_t metadata_bucket_flush(
- const struct stream_subbuffer *buffer, void *data)
+static ssize_t metadata_bucket_flush(const struct stream_subbuffer *buffer, void *data)
{
ssize_t ret;
struct lttng_consumer_stream *stream = (lttng_consumer_stream *) data;
return ret;
}
-static ssize_t metadata_bucket_consume(
- struct lttng_consumer_local_data *unused __attribute__((unused)),
- struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer)
+static ssize_t metadata_bucket_consume(struct lttng_consumer_local_data *unused
+ __attribute__((unused)),
+ struct lttng_consumer_stream *stream,
+ const struct stream_subbuffer *subbuffer)
{
ssize_t ret;
enum metadata_bucket_status status;
return ret;
}
-int consumer_stream_enable_metadata_bucketization(
- struct lttng_consumer_stream *stream)
+int consumer_stream_enable_metadata_bucketization(struct lttng_consumer_stream *stream)
{
int ret = 0;
LTTNG_ASSERT(!stream->metadata_bucket);
LTTNG_ASSERT(stream->chan->output == CONSUMER_CHANNEL_MMAP);
- stream->metadata_bucket = metadata_bucket_create(
- metadata_bucket_flush, stream);
+ stream->metadata_bucket = metadata_bucket_create(metadata_bucket_flush, stream);
if (!stream->metadata_bucket) {
ret = -1;
goto end;
return ret;
}
-void consumer_stream_metadata_set_version(
- struct lttng_consumer_stream *stream, uint64_t new_version)
+void consumer_stream_metadata_set_version(struct lttng_consumer_stream *stream,
+ uint64_t new_version)
{
LTTNG_ASSERT(new_version > stream->metadata_version);
stream->metadata_version = new_version;
}
}
-int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
- bool producer_active)
+int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream, bool producer_active)
{
int ret = 0;
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <signal.h>
-
-#include <bin/lttng-consumerd/health-consumerd.hpp>
#include <common/common.hpp>
#include <common/compat/endian.hpp>
-#include <common/kernel-ctl/kernel-ctl.hpp>
-#include <common/kernel-consumer/kernel-consumer.hpp>
#include <common/consumer/consumer-stream.hpp>
-#include <common/consumer/consumer-timer.hpp>
#include <common/consumer/consumer-testpoint.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/kernel-consumer/kernel-consumer.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
#include <common/ust-consumer/ust-consumer.hpp>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <inttypes.h>
+#include <signal.h>
+
typedef int (*sample_positions_cb)(struct lttng_consumer_stream *stream);
-typedef int (*get_consumed_cb)(struct lttng_consumer_stream *stream,
- unsigned long *consumed);
-typedef int (*get_produced_cb)(struct lttng_consumer_stream *stream,
- unsigned long *produced);
+typedef int (*get_consumed_cb)(struct lttng_consumer_stream *stream, unsigned long *consumed);
+typedef int (*get_produced_cb)(struct lttng_consumer_stream *stream, unsigned long *produced);
typedef int (*flush_index_cb)(struct lttng_consumer_stream *stream);
static struct timer_signal_data timer_signal = {
* while consumer_timer_switch_stop() is called. It would result in
* deadlocks.
*/
-static void metadata_switch_timer(struct lttng_consumer_local_data *ctx,
- siginfo_t *si)
+static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si)
{
int ret;
struct lttng_consumer_channel *channel;
}
}
-static int send_empty_index(struct lttng_consumer_stream *stream, uint64_t ts,
- uint64_t stream_id)
+static int send_empty_index(struct lttng_consumer_stream *stream, uint64_t ts, uint64_t stream_id)
{
int ret;
struct ctf_packet_index index;
return ret;
}
-static int check_stream(struct lttng_consumer_stream *stream,
- flush_index_cb flush_index)
+static int check_stream(struct lttng_consumer_stream *stream, flush_index_cb flush_index)
{
int ret;
ret = pthread_mutex_trylock(&stream->lock);
switch (ret) {
case 0:
- break; /* We have the lock. */
+ break; /* We have the lock. */
case EBUSY:
pthread_mutex_lock(&stream->metadata_timer_lock);
if (stream->waiting_on_metadata) {
ret = 0;
stream->missed_metadata_flush = true;
pthread_mutex_unlock(&stream->metadata_timer_lock);
- goto end; /* Bail out. */
+ goto end; /* Bail out. */
}
pthread_mutex_unlock(&stream->metadata_timer_lock);
/* Try again. */
/*
* Execute action on a live timer
*/
-static void live_timer(struct lttng_consumer_local_data *ctx,
- siginfo_t *si)
+static void live_timer(struct lttng_consumer_local_data *ctx, siginfo_t *si)
{
int ret;
struct lttng_consumer_channel *channel;
struct lttng_consumer_stream *stream;
struct lttng_ht_iter iter;
const struct lttng_ht *ht = the_consumer_data.stream_per_chan_id_ht;
- const flush_index_cb flush_index =
- ctx->type == LTTNG_CONSUMER_KERNEL ?
- consumer_flush_kernel_index :
- consumer_flush_ust_index;
+ const flush_index_cb flush_index = ctx->type == LTTNG_CONSUMER_KERNEL ?
+ consumer_flush_kernel_index :
+ consumer_flush_ust_index;
channel = (lttng_consumer_channel *) si->si_value.sival_ptr;
LTTNG_ASSERT(channel);
rcu_read_lock();
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key, &iter.iter,
- stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
ret = check_stream(stream, flush_index);
if (ret < 0) {
goto error_unlock;
return;
}
-static
-void consumer_timer_signal_thread_qs(unsigned int signr)
+static void consumer_timer_signal_thread_qs(unsigned int signr)
{
sigset_t pending_set;
int ret;
* Returns a negative value on error, 0 if a timer was created, and
* a positive value if no timer was created (not an error).
*/
-static
-int consumer_channel_timer_start(timer_t *timer_id,
- struct lttng_consumer_channel *channel,
- unsigned int timer_interval_us, int signal)
+static int consumer_channel_timer_start(timer_t *timer_id,
+ struct lttng_consumer_channel *channel,
+ unsigned int timer_interval_us,
+ int signal)
{
int ret = 0, delete_ret;
struct sigevent sev = {};
goto end;
}
-static
-int consumer_channel_timer_stop(timer_t *timer_id, int signal)
+static int consumer_channel_timer_stop(timer_t *timer_id, int signal)
{
int ret = 0;
* Set the channel's switch timer.
*/
void consumer_timer_switch_start(struct lttng_consumer_channel *channel,
- unsigned int switch_timer_interval_us)
+ unsigned int switch_timer_interval_us)
{
int ret;
LTTNG_ASSERT(channel);
LTTNG_ASSERT(channel->key);
- ret = consumer_channel_timer_start(&channel->switch_timer, channel,
- switch_timer_interval_us, LTTNG_CONSUMER_SIG_SWITCH);
+ ret = consumer_channel_timer_start(&channel->switch_timer,
+ channel,
+ switch_timer_interval_us,
+ LTTNG_CONSUMER_SIG_SWITCH);
channel->switch_timer_enabled = !!(ret == 0);
}
LTTNG_ASSERT(channel);
- ret = consumer_channel_timer_stop(&channel->switch_timer,
- LTTNG_CONSUMER_SIG_SWITCH);
+ ret = consumer_channel_timer_stop(&channel->switch_timer, LTTNG_CONSUMER_SIG_SWITCH);
if (ret == -1) {
ERR("Failed to stop switch timer");
}
* Set the channel's live timer.
*/
void consumer_timer_live_start(struct lttng_consumer_channel *channel,
- unsigned int live_timer_interval_us)
+ unsigned int live_timer_interval_us)
{
int ret;
LTTNG_ASSERT(channel);
LTTNG_ASSERT(channel->key);
- ret = consumer_channel_timer_start(&channel->live_timer, channel,
- live_timer_interval_us, LTTNG_CONSUMER_SIG_LIVE);
+ ret = consumer_channel_timer_start(
+ &channel->live_timer, channel, live_timer_interval_us, LTTNG_CONSUMER_SIG_LIVE);
channel->live_timer_enabled = !!(ret == 0);
}
LTTNG_ASSERT(channel);
- ret = consumer_channel_timer_stop(&channel->live_timer,
- LTTNG_CONSUMER_SIG_LIVE);
+ ret = consumer_channel_timer_stop(&channel->live_timer, LTTNG_CONSUMER_SIG_LIVE);
if (ret == -1) {
ERR("Failed to stop live timer");
}
* a positive value if no timer was created (not an error).
*/
int consumer_timer_monitor_start(struct lttng_consumer_channel *channel,
- unsigned int monitor_timer_interval_us)
+ unsigned int monitor_timer_interval_us)
{
int ret;
LTTNG_ASSERT(channel->key);
LTTNG_ASSERT(!channel->monitor_timer_enabled);
- ret = consumer_channel_timer_start(&channel->monitor_timer, channel,
- monitor_timer_interval_us, LTTNG_CONSUMER_SIG_MONITOR);
+ ret = consumer_channel_timer_start(&channel->monitor_timer,
+ channel,
+ monitor_timer_interval_us,
+ LTTNG_CONSUMER_SIG_MONITOR);
channel->monitor_timer_enabled = !!(ret == 0);
return ret;
}
LTTNG_ASSERT(channel);
LTTNG_ASSERT(channel->monitor_timer_enabled);
- ret = consumer_channel_timer_stop(&channel->monitor_timer,
- LTTNG_CONSUMER_SIG_MONITOR);
+ ret = consumer_channel_timer_stop(&channel->monitor_timer, LTTNG_CONSUMER_SIG_MONITOR);
if (ret == -1) {
ERR("Failed to stop live timer");
goto end;
return 0;
}
-static
-int sample_channel_positions(struct lttng_consumer_channel *channel,
- uint64_t *_highest_use, uint64_t *_lowest_use, uint64_t *_total_consumed,
- sample_positions_cb sample, get_consumed_cb get_consumed,
- get_produced_cb get_produced)
+static int sample_channel_positions(struct lttng_consumer_channel *channel,
+ uint64_t *_highest_use,
+ uint64_t *_lowest_use,
+ uint64_t *_total_consumed,
+ sample_positions_cb sample,
+ get_consumed_cb get_consumed,
+ get_produced_cb get_produced)
{
int ret = 0;
struct lttng_ht_iter iter;
rcu_read_lock();
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key,
- &iter.iter, stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
unsigned long produced, consumed, usage;
empty_channel = false;
ret = sample(stream);
if (ret) {
- ERR("Failed to take buffer position snapshot in monitor timer (ret = %d)", ret);
+ ERR("Failed to take buffer position snapshot in monitor timer (ret = %d)",
+ ret);
pthread_mutex_unlock(&stream->lock);
goto end;
}
void sample_and_send_channel_buffer_stats(struct lttng_consumer_channel *channel)
{
int ret;
- int channel_monitor_pipe =
- consumer_timer_thread_get_channel_monitor_pipe();
+ int channel_monitor_pipe = consumer_timer_thread_get_channel_monitor_pipe();
struct lttcomm_consumer_channel_monitor_msg msg = {
.key = channel->key,
.session_id = channel->session_id,
abort();
}
- ret = sample_channel_positions(channel, &highest, &lowest,
- &total_consumed, sample, get_consumed, get_produced);
+ ret = sample_channel_positions(
+ channel, &highest, &lowest, &total_consumed, sample, get_consumed, get_produced);
if (ret) {
return;
}
if (errno == EAGAIN) {
/* Not an error, the sample is merely dropped. */
DBG("Channel monitor pipe is full; dropping sample for channel key = %" PRIu64,
- channel->key);
+ channel->key);
} else {
PERROR("write to the channel monitor pipe");
}
} else {
DBG("Sent channel monitoring sample for channel key %" PRIu64
- ", (highest = %" PRIu64 ", lowest = %" PRIu64 ")",
- channel->key, msg.highest, msg.lowest);
+ ", (highest = %" PRIu64 ", lowest = %" PRIu64 ")",
+ channel->key,
+ msg.highest,
+ msg.lowest);
channel->last_consumed_size_sample_sent = msg.consumed_since_last_sample;
}
}
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <poll.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <bin/lttng-consumerd/health-consumerd.hpp>
#include <common/align.hpp>
#include <common/common.hpp>
#include <common/compat/endian.hpp>
#include <common/ust-consumer/ust-consumer.hpp>
#include <common/utils.hpp>
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <inttypes.h>
+#include <poll.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
+
lttng_consumer_global_data the_consumer_data;
enum consumer_channel_action {
namespace {
struct consumer_channel_msg {
enum consumer_channel_action action;
- struct lttng_consumer_channel *chan; /* add */
- uint64_t key; /* del */
+ struct lttng_consumer_channel *chan; /* add */
+ uint64_t key; /* del */
};
/*
}
static void notify_channel_pipe(struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_channel *chan,
- uint64_t key,
- enum consumer_channel_action action)
+ struct lttng_consumer_channel *chan,
+ uint64_t key,
+ enum consumer_channel_action action)
{
struct consumer_channel_msg msg;
ssize_t ret;
}
}
-void notify_thread_del_channel(struct lttng_consumer_local_data *ctx,
- uint64_t key)
+void notify_thread_del_channel(struct lttng_consumer_local_data *ctx, uint64_t key)
{
notify_channel_pipe(ctx, NULL, key, CONSUMER_CHANNEL_DEL);
}
static int read_channel_pipe(struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_channel **chan,
- uint64_t *key,
- enum consumer_channel_action *action)
+ struct lttng_consumer_channel **chan,
+ uint64_t *key,
+ enum consumer_channel_action *action)
{
struct consumer_channel_msg msg;
ssize_t ret;
LTTNG_ASSERT(channel);
/* Delete streams that might have been left in the stream list. */
- cds_list_for_each_entry_safe(stream, stmp, &channel->streams.head,
- send_node) {
+ cds_list_for_each_entry_safe (stream, stmp, &channel->streams.head, send_node) {
/*
* Once a stream is added to this list, the buffers were created so we
* have a guarantee that this call will succeed. Setting the monitor
* Find a stream. The consumer_data.lock must be locked during this
* call.
*/
-static struct lttng_consumer_stream *find_stream(uint64_t key,
- struct lttng_ht *ht)
+static struct lttng_consumer_stream *find_stream(uint64_t key, struct lttng_ht *ht)
{
struct lttng_ht_iter iter;
struct lttng_ht_node_u64 *node;
static void free_channel_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_u64 *node =
- lttng::utils::container_of(head, <tng_ht_node_u64::head);
+ struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head);
struct lttng_consumer_channel *channel =
lttng::utils::container_of(node, <tng_consumer_channel::node);
*/
static void free_relayd_rcu(struct rcu_head *head)
{
- struct lttng_ht_node_u64 *node =
- lttng::utils::container_of(head, <tng_ht_node_u64::head);
+ struct lttng_ht_node_u64 *node = lttng::utils::container_of(head, <tng_ht_node_u64::head);
struct consumer_relayd_sock_pair *relayd =
lttng::utils::container_of(node, &consumer_relayd_sock_pair::node);
LTTNG_ASSERT(!ret);
iter.iter.node = &channel->channels_by_session_id_ht_node.node;
- ret = lttng_ht_del(the_consumer_data.channels_by_session_id_ht,
- &iter);
+ ret = lttng_ht_del(the_consumer_data.channels_by_session_id_ht, &iter);
LTTNG_ASSERT(!ret);
rcu_read_unlock();
}
rcu_read_lock();
- cds_lfht_for_each_entry(the_consumer_data.relayd_ht->ht, &iter.iter,
- relayd, node.node) {
+ cds_lfht_for_each_entry (the_consumer_data.relayd_ht->ht, &iter.iter, relayd, node.node) {
consumer_destroy_relayd(relayd);
}
* because we handle the write/read race with a pipe wakeup for each thread.
*/
static void update_endpoint_status_by_netidx(uint64_t net_seq_idx,
- enum consumer_endpoint_status status)
+ enum consumer_endpoint_status status)
{
struct lttng_ht_iter iter;
struct lttng_consumer_stream *stream;
rcu_read_lock();
/* Let's begin with metadata */
- cds_lfht_for_each_entry(metadata_ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) {
if (stream->net_seq_idx == net_seq_idx) {
uatomic_set(&stream->endpoint_status, status);
DBG("Delete flag set to metadata stream %d", stream->wait_fd);
}
/* Follow up by the data streams */
- cds_lfht_for_each_entry(data_ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (data_ht->ht, &iter.iter, stream, node.node) {
if (stream->net_seq_idx == net_seq_idx) {
uatomic_set(&stream->endpoint_status, status);
DBG("Delete flag set to data stream %d", stream->wait_fd);
*
* One this call returns, the stream object is not longer usable nor visible.
*/
-void consumer_del_stream(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht)
+void consumer_del_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht)
{
consumer_stream_destroy(stream, ht);
}
consumer_stream_destroy(stream, metadata_ht);
}
-void consumer_stream_update_channel_attributes(
- struct lttng_consumer_stream *stream,
- struct lttng_consumer_channel *channel)
+void consumer_stream_update_channel_attributes(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_channel *channel)
{
- stream->channel_read_only_attributes.tracefile_size =
- channel->tracefile_size;
+ stream->channel_read_only_attributes.tracefile_size = channel->tracefile_size;
}
/*
lttng_ht_add_unique_u64(ht, &stream->node);
- lttng_ht_add_u64(the_consumer_data.stream_per_chan_id_ht,
- &stream->node_channel_id);
+ lttng_ht_add_u64(the_consumer_data.stream_per_chan_id_ht, &stream->node_channel_id);
/*
* Add stream to the stream_list_ht of the consumer data. No need to steal
* the key since the HT does not use it and we allow to add redundant keys
* into this table.
*/
- lttng_ht_add_u64(the_consumer_data.stream_list_ht,
- &stream->node_session_id);
+ lttng_ht_add_u64(the_consumer_data.stream_list_ht, &stream->node_session_id);
/*
* When nb_init_stream_left reaches 0, we don't need to trigger any action
LTTNG_ASSERT(relayd);
ASSERT_RCU_READ_LOCKED();
- lttng_ht_lookup(the_consumer_data.relayd_ht, &relayd->net_seq_idx,
- &iter);
+ lttng_ht_lookup(the_consumer_data.relayd_ht, &relayd->net_seq_idx, &iter);
node = lttng_ht_iter_get_node_u64(&iter);
if (node != NULL) {
goto end;
/*
* Allocate and return a consumer relayd socket.
*/
-static struct consumer_relayd_sock_pair *consumer_allocate_relayd_sock_pair(
- uint64_t net_seq_idx)
+static struct consumer_relayd_sock_pair *consumer_allocate_relayd_sock_pair(uint64_t net_seq_idx)
{
struct consumer_relayd_sock_pair *obj = NULL;
*
* Returns 0 on success, < 0 on error
*/
-int consumer_send_relayd_stream(struct lttng_consumer_stream *stream,
- char *path)
+int consumer_send_relayd_stream(struct lttng_consumer_stream *stream, char *path)
{
int ret = 0;
struct consumer_relayd_sock_pair *relayd;
if (relayd != NULL) {
/* Add stream on the relayd */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_add_stream(&relayd->control_sock, stream->name,
- get_consumer_domain(), path, &stream->relayd_stream_id,
- stream->chan->tracefile_size,
- stream->chan->tracefile_count,
- stream->trace_chunk);
+ ret = relayd_add_stream(&relayd->control_sock,
+ stream->name,
+ get_consumer_domain(),
+ path,
+ &stream->relayd_stream_id,
+ stream->chan->tracefile_size,
+ stream->chan->tracefile_count,
+ stream->trace_chunk);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
- ERR("Relayd add stream failed. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd add stream failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
goto end;
}
stream->sent_to_relayd = 1;
} else {
ERR("Stream %" PRIu64 " relayd ID %" PRIu64 " unknown. Can't send it.",
- stream->key, stream->net_seq_idx);
+ stream->key,
+ stream->net_seq_idx);
ret = -1;
goto end;
}
DBG("Stream %s with key %" PRIu64 " sent to relayd id %" PRIu64,
- stream->name, stream->key, stream->net_seq_idx);
+ stream->name,
+ stream->key,
+ stream->net_seq_idx);
end:
rcu_read_unlock();
ret = relayd_streams_sent(&relayd->control_sock);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
- ERR("Relayd streams sent failed. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd streams sent failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
goto end;
}
} else {
- ERR("Relayd ID %" PRIu64 " unknown. Can't send streams_sent.",
- net_seq_idx);
+ ERR("Relayd ID %" PRIu64 " unknown. Can't send streams_sent.", net_seq_idx);
ret = -1;
goto end;
}
* Return destination file descriptor or negative value on error.
*/
static int write_relayd_stream_header(struct lttng_consumer_stream *stream,
- size_t data_size, unsigned long padding,
- struct consumer_relayd_sock_pair *relayd)
+ size_t data_size,
+ unsigned long padding,
+ struct consumer_relayd_sock_pair *relayd)
{
int outfd = -1, ret;
struct lttcomm_relayd_data_hdr data_hdr;
data_hdr.net_seq_num = htobe64(stream->next_net_seq_num);
/* Other fields are zeroed previously */
- ret = relayd_send_data_hdr(&relayd->data_sock, &data_hdr,
- sizeof(data_hdr));
+ ret = relayd_send_data_hdr(&relayd->data_sock, &data_hdr, sizeof(data_hdr));
if (ret < 0) {
goto error;
}
{
int ret = 0;
- DBG("Waking up metadata poll thread (writing to pipe): channel name = '%s'",
- channel->name);
+ DBG("Waking up metadata poll thread (writing to pipe): channel name = '%s'", channel->name);
if (channel->monitor && channel->metadata_stream) {
const char dummy = 'c';
- const ssize_t write_ret = lttng_write(
- channel->metadata_stream->ust_metadata_poll_pipe[1],
- &dummy, 1);
+ const ssize_t write_ret =
+ lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1], &dummy, 1);
if (write_ret < 1) {
if (errno == EWOULDBLOCK) {
*
* The caller must hold the channel and stream locks.
*/
-static
-int consumer_metadata_stream_dump(struct lttng_consumer_stream *stream)
+static int consumer_metadata_stream_dump(struct lttng_consumer_stream *stream)
{
int ret;
return ret;
}
-static
-int lttng_consumer_channel_set_trace_chunk(
- struct lttng_consumer_channel *channel,
- struct lttng_trace_chunk *new_trace_chunk)
+static int lttng_consumer_channel_set_trace_chunk(struct lttng_consumer_channel *channel,
+ struct lttng_trace_chunk *new_trace_chunk)
{
pthread_mutex_lock(&channel->lock);
if (channel->is_deleted) {
* chunk is already held by the caller.
*/
if (new_trace_chunk) {
- const bool acquired_reference = lttng_trace_chunk_get(
- new_trace_chunk);
+ const bool acquired_reference = lttng_trace_chunk_get(new_trace_chunk);
LTTNG_ASSERT(acquired_reference);
}
* On error, return NULL.
*/
struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
- uint64_t session_id,
- const uint64_t *chunk_id,
- const char *pathname,
- const char *name,
- uint64_t relayd_id,
- enum lttng_event_output output,
- uint64_t tracefile_size,
- uint64_t tracefile_count,
- uint64_t session_id_per_pid,
- unsigned int monitor,
- unsigned int live_timer_interval,
- bool is_in_live_session,
- const char *root_shm_path,
- const char *shm_path)
+ uint64_t session_id,
+ const uint64_t *chunk_id,
+ const char *pathname,
+ const char *name,
+ uint64_t relayd_id,
+ enum lttng_event_output output,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ uint64_t session_id_per_pid,
+ unsigned int monitor,
+ unsigned int live_timer_interval,
+ bool is_in_live_session,
+ const char *root_shm_path,
+ const char *shm_path)
{
struct lttng_consumer_channel *channel = NULL;
struct lttng_trace_chunk *trace_chunk = NULL;
if (chunk_id) {
trace_chunk = lttng_trace_chunk_registry_find_chunk(
- the_consumer_data.chunk_registry, session_id,
- *chunk_id);
+ the_consumer_data.chunk_registry, session_id, *chunk_id);
if (!trace_chunk) {
ERR("Failed to find trace chunk reference during creation of channel");
goto end;
}
lttng_ht_node_init_u64(&channel->node, channel->key);
- lttng_ht_node_init_u64(&channel->channels_by_session_id_ht_node,
- channel->session_id);
+ lttng_ht_node_init_u64(&channel->channels_by_session_id_ht_node, channel->session_id);
channel->wait_fd = -1;
CDS_INIT_LIST_HEAD(&channel->streams.head);
if (trace_chunk) {
- int ret = lttng_consumer_channel_set_trace_chunk(channel,
- trace_chunk);
+ int ret = lttng_consumer_channel_set_trace_chunk(channel, trace_chunk);
if (ret) {
goto error;
}
* Always return 0 indicating success.
*/
int consumer_add_channel(struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
pthread_mutex_lock(&the_consumer_data.lock);
pthread_mutex_lock(&channel->lock);
rcu_read_lock();
lttng_ht_add_unique_u64(the_consumer_data.channel_ht, &channel->node);
lttng_ht_add_u64(the_consumer_data.channels_by_session_id_ht,
- &channel->channels_by_session_id_ht_node);
+ &channel->channels_by_session_id_ht_node);
rcu_read_unlock();
channel->is_published = true;
* Returns the number of fds in the structures.
*/
static int update_poll_array(struct lttng_consumer_local_data *ctx,
- struct pollfd **pollfd, struct lttng_consumer_stream **local_stream,
- struct lttng_ht *ht, int *nb_inactive_fd)
+ struct pollfd **pollfd,
+ struct lttng_consumer_stream **local_stream,
+ struct lttng_ht *ht,
+ int *nb_inactive_fd)
{
int i = 0;
struct lttng_ht_iter iter;
DBG("Updating poll fd array");
*nb_inactive_fd = 0;
rcu_read_lock();
- cds_lfht_for_each_entry(ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) {
/*
* Only active streams with an active end point can be added to the
* poll set and local stream storage of the thread.
/*
* Set the error socket.
*/
-void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx,
- int sock)
+void lttng_consumer_set_error_sock(struct lttng_consumer_local_data *ctx, int sock)
{
ctx->consumer_error_socket = sock;
}
/*
* Set the command socket path.
*/
-void lttng_consumer_set_command_sock_path(
- struct lttng_consumer_local_data *ctx, char *sock)
+void lttng_consumer_set_command_sock_path(struct lttng_consumer_local_data *ctx, char *sock)
{
ctx->consumer_command_sock_path = sock;
}
int lttng_consumer_send_error(struct lttng_consumer_local_data *ctx, int cmd)
{
if (ctx->consumer_error_socket > 0) {
- return lttcomm_send_unix_sock(ctx->consumer_error_socket, &cmd,
- sizeof(enum lttcomm_sessiond_command));
+ return lttcomm_send_unix_sock(
+ ctx->consumer_error_socket, &cmd, sizeof(enum lttcomm_sessiond_command));
}
return 0;
rcu_read_lock();
- cds_lfht_for_each_entry(the_consumer_data.channel_ht->ht, &iter.iter,
- channel, node.node) {
+ cds_lfht_for_each_entry (the_consumer_data.channel_ht->ht, &iter.iter, channel, node.node) {
consumer_del_channel(channel);
}
* session daemon and not emptying the registry would cause an assertion
* to hit.
*/
- trace_chunks_left = lttng_trace_chunk_registry_put_each_chunk(
- the_consumer_data.chunk_registry);
+ trace_chunks_left =
+ lttng_trace_chunk_registry_put_each_chunk(the_consumer_data.chunk_registry);
if (trace_chunks_left) {
ERR("%u trace chunks are leaked by lttng-consumerd. "
- "This can be caused by an internal error of the session daemon.",
- trace_chunks_left);
+ "This can be caused by an internal error of the session daemon.",
+ trace_chunks_left);
}
/* Run all callbacks freeing each chunk. */
rcu_barrier();
DBG("Consumer flag that it should quit");
}
-
/*
* Flush pending writes to trace output disk file.
*/
-static
-void lttng_consumer_sync_trace_file(struct lttng_consumer_stream *stream,
- off_t orig_offset)
+static void lttng_consumer_sync_trace_file(struct lttng_consumer_stream *stream, off_t orig_offset)
{
int ret;
int outfd = stream->out_fd;
if (orig_offset < stream->max_sb_size) {
return;
}
- lttng_sync_file_range(outfd, orig_offset - stream->max_sb_size,
- stream->max_sb_size,
- SYNC_FILE_RANGE_WAIT_BEFORE
- | SYNC_FILE_RANGE_WRITE
- | SYNC_FILE_RANGE_WAIT_AFTER);
+ lttng_sync_file_range(outfd,
+ orig_offset - stream->max_sb_size,
+ stream->max_sb_size,
+ SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
+ SYNC_FILE_RANGE_WAIT_AFTER);
/*
* Give hints to the kernel about how we access the file:
* POSIX_FADV_DONTNEED : we won't re-access data in a near future after
* defined. So it can be expected to lead to lower throughput in
* streaming.
*/
- ret = posix_fadvise(outfd, orig_offset - stream->max_sb_size,
- stream->max_sb_size, POSIX_FADV_DONTNEED);
+ ret = posix_fadvise(
+ outfd, orig_offset - stream->max_sb_size, stream->max_sb_size, POSIX_FADV_DONTNEED);
if (ret && ret != -ENOSYS) {
errno = ret;
PERROR("posix_fadvise on fd %i", outfd);
*
* Returns a pointer to the new context or NULL on error.
*/
-struct lttng_consumer_local_data *lttng_consumer_create(
- enum lttng_consumer_type type,
- ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx, bool locked_by_caller),
- int (*recv_channel)(struct lttng_consumer_channel *channel),
- int (*recv_stream)(struct lttng_consumer_stream *stream),
- int (*update_stream)(uint64_t stream_key, uint32_t state))
+struct lttng_consumer_local_data *
+lttng_consumer_create(enum lttng_consumer_type type,
+ ssize_t (*buffer_ready)(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx,
+ bool locked_by_caller),
+ int (*recv_channel)(struct lttng_consumer_channel *channel),
+ int (*recv_stream)(struct lttng_consumer_stream *stream),
+ int (*update_stream)(uint64_t stream_key, uint32_t state))
{
int ret;
struct lttng_consumer_local_data *ctx;
LTTNG_ASSERT(the_consumer_data.type == LTTNG_CONSUMER_UNKNOWN ||
- the_consumer_data.type == type);
+ the_consumer_data.type == type);
the_consumer_data.type = type;
ctx = zmalloc<lttng_consumer_local_data>();
}
rcu_read_lock();
- cds_lfht_for_each_entry(ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) {
/*
* Ignore return value since we are currently cleaning up so any error
* can't be handled.
}
rcu_read_lock();
- cds_lfht_for_each_entry(ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, stream, node.node) {
/*
* Ignore return value since we are currently cleaning up so any error
* can't be handled.
/*
* Write the metadata stream id on the specified file descriptor.
*/
-static int write_relayd_metadata_id(int fd,
- struct lttng_consumer_stream *stream,
- unsigned long padding)
+static int
+write_relayd_metadata_id(int fd, struct lttng_consumer_stream *stream, unsigned long padding)
{
ssize_t ret;
struct lttcomm_relayd_metadata_payload hdr;
goto end;
}
DBG("Metadata stream id %" PRIu64 " with padding %lu written before data",
- stream->relayd_stream_id, padding);
+ stream->relayd_stream_id,
+ padding);
end:
return (int) ret;
*
* Returns the number of bytes written
*/
-ssize_t lttng_consumer_on_read_subbuffer_mmap(
- struct lttng_consumer_stream *stream,
- const struct lttng_buffer_view *buffer,
- unsigned long padding)
+ssize_t lttng_consumer_on_read_subbuffer_mmap(struct lttng_consumer_stream *stream,
+ const struct lttng_buffer_view *buffer,
+ unsigned long padding)
{
ssize_t ret = 0;
off_t orig_offset = stream->out_fd_offset;
/* RCU lock for the relayd pointer */
rcu_read_lock();
- LTTNG_ASSERT(stream->net_seq_idx != (uint64_t) -1ULL ||
- stream->trace_chunk);
+ LTTNG_ASSERT(stream->net_seq_idx != (uint64_t) -1ULL || stream->trace_chunk);
/* Flag that the current stream if set for network streaming. */
if (stream->net_seq_idx != (uint64_t) -1ULL) {
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
if (stream->reset_metadata_flag) {
ret = relayd_reset_metadata(&relayd->control_sock,
- stream->relayd_stream_id,
- stream->metadata_version);
+ stream->relayd_stream_id,
+ stream->metadata_version);
if (ret < 0) {
relayd_hang_up = 1;
goto write_error;
* Check if we need to change the tracefile before writing the packet.
*/
if (stream->chan->tracefile_size > 0 &&
- (stream->tracefile_size_current + buffer->size) >
- stream->chan->tracefile_size) {
+ (stream->tracefile_size_current + buffer->size) >
+ stream->chan->tracefile_size) {
ret = consumer_stream_rotate_output_files(stream);
if (ret) {
goto end;
DBG("Consumer mmap write detected relayd hang up");
} else {
/* Unhandled error, print it and stop function right now. */
- PERROR("Error in write mmap (ret %zd != write_len %zu)", ret,
- write_len);
+ PERROR("Error in write mmap (ret %zd != write_len %zu)", ret, write_len);
}
goto write_error;
}
/* This call is useless on a socket so better save a syscall. */
if (!relayd) {
/* This won't block, but will start writeout asynchronously */
- lttng_sync_file_range(outfd, stream->out_fd_offset, write_len,
- SYNC_FILE_RANGE_WRITE);
+ lttng_sync_file_range(
+ outfd, stream->out_fd_offset, write_len, SYNC_FILE_RANGE_WRITE);
stream->out_fd_offset += write_len;
lttng_consumer_sync_trace_file(stream, orig_offset);
}
* cleanup the relayd object and all associated streams.
*/
if (relayd && relayd_hang_up) {
- ERR("Relayd hangup. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd hangup. Cleaning up relayd %" PRIu64 ".", relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
}
*
* Returns the number of bytes spliced.
*/
-ssize_t lttng_consumer_on_read_subbuffer_splice(
- struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_stream *stream, unsigned long len,
- unsigned long padding)
+ssize_t lttng_consumer_on_read_subbuffer_splice(struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_stream *stream,
+ unsigned long len,
+ unsigned long padding)
{
ssize_t ret = 0, written = 0, ret_splice = 0;
loff_t offset = 0;
if (stream->reset_metadata_flag) {
ret = relayd_reset_metadata(&relayd->control_sock,
- stream->relayd_stream_id,
- stream->metadata_version);
+ stream->relayd_stream_id,
+ stream->metadata_version);
if (ret < 0) {
relayd_hang_up = 1;
goto write_error;
}
stream->reset_metadata_flag = 0;
}
- ret = write_relayd_metadata_id(splice_pipe[1], stream,
- padding);
+ ret = write_relayd_metadata_id(splice_pipe[1], stream, padding);
if (ret < 0) {
written = ret;
relayd_hang_up = 1;
* Check if we need to change the tracefile before writing the packet.
*/
if (stream->chan->tracefile_size > 0 &&
- (stream->tracefile_size_current + len) >
- stream->chan->tracefile_size) {
+ (stream->tracefile_size_current + len) > stream->chan->tracefile_size) {
ret = consumer_stream_rotate_output_files(stream);
if (ret < 0) {
written = ret;
while (len > 0) {
DBG("splice chan to pipe offset %lu of len %lu (fd : %d, pipe: %d)",
- (unsigned long)offset, len, fd, splice_pipe[1]);
- ret_splice = splice(fd, &offset, splice_pipe[1], NULL, len,
- SPLICE_F_MOVE | SPLICE_F_MORE);
+ (unsigned long) offset,
+ len,
+ fd,
+ splice_pipe[1]);
+ ret_splice = splice(
+ fd, &offset, splice_pipe[1], NULL, len, SPLICE_F_MOVE | SPLICE_F_MORE);
DBG("splice chan to pipe, ret %zd", ret_splice);
if (ret_splice < 0) {
ret = errno;
}
/* Splice data out */
- ret_splice = splice(splice_pipe[0], NULL, outfd, NULL,
- ret_splice, SPLICE_F_MOVE | SPLICE_F_MORE);
- DBG("Consumer splice pipe to file (out_fd: %d), ret %zd",
- outfd, ret_splice);
+ ret_splice = splice(splice_pipe[0],
+ NULL,
+ outfd,
+ NULL,
+ ret_splice,
+ SPLICE_F_MOVE | SPLICE_F_MORE);
+ DBG("Consumer splice pipe to file (out_fd: %d), ret %zd", outfd, ret_splice);
if (ret_splice < 0) {
ret = errno;
written = -ret;
*/
ret = errno;
written += ret_splice;
- PERROR("Wrote more data than requested %zd (len: %lu)", ret_splice,
- len);
+ PERROR("Wrote more data than requested %zd (len: %lu)", ret_splice, len);
goto splice_error;
} else {
/* All good, update current len and continue. */
/* This call is useless on a socket so better save a syscall. */
if (!relayd) {
/* This won't block, but will start writeout asynchronously */
- lttng_sync_file_range(outfd, stream->out_fd_offset, ret_splice,
- SYNC_FILE_RANGE_WRITE);
+ lttng_sync_file_range(
+ outfd, stream->out_fd_offset, ret_splice, SYNC_FILE_RANGE_WRITE);
stream->out_fd_offset += ret_splice;
}
stream->output_written += ret_splice;
* cleanup the relayd object and all associated streams.
*/
if (relayd && relayd_hang_up) {
- ERR("Relayd hangup. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd hangup. Cleaning up relayd %" PRIu64 ".", relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
/* Skip splice error so the consumer does not fail */
goto end;
*
* Returns 0 on success, < 0 on error
*/
-int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos)
+int lttng_consumer_get_produced_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos)
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
*
* Returns 0 on success, < 0 on error
*/
-int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos)
+int lttng_consumer_get_consumed_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos)
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
}
int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll)
+ int sock,
+ struct pollfd *consumer_sockpoll)
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
}
}
-static
-void lttng_consumer_close_all_metadata(void)
+static void lttng_consumer_close_all_metadata(void)
{
switch (the_consumer_data.type) {
case LTTNG_CONSUMER_KERNEL:
/*
* Clean up a metadata stream and free its memory.
*/
-void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht)
+void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht)
{
struct lttng_consumer_channel *channel = NULL;
bool free_channel = false;
consumer_stream_destroy_buffers(stream);
/* Atomically decrement channel refcount since other threads can use it. */
- if (!uatomic_sub_return(&channel->refcount, 1)
- && !uatomic_read(&channel->nb_init_stream_left)) {
+ if (!uatomic_sub_return(&channel->refcount, 1) &&
+ !uatomic_read(&channel->nb_init_stream_left)) {
/* Go for channel deletion! */
free_channel = true;
}
lttng_ht_add_unique_u64(ht, &stream->node);
- lttng_ht_add_u64(the_consumer_data.stream_per_chan_id_ht,
- &stream->node_channel_id);
+ lttng_ht_add_u64(the_consumer_data.stream_per_chan_id_ht, &stream->node_channel_id);
/*
* Add stream to the stream_list_ht of the consumer data. No need to steal
* the key since the HT does not use it and we allow to add redundant keys
* into this table.
*/
- lttng_ht_add_u64(the_consumer_data.stream_list_ht,
- &stream->node_session_id);
+ lttng_ht_add_u64(the_consumer_data.stream_list_ht, &stream->node_session_id);
rcu_read_unlock();
DBG("Consumer delete flagged data stream");
rcu_read_lock();
- cds_lfht_for_each_entry(data_ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (data_ht->ht, &iter.iter, stream, node.node) {
/* Validate delete flag of the stream */
if (stream->endpoint_status == CONSUMER_ENDPOINT_ACTIVE) {
continue;
/*
* Delete metadata stream that are flagged for deletion (endpoint_status).
*/
-static void validate_endpoint_status_metadata_stream(
- struct lttng_poll_event *pollset)
+static void validate_endpoint_status_metadata_stream(struct lttng_poll_event *pollset)
{
struct lttng_ht_iter iter;
struct lttng_consumer_stream *stream;
LTTNG_ASSERT(pollset);
rcu_read_lock();
- cds_lfht_for_each_entry(metadata_ht->ht, &iter.iter, stream, node.node) {
+ cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) {
/* Validate delete flag of the stream */
if (stream->endpoint_status == CONSUMER_ENDPOINT_ACTIVE) {
continue;
goto end_poll;
}
- ret = lttng_poll_add(&events,
- lttng_pipe_get_readfd(ctx->consumer_metadata_pipe), LPOLLIN);
+ ret = lttng_poll_add(&events, lttng_pipe_get_readfd(ctx->consumer_metadata_pipe), LPOLLIN);
if (ret < 0) {
goto end;
}
DBG("Metadata main loop started");
while (1) {
-restart:
+ restart:
health_code_update();
health_poll_entry();
DBG("Metadata poll wait");
ret = lttng_poll_wait(&events, -1);
- DBG("Metadata poll return from wait with %d fd(s)",
- LTTNG_POLL_GETNB(&events));
+ DBG("Metadata poll return from wait with %d fd(s)", LTTNG_POLL_GETNB(&events));
health_poll_exit();
DBG("Metadata event caught in thread");
if (ret < 0) {
goto restart;
}
if (LTTNG_POLL_GETNB(&events) == 0) {
- err = 0; /* All is OK */
+ err = 0; /* All is OK */
}
goto end;
}
ssize_t pipe_len;
pipe_len = lttng_pipe_read(ctx->consumer_metadata_pipe,
- &stream, sizeof(stream));
+ &stream,
+ sizeof(stream));
if (pipe_len < sizeof(stream)) {
if (pipe_len < 0) {
PERROR("read metadata stream");
}
/*
- * Remove the pipe from the poll set and continue the loop
- * since their might be data to consume.
+ * Remove the pipe from the poll set and continue
+ * the loop since their might be data to consume.
*/
- lttng_poll_del(&events,
- lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
+ lttng_poll_del(
+ &events,
+ lttng_pipe_get_readfd(
+ ctx->consumer_metadata_pipe));
lttng_pipe_read_close(ctx->consumer_metadata_pipe);
continue;
}
}
DBG("Adding metadata stream %d to poll set",
- stream->wait_fd);
+ stream->wait_fd);
/* Add metadata stream to the global poll events list */
- lttng_poll_add(&events, stream->wait_fd, LPOLLIN | LPOLLPRI);
- }else if (revents & (LPOLLERR | LPOLLHUP)) {
+ lttng_poll_add(
+ &events, stream->wait_fd, LPOLLIN | LPOLLPRI);
+ } else if (revents & (LPOLLERR | LPOLLHUP)) {
DBG("Metadata thread pipe hung up");
/*
* Remove the pipe from the poll set and continue the loop
* since their might be data to consume.
*/
- lttng_poll_del(&events,
- lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
+ lttng_poll_del(
+ &events,
+ lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
lttng_pipe_read_close(ctx->consumer_metadata_pipe);
continue;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto end;
}
node = lttng_ht_iter_get_node_u64(&iter);
LTTNG_ASSERT(node);
- stream = caa_container_of(node, struct lttng_consumer_stream,
- node);
+ stream = caa_container_of(node, struct lttng_consumer_stream, node);
if (revents & (LPOLLIN | LPOLLPRI)) {
/* Get the data out of the metadata file descriptor */
} else if (revents & (LPOLLERR | LPOLLHUP)) {
DBG("Metadata fd %d is hup|err.", pollfd);
if (!stream->hangup_flush_done &&
- (the_consumer_data.type == LTTNG_CONSUMER32_UST ||
- the_consumer_data.type ==
- LTTNG_CONSUMER64_UST)) {
+ (the_consumer_data.type == LTTNG_CONSUMER32_UST ||
+ the_consumer_data.type == LTTNG_CONSUMER64_UST)) {
DBG("Attempting to flush and consume the UST buffers");
lttng_ustconsumer_on_stream_hangup(stream);
len = ctx->on_buffer_ready(stream, ctx, false);
/*
- * We don't check the return value here since if we get
- * a negative len, it means an error occurred thus we
- * simply remove it from the poll set and free the
- * stream.
+ * We don't check the return value here since if we
+ * get a negative len, it means an error occurred
+ * thus we simply remove it from the poll set and
+ * free the stream.
*/
} while (len > 0);
}
local_stream = NULL;
/* Allocate for all fds */
- pollfd = calloc<struct pollfd>(the_consumer_data.stream_count + nb_pipes_fd);
+ pollfd =
+ calloc<struct pollfd>(the_consumer_data.stream_count + nb_pipes_fd);
if (pollfd == NULL) {
PERROR("pollfd malloc");
pthread_mutex_unlock(&the_consumer_data.lock);
goto end;
}
- local_stream = calloc<lttng_consumer_stream *>(the_consumer_data.stream_count + nb_pipes_fd);
+ local_stream = calloc<lttng_consumer_stream *>(
+ the_consumer_data.stream_count + nb_pipes_fd);
if (local_stream == NULL) {
PERROR("local_stream malloc");
pthread_mutex_unlock(&the_consumer_data.lock);
goto end;
}
- ret = update_poll_array(ctx, &pollfd, local_stream,
- data_ht, &nb_inactive_fd);
+ ret = update_poll_array(
+ ctx, &pollfd, local_stream, data_ht, &nb_inactive_fd);
if (ret < 0) {
ERR("Error in allocating pollfd or local_outfds");
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_POLL_ERROR);
pthread_mutex_unlock(&the_consumer_data.lock);
/* No FDs and consumer_quit, consumer_cleanup the thread */
- if (nb_fd == 0 && nb_inactive_fd == 0 &&
- CMM_LOAD_SHARED(consumer_quit) == 1) {
- err = 0; /* All is OK */
+ if (nb_fd == 0 && nb_inactive_fd == 0 && CMM_LOAD_SHARED(consumer_quit) == 1) {
+ err = 0; /* All is OK */
goto end;
}
/* poll on the array of fds */
ssize_t pipe_readlen;
DBG("consumer_data_pipe wake up");
- pipe_readlen = lttng_pipe_read(ctx->consumer_data_pipe,
- &new_stream, sizeof(new_stream));
+ pipe_readlen = lttng_pipe_read(
+ ctx->consumer_data_pipe, &new_stream, sizeof(new_stream));
if (pipe_readlen < sizeof(new_stream)) {
PERROR("Consumer data pipe");
/* Continue so we can at least handle the current stream(s). */
char dummy;
ssize_t pipe_readlen;
- pipe_readlen = lttng_pipe_read(ctx->consumer_wakeup_pipe, &dummy,
- sizeof(dummy));
+ pipe_readlen =
+ lttng_pipe_read(ctx->consumer_wakeup_pipe, &dummy, sizeof(dummy));
if (pipe_readlen < 0) {
PERROR("Consumer data wakeup pipe");
}
consumer_del_stream(local_stream[i], data_ht);
local_stream[i] = NULL;
} else if (len > 0) {
- local_stream[i]->has_data_left_to_be_read_before_teardown = 1;
+ local_stream[i]->has_data_left_to_be_read_before_teardown =
+ 1;
}
}
}
if (local_stream[i] == NULL) {
continue;
}
- if ((pollfd[i].revents & POLLIN) ||
- local_stream[i]->hangup_flush_done ||
- local_stream[i]->has_data) {
+ if ((pollfd[i].revents & POLLIN) || local_stream[i]->hangup_flush_done ||
+ local_stream[i]->has_data) {
DBG("Normal read on fd %d", pollfd[i].fd);
len = ctx->on_buffer_ready(local_stream[i], ctx, false);
/* it's ok to have an unavailable sub-buffer */
consumer_del_stream(local_stream[i], data_ht);
local_stream[i] = NULL;
} else if (len > 0) {
- local_stream[i]->has_data_left_to_be_read_before_teardown = 1;
+ local_stream[i]->has_data_left_to_be_read_before_teardown =
+ 1;
}
}
}
if (local_stream[i] == NULL) {
continue;
}
- if (!local_stream[i]->hangup_flush_done
- && (pollfd[i].revents & (POLLHUP | POLLERR | POLLNVAL))
- && (the_consumer_data.type == LTTNG_CONSUMER32_UST
- || the_consumer_data.type == LTTNG_CONSUMER64_UST)) {
+ if (!local_stream[i]->hangup_flush_done &&
+ (pollfd[i].revents & (POLLHUP | POLLERR | POLLNVAL)) &&
+ (the_consumer_data.type == LTTNG_CONSUMER32_UST ||
+ the_consumer_data.type == LTTNG_CONSUMER64_UST)) {
DBG("fd %d is hup|err|nval. Attempting flush and read.",
- pollfd[i].fd);
+ pollfd[i].fd);
lttng_ustconsumer_on_stream_hangup(local_stream[i]);
/* Attempt read again, for the data we just flushed. */
local_stream[i]->has_data_left_to_be_read_before_teardown = 1;
* allow the poll() on the stream read-side to detect when the
* write-side (application) finally closes them.
*/
-static
-void consumer_close_channel_streams(struct lttng_consumer_channel *channel)
+static void consumer_close_channel_streams(struct lttng_consumer_channel *channel)
{
struct lttng_ht *ht;
struct lttng_consumer_stream *stream;
rcu_read_lock();
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key,
- &iter.iter, stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
/*
* Protect against teardown with mutex.
*/
}
rcu_read_lock();
- cds_lfht_for_each_entry(ht->ht, &iter.iter, channel, wait_fd_node.node) {
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, channel, wait_fd_node.node) {
ret = lttng_ht_del(ht, &iter);
LTTNG_ASSERT(ret != 0);
}
DBG("Channel main loop started");
while (1) {
-restart:
+ restart:
health_code_update();
DBG("Channel poll wait");
health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- DBG("Channel poll return from wait with %d fd(s)",
- LTTNG_POLL_GETNB(&events));
+ DBG("Channel poll return from wait with %d fd(s)", LTTNG_POLL_GETNB(&events));
health_poll_exit();
DBG("Channel event caught in thread");
if (ret < 0) {
goto restart;
}
if (LTTNG_POLL_GETNB(&events) == 0) {
- err = 0; /* All is OK */
+ err = 0; /* All is OK */
}
goto end;
}
if (ret < 0) {
ERR("Error reading channel pipe");
}
- lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
+ lttng_poll_del(&events,
+ ctx->consumer_channel_pipe[0]);
continue;
}
switch (action) {
case CONSUMER_CHANNEL_ADD:
- DBG("Adding channel %d to poll set",
- chan->wait_fd);
+ DBG("Adding channel %d to poll set", chan->wait_fd);
lttng_ht_node_init_u64(&chan->wait_fd_node,
- chan->wait_fd);
+ chan->wait_fd);
rcu_read_lock();
lttng_ht_add_unique_u64(channel_ht,
- &chan->wait_fd_node);
+ &chan->wait_fd_node);
rcu_read_unlock();
/* Add channel to the global poll events list */
- // FIXME: Empty flag on a pipe pollset, this might hang on FreeBSD.
+ // FIXME: Empty flag on a pipe pollset, this might
+ // hang on FreeBSD.
lttng_poll_add(&events, chan->wait_fd, 0);
break;
case CONSUMER_CHANNEL_DEL:
{
/*
- * This command should never be called if the channel
- * has streams monitored by either the data or metadata
- * thread. The consumer only notify this thread with a
- * channel del. command if it receives a destroy
- * channel command from the session daemon that send it
- * if a command prior to the GET_CHANNEL failed.
+ * This command should never be called if the
+ * channel has streams monitored by either the data
+ * or metadata thread. The consumer only notify this
+ * thread with a channel del. command if it receives
+ * a destroy channel command from the session daemon
+ * that send it if a command prior to the
+ * GET_CHANNEL failed.
*/
rcu_read_lock();
chan = consumer_find_channel(key);
if (!chan) {
rcu_read_unlock();
- ERR("UST consumer get channel key %" PRIu64 " not found for del channel", key);
+ ERR("UST consumer get channel key %" PRIu64
+ " not found for del channel",
+ key);
break;
}
lttng_poll_del(&events, chan->wait_fd);
case LTTNG_CONSUMER32_UST:
case LTTNG_CONSUMER64_UST:
health_code_update();
- /* Destroy streams that might have been left in the stream list. */
+ /* Destroy streams that might have been left
+ * in the stream list. */
clean_channel_stream_list(chan);
break;
default:
}
/*
- * Release our own refcount. Force channel deletion even if
- * streams were not initialized.
+ * Release our own refcount. Force channel deletion
+ * even if streams were not initialized.
*/
if (!uatomic_sub_return(&chan->refcount, 1)) {
consumer_del_channel(chan);
}
case CONSUMER_CHANNEL_QUIT:
/*
- * Remove the pipe from the poll set and continue the loop
- * since their might be data to consume.
+ * Remove the pipe from the poll set and continue
+ * the loop since their might be data to consume.
*/
- lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
+ lttng_poll_del(&events,
+ ctx->consumer_channel_pipe[0]);
continue;
default:
ERR("Unknown action");
lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
continue;
} else {
- ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ ERR("Unexpected poll events %u for sock %d",
+ revents,
+ pollfd);
goto end;
}
node = lttng_ht_iter_get_node_u64(&iter);
LTTNG_ASSERT(node);
- chan = caa_container_of(node, struct lttng_consumer_channel,
- wait_fd_node);
+ chan = caa_container_of(node, struct lttng_consumer_channel, wait_fd_node);
/* Check for error event */
if (revents & (LPOLLERR | LPOLLHUP)) {
consumer_close_channel_streams(chan);
/* Release our own refcount */
- if (!uatomic_sub_return(&chan->refcount, 1)
- && !uatomic_read(&chan->nb_init_stream_left)) {
+ if (!uatomic_sub_return(&chan->refcount, 1) &&
+ !uatomic_read(&chan->nb_init_stream_left)) {
consumer_del_channel(chan);
}
} else {
}
static int set_metadata_socket(struct lttng_consumer_local_data *ctx,
- struct pollfd *sockpoll, int client_socket)
+ struct pollfd *sockpoll,
+ int client_socket)
{
int ret;
}
if (CMM_LOAD_SHARED(consumer_quit)) {
DBG("consumer_thread_receive_fds received quit from signal");
- err = 0; /* All is OK */
+ err = 0; /* All is OK */
goto end;
}
DBG("Received command on sock");
}
static int post_consume(struct lttng_consumer_stream *stream,
- const struct stream_subbuffer *subbuffer,
- struct lttng_consumer_local_data *ctx)
+ const struct stream_subbuffer *subbuffer,
+ struct lttng_consumer_local_data *ctx)
{
size_t i;
int ret = 0;
- const size_t count = lttng_dynamic_array_get_count(
- &stream->read_subbuffer_ops.post_consume_cbs);
+ const size_t count =
+ lttng_dynamic_array_get_count(&stream->read_subbuffer_ops.post_consume_cbs);
for (i = 0; i < count; i++) {
const post_consume_cb op = *(post_consume_cb *) lttng_dynamic_array_get_element(
- &stream->read_subbuffer_ops.post_consume_cbs,
- i);
+ &stream->read_subbuffer_ops.post_consume_cbs, i);
ret = op(stream, subbuffer, ctx);
if (ret) {
}
ssize_t lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx,
- bool locked_by_caller)
+ struct lttng_consumer_local_data *ctx,
+ bool locked_by_caller)
{
ssize_t ret, written_bytes = 0;
int rotation_ret;
}
}
- get_next_status = stream->read_subbuffer_ops.get_next_subbuffer(
- stream, &subbuffer);
+ get_next_status = stream->read_subbuffer_ops.get_next_subbuffer(stream, &subbuffer);
switch (get_next_status) {
case GET_NEXT_SUBBUFFER_STATUS_OK:
break;
abort();
}
- ret = stream->read_subbuffer_ops.pre_consume_subbuffer(
- stream, &subbuffer);
+ ret = stream->read_subbuffer_ops.pre_consume_subbuffer(stream, &subbuffer);
if (ret) {
goto error_put_subbuf;
}
- written_bytes = stream->read_subbuffer_ops.consume_subbuffer(
- ctx, stream, &subbuffer);
+ written_bytes = stream->read_subbuffer_ops.consume_subbuffer(ctx, stream, &subbuffer);
if (written_bytes <= 0) {
ERR("Error consuming subbuffer: (%zd)", written_bytes);
ret = (int) written_bytes;
goto error;
}
- the_consumer_data.channels_by_session_id_ht =
- lttng_ht_new(0, LTTNG_HT_TYPE_U64);
+ the_consumer_data.channels_by_session_id_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!the_consumer_data.channels_by_session_id_ht) {
goto error;
}
goto error;
}
- the_consumer_data.stream_per_chan_id_ht =
- lttng_ht_new(0, LTTNG_HT_TYPE_U64);
+ the_consumer_data.stream_per_chan_id_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!the_consumer_data.stream_per_chan_id_ht) {
goto error;
}
* The caller MUST acquire a RCU read side lock before calling it.
*/
void consumer_add_relayd_socket(uint64_t net_seq_idx,
- int sock_type,
- struct lttng_consumer_local_data *ctx,
- int sock,
- struct pollfd *consumer_sockpoll,
- uint64_t sessiond_id,
- uint64_t relayd_session_id,
- uint32_t relayd_version_major,
- uint32_t relayd_version_minor,
- enum lttcomm_sock_proto relayd_socket_protocol)
+ int sock_type,
+ struct lttng_consumer_local_data *ctx,
+ int sock,
+ struct pollfd *consumer_sockpoll,
+ uint64_t sessiond_id,
+ uint64_t relayd_session_id,
+ uint32_t relayd_version_major,
+ uint32_t relayd_version_minor,
+ enum lttcomm_sock_proto relayd_socket_protocol)
{
int fd = -1, ret = -1, relayd_created = 0;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
/* Get relayd socket from session daemon */
ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1);
if (ret != sizeof(fd)) {
- fd = -1; /* Just in case it gets set with an invalid value. */
+ fd = -1; /* Just in case it gets set with an invalid value. */
/*
* Failing to receive FDs might indicate a major problem such as
case LTTNG_STREAM_CONTROL:
/* Copy received lttcomm socket */
ret = lttcomm_populate_sock_from_open_socket(
- &relayd->control_sock.sock, fd,
- relayd_socket_protocol);
+ &relayd->control_sock.sock, fd, relayd_socket_protocol);
/* Assign version values. */
relayd->control_sock.major = relayd_version_major;
case LTTNG_STREAM_DATA:
/* Copy received lttcomm socket */
ret = lttcomm_populate_sock_from_open_socket(
- &relayd->data_sock.sock, fd,
- relayd_socket_protocol);
+ &relayd->data_sock.sock, fd, relayd_socket_protocol);
/* Assign version values. */
relayd->data_sock.major = relayd_version_major;
relayd->data_sock.minor = relayd_version_minor;
}
DBG("Consumer %s socket created successfully with net idx %" PRIu64 " (fd: %d)",
- sock_type == LTTNG_STREAM_CONTROL ? "control" : "data",
- relayd->net_seq_idx, fd);
+ sock_type == LTTNG_STREAM_CONTROL ? "control" : "data",
+ relayd->net_seq_idx,
+ fd);
/*
* We gave the ownership of the fd to the relayd structure. Set the
* fd to -1 so we don't call close() on it in the error path below.
ASSERT_RCU_READ_LOCKED();
/* Iterate over all relayd since they are indexed by net_seq_idx. */
- cds_lfht_for_each_entry(the_consumer_data.relayd_ht->ht, &iter.iter,
- relayd, node.node) {
+ cds_lfht_for_each_entry (the_consumer_data.relayd_ht->ht, &iter.iter, relayd, node.node) {
/*
* Check by sessiond id which is unique here where the relayd session
* id might not be when having multiple relayd.
ht = the_consumer_data.stream_list_ht;
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&id, lttng_ht_seed),
- ht->match_fct, &id,
- &iter.iter, stream, node_session_id.node) {
+ ht->hash_fct(&id, lttng_ht_seed),
+ ht->match_fct,
+ &id,
+ &iter.iter,
+ stream,
+ node_session_id.node)
+ {
pthread_mutex_lock(&stream->lock);
/*
/* Send init command for data pending. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_begin_data_pending(&relayd->control_sock,
- relayd->relayd_session_id);
+ ret = relayd_begin_data_pending(&relayd->control_sock, relayd->relayd_session_id);
if (ret < 0) {
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
/* Communication error thus the relayd so no data pending. */
}
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&id, lttng_ht_seed),
- ht->match_fct, &id,
- &iter.iter, stream, node_session_id.node) {
+ ht->hash_fct(&id, lttng_ht_seed),
+ ht->match_fct,
+ &id,
+ &iter.iter,
+ stream,
+ node_session_id.node)
+ {
if (stream->metadata_flag) {
ret = relayd_quiescent_control(&relayd->control_sock,
- stream->relayd_stream_id);
+ stream->relayd_stream_id);
} else {
ret = relayd_data_pending(&relayd->control_sock,
- stream->relayd_stream_id,
- stream->next_net_seq_num - 1);
+ stream->relayd_stream_id,
+ stream->next_net_seq_num - 1);
}
if (ret == 1) {
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
goto data_pending;
} else if (ret < 0) {
- ERR("Relayd data pending failed. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd data pending failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
goto data_not_pending;
}
/* Send end command for data pending. */
- ret = relayd_end_data_pending(&relayd->control_sock,
- relayd->relayd_session_id, &is_data_inflight);
+ ret = relayd_end_data_pending(
+ &relayd->control_sock, relayd->relayd_session_id, &is_data_inflight);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
- ERR("Relayd end data pending failed. Cleaning up relayd %" PRIu64".", relayd->net_seq_idx);
+ ERR("Relayd end data pending failed. Cleaning up relayd %" PRIu64 ".",
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
goto data_not_pending;
}
*
* Return the sendmsg() return value.
*/
-int consumer_send_status_channel(int sock,
- struct lttng_consumer_channel *channel)
+int consumer_send_status_channel(int sock, struct lttng_consumer_channel *channel)
{
struct lttcomm_consumer_status_channel msg;
}
unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
- unsigned long produced_pos, uint64_t nb_packets_per_stream,
- uint64_t max_sb_size)
+ unsigned long produced_pos,
+ uint64_t nb_packets_per_stream,
+ uint64_t max_sb_size)
{
unsigned long start_pos;
if (!nb_packets_per_stream) {
- return consumed_pos; /* Grab everything */
+ return consumed_pos; /* Grab everything */
}
start_pos = produced_pos - lttng_offset_align_floor(produced_pos, max_sb_size);
start_pos -= max_sb_size * nb_packets_per_stream;
if ((long) (start_pos - consumed_pos) < 0) {
- return consumed_pos; /* Grab everything */
+ return consumed_pos; /* Grab everything */
}
return start_pos;
}
/* Stream lock must be held by the caller. */
static int sample_stream_positions(struct lttng_consumer_stream *stream,
- unsigned long *produced, unsigned long *consumed)
+ unsigned long *produced,
+ unsigned long *consumed)
{
int ret;
* Returns 0 on success, < 0 on error
*/
int lttng_consumer_rotate_channel(struct lttng_consumer_channel *channel,
- uint64_t key, uint64_t relayd_id)
+ uint64_t key,
+ uint64_t relayd_id)
{
int ret;
struct lttng_consumer_stream *stream;
DBG("Consumer sample rotate position for channel %" PRIu64, key);
- lttng_dynamic_array_init(&stream_rotation_positions,
- sizeof(struct relayd_stream_rotation_position), NULL);
+ lttng_dynamic_array_init(
+ &stream_rotation_positions, sizeof(struct relayd_stream_rotation_position), NULL);
lttng_dynamic_pointer_array_init(&streams_packet_to_open, NULL);
rcu_read_lock();
pthread_mutex_lock(&channel->lock);
LTTNG_ASSERT(channel->trace_chunk);
- chunk_status = lttng_trace_chunk_get_id(channel->trace_chunk,
- &next_chunk_id);
+ chunk_status = lttng_trace_chunk_get_id(channel->trace_chunk, &next_chunk_id);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end_unlock_channel;
}
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key, &iter.iter,
- stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
unsigned long produced_pos = 0, consumed_pos = 0;
health_code_update();
* for this stream during this trace
* chunk's lifetime.
*/
- ret = sample_stream_positions(stream, &produced_pos, &consumed_pos);
+ ret = sample_stream_positions(
+ stream, &produced_pos, &consumed_pos);
if (ret) {
goto end_unlock_stream;
}
uint64_t trace_chunk_id;
chunk_status = lttng_trace_chunk_get_name(
- stream->trace_chunk,
- &trace_chunk_name,
- NULL);
+ stream->trace_chunk,
+ &trace_chunk_name,
+ NULL);
if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NONE) {
trace_chunk_name = "none";
}
* never anonymous.
*/
chunk_status = lttng_trace_chunk_get_id(
- stream->trace_chunk,
- &trace_chunk_id);
+ stream->trace_chunk, &trace_chunk_id);
LTTNG_ASSERT(chunk_status ==
- LTTNG_TRACE_CHUNK_STATUS_OK);
+ LTTNG_TRACE_CHUNK_STATUS_OK);
DBG("Unable to open packet for stream during trace chunk's lifetime. "
- "Flushing an empty packet to prevent an empty file from being created: "
- "stream id = %" PRIu64 ", trace chunk name = `%s`, trace chunk id = %" PRIu64,
- stream->key, trace_chunk_name, trace_chunk_id);
+ "Flushing an empty packet to prevent an empty file from being created: "
+ "stream id = %" PRIu64
+ ", trace chunk name = `%s`, trace chunk id = %" PRIu64,
+ stream->key,
+ trace_chunk_name,
+ trace_chunk_id);
}
}
}
ret = consumer_stream_flush_buffer(stream, flush_active);
if (ret < 0) {
ERR("Failed to flush stream %" PRIu64 " during channel rotation",
- stream->key);
+ stream->key);
goto end_unlock_stream;
}
}
goto end_unlock_stream;
}
if (!ret) {
- ret = lttng_consumer_get_produced_snapshot(stream,
- &produced_pos);
+ ret = lttng_consumer_get_produced_snapshot(stream, &produced_pos);
if (ret < 0) {
ERR("Failed to sample produced position during channel rotation");
goto end_unlock_stream;
}
- ret = lttng_consumer_get_consumed_snapshot(stream,
- &consumed_pos);
+ ret = lttng_consumer_get_consumed_snapshot(stream, &consumed_pos);
if (ret < 0) {
ERR("Failed to sample consumed position during channel rotation");
goto end_unlock_stream;
produced_pos = lttng_align_floor(produced_pos, stream->max_sb_size);
if (consumed_pos == produced_pos) {
DBG("Set rotate ready for stream %" PRIu64 " produced = %lu consumed = %lu",
- stream->key, produced_pos, consumed_pos);
+ stream->key,
+ produced_pos,
+ consumed_pos);
stream->rotate_ready = true;
} else {
DBG("Different consumed and produced positions "
- "for stream %" PRIu64 " produced = %lu consumed = %lu",
- stream->key, produced_pos, consumed_pos);
+ "for stream %" PRIu64 " produced = %lu consumed = %lu",
+ stream->key,
+ produced_pos,
+ consumed_pos);
}
/*
* The rotation position is based on the packet_seq_num of the
* not implement packet sequence number.
*/
ERR("Failure to rotate stream %" PRIu64 ": sequence number unavailable",
- stream->key);
+ stream->key);
ret = -1;
goto end_unlock_stream;
}
stream->rotate_position = stream->last_sequence_number + 1 +
- ((produced_pos - consumed_pos) / stream->max_sb_size);
+ ((produced_pos - consumed_pos) / stream->max_sb_size);
DBG("Set rotation position for stream %" PRIu64 " at position %" PRIu64,
- stream->key, stream->rotate_position);
+ stream->key,
+ stream->rotate_position);
if (!is_local_trace) {
/*
.rotate_at_seq_num = stream->rotate_position,
};
- ret = lttng_dynamic_array_add_element(
- &stream_rotation_positions,
- &position);
+ ret = lttng_dynamic_array_add_element(&stream_rotation_positions,
+ &position);
if (ret) {
ERR("Failed to allocate stream rotation position");
goto end_unlock_stream;
* is performed in a stream that has no active trace
* chunk.
*/
- ret = lttng_dynamic_pointer_array_add_pointer(
- &streams_packet_to_open, stream);
+ ret = lttng_dynamic_pointer_array_add_pointer(&streams_packet_to_open,
+ stream);
if (ret) {
PERROR("Failed to add a stream pointer to array of streams in which to open a packet");
ret = -1;
}
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_rotate_streams(&relayd->control_sock, stream_count,
- rotating_to_new_chunk ? &next_chunk_id : NULL,
- (const struct relayd_stream_rotation_position *)
- stream_rotation_positions.buffer
- .data);
+ ret = relayd_rotate_streams(&relayd->control_sock,
+ stream_count,
+ rotating_to_new_chunk ? &next_chunk_id : NULL,
+ (const struct relayd_stream_rotation_position *)
+ stream_rotation_positions.buffer.data);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
ERR("Relayd rotate stream failed. Cleaning up relayd %" PRIu64,
- relayd->net_seq_idx);
+ relayd->net_seq_idx);
lttng_consumer_cleanup_relayd(relayd);
goto end_unlock_channel;
}
}
for (stream_idx = 0;
- stream_idx < lttng_dynamic_pointer_array_get_count(
- &streams_packet_to_open);
- stream_idx++) {
+ stream_idx < lttng_dynamic_pointer_array_get_count(&streams_packet_to_open);
+ stream_idx++) {
enum consumer_stream_open_packet_status status;
stream = (lttng_consumer_stream *) lttng_dynamic_pointer_array_get_pointer(
- &streams_packet_to_open, stream_idx);
+ &streams_packet_to_open, stream_idx);
pthread_mutex_lock(&stream->lock);
status = consumer_stream_open_packet(stream);
case CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED:
DBG("Opened a packet after a rotation: stream id = %" PRIu64
", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE:
/*
*/
DBG("No space left to open a packet after a rotation: stream id = %" PRIu64
", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR:
/* Logged by callee. */
return ret;
}
-static
-int consumer_clear_buffer(struct lttng_consumer_stream *stream)
+static int consumer_clear_buffer(struct lttng_consumer_stream *stream)
{
int ret = 0;
unsigned long consumed_pos_before, consumed_pos_after;
return ret;
}
-static
-int consumer_clear_stream(struct lttng_consumer_stream *stream)
+static int consumer_clear_stream(struct lttng_consumer_stream *stream)
{
int ret;
ret = consumer_stream_flush_buffer(stream, 1);
if (ret < 0) {
- ERR("Failed to flush stream %" PRIu64 " during channel clear",
- stream->key);
+ ERR("Failed to flush stream %" PRIu64 " during channel clear", stream->key);
ret = LTTCOMM_CONSUMERD_FATAL;
goto error;
}
ret = consumer_clear_buffer(stream);
if (ret < 0) {
- ERR("Failed to clear stream %" PRIu64 " during channel clear",
- stream->key);
+ ERR("Failed to clear stream %" PRIu64 " during channel clear", stream->key);
ret = LTTCOMM_CONSUMERD_FATAL;
goto error;
}
return ret;
}
-static
-int consumer_clear_unmonitored_channel(struct lttng_consumer_channel *channel)
+static int consumer_clear_unmonitored_channel(struct lttng_consumer_channel *channel)
{
int ret;
struct lttng_consumer_stream *stream;
rcu_read_lock();
pthread_mutex_lock(&channel->lock);
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
health_code_update();
pthread_mutex_lock(&stream->lock);
ret = consumer_clear_stream(stream);
*/
int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream)
{
- DBG("Check is rotate ready for stream %" PRIu64
- " ready %u rotate_position %" PRIu64
- " last_sequence_number %" PRIu64,
- stream->key, stream->rotate_ready,
- stream->rotate_position, stream->last_sequence_number);
+ DBG("Check is rotate ready for stream %" PRIu64 " ready %u rotate_position %" PRIu64
+ " last_sequence_number %" PRIu64,
+ stream->key,
+ stream->rotate_ready,
+ stream->rotate_position,
+ stream->last_sequence_number);
if (stream->rotate_ready) {
return 1;
}
*/
if (stream->sequence_number_unavailable) {
ERR("Internal error: rotation used on stream %" PRIu64
- " with unavailable sequence number",
- stream->key);
+ " with unavailable sequence number",
+ stream->key);
return -1;
}
- if (stream->rotate_position == -1ULL ||
- stream->last_sequence_number == -1ULL) {
+ if (stream->rotate_position == -1ULL || stream->last_sequence_number == -1ULL) {
return 0;
}
* packet of the current chunk, hence the "rotate_position - 1".
*/
- DBG("Check is rotate ready for stream %" PRIu64
- " last_sequence_number %" PRIu64
- " rotate_position %" PRIu64,
- stream->key, stream->last_sequence_number,
- stream->rotate_position);
+ DBG("Check is rotate ready for stream %" PRIu64 " last_sequence_number %" PRIu64
+ " rotate_position %" PRIu64,
+ stream->key,
+ stream->last_sequence_number,
+ stream->rotate_position);
if (stream->last_sequence_number >= stream->rotate_position - 1) {
return 1;
}
*/
void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream)
{
- DBG("lttng_consumer_reset_stream_rotate_state for stream %" PRIu64,
- stream->key);
+ DBG("lttng_consumer_reset_stream_rotate_state for stream %" PRIu64, stream->key);
stream->rotate_position = -1ULL;
stream->rotate_ready = false;
}
/*
* Perform the rotation a local stream file.
*/
-static
-int rotate_local_stream(struct lttng_consumer_stream *stream)
+static int rotate_local_stream(struct lttng_consumer_stream *stream)
{
int ret = 0;
DBG("Rotate local stream: stream key %" PRIu64 ", channel key %" PRIu64,
- stream->key,
- stream->chan->key);
+ stream->key,
+ stream->chan->key);
stream->tracefile_size_current = 0;
stream->tracefile_count_current = 0;
ret = close(stream->out_fd);
if (ret) {
PERROR("Failed to close stream out_fd of channel \"%s\"",
- stream->chan->name);
+ stream->chan->name);
}
stream->out_fd = -1;
}
* anything until a new trace chunk is created.
*/
stream->trace_chunk = NULL;
- } else if (stream->chan->trace_chunk &&
- !lttng_trace_chunk_get(stream->chan->trace_chunk)) {
+ } else if (stream->chan->trace_chunk && !lttng_trace_chunk_get(stream->chan->trace_chunk)) {
ERR("Failed to acquire a reference to channel's trace chunk during stream rotation");
ret = -1;
goto error;
*
* Returns 0 on success, < 0 on error
*/
-int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel,
- uint64_t key)
+int lttng_consumer_rotate_ready_streams(struct lttng_consumer_channel *channel, uint64_t key)
{
int ret;
struct lttng_consumer_stream *stream;
DBG("Consumer rotate ready streams in channel %" PRIu64, key);
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key, &iter.iter,
- stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
health_code_update();
pthread_mutex_lock(&stream->chan->lock);
return ret;
}
-enum lttcomm_return_code lttng_consumer_init_command(
- struct lttng_consumer_local_data *ctx,
- const lttng_uuid& sessiond_uuid)
+enum lttcomm_return_code lttng_consumer_init_command(struct lttng_consumer_local_data *ctx,
+ const lttng_uuid& sessiond_uuid)
{
enum lttcomm_return_code ret;
char uuid_str[LTTNG_UUID_STR_LEN];
return ret;
}
-enum lttcomm_return_code lttng_consumer_create_trace_chunk(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id,
- time_t chunk_creation_timestamp,
- const char *chunk_override_name,
- const struct lttng_credentials *credentials,
- struct lttng_directory_handle *chunk_directory_handle)
+enum lttcomm_return_code
+lttng_consumer_create_trace_chunk(const uint64_t *relayd_id,
+ uint64_t session_id,
+ uint64_t chunk_id,
+ time_t chunk_creation_timestamp,
+ const char *chunk_override_name,
+ const struct lttng_credentials *credentials,
+ struct lttng_directory_handle *chunk_directory_handle)
{
int ret;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
if (relayd_id) {
/* Only used for logging purposes. */
- ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer),
- "%" PRIu64, *relayd_id);
+ ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer), "%" PRIu64, *relayd_id);
if (ret > 0 && ret < sizeof(relayd_id_buffer)) {
relayd_id_str = relayd_id_buffer;
} else {
/* Local protocol error. */
LTTNG_ASSERT(chunk_creation_timestamp);
ret = time_to_iso8601_str(chunk_creation_timestamp,
- creation_timestamp_buffer,
- sizeof(creation_timestamp_buffer));
- creation_timestamp_str = !ret ? creation_timestamp_buffer :
- "(formatting error)";
+ creation_timestamp_buffer,
+ sizeof(creation_timestamp_buffer));
+ creation_timestamp_str = !ret ? creation_timestamp_buffer : "(formatting error)";
DBG("Consumer create trace chunk command: relay_id = %s"
- ", session_id = %" PRIu64 ", chunk_id = %" PRIu64
- ", chunk_override_name = %s"
- ", chunk_creation_timestamp = %s",
- relayd_id_str, session_id, chunk_id,
- chunk_override_name ? : "(none)",
- creation_timestamp_str);
+ ", session_id = %" PRIu64 ", chunk_id = %" PRIu64 ", chunk_override_name = %s"
+ ", chunk_creation_timestamp = %s",
+ relayd_id_str,
+ session_id,
+ chunk_id,
+ chunk_override_name ?: "(none)",
+ creation_timestamp_str);
/*
* The trace chunk registry, as used by the consumer daemon, implicitly
* the session daemon through the LTTNG_CONSUMER_CREATE_TRACE_CHUNK
* and LTTNG_CONSUMER_DESTROY_TRACE_CHUNK commands.
*/
- created_chunk = lttng_trace_chunk_create(chunk_id,
- chunk_creation_timestamp, NULL);
+ created_chunk = lttng_trace_chunk_create(chunk_id, chunk_creation_timestamp, NULL);
if (!created_chunk) {
ERR("Failed to create trace chunk");
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
}
if (chunk_override_name) {
- chunk_status = lttng_trace_chunk_override_name(created_chunk,
- chunk_override_name);
+ chunk_status = lttng_trace_chunk_override_name(created_chunk, chunk_override_name);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
goto error;
}
if (chunk_directory_handle) {
- chunk_status = lttng_trace_chunk_set_credentials(created_chunk,
- credentials);
+ chunk_status = lttng_trace_chunk_set_credentials(created_chunk, credentials);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to set trace chunk credentials");
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
* The consumer daemon has no ownership of the chunk output
* directory.
*/
- chunk_status = lttng_trace_chunk_set_as_user(created_chunk,
- chunk_directory_handle);
+ chunk_status = lttng_trace_chunk_set_as_user(created_chunk, chunk_directory_handle);
chunk_directory_handle = NULL;
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to set trace chunk's directory handle");
}
published_chunk = lttng_trace_chunk_registry_publish_chunk(
- the_consumer_data.chunk_registry, session_id,
- created_chunk);
+ the_consumer_data.chunk_registry, session_id, created_chunk);
lttng_trace_chunk_put(created_chunk);
created_chunk = NULL;
if (!published_chunk) {
rcu_read_lock();
cds_lfht_for_each_entry_duplicate(
- the_consumer_data.channels_by_session_id_ht->ht,
- the_consumer_data.channels_by_session_id_ht->hash_fct(
- &session_id, lttng_ht_seed),
- the_consumer_data.channels_by_session_id_ht->match_fct,
- &session_id, &iter.iter, channel,
- channels_by_session_id_ht_node.node) {
- ret = lttng_consumer_channel_set_trace_chunk(channel,
- published_chunk);
+ the_consumer_data.channels_by_session_id_ht->ht,
+ the_consumer_data.channels_by_session_id_ht->hash_fct(&session_id, lttng_ht_seed),
+ the_consumer_data.channels_by_session_id_ht->match_fct,
+ &session_id,
+ &iter.iter,
+ channel,
+ channels_by_session_id_ht_node.node)
+ {
+ ret = lttng_consumer_channel_set_trace_chunk(channel, published_chunk);
if (ret) {
/*
* Roll-back the creation of this chunk.
DBG("Failed to set new trace chunk on existing channels, rolling back");
close_ret = lttng_consumer_close_trace_chunk(relayd_id,
- session_id, chunk_id,
- chunk_creation_timestamp, NULL,
- path);
+ session_id,
+ chunk_id,
+ chunk_creation_timestamp,
+ NULL,
+ path);
if (close_ret != LTTCOMM_CONSUMERD_SUCCESS) {
- ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64 ", chunk_id = %" PRIu64,
- session_id, chunk_id);
+ ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64
+ ", chunk_id = %" PRIu64,
+ session_id,
+ chunk_id);
}
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
relayd = consumer_find_relayd(*relayd_id);
if (relayd) {
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_create_trace_chunk(
- &relayd->control_sock, published_chunk);
+ ret = relayd_create_trace_chunk(&relayd->control_sock, published_chunk);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
} else {
ERR("Failed to find relay daemon socket: relayd_id = %" PRIu64, *relayd_id);
char path[LTTNG_PATH_MAX];
close_ret = lttng_consumer_close_trace_chunk(relayd_id,
- session_id,
- chunk_id,
- chunk_creation_timestamp,
- NULL, path);
+ session_id,
+ chunk_id,
+ chunk_creation_timestamp,
+ NULL,
+ path);
if (close_ret != LTTCOMM_CONSUMERD_SUCCESS) {
- ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64 ", chunk_id = %" PRIu64,
- session_id,
- chunk_id);
+ ERR("Failed to roll-back the creation of new chunk: session_id = %" PRIu64
+ ", chunk_id = %" PRIu64,
+ session_id,
+ chunk_id);
}
ret_code = LTTCOMM_CONSUMERD_CREATE_TRACE_CHUNK_FAILED;
return ret_code;
}
-enum lttcomm_return_code lttng_consumer_close_trace_chunk(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id, time_t chunk_close_timestamp,
- const enum lttng_trace_chunk_command_type *close_command,
- char *path)
+enum lttcomm_return_code
+lttng_consumer_close_trace_chunk(const uint64_t *relayd_id,
+ uint64_t session_id,
+ uint64_t chunk_id,
+ time_t chunk_close_timestamp,
+ const enum lttng_trace_chunk_command_type *close_command,
+ char *path)
{
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttng_trace_chunk *chunk;
int ret;
/* Only used for logging purposes. */
- ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer),
- "%" PRIu64, *relayd_id);
+ ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer), "%" PRIu64, *relayd_id);
if (ret > 0 && ret < sizeof(relayd_id_buffer)) {
relayd_id_str = relayd_id_buffer;
} else {
}
}
if (close_command) {
- close_command_name = lttng_trace_chunk_command_type_get_name(
- *close_command);
+ close_command_name = lttng_trace_chunk_command_type_get_name(*close_command);
}
DBG("Consumer close trace chunk command: relayd_id = %s"
- ", session_id = %" PRIu64 ", chunk_id = %" PRIu64
- ", close command = %s",
- relayd_id_str, session_id, chunk_id,
- close_command_name);
+ ", session_id = %" PRIu64 ", chunk_id = %" PRIu64 ", close command = %s",
+ relayd_id_str,
+ session_id,
+ chunk_id,
+ close_command_name);
chunk = lttng_trace_chunk_registry_find_chunk(
- the_consumer_data.chunk_registry, session_id, chunk_id);
+ the_consumer_data.chunk_registry, session_id, chunk_id);
if (!chunk) {
- ERR("Failed to find chunk: session_id = %" PRIu64
- ", chunk_id = %" PRIu64,
- session_id, chunk_id);
+ ERR("Failed to find chunk: session_id = %" PRIu64 ", chunk_id = %" PRIu64,
+ session_id,
+ chunk_id);
ret_code = LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK;
goto end;
}
- chunk_status = lttng_trace_chunk_set_close_timestamp(chunk,
- chunk_close_timestamp);
+ chunk_status = lttng_trace_chunk_set_close_timestamp(chunk, chunk_close_timestamp);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret_code = LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED;
goto end;
}
if (close_command) {
- chunk_status = lttng_trace_chunk_set_close_command(
- chunk, *close_command);
+ chunk_status = lttng_trace_chunk_set_close_command(chunk, *close_command);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret_code = LTTCOMM_CONSUMERD_CLOSE_TRACE_CHUNK_FAILED;
goto end;
* current chunk found in the session's channels.
*/
rcu_read_lock();
- cds_lfht_for_each_entry(the_consumer_data.channel_ht->ht, &iter.iter,
- channel, node.node) {
+ cds_lfht_for_each_entry (the_consumer_data.channel_ht->ht, &iter.iter, channel, node.node) {
int ret;
/*
relayd = consumer_find_relayd(*relayd_id);
if (relayd) {
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_close_trace_chunk(
- &relayd->control_sock, chunk,
- path);
+ ret = relayd_close_trace_chunk(&relayd->control_sock, chunk, path);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
} else {
- ERR("Failed to find relay daemon socket: relayd_id = %" PRIu64,
- *relayd_id);
+ ERR("Failed to find relay daemon socket: relayd_id = %" PRIu64, *relayd_id);
}
if (!relayd || ret) {
return ret_code;
}
-enum lttcomm_return_code lttng_consumer_trace_chunk_exists(
- const uint64_t *relayd_id, uint64_t session_id,
- uint64_t chunk_id)
+enum lttcomm_return_code
+lttng_consumer_trace_chunk_exists(const uint64_t *relayd_id, uint64_t session_id, uint64_t chunk_id)
{
int ret;
enum lttcomm_return_code ret_code;
if (relayd_id) {
/* Only used for logging purposes. */
- ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer),
- "%" PRIu64, *relayd_id);
+ ret = snprintf(relayd_id_buffer, sizeof(relayd_id_buffer), "%" PRIu64, *relayd_id);
if (ret > 0 && ret < sizeof(relayd_id_buffer)) {
relayd_id_str = relayd_id_buffer;
} else {
}
DBG("Consumer trace chunk exists command: relayd_id = %s"
- ", chunk_id = %" PRIu64, relayd_id_str,
- chunk_id);
+ ", chunk_id = %" PRIu64,
+ relayd_id_str,
+ chunk_id);
ret = lttng_trace_chunk_registry_chunk_exists(
- the_consumer_data.chunk_registry, session_id, chunk_id,
- &chunk_exists_local);
+ the_consumer_data.chunk_registry, session_id, chunk_id, &chunk_exists_local);
if (ret) {
/* Internal error. */
ERR("Failed to query the existence of a trace chunk");
ret_code = LTTCOMM_CONSUMERD_FATAL;
goto end;
}
- DBG("Trace chunk %s locally",
- chunk_exists_local ? "exists" : "does not exist");
+ DBG("Trace chunk %s locally", chunk_exists_local ? "exists" : "does not exist");
if (chunk_exists_local) {
ret_code = LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_LOCAL;
goto end;
}
DBG("Looking up existence of trace chunk on relay daemon");
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
- ret = relayd_trace_chunk_exists(&relayd->control_sock, chunk_id,
- &chunk_exists_remote);
+ ret = relayd_trace_chunk_exists(&relayd->control_sock, chunk_id, &chunk_exists_remote);
pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
if (ret < 0) {
ERR("Failed to look-up the existence of trace chunk on relay daemon");
goto end_rcu_unlock;
}
- ret_code = chunk_exists_remote ?
- LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE :
- LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK;
- DBG("Trace chunk %s on relay daemon",
- chunk_exists_remote ? "exists" : "does not exist");
+ ret_code = chunk_exists_remote ? LTTCOMM_CONSUMERD_TRACE_CHUNK_EXISTS_REMOTE :
+ LTTCOMM_CONSUMERD_UNKNOWN_TRACE_CHUNK;
+ DBG("Trace chunk %s on relay daemon", chunk_exists_remote ? "exists" : "does not exist");
end_rcu_unlock:
rcu_read_unlock();
return ret_code;
}
-static
-int consumer_clear_monitored_channel(struct lttng_consumer_channel *channel)
+static int consumer_clear_monitored_channel(struct lttng_consumer_channel *channel)
{
struct lttng_ht *ht;
struct lttng_consumer_stream *stream;
rcu_read_lock();
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed),
- ht->match_fct, &channel->key,
- &iter.iter, stream, node_channel_id.node) {
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
/*
* Protect against teardown with mutex.
*/
return ret;
}
-enum lttcomm_return_code lttng_consumer_open_channel_packets(
- struct lttng_consumer_channel *channel)
+enum lttcomm_return_code lttng_consumer_open_channel_packets(struct lttng_consumer_channel *channel)
{
struct lttng_consumer_stream *stream;
enum lttcomm_return_code ret = LTTCOMM_CONSUMERD_SUCCESS;
}
rcu_read_lock();
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
enum consumer_stream_open_packet_status status;
pthread_mutex_lock(&stream->lock);
switch (status) {
case CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED:
DBG("Opened a packet in \"open channel packets\" command: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
stream->opened_packet_in_current_trace_chunk = true;
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE:
DBG("No space left to open a packet in \"open channel packets\" command: stream id = %" PRIu64
- ", channel name = %s, session id = %" PRIu64,
- stream->key, stream->chan->name,
- stream->chan->session_id);
+ ", channel name = %s, session id = %" PRIu64,
+ stream->key,
+ stream->chan->name,
+ stream->chan->session_id);
break;
case CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR:
/*
* failing. Report an unknown error.
*/
ERR("Failed to flush empty buffer in \"open channel packets\" command: stream id = %" PRIu64
- ", channel id = %" PRIu64
- ", channel name = %s"
- ", session id = %" PRIu64,
- stream->key, channel->key,
- channel->name, channel->session_id);
+ ", channel id = %" PRIu64 ", channel name = %s"
+ ", session id = %" PRIu64,
+ stream->key,
+ channel->key,
+ channel->name,
+ channel->session_id);
ret = LTTCOMM_CONSUMERD_UNKNOWN_ERROR;
goto error_unlock;
default:
#include <common/buffer-view.hpp>
#include <common/consumer/consumer.hpp>
#include <common/dynamic-buffer.hpp>
-#include <common/macros.hpp>
#include <common/error.hpp>
+#include <common/macros.hpp>
struct metadata_bucket {
struct lttng_dynamic_buffer content;
unsigned int buffer_count;
};
-struct metadata_bucket *metadata_bucket_create(
- metadata_bucket_flush_cb flush, void *data)
+struct metadata_bucket *metadata_bucket_create(metadata_bucket_flush_cb flush, void *data)
{
metadata_bucket *bucket = zmalloc<metadata_bucket>();
if (!bucket) {
if (bucket->content.size > 0) {
WARN("Stream metadata bucket destroyed with remaining data: size = %zu, buffer count = %u",
- bucket->content.size, bucket->buffer_count);
+ bucket->content.size,
+ bucket->buffer_count);
}
lttng_dynamic_buffer_reset(&bucket->content);
}
enum metadata_bucket_status metadata_bucket_fill(struct metadata_bucket *bucket,
- const struct stream_subbuffer *buffer)
+ const struct stream_subbuffer *buffer)
{
ssize_t ret;
struct lttng_buffer_view flushed_view;
struct stream_subbuffer flushed_subbuffer;
enum metadata_bucket_status status;
- const bool should_flush =
- LTTNG_OPTIONAL_GET(buffer->info.metadata.coherent);
+ const bool should_flush = LTTNG_OPTIONAL_GET(buffer->info.metadata.coherent);
const size_t padding_this_buffer =
- buffer->info.metadata.padded_subbuf_size -
- buffer->info.metadata.subbuf_size;
+ buffer->info.metadata.padded_subbuf_size - buffer->info.metadata.subbuf_size;
size_t flush_size;
DBG("Metadata bucket filled with %zu bytes buffer view, sub-buffer size: %lu, padded sub-buffer size: %lu, coherent: %s",
- buffer->buffer.buffer.size,
- buffer->info.metadata.subbuf_size,
- buffer->info.metadata.padded_subbuf_size,
- buffer->info.metadata.coherent.value ? "true" : "false");
+ buffer->buffer.buffer.size,
+ buffer->info.metadata.subbuf_size,
+ buffer->info.metadata.padded_subbuf_size,
+ buffer->info.metadata.coherent.value ? "true" : "false");
/*
* If no metadata was accumulated and this buffer should be
* flushed, don't copy it unecessarily; just flush it directly.
* the bucket is not sent, which is what really matters
* from an efficiency point of view.
*/
- ret = lttng_dynamic_buffer_append_view(
- &bucket->content, &buffer->buffer.buffer);
+ ret = lttng_dynamic_buffer_append_view(&bucket->content, &buffer->buffer.buffer);
if (ret) {
status = METADATA_BUCKET_STATUS_ERROR;
goto end;
};
DBG("Metadata bucket flushing %zu bytes (%u sub-buffer%s)",
- flushed_view.size, bucket->buffer_count,
- bucket->buffer_count > 1 ? "s" : "");
+ flushed_view.size,
+ bucket->buffer_count,
+ bucket->buffer_count > 1 ? "s" : "");
ret = bucket->flush.fn(&flushed_subbuffer, bucket->flush.data);
if (ret >= 0) {
status = METADATA_BUCKET_STATUS_OK;
*/
#include "context.hpp"
-#include <stddef.h>
-#include <string.h>
+
#include <common/error.hpp>
#include <common/macros.hpp>
-int parse_application_context(const char *str, char **out_provider_name,
- char **out_ctx_name)
+#include <stddef.h>
+#include <string.h>
+
+int parse_application_context(const char *str, char **out_provider_name, char **out_ctx_name)
{
const char app_ctx_prefix[] = "$app.";
char *provider_name = NULL, *ctx_name = NULL;
* No colon found or no ctx name ("$app.provider:") or no provider name
* given ("$app.:..."), which is invalid.
*/
- if (!colon_pos || colon_pos == len ||
- colon_pos == sizeof(app_ctx_prefix)) {
+ if (!colon_pos || colon_pos == len || colon_pos == sizeof(app_ctx_prefix)) {
goto not_found;
}
PERROR("malloc provider_name");
goto not_found;
}
- strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1,
- provider_name_len - 1);
+ strncpy(provider_name, str + sizeof(app_ctx_prefix) - 1, provider_name_len - 1);
ctx_name_len = len - colon_pos;
ctx_name = calloc<char>(ctx_name_len);
free(ctx_name);
return -1;
}
-
*
*/
-#include <stdbool.h>
#include "credentials.hpp"
+#include <stdbool.h>
+
uid_t lttng_credentials_get_uid(const struct lttng_credentials *creds)
{
return LTTNG_OPTIONAL_GET(creds->uid);
}
bool lttng_credentials_is_equal_uid(const struct lttng_credentials *a,
- const struct lttng_credentials *b)
+ const struct lttng_credentials *b)
{
LTTNG_ASSERT(a);
LTTNG_ASSERT(b);
}
bool lttng_credentials_is_equal_gid(const struct lttng_credentials *a,
- const struct lttng_credentials *b)
+ const struct lttng_credentials *b)
{
LTTNG_ASSERT(a);
LTTNG_ASSERT(b);
}
bool lttng_credentials_is_equal(const struct lttng_credentials *a,
- const struct lttng_credentials *b)
+ const struct lttng_credentials *b)
{
LTTNG_ASSERT(a);
LTTNG_ASSERT(b);
- return lttng_credentials_is_equal_uid(a, b) &&
- lttng_credentials_is_equal_gid(a, b);
+ return lttng_credentials_is_equal_uid(a, b) && lttng_credentials_is_equal_gid(a, b);
}
*/
#define _LGPL_SOURCE
-#include <unistd.h>
#include <common/compat/paths.hpp>
+#include <common/daemonize.hpp>
+#include <common/error.hpp>
+
#include <fcntl.h>
-#include <sys/wait.h>
#include <stdlib.h>
-
+#include <sys/wait.h>
+#include <unistd.h>
#include <urcu/system.h>
-#include <common/daemonize.hpp>
-#include <common/error.hpp>
-
-int lttng_daemonize(pid_t *child_ppid, int *completion_flag,
- int close_fds)
+int lttng_daemonize(pid_t *child_ppid, int *completion_flag, int close_fds)
{
pid_t pid;
*/
#define _LGPL_SOURCE
-#include <stddef.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/resource.h>
-#include <pthread.h>
-#include <algorithm>
-
#include "defaults.hpp"
-#include "macros.hpp"
#include "error.hpp"
+#include "macros.hpp"
+
+#include <algorithm>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <sys/resource.h>
+#include <unistd.h>
static int pthread_attr_init_done;
static pthread_attr_t tattr;
goto error_destroy;
}
DBG("Stack size limits: soft %lld, hard %lld bytes",
- (long long) rlim.rlim_cur,
- (long long) rlim.rlim_max);
+ (long long) rlim.rlim_cur,
+ (long long) rlim.rlim_max);
/*
* getrlimit() may return a stack size of "-1", meaning "unlimited".
* In this case, we impose a known-good default minimum value which will
* override the libc's default stack size if it is smaller.
*/
- system_ss = rlim.rlim_cur != -1 ? rlim.rlim_cur :
- DEFAULT_LTTNG_THREAD_STACK_SIZE;
+ system_ss = rlim.rlim_cur != -1 ? rlim.rlim_cur : DEFAULT_LTTNG_THREAD_STACK_SIZE;
/* Get pthread default thread stack size. */
ret = pthread_attr_getstacksize(&tattr, &pthread_ss);
selected_ss = std::max(pthread_ss, system_ss);
if (selected_ss < DEFAULT_LTTNG_THREAD_STACK_SIZE) {
DBG("Default stack size is too small, setting it to %zu bytes",
- (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
+ (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
selected_ss = DEFAULT_LTTNG_THREAD_STACK_SIZE;
}
if (rlim.rlim_max > 0 && selected_ss > rlim.rlim_max) {
WARN("Your system's stack size restrictions (%zu bytes) may be too low for the LTTng daemons to function properly, please set the stack size limit to at least %zu bytes to ensure reliable operation",
- (size_t) rlim.rlim_max, (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
+ (size_t) rlim.rlim_max,
+ (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
selected_ss = (size_t) rlim.rlim_max;
}
*
*/
-#include "lttng/domain-internal.hpp"
#include "common/macros.hpp"
+#include "lttng/domain-internal.hpp"
const char *lttng_domain_type_str(enum lttng_domain_type domain_type)
{
#include <common/dynamic-array.hpp>
void lttng_dynamic_array_init(struct lttng_dynamic_array *array,
- size_t element_size,
- lttng_dynamic_array_element_destructor destructor)
+ size_t element_size,
+ lttng_dynamic_array_element_destructor destructor)
{
lttng_dynamic_buffer_init(&array->buffer);
array->element_size = element_size;
array->destructor = destructor;
}
-int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array,
- size_t new_element_count)
+int lttng_dynamic_array_set_count(struct lttng_dynamic_array *array, size_t new_element_count)
{
int ret;
size_t i;
for (i = new_element_count; i < array->size; i++) {
- void *element = lttng_dynamic_array_get_element(
- array, i);
+ void *element = lttng_dynamic_array_get_element(array, i);
array->destructor(element);
}
array->size = new_element_count;
ret = lttng_dynamic_buffer_set_size(&array->buffer,
- new_element_count * array->element_size);
+ new_element_count * array->element_size);
end:
return ret;
}
-int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array,
- const void *element)
+int lttng_dynamic_array_add_element(struct lttng_dynamic_array *array, const void *element)
{
int ret;
goto end;
}
- ret = lttng_dynamic_buffer_append(&array->buffer, element,
- array->element_size);
+ ret = lttng_dynamic_buffer_append(&array->buffer, element, array->element_size);
if (ret) {
goto end;
}
return ret;
}
-int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array,
- size_t element_index)
+int lttng_dynamic_array_remove_element(struct lttng_dynamic_array *array, size_t element_index)
{
- void *element = lttng_dynamic_array_get_element(array,
- element_index);
+ void *element = lttng_dynamic_array_get_element(array, element_index);
if (array->destructor) {
array->destructor(element);
}
if (element_index != lttng_dynamic_array_get_count(array) - 1) {
- void *next_element = lttng_dynamic_array_get_element(array,
- element_index + 1);
+ void *next_element = lttng_dynamic_array_get_element(array, element_index + 1);
- memmove(element, next_element,
- (array->size - element_index - 1) * array->element_size);
+ memmove(element,
+ next_element,
+ (array->size - element_index - 1) * array->element_size);
}
array->size--;
return lttng_dynamic_buffer_set_size(&array->buffer,
- array->buffer.size - array->element_size);
+ array->buffer.size - array->element_size);
}
void lttng_dynamic_array_reset(struct lttng_dynamic_array *array)
size_t i;
for (i = 0; i < lttng_dynamic_array_get_count(array); i++) {
- array->destructor(lttng_dynamic_array_get_element(array,
- i));
+ array->destructor(lttng_dynamic_array_get_element(array, i));
}
}
size_t i;
for (i = 0; i < lttng_dynamic_array_get_count(array); i++) {
- array->destructor(lttng_dynamic_array_get_element(array,
- i));
+ array->destructor(lttng_dynamic_array_get_element(array, i));
}
}
array->size = 0;
}
-void lttng_dynamic_pointer_array_init(
- struct lttng_dynamic_pointer_array *array,
- lttng_dynamic_pointer_array_destructor destructor)
+void lttng_dynamic_pointer_array_init(struct lttng_dynamic_pointer_array *array,
+ lttng_dynamic_pointer_array_destructor destructor)
{
lttng_dynamic_array_init(&array->array, sizeof(void *), destructor);
-}
+}
-int lttng_dynamic_pointer_array_remove_pointer(
- struct lttng_dynamic_pointer_array *array, size_t index)
+int lttng_dynamic_pointer_array_remove_pointer(struct lttng_dynamic_pointer_array *array,
+ size_t index)
{
int ret;
- const lttng_dynamic_array_element_destructor destructor =
- array->array.destructor;
+ const lttng_dynamic_array_element_destructor destructor = array->array.destructor;
/*
* Prevent the destructor from being used by the underlying
*/
array->array.destructor = NULL;
if (destructor) {
- destructor(lttng_dynamic_pointer_array_get_pointer(array,
- index));
+ destructor(lttng_dynamic_pointer_array_get_pointer(array, index));
}
ret = lttng_dynamic_array_remove_element(&array->array, index);
array->array.destructor = destructor;
}
/* Release any memory used by the dynamic array. */
-void lttng_dynamic_pointer_array_reset(
- struct lttng_dynamic_pointer_array *array)
+void lttng_dynamic_pointer_array_reset(struct lttng_dynamic_pointer_array *array)
{
if (array->array.destructor) {
size_t i, count = lttng_dynamic_pointer_array_get_count(array);
for (i = 0; i < count; i++) {
- void *ptr = lttng_dynamic_pointer_array_get_pointer(
- array, i);
+ void *ptr = lttng_dynamic_pointer_array_get_pointer(array, i);
array->array.destructor(ptr);
}
/*
lttng_dynamic_array_reset(&array->array);
}
-void lttng_dynamic_pointer_array_clear(
- struct lttng_dynamic_pointer_array *array)
+void lttng_dynamic_pointer_array_clear(struct lttng_dynamic_pointer_array *array)
{
- const lttng_dynamic_array_element_destructor destructor =
- array->array.destructor;
+ const lttng_dynamic_array_element_destructor destructor = array->array.destructor;
/*
* Prevent the destructor from being used by the underlying
size_t i, count = lttng_dynamic_pointer_array_get_count(array);
for (i = 0; i < count; i++) {
- void *ptr = lttng_dynamic_pointer_array_get_pointer(
- array, i);
+ void *ptr = lttng_dynamic_pointer_array_get_pointer(array, i);
destructor(ptr);
}
}
*
*/
-#include <common/dynamic-buffer.hpp>
#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
#include <common/utils.hpp>
/*
* Round to (upper) power of two, val is returned if it already is a power of
* two.
*/
-static
-size_t round_to_power_of_2(size_t val)
+static size_t round_to_power_of_2(size_t val)
{
size_t rounded;
const int order = utils_get_count_order_u64(val);
memset(buffer, 0, sizeof(*buffer));
}
-int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer,
- const void *buf, size_t len)
+int lttng_dynamic_buffer_append(struct lttng_dynamic_buffer *buffer, const void *buf, size_t len)
{
int ret = 0;
LTTNG_ASSERT(buffer->_capacity >= buffer->size);
if (buffer->_capacity < (len + buffer->size)) {
- ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->_capacity +
- (len - (buffer->_capacity - buffer->size)));
+ ret = lttng_dynamic_buffer_set_capacity(
+ buffer, buffer->_capacity + (len - (buffer->_capacity - buffer->size)));
if (ret) {
goto end;
}
}
int lttng_dynamic_buffer_append_buffer(struct lttng_dynamic_buffer *dst_buffer,
- const struct lttng_dynamic_buffer *src_buffer)
+ const struct lttng_dynamic_buffer *src_buffer)
{
int ret;
goto end;
}
- ret = lttng_dynamic_buffer_append(dst_buffer, src_buffer->data,
- src_buffer->size);
+ ret = lttng_dynamic_buffer_append(dst_buffer, src_buffer->data, src_buffer->size);
end:
return ret;
}
int lttng_dynamic_buffer_append_view(struct lttng_dynamic_buffer *buffer,
- const struct lttng_buffer_view *src)
+ const struct lttng_buffer_view *src)
{
int ret;
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer, src->data,
- src->size);
+ ret = lttng_dynamic_buffer_append(buffer, src->data, src->size);
end:
return ret;
}
-int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer,
- size_t new_size)
+int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer, size_t new_size)
{
int ret = 0;
return ret;
}
-int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer,
- size_t demanded_capacity)
+int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer, size_t demanded_capacity)
{
int ret = 0;
void *new_buf;
- size_t new_capacity = demanded_capacity ?
- round_to_power_of_2(demanded_capacity) : 0;
+ size_t new_capacity = demanded_capacity ? round_to_power_of_2(demanded_capacity) : 0;
if (!buffer || demanded_capacity < buffer->size) {
/*
buffer->data = NULL;
}
-size_t lttng_dynamic_buffer_get_capacity_left(
- struct lttng_dynamic_buffer *buffer)
+size_t lttng_dynamic_buffer_get_capacity_left(struct lttng_dynamic_buffer *buffer)
{
if (!buffer) {
return 0;
#include <lttng/endpoint-internal.hpp>
-static
-struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
+static struct lttng_endpoint lttng_session_daemon_notification_endpoint_instance = {
.type = LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_NOTIFICATION,
};
-static
-struct lttng_endpoint lttng_session_daemon_command_endpoint_instance = {
+static struct lttng_endpoint lttng_session_daemon_command_endpoint_instance = {
.type = LTTNG_ENDPOINT_TYPE_DEFAULT_SESSIOND_COMMAND,
};
struct lttng_endpoint *lttng_session_daemon_notification_endpoint =
- <tng_session_daemon_notification_endpoint_instance;
+ <tng_session_daemon_notification_endpoint_instance;
struct lttng_endpoint *lttng_session_daemon_command_endpoint =
- <tng_session_daemon_command_endpoint_instance;
+ <tng_session_daemon_command_endpoint_instance;
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/list-internal.hpp>
#include <lttng/action/path-internal.hpp>
#include <lttng/error-query-internal.hpp>
#include <lttng/error-query.h>
#include <lttng/trigger/trigger-internal.hpp>
+
#include <stddef.h>
struct lttng_error_query {
} LTTNG_PACKED;
} /* namespace */
-static
-enum lttng_error_code lttng_error_query_result_mi_serialize(
- const struct lttng_error_query_result *result,
- struct mi_writer *writer);
+static enum lttng_error_code
+lttng_error_query_result_mi_serialize(const struct lttng_error_query_result *result,
+ struct mi_writer *writer);
-static
-enum lttng_error_code lttng_error_query_result_counter_mi_serialize(
- const struct lttng_error_query_result *result,
- struct mi_writer *writer);
+static enum lttng_error_code
+lttng_error_query_result_counter_mi_serialize(const struct lttng_error_query_result *result,
+ struct mi_writer *writer);
-struct lttng_error_query *lttng_error_query_trigger_create(
- const struct lttng_trigger *trigger)
+struct lttng_error_query *lttng_error_query_trigger_create(const struct lttng_trigger *trigger)
{
struct lttng_error_query_trigger *query = NULL;
struct lttng_trigger *trigger_copy = NULL;
return query ? &query->parent : NULL;
}
-struct lttng_error_query *lttng_error_query_condition_create(
- const struct lttng_trigger *trigger)
+struct lttng_error_query *lttng_error_query_condition_create(const struct lttng_trigger *trigger)
{
struct lttng_error_query_condition *query = NULL;
struct lttng_trigger *trigger_copy = NULL;
return query ? &query->parent : NULL;
}
-static
-struct lttng_action *get_trigger_action_from_path(
- struct lttng_trigger *trigger,
- const struct lttng_action_path *action_path)
+static struct lttng_action *
+get_trigger_action_from_path(struct lttng_trigger *trigger,
+ const struct lttng_action_path *action_path)
{
size_t index_count, i;
enum lttng_action_path_status path_status;
struct lttng_action *current_action = NULL;
- path_status = lttng_action_path_get_index_count(
- action_path, &index_count);
+ path_status = lttng_action_path_get_index_count(action_path, &index_count);
if (path_status != LTTNG_ACTION_PATH_STATUS_OK) {
goto end;
}
for (i = 0; i < index_count; i++) {
uint64_t path_index;
- path_status = lttng_action_path_get_index_at_index(
- action_path, i, &path_index);
- current_action = lttng_action_list_borrow_mutable_at_index(
- current_action, path_index);
+ path_status = lttng_action_path_get_index_at_index(action_path, i, &path_index);
+ current_action =
+ lttng_action_list_borrow_mutable_at_index(current_action, path_index);
if (!current_action) {
/* Invalid action path. */
goto end;
return current_action;
}
-static
-bool is_valid_action_path(const struct lttng_trigger *trigger,
- const struct lttng_action_path *action_path)
+static bool is_valid_action_path(const struct lttng_trigger *trigger,
+ const struct lttng_action_path *action_path)
{
/*
* While 'trigger's constness is casted-away, the trigger and resulting
* action are not modified; we merely check for the action's existence.
*/
- return !!get_trigger_action_from_path(
- (struct lttng_trigger *) trigger, action_path);
+ return !!get_trigger_action_from_path((struct lttng_trigger *) trigger, action_path);
}
-struct lttng_error_query *lttng_error_query_action_create(
- const struct lttng_trigger *trigger,
- const struct lttng_action_path *action_path)
+struct lttng_error_query *
+lttng_error_query_action_create(const struct lttng_trigger *trigger,
+ const struct lttng_action_path *action_path)
{
struct lttng_error_query_action *query = NULL;
struct lttng_trigger *trigger_copy = NULL;
int ret_copy;
- if (!trigger || !action_path ||
- !is_valid_action_path(trigger, action_path)) {
+ if (!trigger || !action_path || !is_valid_action_path(trigger, action_path)) {
goto end;
}
case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
{
struct lttng_error_query_trigger *trigger_query =
- lttng::utils::container_of(query, <tng_error_query_trigger::parent);
+ lttng::utils::container_of(query, <tng_error_query_trigger::parent);
lttng_trigger_put(trigger_query->trigger);
free(trigger_query);
}
case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
{
- struct lttng_error_query_condition *condition_query = lttng::utils::container_of(
- query, <tng_error_query_condition::parent);
+ struct lttng_error_query_condition *condition_query =
+ lttng::utils::container_of(query, <tng_error_query_condition::parent);
lttng_trigger_put(condition_query->trigger);
free(condition_query);
}
case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
{
- struct lttng_error_query_action *action_query = lttng::utils::container_of(
- query, <tng_error_query_action::parent);
+ struct lttng_error_query_action *action_query =
+ lttng::utils::container_of(query, <tng_error_query_action::parent);
lttng_trigger_put(action_query->trigger);
lttng_action_path_destroy(action_query->action_path);
}
}
-static
-int lttng_error_query_result_counter_serialize(
- const struct lttng_error_query_result *result,
- struct lttng_payload *payload)
+static int lttng_error_query_result_counter_serialize(const struct lttng_error_query_result *result,
+ struct lttng_payload *payload)
{
const struct lttng_error_query_result_counter *counter_result;
LTTNG_ASSERT(result->type == LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER);
- counter_result = lttng::utils::container_of(
- result, <tng_error_query_result_counter::parent);
+ counter_result =
+ lttng::utils::container_of(result, <tng_error_query_result_counter::parent);
lttng_error_query_result_counter_comm comm = {
.value = counter_result->value,
};
- return lttng_dynamic_buffer_append(&payload->buffer,
- &comm,
- sizeof(struct lttng_error_query_result_counter_comm));
+ return lttng_dynamic_buffer_append(
+ &payload->buffer, &comm, sizeof(struct lttng_error_query_result_counter_comm));
}
-int lttng_error_query_result_serialize(
- const struct lttng_error_query_result *result,
- struct lttng_payload *payload)
+int lttng_error_query_result_serialize(const struct lttng_error_query_result *result,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_error_query_result_comm header;
header.description_len = (typeof(header.name_len)) strlen(result->description) + 1;
/* Header. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &header, sizeof(header));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &header, sizeof(header));
if (ret) {
ERR("Failed to append error query result communication header to payload");
goto end;
}
/* Name. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, result->name, header.name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, result->name, header.name_len);
if (ret) {
ERR("Failed to append error query result name to payload");
goto end;
}
/* Description. */
- ret = lttng_dynamic_buffer_append(&payload->buffer, result->description,
- header.description_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, result->description, header.description_len);
if (ret) {
ERR("Failed to append error query result description to payload");
goto end;
/* Type-specific payload. */
switch (result->type) {
case LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER:
- ret = lttng_error_query_result_counter_serialize(
- result, payload);
+ ret = lttng_error_query_result_counter_serialize(result, payload);
if (ret) {
ERR("Failed to serialize counter error query result");
goto end;
return ret;
}
-static
-int lttng_error_query_result_init(
- struct lttng_error_query_result *result,
- enum lttng_error_query_result_type result_type,
- const char *name,
- const char *description)
+static int lttng_error_query_result_init(struct lttng_error_query_result *result,
+ enum lttng_error_query_result_type result_type,
+ const char *name,
+ const char *description)
{
int ret;
}
struct lttng_error_query_result *
-lttng_error_query_result_counter_create(
- const char *name, const char *description, uint64_t value)
+lttng_error_query_result_counter_create(const char *name, const char *description, uint64_t value)
{
int init_ret;
struct lttng_error_query_result_counter *counter;
goto end;
}
- init_ret = lttng_error_query_result_init(&counter->parent,
- LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER, name,
- description);
+ init_ret = lttng_error_query_result_init(
+ &counter->parent, LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER, name, description);
if (init_ret) {
goto error;
}
return counter ? &counter->parent : NULL;
}
-static
-void destroy_result(void *ptr)
+static void destroy_result(void *ptr)
{
struct lttng_error_query_result *result = (typeof(result)) ptr;
return set;
}
-int lttng_error_query_results_add_result(
- struct lttng_error_query_results *results,
- struct lttng_error_query_result *result)
+int lttng_error_query_results_add_result(struct lttng_error_query_results *results,
+ struct lttng_error_query_result *result)
{
- return lttng_dynamic_pointer_array_add_pointer(
- &results->results, result);
+ return lttng_dynamic_pointer_array_add_pointer(&results->results, result);
}
-ssize_t lttng_error_query_result_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_error_query_result **result)
+ssize_t lttng_error_query_result_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_error_query_result **result)
{
ssize_t used_size = 0;
struct lttng_error_query_result_comm *header;
struct lttng_payload_view header_view =
- lttng_payload_view_from_view(view, 0, sizeof(*header));
+ lttng_payload_view_from_view(view, 0, sizeof(*header));
const char *name;
const char *description;
{
struct lttng_payload_view name_view =
- lttng_payload_view_from_view(view, used_size,
- header->name_len);
+ lttng_payload_view_from_view(view, used_size, header->name_len);
if (!lttng_payload_view_is_valid(&name_view) ||
- !lttng_buffer_view_contains_string(
- &name_view.buffer,
- name_view.buffer.data,
- header->name_len)) {
+ !lttng_buffer_view_contains_string(
+ &name_view.buffer, name_view.buffer.data, header->name_len)) {
used_size = -1;
goto end;
}
{
struct lttng_payload_view description_view =
- lttng_payload_view_from_view(view, used_size,
- header->description_len);
+ lttng_payload_view_from_view(view, used_size, header->description_len);
if (!lttng_payload_view_is_valid(&description_view) ||
- !lttng_buffer_view_contains_string(
- &description_view.buffer,
- description_view.buffer.data,
- header->description_len)) {
+ !lttng_buffer_view_contains_string(&description_view.buffer,
+ description_view.buffer.data,
+ header->description_len)) {
used_size = -1;
goto end;
}
{
struct lttng_error_query_result_counter_comm *counter;
struct lttng_payload_view counter_payload_view =
- lttng_payload_view_from_view(view, used_size,
- sizeof(*counter));
+ lttng_payload_view_from_view(view, used_size, sizeof(*counter));
if (!lttng_payload_view_is_valid(&counter_payload_view)) {
used_size = -1;
}
counter = (typeof(counter)) counter_payload_view.buffer.data;
- *result = lttng_error_query_result_counter_create(
- name, description, counter->value);
+ *result =
+ lttng_error_query_result_counter_create(name, description, counter->value);
if (!*result) {
used_size = -1;
goto end;
return used_size;
}
-int lttng_error_query_results_serialize(
- const struct lttng_error_query_results *results,
- struct lttng_payload *payload)
+int lttng_error_query_results_serialize(const struct lttng_error_query_results *results,
+ struct lttng_payload *payload)
{
int ret;
size_t result_index;
- const size_t result_count = lttng_dynamic_pointer_array_get_count(
- &results->results);
+ const size_t result_count = lttng_dynamic_pointer_array_get_count(&results->results);
struct lttng_error_query_results_comm header;
header.count = (decltype(header.count)) result_count;
/* Results. */
for (result_index = 0; result_index < result_count; result_index++) {
- const struct lttng_error_query_result *result = (typeof(result))
- lttng_dynamic_pointer_array_get_pointer(
- &results->results,
- result_index);
+ const struct lttng_error_query_result *result =
+ (typeof(result)) lttng_dynamic_pointer_array_get_pointer(&results->results,
+ result_index);
ret = lttng_error_query_result_serialize(result, payload);
if (ret) {
return ret;
}
-ssize_t lttng_error_query_results_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_error_query_results **_results)
+ssize_t lttng_error_query_results_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_error_query_results **_results)
{
size_t result_index;
ssize_t total_used_size = 0;
struct lttng_error_query_results_comm *header;
struct lttng_payload_view header_view =
- lttng_payload_view_from_view(view, 0, sizeof(*header));
+ lttng_payload_view_from_view(view, 0, sizeof(*header));
struct lttng_error_query_results *results = NULL;
if (!lttng_payload_view_is_valid(&header_view)) {
ssize_t used_size;
struct lttng_error_query_result *result;
struct lttng_payload_view result_view =
- lttng_payload_view_from_view(
- view, total_used_size, -1);
+ lttng_payload_view_from_view(view, total_used_size, -1);
if (!lttng_payload_view_is_valid(&result_view)) {
total_used_size = -1;
goto end;
}
- used_size = lttng_error_query_result_create_from_payload(
- &result_view, &result);
+ used_size = lttng_error_query_result_create_from_payload(&result_view, &result);
if (used_size < 0) {
total_used_size = -1;
goto end;
total_used_size += used_size;
- if (lttng_dynamic_pointer_array_add_pointer(
- &results->results, result)) {
+ if (lttng_dynamic_pointer_array_add_pointer(&results->results, result)) {
lttng_error_query_result_destroy(result);
total_used_size = -1;
goto end;
return total_used_size;
}
-static
-int lttng_error_query_trigger_serialize(const struct lttng_error_query *query,
- struct lttng_payload *payload)
+static int lttng_error_query_trigger_serialize(const struct lttng_error_query *query,
+ struct lttng_payload *payload)
{
int ret;
const struct lttng_error_query_trigger *query_trigger =
- lttng::utils::container_of(query, <tng_error_query_trigger::parent);
+ lttng::utils::container_of(query, <tng_error_query_trigger::parent);
if (!lttng_trigger_validate(query_trigger->trigger)) {
ret = -1;
return ret;
}
-static
-int lttng_error_query_condition_serialize(const struct lttng_error_query *query,
- struct lttng_payload *payload)
+static int lttng_error_query_condition_serialize(const struct lttng_error_query *query,
+ struct lttng_payload *payload)
{
int ret;
const struct lttng_error_query_condition *query_trigger =
- lttng::utils::container_of(query, <tng_error_query_condition::parent);
+ lttng::utils::container_of(query, <tng_error_query_condition::parent);
if (!lttng_trigger_validate(query_trigger->trigger)) {
ret = -1;
return ret;
}
-static
-int lttng_error_query_action_serialize(const struct lttng_error_query *query,
- struct lttng_payload *payload)
+static int lttng_error_query_action_serialize(const struct lttng_error_query *query,
+ struct lttng_payload *payload)
{
int ret;
const struct lttng_error_query_action *query_action =
- lttng::utils::container_of(query, <tng_error_query_action::parent);
+ lttng::utils::container_of(query, <tng_error_query_action::parent);
if (!lttng_trigger_validate(query_action->trigger)) {
ret = -1;
return ret;
}
-enum lttng_error_query_target_type lttng_error_query_get_target_type(
- const struct lttng_error_query *query)
+enum lttng_error_query_target_type
+lttng_error_query_get_target_type(const struct lttng_error_query *query)
{
return query->target_type;
}
-const struct lttng_trigger *lttng_error_query_trigger_borrow_target(
- const struct lttng_error_query *query)
+const struct lttng_trigger *
+lttng_error_query_trigger_borrow_target(const struct lttng_error_query *query)
{
const struct lttng_error_query_trigger *query_trigger =
- lttng::utils::container_of(query, <tng_error_query_trigger::parent);
+ lttng::utils::container_of(query, <tng_error_query_trigger::parent);
return query_trigger->trigger;
}
-const struct lttng_trigger *lttng_error_query_condition_borrow_target(
- const struct lttng_error_query *query)
+const struct lttng_trigger *
+lttng_error_query_condition_borrow_target(const struct lttng_error_query *query)
{
const struct lttng_error_query_condition *query_trigger =
- lttng::utils::container_of(query, <tng_error_query_condition::parent);
+ lttng::utils::container_of(query, <tng_error_query_condition::parent);
return query_trigger->trigger;
}
-const struct lttng_trigger *lttng_error_query_action_borrow_trigger_target(
- const struct lttng_error_query *query)
+const struct lttng_trigger *
+lttng_error_query_action_borrow_trigger_target(const struct lttng_error_query *query)
{
const struct lttng_error_query_action *query_action =
- lttng::utils::container_of(query, <tng_error_query_action::parent);
+ lttng::utils::container_of(query, <tng_error_query_action::parent);
return query_action->trigger;
}
-struct lttng_action *lttng_error_query_action_borrow_action_target(
- const struct lttng_error_query *query, struct lttng_trigger *trigger)
+struct lttng_action *
+lttng_error_query_action_borrow_action_target(const struct lttng_error_query *query,
+ struct lttng_trigger *trigger)
{
const struct lttng_error_query_action *query_action =
- lttng::utils::container_of(query, <tng_error_query_action::parent);
+ lttng::utils::container_of(query, <tng_error_query_action::parent);
- return get_trigger_action_from_path(
- trigger, query_action->action_path);
+ return get_trigger_action_from_path(trigger, query_action->action_path);
}
int lttng_error_query_serialize(const struct lttng_error_query *query,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_error_query_comm header;
header.target_type = (decltype(header.target_type)) query->target_type;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &header, sizeof(header));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &header, sizeof(header));
if (ret) {
ERR("Failed to append error query header to payload");
goto end;
}
ssize_t lttng_error_query_create_from_payload(struct lttng_payload_view *view,
- struct lttng_error_query **query)
+ struct lttng_error_query **query)
{
ssize_t used_size = 0;
struct lttng_error_query_comm *header;
struct lttng_trigger *trigger = NULL;
struct lttng_payload_view header_view =
- lttng_payload_view_from_view(view, 0, sizeof(*header));
+ lttng_payload_view_from_view(view, 0, sizeof(*header));
if (!lttng_payload_view_is_valid(&header_view)) {
ERR("Failed to map error query header");
{
ssize_t trigger_used_size;
struct lttng_payload_view trigger_view =
- lttng_payload_view_from_view(
- view, used_size, -1);
+ lttng_payload_view_from_view(view, used_size, -1);
if (!lttng_payload_view_is_valid(&trigger_view)) {
used_size = -1;
goto end;
}
- trigger_used_size = lttng_trigger_create_from_payload(
- &trigger_view, &trigger);
+ trigger_used_size = lttng_trigger_create_from_payload(&trigger_view, &trigger);
if (trigger_used_size < 0) {
used_size = -1;
goto end;
{
ssize_t trigger_used_size;
struct lttng_payload_view trigger_view =
- lttng_payload_view_from_view(
- view, used_size, -1);
+ lttng_payload_view_from_view(view, used_size, -1);
if (!lttng_payload_view_is_valid(&trigger_view)) {
used_size = -1;
goto end;
}
- trigger_used_size = lttng_trigger_create_from_payload(
- &trigger_view, &trigger);
+ trigger_used_size = lttng_trigger_create_from_payload(&trigger_view, &trigger);
if (trigger_used_size < 0) {
used_size = -1;
goto end;
{
ssize_t trigger_used_size;
struct lttng_payload_view trigger_view =
- lttng_payload_view_from_view(
- view, used_size, -1);
+ lttng_payload_view_from_view(view, used_size, -1);
if (!lttng_payload_view_is_valid(&trigger_view)) {
used_size = -1;
goto end;
}
- trigger_used_size = lttng_trigger_create_from_payload(
- &trigger_view, &trigger);
+ trigger_used_size =
+ lttng_trigger_create_from_payload(&trigger_view, &trigger);
if (trigger_used_size < 0) {
used_size = -1;
goto end;
{
ssize_t action_path_used_size;
struct lttng_payload_view action_path_view =
- lttng_payload_view_from_view(
- view, used_size, -1);
+ lttng_payload_view_from_view(view, used_size, -1);
if (!lttng_payload_view_is_valid(&action_path_view)) {
used_size = -1;
}
action_path_used_size = lttng_action_path_create_from_payload(
- &action_path_view, &action_path);
+ &action_path_view, &action_path);
if (action_path_used_size < 0) {
used_size = -1;
goto end;
used_size += action_path_used_size;
}
- *query = lttng_error_query_action_create(
- trigger, action_path);
+ *query = lttng_error_query_action_create(trigger, action_path);
lttng_action_path_destroy(action_path);
if (!*query) {
used_size = -1;
return used_size;
}
-enum lttng_error_query_results_status lttng_error_query_results_get_count(
- const struct lttng_error_query_results *results,
- unsigned int *count)
+enum lttng_error_query_results_status
+lttng_error_query_results_get_count(const struct lttng_error_query_results *results,
+ unsigned int *count)
{
enum lttng_error_query_results_status status;
}
enum lttng_error_query_results_status
-lttng_error_query_results_get_result(
- const struct lttng_error_query_results *results,
- const struct lttng_error_query_result **result,
- unsigned int index)
+lttng_error_query_results_get_result(const struct lttng_error_query_results *results,
+ const struct lttng_error_query_result **result,
+ unsigned int index)
{
unsigned int result_count;
enum lttng_error_query_results_status status;
goto end;
}
- *result = (typeof(*result)) lttng_dynamic_pointer_array_get_pointer(
- &results->results, index);
+ *result =
+ (typeof(*result)) lttng_dynamic_pointer_array_get_pointer(&results->results, index);
LTTNG_ASSERT(*result);
status = LTTNG_ERROR_QUERY_RESULTS_STATUS_OK;
end:
return status;
}
-void lttng_error_query_results_destroy(
- struct lttng_error_query_results *results)
+void lttng_error_query_results_destroy(struct lttng_error_query_results *results)
{
if (!results) {
return;
return result ? result->type : LTTNG_ERROR_QUERY_RESULT_TYPE_UNKNOWN;
}
-enum lttng_error_query_result_status lttng_error_query_result_get_name(
- const struct lttng_error_query_result *result,
- const char **name)
+enum lttng_error_query_result_status
+lttng_error_query_result_get_name(const struct lttng_error_query_result *result, const char **name)
{
enum lttng_error_query_result_status status;
return status;
}
-enum lttng_error_query_result_status lttng_error_query_result_get_description(
- const struct lttng_error_query_result *result,
- const char **description)
+enum lttng_error_query_result_status
+lttng_error_query_result_get_description(const struct lttng_error_query_result *result,
+ const char **description)
{
enum lttng_error_query_result_status status;
return status;
}
-enum lttng_error_query_result_status lttng_error_query_result_counter_get_value(
- const struct lttng_error_query_result *result,
- uint64_t *value)
+enum lttng_error_query_result_status
+lttng_error_query_result_counter_get_value(const struct lttng_error_query_result *result,
+ uint64_t *value)
{
enum lttng_error_query_result_status status;
const struct lttng_error_query_result_counter *counter_result;
- if (!result || !value ||
- result->type != LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
+ if (!result || !value || result->type != LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
status = LTTNG_ERROR_QUERY_RESULT_STATUS_INVALID_PARAMETER;
goto end;
}
- counter_result = lttng::utils::container_of(
- result, <tng_error_query_result_counter::parent);
+ counter_result =
+ lttng::utils::container_of(result, <tng_error_query_result_counter::parent);
*value = counter_result->value;
status = LTTNG_ERROR_QUERY_RESULT_STATUS_OK;
return status;
}
-static
-enum lttng_error_code lttng_error_query_result_counter_mi_serialize(
- const struct lttng_error_query_result *result,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_error_query_result_counter_mi_serialize(const struct lttng_error_query_result *result,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
/* Open error query result counter element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_error_query_result_counter);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_error_query_result_counter);
if (ret) {
goto mi_error;
}
/* Value. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_error_query_result_counter_value,
- value);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_error_query_result_counter_value, value);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-enum lttng_error_code lttng_error_query_result_mi_serialize(
- const struct lttng_error_query_result *result,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_error_query_result_mi_serialize(const struct lttng_error_query_result *result,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
result_status = lttng_error_query_result_get_name(result, &name);
LTTNG_ASSERT(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
- result_status = lttng_error_query_result_get_description(
- result, &description);
+ result_status = lttng_error_query_result_get_description(result, &description);
LTTNG_ASSERT(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
/* Open error query result element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_error_query_result);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_error_query_result);
if (ret) {
goto mi_error;
}
/* Name. */
ret = mi_lttng_writer_write_element_string(
- writer, mi_lttng_element_error_query_result_name, name);
+ writer, mi_lttng_element_error_query_result_name, name);
if (ret) {
goto mi_error;
}
/* Description. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_error_query_result_description,
- description);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_error_query_result_description, description);
if (ret) {
goto mi_error;
}
/* Serialize the result according to its sub type. */
switch (type) {
case LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER:
- ret_code = lttng_error_query_result_counter_mi_serialize(
- result, writer);
+ ret_code = lttng_error_query_result_counter_mi_serialize(result, writer);
break;
default:
abort();
return ret_code;
}
-enum lttng_error_code lttng_error_query_results_mi_serialize(
- const struct lttng_error_query_results *results,
- struct mi_writer *writer)
+enum lttng_error_code
+lttng_error_query_results_mi_serialize(const struct lttng_error_query_results *results,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
/* Open error query results element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_error_query_results);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_error_query_results);
if (ret) {
goto mi_error;
}
for (i = 0; i < count; i++) {
const struct lttng_error_query_result *result;
- results_status = lttng_error_query_results_get_result(
- results, &result, i);
+ results_status = lttng_error_query_results_get_result(results, &result, i);
LTTNG_ASSERT(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
/* A single error query result. */
*/
#define _LGPL_SOURCE
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
+#include "error.hpp"
#include <common/common.hpp>
-#include <common/thread.hpp>
#include <common/compat/errno.hpp>
#include <common/compat/getenv.hpp>
+#include <common/thread.hpp>
+
#include <lttng/lttng-error.h>
-#include "error.hpp"
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
/*
* lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
}
/* Format time in the TLS variable. */
- ret = snprintf(URCU_TLS(error_log_time).str, sizeof(URCU_TLS(error_log_time).str),
- "%02d:%02d:%02d.%09ld",
- tm.tm_hour, tm.tm_min, tm.tm_sec, tp.tv_nsec);
+ ret = snprintf(URCU_TLS(error_log_time).str,
+ sizeof(URCU_TLS(error_log_time).str),
+ "%02d:%02d:%02d.%09ld",
+ tm.tm_hour,
+ tm.tm_min,
+ tm.tm_sec,
+ tp.tv_nsec);
if (ret < 0) {
goto error;
}
/*
* Human readable error message.
*/
-static
-const char *lttng_error_code_str(lttng_error_code code)
+static const char *lttng_error_code_str(lttng_error_code code)
{
switch (code) {
case LTTNG_OK:
*
*/
+#include <common/error.hpp>
+#include <common/macros.hpp>
+
+#include <lttng/condition/buffer-usage-internal.hpp>
#include <lttng/condition/condition-internal.hpp>
#include <lttng/condition/evaluation-internal.hpp>
-#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/session-consumed-size-internal.hpp>
#include <lttng/condition/session-rotation-internal.hpp>
-#include <lttng/condition/event-rule-matches-internal.hpp>
-#include <common/macros.hpp>
-#include <common/error.hpp>
+
#include <stdbool.h>
-void lttng_evaluation_init(struct lttng_evaluation *evaluation,
- enum lttng_condition_type type)
+void lttng_evaluation_init(struct lttng_evaluation *evaluation, enum lttng_condition_type type)
{
evaluation->type = type;
}
int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_evaluation_comm evaluation_comm;
evaluation_comm.type = (int8_t) evaluation->type;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &evaluation_comm,
- sizeof(evaluation_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &evaluation_comm, sizeof(evaluation_comm));
if (ret) {
goto end;
}
return ret;
}
-ssize_t lttng_evaluation_create_from_payload(
- const struct lttng_condition *condition,
- struct lttng_payload_view *src_view,
- struct lttng_evaluation **evaluation)
+ssize_t lttng_evaluation_create_from_payload(const struct lttng_condition *condition,
+ struct lttng_payload_view *src_view,
+ struct lttng_evaluation **evaluation)
{
ssize_t ret, evaluation_size = 0;
const struct lttng_evaluation_comm *evaluation_comm;
struct lttng_payload_view evaluation_comm_view =
- lttng_payload_view_from_view(
- src_view, 0, sizeof(*evaluation_comm));
+ lttng_payload_view_from_view(src_view, 0, sizeof(*evaluation_comm));
struct lttng_payload_view evaluation_view =
- lttng_payload_view_from_view(src_view,
- sizeof(*evaluation_comm), -1);
+ lttng_payload_view_from_view(src_view, sizeof(*evaluation_comm), -1);
if (!src_view || !evaluation) {
ret = -1;
switch ((enum lttng_condition_type) evaluation_comm->type) {
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
- ret = lttng_evaluation_buffer_usage_low_create_from_payload(
- &evaluation_view, evaluation);
+ ret = lttng_evaluation_buffer_usage_low_create_from_payload(&evaluation_view,
+ evaluation);
if (ret < 0) {
goto end;
}
evaluation_size += ret;
break;
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
- ret = lttng_evaluation_buffer_usage_high_create_from_payload(
- &evaluation_view, evaluation);
+ ret = lttng_evaluation_buffer_usage_high_create_from_payload(&evaluation_view,
+ evaluation);
if (ret < 0) {
goto end;
}
evaluation_size += ret;
break;
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
- ret = lttng_evaluation_session_consumed_size_create_from_payload(
- &evaluation_view, evaluation);
+ ret = lttng_evaluation_session_consumed_size_create_from_payload(&evaluation_view,
+ evaluation);
if (ret < 0) {
goto end;
}
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
ret = lttng_evaluation_session_rotation_ongoing_create_from_payload(
- &evaluation_view, evaluation);
+ &evaluation_view, evaluation);
if (ret < 0) {
goto end;
}
break;
case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
ret = lttng_evaluation_session_rotation_completed_create_from_payload(
- &evaluation_view, evaluation);
+ &evaluation_view, evaluation);
if (ret < 0) {
goto end;
}
break;
case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
LTTNG_ASSERT(condition);
- LTTNG_ASSERT(condition->type ==
- LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+ LTTNG_ASSERT(condition->type == LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
ret = lttng_evaluation_event_rule_matches_create_from_payload(
- lttng::utils::container_of(condition,
- <tng_condition_event_rule_matches::parent),
- &evaluation_view, evaluation);
+ lttng::utils::container_of(condition,
+ <tng_condition_event_rule_matches::parent),
+ &evaluation_view,
+ evaluation);
if (ret < 0) {
goto end;
}
break;
default:
ERR("Attempted to create evaluation of unknown type (%i)",
- (int) evaluation_comm->type);
+ (int) evaluation_comm->type);
ret = -1;
goto end;
}
return ret;
}
-enum lttng_condition_type lttng_evaluation_get_type(
- const struct lttng_evaluation *evaluation)
+enum lttng_condition_type lttng_evaluation_get_type(const struct lttng_evaluation *evaluation)
{
return evaluation ? evaluation->type : LTTNG_CONDITION_TYPE_UNKNOWN;
}
*/
#define _LGPL_SOURCE
-#include <stddef.h>
-
#include <common/bytecode/bytecode.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>
+
+#include <stddef.h>
#include <stdio.h>
-enum lttng_event_expr_type lttng_event_expr_get_type(
- const struct lttng_event_expr *expr)
+enum lttng_event_expr_type lttng_event_expr_get_type(const struct lttng_event_expr *expr)
{
enum lttng_event_expr_type type;
return type;
}
-static
-struct lttng_event_expr *create_empty_expr(enum lttng_event_expr_type type,
- size_t size)
+static struct lttng_event_expr *create_empty_expr(enum lttng_event_expr_type type, size_t size)
{
struct lttng_event_expr *expr;
return expr;
}
-static
-struct lttng_event_expr_field *create_field_event_expr(
- enum lttng_event_expr_type type,
- const char *name)
+static struct lttng_event_expr_field *create_field_event_expr(enum lttng_event_expr_type type,
+ const char *name)
{
struct lttng_event_expr_field *expr = lttng::utils::container_of(
- create_empty_expr(type, sizeof(*expr)), <tng_event_expr_field::parent);
+ create_empty_expr(type, sizeof(*expr)), <tng_event_expr_field::parent);
if (!expr) {
goto error;
return expr;
}
-struct lttng_event_expr *lttng_event_expr_event_payload_field_create(
- const char *field_name)
+struct lttng_event_expr *lttng_event_expr_event_payload_field_create(const char *field_name)
{
struct lttng_event_expr *expr = NULL;
goto end;
}
- expr = &create_field_event_expr(
- LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD,
- field_name)->parent;
+ expr = &create_field_event_expr(LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD, field_name)
+ ->parent;
end:
return expr;
}
-struct lttng_event_expr *lttng_event_expr_channel_context_field_create(
- const char *field_name)
+struct lttng_event_expr *lttng_event_expr_channel_context_field_create(const char *field_name)
{
struct lttng_event_expr *expr = NULL;
goto end;
}
- expr = &create_field_event_expr(
- LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD,
- field_name)->parent;
+ expr = &create_field_event_expr(LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD, field_name)
+ ->parent;
end:
return expr;
}
-struct lttng_event_expr *lttng_event_expr_app_specific_context_field_create(
- const char *provider_name, const char *type_name)
+struct lttng_event_expr *
+lttng_event_expr_app_specific_context_field_create(const char *provider_name, const char *type_name)
{
struct lttng_event_expr_app_specific_context_field *expr = NULL;
struct lttng_event_expr *ret_parent_expr;
goto error;
}
- expr = lttng::utils::container_of(create_empty_expr(
- LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD,
- sizeof(*expr)),
- <tng_event_expr_app_specific_context_field::parent);
+ expr = lttng::utils::container_of(
+ create_empty_expr(LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD, sizeof(*expr)),
+ <tng_event_expr_app_specific_context_field::parent);
if (!expr) {
goto error;
}
return ret_parent_expr;
}
-struct lttng_event_expr *lttng_event_expr_array_field_element_create(
- struct lttng_event_expr *array_field_expr,
- unsigned int index)
+struct lttng_event_expr *
+lttng_event_expr_array_field_element_create(struct lttng_event_expr *array_field_expr,
+ unsigned int index)
{
struct lttng_event_expr_array_field_element *expr = NULL;
struct lttng_event_expr *ret_parent_expr;
/* The parent array field expression must be an l-value */
- if (!array_field_expr ||
- !lttng_event_expr_is_lvalue(array_field_expr)) {
+ if (!array_field_expr || !lttng_event_expr_is_lvalue(array_field_expr)) {
goto error;
}
- expr = lttng::utils::container_of(create_empty_expr(
- LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT,
- sizeof(*expr)),
- <tng_event_expr_array_field_element::parent);
+ expr = lttng::utils::container_of(
+ create_empty_expr(LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT, sizeof(*expr)),
+ <tng_event_expr_array_field_element::parent);
if (!expr) {
goto error;
}
return ret_parent_expr;
}
-const char *lttng_event_expr_event_payload_field_get_name(
- const struct lttng_event_expr *expr)
+const char *lttng_event_expr_event_payload_field_get_name(const struct lttng_event_expr *expr)
{
const char *ret = NULL;
goto end;
}
- ret = lttng::utils::container_of(expr,
- <tng_event_expr_field::parent)->name;
+ ret = lttng::utils::container_of(expr, <tng_event_expr_field::parent)->name;
end:
return ret;
}
-const char *lttng_event_expr_channel_context_field_get_name(
- const struct lttng_event_expr *expr)
+const char *lttng_event_expr_channel_context_field_get_name(const struct lttng_event_expr *expr)
{
const char *ret = NULL;
goto end;
}
- ret = lttng::utils::container_of(expr,
- <tng_event_expr_field::parent)->name;
+ ret = lttng::utils::container_of(expr, <tng_event_expr_field::parent)->name;
end:
return ret;
}
-const char *lttng_event_expr_app_specific_context_field_get_provider_name(
- const struct lttng_event_expr *expr)
+const char *
+lttng_event_expr_app_specific_context_field_get_provider_name(const struct lttng_event_expr *expr)
{
const char *ret = NULL;
goto end;
}
- ret = lttng::utils::container_of(expr,
- <tng_event_expr_app_specific_context_field::parent)->provider_name;
+ ret = lttng::utils::container_of(expr, <tng_event_expr_app_specific_context_field::parent)
+ ->provider_name;
end:
return ret;
}
-const char *lttng_event_expr_app_specific_context_field_get_type_name(
- const struct lttng_event_expr *expr)
+const char *
+lttng_event_expr_app_specific_context_field_get_type_name(const struct lttng_event_expr *expr)
{
const char *ret = NULL;
goto end;
}
- ret = lttng::utils::container_of(expr,
- <tng_event_expr_app_specific_context_field::parent)->type_name;
+ ret = lttng::utils::container_of(expr, <tng_event_expr_app_specific_context_field::parent)
+ ->type_name;
end:
return ret;
}
const struct lttng_event_expr *
-lttng_event_expr_array_field_element_get_parent_expr(
- const struct lttng_event_expr *expr)
+lttng_event_expr_array_field_element_get_parent_expr(const struct lttng_event_expr *expr)
{
const struct lttng_event_expr *ret = NULL;
goto end;
}
- ret = lttng::utils::container_of(expr,
- <tng_event_expr_array_field_element::parent)->array_field_expr;
+ ret = lttng::utils::container_of(expr, <tng_event_expr_array_field_element::parent)
+ ->array_field_expr;
end:
return ret;
}
-enum lttng_event_expr_status lttng_event_expr_array_field_element_get_index(
- const struct lttng_event_expr *expr, unsigned int *index)
+enum lttng_event_expr_status
+lttng_event_expr_array_field_element_get_index(const struct lttng_event_expr *expr,
+ unsigned int *index)
{
enum lttng_event_expr_status ret = LTTNG_EVENT_EXPR_STATUS_OK;
- if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT ||
- !index) {
+ if (!expr || expr->type != LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT || !index) {
ret = LTTNG_EVENT_EXPR_STATUS_INVALID;
goto end;
}
- *index = lttng::utils::container_of(expr,
- <tng_event_expr_array_field_element::parent)->index;
+ *index = lttng::utils::container_of(expr, <tng_event_expr_array_field_element::parent)
+ ->index;
end:
return ret;
}
bool lttng_event_expr_is_equal(const struct lttng_event_expr *expr_a,
- const struct lttng_event_expr *expr_b)
+ const struct lttng_event_expr *expr_b)
{
bool is_equal = true;
case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
{
const struct lttng_event_expr_field *field_expr_a =
- lttng::utils::container_of(expr_a,
- <tng_event_expr_field::parent);
+ lttng::utils::container_of(expr_a, <tng_event_expr_field::parent);
const struct lttng_event_expr_field *field_expr_b =
- lttng::utils::container_of(expr_b,
- <tng_event_expr_field::parent);
+ lttng::utils::container_of(expr_b, <tng_event_expr_field::parent);
if (strcmp(field_expr_a->name, field_expr_b->name) != 0) {
goto not_equal;
case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
{
const struct lttng_event_expr_app_specific_context_field *field_expr_a =
- lttng::utils::container_of(expr_a,
- <tng_event_expr_app_specific_context_field::parent);
+ lttng::utils::container_of(
+ expr_a, <tng_event_expr_app_specific_context_field::parent);
const struct lttng_event_expr_app_specific_context_field *field_expr_b =
- lttng::utils::container_of(expr_b,
- <tng_event_expr_app_specific_context_field::parent);
+ lttng::utils::container_of(
+ expr_b, <tng_event_expr_app_specific_context_field::parent);
- if (strcmp(field_expr_a->provider_name,
- field_expr_b->provider_name) != 0) {
+ if (strcmp(field_expr_a->provider_name, field_expr_b->provider_name) != 0) {
goto not_equal;
}
- if (strcmp(field_expr_a->type_name,
- field_expr_b->type_name) != 0) {
+ if (strcmp(field_expr_a->type_name, field_expr_b->type_name) != 0) {
goto not_equal;
}
case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
{
const struct lttng_event_expr_array_field_element *elem_expr_a =
- lttng::utils::container_of(expr_a,
- <tng_event_expr_array_field_element::parent);
+ lttng::utils::container_of(expr_a,
+ <tng_event_expr_array_field_element::parent);
const struct lttng_event_expr_array_field_element *elem_expr_b =
- lttng::utils::container_of(expr_b,
- <tng_event_expr_array_field_element::parent);
+ lttng::utils::container_of(expr_b,
+ <tng_event_expr_array_field_element::parent);
if (!lttng_event_expr_is_equal(elem_expr_a->array_field_expr,
- elem_expr_b->array_field_expr)) {
+ elem_expr_b->array_field_expr)) {
goto not_equal;
}
case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
{
struct lttng_event_expr_field *field_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_field::parent);
+ lttng::utils::container_of(expr, <tng_event_expr_field::parent);
free(field_expr->name);
break;
case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
{
struct lttng_event_expr_app_specific_context_field *field_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_app_specific_context_field::parent);
+ lttng::utils::container_of(
+ expr, <tng_event_expr_app_specific_context_field::parent);
free(field_expr->provider_name);
free(field_expr->type_name);
}
case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
{
- struct lttng_event_expr_array_field_element *elem_expr =
- lttng::utils::container_of(expr,
- <tng_event_expr_array_field_element::parent);
+ struct lttng_event_expr_array_field_element *elem_expr = lttng::utils::container_of(
+ expr, <tng_event_expr_array_field_element::parent);
lttng_event_expr_destroy(elem_expr->array_field_expr);
break;
}
static int event_expr_to_bytecode_recursive(const struct lttng_event_expr *expr,
- struct lttng_bytecode_alloc **bytecode,
- struct lttng_bytecode_alloc **bytecode_reloc)
+ struct lttng_bytecode_alloc **bytecode,
+ struct lttng_bytecode_alloc **bytecode_reloc)
{
int status;
enum lttng_event_expr_status event_expr_status;
goto end;
}
- status = bytecode_push_get_symbol(
- bytecode, bytecode_reloc, name);
+ status = bytecode_push_get_symbol(bytecode, bytecode_reloc, name);
if (status) {
ERR("Failed to push 'get symbol %s' in bytecode", name);
goto end;
goto end;
}
- status = bytecode_push_get_symbol(
- bytecode, bytecode_reloc, name);
+ status = bytecode_push_get_symbol(bytecode, bytecode_reloc, name);
if (status) {
ERR("Failed to push 'get symbol %s' in bytecode", name);
goto end;
goto end;
}
- provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(
- expr);
+ provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(expr);
if (!provider_name) {
ERR("Failed to get application context provider name from event expression");
status = -1;
goto end;
}
- type_name = lttng_event_expr_app_specific_context_field_get_type_name(
- expr);
+ type_name = lttng_event_expr_app_specific_context_field_get_type_name(expr);
if (!type_name) {
ERR("Failed to get application context type name from event expression");
status = -1;
ret = asprintf(&name, "%s:%s", provider_name, type_name);
if (ret < 0) {
PERROR("Failed to format application specific context: provider_name = '%s', type_name = '%s'",
- provider_name, type_name);
+ provider_name,
+ type_name);
status = -1;
goto end;
}
- status = bytecode_push_get_symbol(
- bytecode, bytecode_reloc, name);
+ status = bytecode_push_get_symbol(bytecode, bytecode_reloc, name);
free(name);
if (status) {
ERR("Failed to push 'get symbol %s:%s' in bytecode",
- provider_name, type_name);
+ provider_name,
+ type_name);
goto end;
}
unsigned int index;
const struct lttng_event_expr *parent;
- parent = lttng_event_expr_array_field_element_get_parent_expr(
- expr);
+ parent = lttng_event_expr_array_field_element_get_parent_expr(expr);
if (!parent) {
ERR("Failed to get parent expression from array event expression");
status = -1;
goto end;
}
- status = event_expr_to_bytecode_recursive(
- parent, bytecode, bytecode_reloc);
+ status = event_expr_to_bytecode_recursive(parent, bytecode, bytecode_reloc);
if (status) {
goto end;
}
- event_expr_status =
- lttng_event_expr_array_field_element_get_index(
- expr, &index);
+ event_expr_status = lttng_event_expr_array_field_element_get_index(expr, &index);
if (event_expr_status != LTTNG_EVENT_EXPR_STATUS_OK) {
ERR("Failed to get array field element index from event expression");
status = -1;
}
int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
- struct lttng_bytecode **bytecode_out)
+ struct lttng_bytecode **bytecode_out)
{
int status;
struct return_op ret_insn;
goto end;
}
- status = event_expr_to_bytecode_recursive(
- expr, &bytecode, &bytecode_reloc);
+ status = event_expr_to_bytecode_recursive(expr, &bytecode, &bytecode_reloc);
if (status) {
/* Errors already logged. */
goto end;
/* Append symbol table to bytecode. */
bytecode->b.reloc_table_offset = bytecode_get_len(&bytecode->b);
- status = bytecode_push(&bytecode, bytecode_reloc->b.data, 1,
- bytecode_get_len(&bytecode_reloc->b));
+ status = bytecode_push(
+ &bytecode, bytecode_reloc->b.data, 1, bytecode_get_len(&bytecode_reloc->b));
if (status) {
ERR("Failed to push symbol table to bytecode");
goto end;
return status;
}
-static
-enum lttng_error_code lttng_event_expr_event_payload_field_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_expr_event_payload_field_mi_serialize(const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(name);
/* Open event expr payload field element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_expr_payload_field);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_expr_payload_field);
if (ret) {
goto mi_error;
}
/* Name. */
- ret = mi_lttng_writer_write_element_string(
- writer, config_element_name, name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, name);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-enum lttng_error_code lttng_event_expr_channel_context_field_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_expr_channel_context_field_mi_serialize(const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
/* Open event expr channel context field element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_event_expr_channel_context_field);
+ mi_lttng_element_event_expr_channel_context_field);
if (ret) {
goto mi_error;
}
/* Name. */
- ret = mi_lttng_writer_write_element_string(
- writer, config_element_name, name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, name);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-enum lttng_error_code lttng_event_expr_app_specific_context_field_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_expr_app_specific_context_field_mi_serialize(const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(expression);
LTTNG_ASSERT(writer);
- LTTNG_ASSERT(expression->type ==
- LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD);
+ LTTNG_ASSERT(expression->type == LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD);
- provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(
- expression);
+ provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(expression);
LTTNG_ASSERT(provider_name);
- type_name = lttng_event_expr_app_specific_context_field_get_type_name(
- expression);
+ type_name = lttng_event_expr_app_specific_context_field_get_type_name(expression);
LTTNG_ASSERT(provider_name);
/* Open event expr app specific context field element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_event_expr_app_specific_context_field);
+ mi_lttng_element_event_expr_app_specific_context_field);
if (ret) {
goto mi_error;
}
/* Provider name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_expr_provider_name,
- provider_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_expr_provider_name, provider_name);
if (ret) {
goto mi_error;
}
/* Type name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_expr_type_name, type_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_expr_type_name, type_name);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-enum lttng_error_code lttng_event_expr_array_field_element_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_expr_array_field_element_mi_serialize(const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(expression->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT);
- status = lttng_event_expr_array_field_element_get_index(
- expression, &index);
+ status = lttng_event_expr_array_field_element_get_index(expression, &index);
LTTNG_ASSERT(status == LTTNG_EVENT_EXPR_STATUS_OK);
- parent_expr = lttng_event_expr_array_field_element_get_parent_expr(
- expression);
+ parent_expr = lttng_event_expr_array_field_element_get_parent_expr(expression);
LTTNG_ASSERT(parent_expr != NULL);
/* Open event expr array field element. */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_event_expr_array_field_element);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_expr_array_field_element);
if (ret) {
goto mi_error;
}
/* Index. */
ret = mi_lttng_writer_write_element_unsigned_int(
- writer, mi_lttng_element_event_expr_index, index);
+ writer, mi_lttng_element_event_expr_index, index);
if (ret) {
goto mi_error;
}
return ret_code;
}
-enum lttng_error_code lttng_event_expr_mi_serialize(
- const struct lttng_event_expr *expression,
- struct mi_writer *writer)
+enum lttng_error_code lttng_event_expr_mi_serialize(const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
switch (expression->type) {
case LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD:
- ret_code = lttng_event_expr_event_payload_field_mi_serialize(
- expression, writer);
+ ret_code = lttng_event_expr_event_payload_field_mi_serialize(expression, writer);
break;
case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
- ret_code = lttng_event_expr_channel_context_field_mi_serialize(
- expression, writer);
+ ret_code = lttng_event_expr_channel_context_field_mi_serialize(expression, writer);
break;
case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
- ret_code = lttng_event_expr_app_specific_context_field_mi_serialize(
- expression, writer);
+ ret_code = lttng_event_expr_app_specific_context_field_mi_serialize(expression,
+ writer);
break;
case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
- ret_code = lttng_event_expr_array_field_element_mi_serialize(
- expression, writer);
+ ret_code = lttng_event_expr_array_field_element_mi_serialize(expression, writer);
break;
default:
abort();
*/
#define _LGPL_SOURCE
-#include <stddef.h>
-#include <stdbool.h>
-
#include <common/error.hpp>
#include <common/macros.hpp>
+
#include <lttng/event-field-value-internal.hpp>
-static
-struct lttng_event_field_value *create_empty_field_val(
- enum lttng_event_field_value_type type, size_t size)
+#include <stdbool.h>
+#include <stddef.h>
+
+static struct lttng_event_field_value *
+create_empty_field_val(enum lttng_event_field_value_type type, size_t size)
{
struct lttng_event_field_value *field_val;
return field_val;
}
-struct lttng_event_field_value *lttng_event_field_value_uint_create(
- uint64_t val)
+struct lttng_event_field_value *lttng_event_field_value_uint_create(uint64_t val)
{
struct lttng_event_field_value_uint *field_val;
- field_val = lttng::utils::container_of(create_empty_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT,
- sizeof(*field_val)),
- <tng_event_field_value_uint::parent);
+ field_val = lttng::utils::container_of(
+ create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT,
+ sizeof(*field_val)),
+ <tng_event_field_value_uint::parent);
if (!field_val) {
goto error;
}
return &field_val->parent;
}
-struct lttng_event_field_value *lttng_event_field_value_int_create(
- int64_t val)
+struct lttng_event_field_value *lttng_event_field_value_int_create(int64_t val)
{
struct lttng_event_field_value_int *field_val;
- field_val = lttng::utils::container_of(create_empty_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT,
- sizeof(*field_val)),
- <tng_event_field_value_int::parent);
+ field_val = lttng::utils::container_of(
+ create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT, sizeof(*field_val)),
+ <tng_event_field_value_int::parent);
if (!field_val) {
goto error;
}
return &field_val->parent;
}
-static
-struct lttng_event_field_value_enum *create_enum_field_val(
- enum lttng_event_field_value_type type, size_t size)
+static struct lttng_event_field_value_enum *
+create_enum_field_val(enum lttng_event_field_value_type type, size_t size)
{
struct lttng_event_field_value_enum *field_val;
field_val = lttng::utils::container_of(create_empty_field_val(type, size),
- <tng_event_field_value_enum::parent);
+ <tng_event_field_value_enum::parent);
if (!field_val) {
goto error;
}
return field_val;
}
-struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
- uint64_t val)
+struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(uint64_t val)
{
struct lttng_event_field_value_enum_uint *field_val;
- field_val = lttng::utils::container_of(create_enum_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM,
- sizeof(*field_val)),
- <tng_event_field_value_enum_uint::parent);
+ field_val = lttng::utils::container_of(
+ create_enum_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM,
+ sizeof(*field_val)),
+ <tng_event_field_value_enum_uint::parent);
if (!field_val) {
goto error;
}
return &field_val->parent.parent;
}
-struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
- int64_t val)
+struct lttng_event_field_value *lttng_event_field_value_enum_int_create(int64_t val)
{
struct lttng_event_field_value_enum_int *field_val;
- field_val = lttng::utils::container_of(create_enum_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM,
- sizeof(*field_val)),
- <tng_event_field_value_enum_int::parent);
+ field_val = lttng::utils::container_of(
+ create_enum_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM, sizeof(*field_val)),
+ <tng_event_field_value_enum_int::parent);
if (!field_val) {
goto error;
}
struct lttng_event_field_value *lttng_event_field_value_real_create(double val)
{
struct lttng_event_field_value_real *field_val = lttng::utils::container_of(
- create_empty_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_REAL,
- sizeof(*field_val)),
- <tng_event_field_value_real::parent);
+ create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_REAL, sizeof(*field_val)),
+ <tng_event_field_value_real::parent);
if (!field_val) {
goto error;
return &field_val->parent;
}
-struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
- const char *val, size_t size)
+struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(const char *val,
+ size_t size)
{
struct lttng_event_field_value_string *field_val = lttng::utils::container_of(
- create_empty_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_STRING,
- sizeof(*field_val)),
- <tng_event_field_value_string::parent);
+ create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_STRING, sizeof(*field_val)),
+ <tng_event_field_value_string::parent);
if (!field_val) {
goto error;
return &field_val->parent;
}
-struct lttng_event_field_value *lttng_event_field_value_string_create(
- const char *val)
+struct lttng_event_field_value *lttng_event_field_value_string_create(const char *val)
{
LTTNG_ASSERT(val);
- return lttng_event_field_value_string_create_with_size(val,
- strlen(val));
+ return lttng_event_field_value_string_create_with_size(val, strlen(val));
}
-static
-void destroy_field_val(void *field_val)
+static void destroy_field_val(void *field_val)
{
lttng_event_field_value_destroy((lttng_event_field_value *) field_val);
}
struct lttng_event_field_value *lttng_event_field_value_array_create(void)
{
struct lttng_event_field_value_array *field_val = lttng::utils::container_of(
- create_empty_field_val(
- LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY,
- sizeof(*field_val)),
- <tng_event_field_value_array::parent);
+ create_empty_field_val(LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY, sizeof(*field_val)),
+ <tng_event_field_value_array::parent);
if (!field_val) {
goto error;
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM:
case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM:
{
- struct lttng_event_field_value_enum *enum_field_val =
- lttng::utils::container_of(field_val,
- <tng_event_field_value_enum::parent);
+ struct lttng_event_field_value_enum *enum_field_val = lttng::utils::container_of(
+ field_val, <tng_event_field_value_enum::parent);
lttng_dynamic_pointer_array_reset(&enum_field_val->labels);
break;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_STRING:
{
- struct lttng_event_field_value_string *str_field_val =
- lttng::utils::container_of(field_val,
- <tng_event_field_value_string::parent);
+ struct lttng_event_field_value_string *str_field_val = lttng::utils::container_of(
+ field_val, <tng_event_field_value_string::parent);
free(str_field_val->val);
break;
}
case LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY:
{
- struct lttng_event_field_value_array *array_field_expr =
- lttng::utils::container_of(field_val,
- <tng_event_field_value_array::parent);
+ struct lttng_event_field_value_array *array_field_expr = lttng::utils::container_of(
+ field_val, <tng_event_field_value_array::parent);
lttng_dynamic_pointer_array_reset(&array_field_expr->elems);
break;
return;
}
-int lttng_event_field_value_enum_append_label_with_size(
- struct lttng_event_field_value *field_val,
- const char *label, size_t size)
+int lttng_event_field_value_enum_append_label_with_size(struct lttng_event_field_value *field_val,
+ const char *label,
+ size_t size)
{
int ret;
char *new_label;
}
ret = lttng_dynamic_pointer_array_add_pointer(
- <tng::utils::container_of(field_val,
- <tng_event_field_value_enum::parent)->labels,
- new_label);
+ <tng::utils::container_of(field_val, <tng_event_field_value_enum::parent)
+ ->labels,
+ new_label);
if (ret == 0) {
new_label = NULL;
}
return ret;
}
-int lttng_event_field_value_enum_append_label(
- struct lttng_event_field_value *field_val,
- const char *label)
+int lttng_event_field_value_enum_append_label(struct lttng_event_field_value *field_val,
+ const char *label)
{
LTTNG_ASSERT(label);
- return lttng_event_field_value_enum_append_label_with_size(field_val,
- label, strlen(label));
+ return lttng_event_field_value_enum_append_label_with_size(field_val, label, strlen(label));
}
-int lttng_event_field_value_array_append(
- struct lttng_event_field_value *array_field_val,
- struct lttng_event_field_value *field_val)
+int lttng_event_field_value_array_append(struct lttng_event_field_value *array_field_val,
+ struct lttng_event_field_value *field_val)
{
LTTNG_ASSERT(array_field_val);
LTTNG_ASSERT(field_val);
return lttng_dynamic_pointer_array_add_pointer(
- <tng::utils::container_of(array_field_val,
- <tng_event_field_value_array::parent)->elems,
- field_val);
+ <tng::utils::container_of(array_field_val, <tng_event_field_value_array::parent)
+ ->elems,
+ field_val);
}
-int lttng_event_field_value_array_append_unavailable(
- struct lttng_event_field_value *array_field_val)
+int lttng_event_field_value_array_append_unavailable(struct lttng_event_field_value *array_field_val)
{
LTTNG_ASSERT(array_field_val);
return lttng_dynamic_pointer_array_add_pointer(
- <tng::utils::container_of(array_field_val,
- <tng_event_field_value_array::parent)->elems,
- NULL);
+ <tng::utils::container_of(array_field_val, <tng_event_field_value_array::parent)
+ ->elems,
+ NULL);
}
-enum lttng_event_field_value_type lttng_event_field_value_get_type(
- const struct lttng_event_field_value *field_val)
+enum lttng_event_field_value_type
+lttng_event_field_value_get_type(const struct lttng_event_field_value *field_val)
{
enum lttng_event_field_value_type type;
}
enum lttng_event_field_value_status
-lttng_event_field_value_unsigned_int_get_value(
- const struct lttng_event_field_value *field_val, uint64_t *val)
+lttng_event_field_value_unsigned_int_get_value(const struct lttng_event_field_value *field_val,
+ uint64_t *val)
{
enum lttng_event_field_value_status status;
switch (field_val->type) {
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT:
- *val = lttng::utils::container_of(field_val,
- <tng_event_field_value_uint::parent)->val;
+ *val = lttng::utils::container_of(field_val, <tng_event_field_value_uint::parent)
+ ->val;
break;
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM:
{
const struct lttng_event_field_value_enum *field_val_enum =
- lttng::utils::container_of(
- field_val, <tng_event_field_value_enum::parent);
+ lttng::utils::container_of(field_val,
+ <tng_event_field_value_enum::parent);
const struct lttng_event_field_value_enum_uint *field_val_enum_uint =
- lttng::utils::container_of(field_val_enum,
- <tng_event_field_value_enum_uint::parent);
+ lttng::utils::container_of(field_val_enum,
+ <tng_event_field_value_enum_uint::parent);
*val = field_val_enum_uint->val;
break;
}
}
enum lttng_event_field_value_status
-lttng_event_field_value_signed_int_get_value(
- const struct lttng_event_field_value *field_val, int64_t *val)
+lttng_event_field_value_signed_int_get_value(const struct lttng_event_field_value *field_val,
+ int64_t *val)
{
enum lttng_event_field_value_status status;
switch (field_val->type) {
case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT:
- *val = lttng::utils::container_of(field_val,
- <tng_event_field_value_int::parent)->val;
+ *val = lttng::utils::container_of(field_val, <tng_event_field_value_int::parent)
+ ->val;
break;
case LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM:
{
- const struct lttng_event_field_value_enum *field_val_enum = lttng::utils::container_of(
- field_val,
- <tng_event_field_value_enum::parent);
+ const struct lttng_event_field_value_enum *field_val_enum =
+ lttng::utils::container_of(field_val,
+ <tng_event_field_value_enum::parent);
const struct lttng_event_field_value_enum_int *field_val_enum_uint =
- lttng::utils::container_of(field_val_enum,
- <tng_event_field_value_enum_int::parent);
+ lttng::utils::container_of(field_val_enum,
+ <tng_event_field_value_enum_int::parent);
*val = field_val_enum_uint->val;
break;
}
}
enum lttng_event_field_value_status
-lttng_event_field_value_real_get_value(
- const struct lttng_event_field_value *field_val, double *val)
+lttng_event_field_value_real_get_value(const struct lttng_event_field_value *field_val, double *val)
{
enum lttng_event_field_value_status status;
- if (!field_val || field_val->type != LTTNG_EVENT_FIELD_VALUE_TYPE_REAL ||
- !val) {
+ if (!field_val || field_val->type != LTTNG_EVENT_FIELD_VALUE_TYPE_REAL || !val) {
status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID;
goto end;
}
- *val = lttng::utils::container_of(field_val,
- <tng_event_field_value_real::parent)->val;
+ *val = lttng::utils::container_of(field_val, <tng_event_field_value_real::parent)->val;
status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
end:
return status;
}
-static
-bool is_enum_field_val(const struct lttng_event_field_value *field_val)
+static bool is_enum_field_val(const struct lttng_event_field_value *field_val)
{
return field_val->type == LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM ||
field_val->type == LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM;
}
enum lttng_event_field_value_status
-lttng_event_field_value_enum_get_label_count(
- const struct lttng_event_field_value *field_val,
- unsigned int *count)
+lttng_event_field_value_enum_get_label_count(const struct lttng_event_field_value *field_val,
+ unsigned int *count)
{
enum lttng_event_field_value_status status;
}
*count = (unsigned int) lttng_dynamic_pointer_array_get_count(
- <tng::utils::container_of(field_val,
- <tng_event_field_value_enum::parent)->labels);
+ <tng::utils::container_of(field_val, <tng_event_field_value_enum::parent)
+ ->labels);
status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
end:
return status;
}
-const char *lttng_event_field_value_enum_get_label_at_index(
- const struct lttng_event_field_value *field_val,
- unsigned int index)
+const char *
+lttng_event_field_value_enum_get_label_at_index(const struct lttng_event_field_value *field_val,
+ unsigned int index)
{
const char *ret;
const struct lttng_event_field_value_enum *enum_field_val;
goto end;
}
- enum_field_val = lttng::utils::container_of(field_val,
- <tng_event_field_value_enum::parent);
+ enum_field_val =
+ lttng::utils::container_of(field_val, <tng_event_field_value_enum::parent);
if (index >= lttng_dynamic_pointer_array_get_count(&enum_field_val->labels)) {
ret = NULL;
}
ret = (const char *) lttng_dynamic_pointer_array_get_pointer(&enum_field_val->labels,
- index);
+ index);
end:
return ret;
}
-enum lttng_event_field_value_status lttng_event_field_value_string_get_value(
- const struct lttng_event_field_value *field_val,
- const char **value)
+enum lttng_event_field_value_status
+lttng_event_field_value_string_get_value(const struct lttng_event_field_value *field_val,
+ const char **value)
{
enum lttng_event_field_value_status status;
goto end;
}
- *value = lttng::utils::container_of(field_val,
- <tng_event_field_value_string::parent)->val;
+ *value =
+ lttng::utils::container_of(field_val, <tng_event_field_value_string::parent)->val;
status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
end:
return status;
}
-enum lttng_event_field_value_status lttng_event_field_value_array_get_length(
- const struct lttng_event_field_value *field_val,
- unsigned int *length)
+enum lttng_event_field_value_status
+lttng_event_field_value_array_get_length(const struct lttng_event_field_value *field_val,
+ unsigned int *length)
{
enum lttng_event_field_value_status status;
- if (!field_val || field_val->type != LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY ||
- !length) {
+ if (!field_val || field_val->type != LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY || !length) {
status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID;
goto end;
}
*length = (unsigned int) lttng_dynamic_pointer_array_get_count(
- <tng::utils::container_of(field_val,
- <tng_event_field_value_array::parent)->elems);
+ <tng::utils::container_of(field_val, <tng_event_field_value_array::parent)
+ ->elems);
status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
end:
return status;
}
-enum lttng_event_field_value_status
-lttng_event_field_value_array_get_element_at_index(
- const struct lttng_event_field_value *field_val,
- unsigned int index,
- const struct lttng_event_field_value **elem_field_val)
+enum lttng_event_field_value_status lttng_event_field_value_array_get_element_at_index(
+ const struct lttng_event_field_value *field_val,
+ unsigned int index,
+ const struct lttng_event_field_value **elem_field_val)
{
enum lttng_event_field_value_status status;
const struct lttng_event_field_value_array *array_field_val;
if (!field_val || field_val->type != LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY ||
- !elem_field_val) {
+ !elem_field_val) {
status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID;
goto end;
}
- array_field_val = lttng::utils::container_of(
- field_val, <tng_event_field_value_array::parent);
+ array_field_val =
+ lttng::utils::container_of(field_val, <tng_event_field_value_array::parent);
if (index >= lttng_dynamic_pointer_array_get_count(&array_field_val->elems)) {
status = LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID;
}
*elem_field_val = (lttng_event_field_value *) lttng_dynamic_pointer_array_get_pointer(
- &array_field_val->elems, index);
+ &array_field_val->elems, index);
if (*elem_field_val) {
status = LTTNG_EVENT_FIELD_VALUE_STATUS_OK;
} else {
#include <common/mi-lttng.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/jul-logging-internal.hpp>
#include <lttng/event-rule/kernel-kprobe-internal.hpp>
#include <lttng/event-rule/log4j-logging-internal.hpp>
#include <lttng/event-rule/python-logging-internal.hpp>
#include <lttng/event-rule/user-tracepoint-internal.hpp>
+
#include <stdbool.h>
-enum lttng_event_rule_type lttng_event_rule_get_type(
- const struct lttng_event_rule *event_rule)
+enum lttng_event_rule_type lttng_event_rule_get_type(const struct lttng_event_rule *event_rule)
{
return event_rule ? event_rule->type : LTTNG_EVENT_RULE_TYPE_UNKNOWN;
}
-enum lttng_domain_type lttng_event_rule_get_domain_type(
- const struct lttng_event_rule *event_rule)
+enum lttng_domain_type lttng_event_rule_get_domain_type(const struct lttng_event_rule *event_rule)
{
enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
static void lttng_event_rule_release(struct urcu_ref *ref)
{
struct lttng_event_rule *event_rule =
- lttng::utils::container_of(ref, <tng_event_rule::ref);
+ lttng::utils::container_of(ref, <tng_event_rule::ref);
LTTNG_ASSERT(event_rule->destroy);
event_rule->destroy(event_rule);
}
int lttng_event_rule_serialize(const struct lttng_event_rule *event_rule,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_event_rule_comm event_rule_comm = {};
event_rule_comm.event_rule_type = (int8_t) event_rule->type;
ret = lttng_dynamic_buffer_append(
- &payload->buffer, &event_rule_comm, sizeof(event_rule_comm));
+ &payload->buffer, &event_rule_comm, sizeof(event_rule_comm));
if (ret) {
goto end;
}
return ret;
}
-bool lttng_event_rule_is_equal(const struct lttng_event_rule *a,
- const struct lttng_event_rule *b)
+bool lttng_event_rule_is_equal(const struct lttng_event_rule *a, const struct lttng_event_rule *b)
{
bool is_equal = false;
return is_equal;
}
-ssize_t lttng_event_rule_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **event_rule)
+ssize_t lttng_event_rule_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **event_rule)
{
ssize_t ret, consumed = 0;
event_rule_create_from_payload_cb create_from_payload = NULL;
const struct lttng_event_rule_comm *event_rule_comm;
const struct lttng_payload_view event_rule_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*event_rule_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*event_rule_comm));
if (!view || !event_rule) {
ret = -1;
create_from_payload = lttng_event_rule_kernel_uprobe_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL:
- create_from_payload =
- lttng_event_rule_kernel_syscall_create_from_payload;
+ create_from_payload = lttng_event_rule_kernel_syscall_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT:
- create_from_payload =
- lttng_event_rule_kernel_tracepoint_create_from_payload;
+ create_from_payload = lttng_event_rule_kernel_tracepoint_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT:
- create_from_payload =
- lttng_event_rule_user_tracepoint_create_from_payload;
+ create_from_payload = lttng_event_rule_user_tracepoint_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_JUL_LOGGING:
- create_from_payload =
- lttng_event_rule_jul_logging_create_from_payload;
+ create_from_payload = lttng_event_rule_jul_logging_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING:
- create_from_payload =
- lttng_event_rule_log4j_logging_create_from_payload;
+ create_from_payload = lttng_event_rule_log4j_logging_create_from_payload;
break;
case LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING:
- create_from_payload =
- lttng_event_rule_python_logging_create_from_payload;
+ create_from_payload = lttng_event_rule_python_logging_create_from_payload;
break;
default:
ERR("Attempted to create event rule of unknown type (%i)",
- (int) event_rule_comm->event_rule_type);
+ (int) event_rule_comm->event_rule_type);
ret = -1;
goto end;
}
{
struct lttng_payload_view child_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
ret = create_from_payload(&child_view, event_rule);
if (ret < 0) {
return ret;
}
-void lttng_event_rule_init(struct lttng_event_rule *event_rule,
- enum lttng_event_rule_type type)
+void lttng_event_rule_init(struct lttng_event_rule *event_rule, enum lttng_event_rule_type type)
{
urcu_ref_init(&event_rule->ref);
event_rule->type = type;
urcu_ref_put(&event_rule->ref, lttng_event_rule_release);
}
-enum lttng_error_code lttng_event_rule_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+enum lttng_error_code
+lttng_event_rule_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
LTTNG_ASSERT(rule->generate_filter_bytecode);
return rule->generate_filter_bytecode(rule, creds);
return rule->get_filter(rule);
}
-const struct lttng_bytecode *lttng_event_rule_get_filter_bytecode(
- const struct lttng_event_rule *rule)
+const struct lttng_bytecode *
+lttng_event_rule_get_filter_bytecode(const struct lttng_event_rule *rule)
{
LTTNG_ASSERT(rule->get_filter_bytecode);
return rule->get_filter_bytecode(rule);
enum lttng_event_rule_generate_exclusions_status
lttng_event_rule_generate_exclusions(const struct lttng_event_rule *rule,
- struct lttng_event_exclusion **exclusions)
+ struct lttng_event_exclusion **exclusions)
{
LTTNG_ASSERT(rule->generate_exclusions);
return rule->generate_exclusions(rule, exclusions);
}
-struct lttng_event *lttng_event_rule_generate_lttng_event(
- const struct lttng_event_rule *rule)
+struct lttng_event *lttng_event_rule_generate_lttng_event(const struct lttng_event_rule *rule)
{
LTTNG_ASSERT(rule->generate_lttng_event);
return rule->generate_lttng_event(rule);
return rule->hash(rule);
}
-enum lttng_error_code lttng_event_rule_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+enum lttng_error_code lttng_event_rule_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/jul-logging-internal.hpp>
#include <lttng/event.h>
return;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
lttng_log_level_rule_destroy(jul_logging->log_level_rule);
free(jul_logging->pattern);
free(jul_logging);
}
-static bool lttng_event_rule_jul_logging_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_jul_logging_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_jul_logging *jul_logging;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
/* Required field. */
if (!jul_logging->pattern) {
return valid;
}
-static int lttng_event_rule_jul_logging_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_jul_logging_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t pattern_len, filter_expression_len, header_offset;
header_offset = payload->buffer.size;
DBG("Serializing jul_logging event rule.");
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
pattern_len = strlen(jul_logging->pattern) + 1;
if (jul_logging->filter_expression != NULL) {
- filter_expression_len =
- strlen(jul_logging->filter_expression) + 1;
+ filter_expression_len = strlen(jul_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
}
jul_logging_comm.pattern_len = pattern_len;
jul_logging_comm.filter_expression_len = filter_expression_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &jul_logging_comm,
- sizeof(jul_logging_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &jul_logging_comm, sizeof(jul_logging_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, jul_logging->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, jul_logging->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, jul_logging->filter_expression,
- filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, jul_logging->filter_expression, filter_expression_len);
if (ret) {
goto end;
}
}
header = (typeof(header)) ((char *) payload->buffer.data + header_offset);
- header->log_level_rule_len =
- payload->buffer.size - size_before_log_level_rule;
+ header->log_level_rule_len = payload->buffer.size - size_before_log_level_rule;
end:
return ret;
}
-static bool lttng_event_rule_jul_logging_is_equal(
- const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+static bool lttng_event_rule_jul_logging_is_equal(const struct lttng_event_rule *_a,
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_jul_logging *a, *b;
goto end;
}
- if (!lttng_log_level_rule_is_equal(
- a->log_level_rule, b->log_level_rule)) {
+ if (!lttng_log_level_rule_is_equal(a->log_level_rule, b->log_level_rule)) {
goto end;
}
*
* An event with NO loglevel and the name is * will return NULL.
*/
-static int generate_agent_filter(
- const struct lttng_event_rule *rule, char **_agent_filter)
+static int generate_agent_filter(const struct lttng_event_rule *rule, char **_agent_filter)
{
int err;
int ret = 0;
goto end;
}
-
/* Don't add filter for the '*' event. */
if (strcmp(pattern, "*") != 0) {
if (filter) {
- err = asprintf(&agent_filter,
- "(%s) && (logger_name == \"%s\")",
- filter, pattern);
+ err = asprintf(
+ &agent_filter, "(%s) && (logger_name == \"%s\")", filter, pattern);
} else {
- err = asprintf(&agent_filter, "logger_name == \"%s\"",
- pattern);
+ err = asprintf(&agent_filter, "logger_name == \"%s\"", pattern);
}
if (err < 0) {
}
}
- status = lttng_event_rule_jul_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_jul_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_OK) {
enum lttng_log_level_rule_status llr_status;
const char *op;
int level;
- switch (lttng_log_level_rule_get_type(log_level_rule))
- {
+ switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &level);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule, &level);
op = "==";
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &level);
+ log_level_rule, &level);
op = ">=";
break;
default:
char *new_filter;
err = asprintf(&new_filter,
- "(%s) && (int_loglevel %s %d)",
- agent_filter ? agent_filter : filter,
- op, level);
+ "(%s) && (int_loglevel %s %d)",
+ agent_filter ? agent_filter : filter,
+ op,
+ level);
if (agent_filter) {
free(agent_filter);
}
agent_filter = new_filter;
} else {
- err = asprintf(&agent_filter, "int_loglevel %s %d", op,
- level);
+ err = asprintf(&agent_filter, "int_loglevel %s %d", op, level);
}
if (err < 0) {
}
static enum lttng_error_code
-lttng_event_rule_jul_logging_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+lttng_event_rule_jul_logging_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule);
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
}
ret = run_as_generate_filter_bytecode(
- jul_logging->internal_filter.filter, creds,
- &bytecode);
+ jul_logging->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
return ret_code;
}
-static const char *lttng_event_rule_jul_logging_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_jul_logging_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_jul_logging *jul_logging;
LTTNG_ASSERT(rule);
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
return jul_logging->internal_filter.filter;
}
static const struct lttng_bytecode *
-lttng_event_rule_jul_logging_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_jul_logging_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_jul_logging *jul_logging;
LTTNG_ASSERT(rule);
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
return jul_logging->internal_filter.bytecode;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_jul_logging_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **_exclusions)
+lttng_event_rule_jul_logging_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
*_exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long lttng_event_rule_jul_logging_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_jul_logging_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_jul_logging *tp_rule =
- lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_JUL_LOGGING,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_JUL_LOGGING, lttng_ht_seed);
hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
if (tp_rule->filter_expression) {
return hash;
}
-static struct lttng_event *lttng_event_rule_jul_logging_generate_lttng_event(
- const struct lttng_event_rule *rule)
+static struct lttng_event *
+lttng_event_rule_jul_logging_generate_lttng_event(const struct lttng_event_rule *rule)
{
int ret;
const struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status;
const struct lttng_log_level_rule *log_level_rule;
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
local_event = zmalloc<lttng_event>();
if (!local_event) {
}
local_event->type = LTTNG_EVENT_TRACEPOINT;
- ret = lttng_strncpy(local_event->name, jul_logging->pattern,
- sizeof(local_event->name));
+ ret = lttng_strncpy(local_event->name, jul_logging->pattern, sizeof(local_event->name));
if (ret) {
ERR("Truncation occurred when copying event rule pattern to `lttng_event` structure: pattern = '%s'",
- jul_logging->pattern);
+ jul_logging->pattern);
goto error;
}
-
/* Map the log level rule to an equivalent lttng_loglevel. */
- status = lttng_event_rule_jul_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_jul_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
loglevel_value = 0;
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &loglevel_value);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule,
+ &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &loglevel_value);
+ log_level_rule, &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
break;
default:
return event;
}
-static enum lttng_error_code lttng_event_rule_jul_logging_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_jul_logging_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_JUL_LOGGING_EVENT_RULE(rule));
- status = lttng_event_rule_jul_logging_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_jul_logging_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
- status = lttng_event_rule_jul_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_jul_logging_get_log_level_rule(rule, &log_level_rule);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
/* Open event rule jul logging element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_jul_logging);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_jul_logging);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter expression. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
/* Log level rule. */
if (log_level_rule) {
- ret_code = lttng_log_level_rule_mi_serialize(
- log_level_rule, writer);
+ ret_code = lttng_log_level_rule_mi_serialize(log_level_rule, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
tp_rule->parent.equal = lttng_event_rule_jul_logging_is_equal;
tp_rule->parent.destroy = lttng_event_rule_jul_logging_destroy;
tp_rule->parent.generate_filter_bytecode =
- lttng_event_rule_jul_logging_generate_filter_bytecode;
- tp_rule->parent.get_filter =
- lttng_event_rule_jul_logging_get_internal_filter;
+ lttng_event_rule_jul_logging_generate_filter_bytecode;
+ tp_rule->parent.get_filter = lttng_event_rule_jul_logging_get_internal_filter;
tp_rule->parent.get_filter_bytecode =
- lttng_event_rule_jul_logging_get_internal_filter_bytecode;
- tp_rule->parent.generate_exclusions =
- lttng_event_rule_jul_logging_generate_exclusions;
+ lttng_event_rule_jul_logging_get_internal_filter_bytecode;
+ tp_rule->parent.generate_exclusions = lttng_event_rule_jul_logging_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_jul_logging_hash;
- tp_rule->parent.generate_lttng_event =
- lttng_event_rule_jul_logging_generate_lttng_event;
+ tp_rule->parent.generate_lttng_event = lttng_event_rule_jul_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_jul_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
return rule;
}
-ssize_t lttng_event_rule_jul_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_jul_logging_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*jul_logging_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*jul_logging_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule jul_logging: buffer too short to contain header.");
ret = -1;
offset += current_buffer_view.size;
/* Map the pattern. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, jul_logging_comm->pattern_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, jul_logging_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- jul_logging_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, jul_logging_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- jul_logging_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, jul_logging_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
filter_expression = current_buffer_view.data;
if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- jul_logging_comm->filter_expression_len)) {
+ filter_expression,
+ jul_logging_comm->filter_expression_len)) {
ret = -1;
goto end;
}
{
/* Map the log level rule. */
- struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- jul_logging_comm->log_level_rule_len);
+ struct lttng_payload_view current_payload_view = lttng_payload_view_from_view(
+ view, offset, jul_logging_comm->log_level_rule_len);
- ret = lttng_log_level_rule_create_from_payload(
- ¤t_payload_view, &log_level_rule);
+ ret = lttng_log_level_rule_create_from_payload(¤t_payload_view,
+ &log_level_rule);
if (ret < 0) {
ret = -1;
goto end;
}
if (filter_expression) {
- status = lttng_event_rule_jul_logging_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_jul_logging_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule jul_logging pattern.");
ret = -1;
}
if (log_level_rule) {
- status = lttng_event_rule_jul_logging_set_log_level_rule(
- rule, log_level_rule);
+ status = lttng_event_rule_jul_logging_set_log_level_rule(rule, log_level_rule);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule jul_logging log level rule.");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_jul_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_JUL_LOGGING_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_JUL_LOGGING_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
pattern_copy = strdup(pattern);
if (!pattern_copy) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_jul_logging_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
if (!jul_logging->pattern) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status lttng_event_rule_jul_logging_set_filter(struct lttng_event_rule *rule,
+ const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_JUL_LOGGING_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ if (!rule || !IS_JUL_LOGGING_EVENT_RULE(rule) || !expression || strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
expression_copy = strdup(expression);
if (!expression_copy) {
PERROR("Failed to copy filter expression");
return status;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_jul_logging_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
if (!jul_logging->filter_expression) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-static bool log_level_rule_valid(
- const struct lttng_log_level_rule *rule __attribute__((unused)))
+static bool log_level_rule_valid(const struct lttng_log_level_rule *rule __attribute__((unused)))
{
/*
* For both JUL and LOG4J custom log level are possible and can
return true;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_set_log_level_rule(
- struct lttng_event_rule *rule,
- const struct lttng_log_level_rule *log_level_rule)
+enum lttng_event_rule_status
+lttng_event_rule_jul_logging_set_log_level_rule(struct lttng_event_rule *rule,
+ const struct lttng_log_level_rule *log_level_rule)
{
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
if (!log_level_rule_valid(log_level_rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_jul_logging_get_log_level_rule(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule
- )
+enum lttng_event_rule_status
+lttng_event_rule_jul_logging_get_log_level_rule(const struct lttng_event_rule *rule,
+ const struct lttng_log_level_rule **log_level_rule)
{
struct lttng_event_rule_jul_logging *jul_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- jul_logging = lttng::utils::container_of(
- rule, <tng_event_rule_jul_logging::parent);
+ jul_logging = lttng::utils::container_of(rule, <tng_event_rule_jul_logging::parent);
if (jul_logging->log_level_rule == NULL) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
#include <common/payload-view.hpp>
#include <common/payload.hpp>
#include <common/runas.hpp>
-#include <ctype.h>
+
#include <lttng/constant.h>
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/kernel-kprobe-internal.hpp>
#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
+
+#include <ctype.h>
#include <stdio.h>
#define IS_KPROBE_EVENT_RULE(rule) \
free(kprobe);
}
-static bool lttng_event_rule_kernel_kprobe_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_kernel_kprobe_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_kernel_kprobe *kprobe;
}
/* Required field. */
- if(!kprobe->location) {
+ if (!kprobe->location) {
ERR("Invalid name event rule: a location must be set.");
goto end;
}
return valid;
}
-static int lttng_event_rule_kernel_kprobe_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_kernel_kprobe_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t name_len, header_offset, size_before_location;
name_len = strlen(kprobe->name) + 1;
kprobe_comm.name_len = name_len;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &kprobe_comm, sizeof(kprobe_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &kprobe_comm, sizeof(kprobe_comm));
if (ret) {
goto end;
}
}
/* Update the header regarding the probe size. */
- header = (struct lttng_event_rule_kernel_kprobe_comm*) (
- (char *) payload->buffer.data + header_offset);
+ header = (struct lttng_event_rule_kernel_kprobe_comm *) ((char *) payload->buffer.data +
+ header_offset);
header->location_len = payload->buffer.size - size_before_location;
ret = 0;
}
static bool lttng_event_rule_kernel_kprobe_is_equal(const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_kernel_kprobe *a, *b;
goto end;
}
- is_equal = lttng_kernel_probe_location_is_equal(
- a->location, b->location);
+ is_equal = lttng_kernel_probe_location_is_equal(a->location, b->location);
end:
return is_equal;
}
static enum lttng_error_code lttng_event_rule_kernel_kprobe_generate_filter_bytecode(
- struct lttng_event_rule *rule __attribute__((unused)),
- const struct lttng_credentials *creds __attribute__((unused)))
+ struct lttng_event_rule *rule __attribute__((unused)),
+ const struct lttng_credentials *creds __attribute__((unused)))
{
/* Nothing to do. */
return LTTNG_OK;
}
-static const char *lttng_event_rule_kernel_kprobe_get_filter(
- const struct lttng_event_rule *rule __attribute__((unused)))
+static const char *lttng_event_rule_kernel_kprobe_get_filter(const struct lttng_event_rule *rule
+ __attribute__((unused)))
{
/* Not supported. */
return NULL;
}
static const struct lttng_bytecode *
-lttng_event_rule_kernel_kprobe_get_filter_bytecode(
- const struct lttng_event_rule *rule __attribute__((unused)))
+lttng_event_rule_kernel_kprobe_get_filter_bytecode(const struct lttng_event_rule *rule
+ __attribute__((unused)))
{
/* Not supported. */
return NULL;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_kernel_kprobe_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **exclusions)
+lttng_event_rule_kernel_kprobe_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **exclusions)
{
/* Not supported. */
*exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long
-lttng_event_rule_kernel_kprobe_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_kernel_kprobe_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_kernel_kprobe *krule =
- lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_kernel_kprobe::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE, lttng_ht_seed);
hash ^= hash_key_str(krule->name, lttng_ht_seed);
hash ^= lttng_kernel_probe_location_hash(krule->location);
return hash;
}
-static
-int kernel_probe_set_location(
- struct lttng_event_rule_kernel_kprobe *kprobe,
- const struct lttng_kernel_probe_location *location)
+static int kernel_probe_set_location(struct lttng_event_rule_kernel_kprobe *kprobe,
+ const struct lttng_kernel_probe_location *location)
{
int ret;
struct lttng_kernel_probe_location *location_copy = NULL;
return ret;
}
-static
-enum lttng_error_code lttng_event_rule_kernel_kprobe_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_kernel_kprobe_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_KPROBE_EVENT_RULE(rule));
- status = lttng_event_rule_kernel_kprobe_get_event_name(
- rule, &event_name);
+ status = lttng_event_rule_kernel_kprobe_get_event_name(rule, &event_name);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(event_name);
LTTNG_ASSERT(location);
/* Open event rule kernel kprobe element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_kernel_kprobe);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_kernel_kprobe);
if (ret) {
goto mi_error;
}
/* Name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_event_name, event_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_event_name, event_name);
if (ret) {
goto mi_error;
}
return ret_code;
}
-struct lttng_event_rule *lttng_event_rule_kernel_kprobe_create(
- const struct lttng_kernel_probe_location *location)
+struct lttng_event_rule *
+lttng_event_rule_kernel_kprobe_create(const struct lttng_kernel_probe_location *location)
{
struct lttng_event_rule *rule = NULL;
struct lttng_event_rule_kernel_kprobe *krule;
krule->parent.equal = lttng_event_rule_kernel_kprobe_is_equal;
krule->parent.destroy = lttng_event_rule_kernel_kprobe_destroy;
krule->parent.generate_filter_bytecode =
- lttng_event_rule_kernel_kprobe_generate_filter_bytecode;
+ lttng_event_rule_kernel_kprobe_generate_filter_bytecode;
krule->parent.get_filter = lttng_event_rule_kernel_kprobe_get_filter;
- krule->parent.get_filter_bytecode =
- lttng_event_rule_kernel_kprobe_get_filter_bytecode;
- krule->parent.generate_exclusions =
- lttng_event_rule_kernel_kprobe_generate_exclusions;
+ krule->parent.get_filter_bytecode = lttng_event_rule_kernel_kprobe_get_filter_bytecode;
+ krule->parent.generate_exclusions = lttng_event_rule_kernel_kprobe_generate_exclusions;
krule->parent.hash = lttng_event_rule_kernel_kprobe_hash;
krule->parent.mi_serialize = lttng_event_rule_kernel_kprobe_mi_serialize;
return rule;
}
-ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_kernel_kprobe_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*kprobe_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*kprobe_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule kprobe: buffer too short to contain header.");
ret = -1;
{
/* Map the name. */
struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- kprobe_comm->name_len);
+ lttng_payload_view_from_view(view, offset, kprobe_comm->name_len);
if (!lttng_payload_view_is_valid(¤t_payload_view)) {
ret = -1;
name = current_payload_view.buffer.data;
if (!lttng_buffer_view_contains_string(
- ¤t_payload_view.buffer, name,
- kprobe_comm->name_len)) {
+ ¤t_payload_view.buffer, name, kprobe_comm->name_len)) {
ret = -1;
goto end;
}
/* Map the kernel probe location. */
{
struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- kprobe_comm->location_len);
+ lttng_payload_view_from_view(view, offset, kprobe_comm->location_len);
if (!lttng_payload_view_is_valid(¤t_payload_view)) {
ret = -1;
goto end;
}
- ret = lttng_kernel_probe_location_create_from_payload(
- ¤t_payload_view, &location);
+ ret = lttng_kernel_probe_location_create_from_payload(¤t_payload_view,
+ &location);
if (ret < 0) {
ret = -1;
goto end;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_location(
- const struct lttng_event_rule *rule,
- const struct lttng_kernel_probe_location **location)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_kprobe_get_location(const struct lttng_event_rule *rule,
+ const struct lttng_kernel_probe_location **location)
{
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
struct lttng_event_rule_kernel_kprobe *kprobe;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_set_event_name(
- struct lttng_event_rule *rule, const char *name)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_kprobe_set_event_name(struct lttng_event_rule *rule, const char *name)
{
char *name_copy = NULL;
struct lttng_event_rule_kernel_kprobe *kprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name ||
- strlen(name) == 0) {
+ if (!rule || !IS_KPROBE_EVENT_RULE(rule) || !name || strlen(name) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_kprobe_get_event_name(
- const struct lttng_event_rule *rule, const char **name)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_kprobe_get_event_name(const struct lttng_event_rule *rule,
+ const char **name)
{
struct lttng_event_rule_kernel_kprobe *kprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/kernel-syscall-internal.hpp>
free(syscall);
}
-static bool lttng_event_rule_kernel_syscall_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_kernel_syscall_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_kernel_syscall *syscall;
return valid;
}
-static int lttng_event_rule_kernel_syscall_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_kernel_syscall_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t pattern_len, filter_expression_len;
syscall_comm.filter_expression_len = filter_expression_len;
syscall_comm.emission_site = syscall->emission_site;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &syscall_comm, sizeof(syscall_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &syscall_comm, sizeof(syscall_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, syscall->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, syscall->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- syscall->filter_expression, filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, syscall->filter_expression, filter_expression_len);
end:
return ret;
}
static bool lttng_event_rule_kernel_syscall_is_equal(const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_kernel_syscall *a, *b;
return is_equal;
}
-static enum lttng_error_code lttng_event_rule_kernel_syscall_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+static enum lttng_error_code
+lttng_event_rule_kernel_syscall_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code = LTTNG_OK;
goto end;
}
- ret = run_as_generate_filter_bytecode(
- syscall->internal_filter.filter, creds, &bytecode);
+ ret = run_as_generate_filter_bytecode(syscall->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
}
return ret_code;
}
-static const char *lttng_event_rule_kernel_syscall_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_kernel_syscall_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_syscall *syscall;
}
static const struct lttng_bytecode *
-lttng_event_rule_kernel_syscall_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_kernel_syscall_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_syscall *syscall;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_kernel_syscall_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **exclusions)
+lttng_event_rule_kernel_syscall_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **exclusions)
{
/* Unsupported. */
*exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long
-lttng_event_rule_kernel_syscall_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_kernel_syscall_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_kernel_syscall *syscall_rule =
- lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_kernel_syscall::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL, lttng_ht_seed);
hash ^= hash_key_str(syscall_rule->pattern, lttng_ht_seed);
if (syscall_rule->filter_expression) {
- hash ^= hash_key_str(syscall_rule->filter_expression,
- lttng_ht_seed);
+ hash ^= hash_key_str(syscall_rule->filter_expression, lttng_ht_seed);
}
return hash;
}
-static enum lttng_error_code lttng_event_rule_kernel_syscall_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_kernel_syscall_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_SYSCALL_EVENT_RULE(rule));
- status = lttng_event_rule_kernel_syscall_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_kernel_syscall_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_kernel_syscall_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
site_type = lttng_event_rule_kernel_syscall_get_emission_site(rule);
}
/* Open event rule kernel syscall element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_kernel_syscall);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_kernel_syscall);
if (ret) {
goto mi_error;
}
/* Emission site. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_kernel_syscall_emission_site,
- site_type_str);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_kernel_syscall_emission_site, site_type_str);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
}
struct lttng_event_rule *lttng_event_rule_kernel_syscall_create(
- enum lttng_event_rule_kernel_syscall_emission_site
- emission_site)
+ enum lttng_event_rule_kernel_syscall_emission_site emission_site)
{
struct lttng_event_rule *rule = NULL;
struct lttng_event_rule_kernel_syscall *syscall_rule;
}
rule = &syscall_rule->parent;
- lttng_event_rule_init(
- &syscall_rule->parent, LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL);
+ lttng_event_rule_init(&syscall_rule->parent, LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL);
syscall_rule->parent.validate = lttng_event_rule_kernel_syscall_validate;
syscall_rule->parent.serialize = lttng_event_rule_kernel_syscall_serialize;
syscall_rule->parent.equal = lttng_event_rule_kernel_syscall_is_equal;
syscall_rule->parent.destroy = lttng_event_rule_kernel_syscall_destroy;
syscall_rule->parent.generate_filter_bytecode =
- lttng_event_rule_kernel_syscall_generate_filter_bytecode;
- syscall_rule->parent.get_filter =
- lttng_event_rule_kernel_syscall_get_internal_filter;
+ lttng_event_rule_kernel_syscall_generate_filter_bytecode;
+ syscall_rule->parent.get_filter = lttng_event_rule_kernel_syscall_get_internal_filter;
syscall_rule->parent.get_filter_bytecode =
- lttng_event_rule_kernel_syscall_get_internal_filter_bytecode;
+ lttng_event_rule_kernel_syscall_get_internal_filter_bytecode;
syscall_rule->parent.generate_exclusions =
- lttng_event_rule_kernel_syscall_generate_exclusions;
+ lttng_event_rule_kernel_syscall_generate_exclusions;
syscall_rule->parent.hash = lttng_event_rule_kernel_syscall_hash;
syscall_rule->parent.mi_serialize = lttng_event_rule_kernel_syscall_mi_serialize;
return rule;
}
-ssize_t lttng_event_rule_kernel_syscall_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_kernel_syscall_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*syscall_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*syscall_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
}
syscall_comm = (typeof(syscall_comm)) current_buffer_view.data;
- rule = lttng_event_rule_kernel_syscall_create((lttng_event_rule_kernel_syscall_emission_site) syscall_comm->emission_site);
+ rule = lttng_event_rule_kernel_syscall_create(
+ (lttng_event_rule_kernel_syscall_emission_site) syscall_comm->emission_site);
if (!rule) {
ERR("Failed to create event rule syscall");
ret = -1;
offset += current_buffer_view.size;
/* Map the pattern. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, syscall_comm->pattern_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, syscall_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- syscall_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, syscall_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- syscall_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, syscall_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
}
filter_expression = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- syscall_comm->filter_expression_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, filter_expression, syscall_comm->filter_expression_len)) {
ret = -1;
goto end;
}
}
if (filter_expression) {
- status = lttng_event_rule_kernel_syscall_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_kernel_syscall_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule syscall pattern");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_syscall_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_SYSCALL_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_SYSCALL_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_syscall_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_syscall_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_syscall_set_filter(struct lttng_event_rule *rule, const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_kernel_syscall *syscall;
/* TODO: validate that the passed expression is valid. */
- if (!rule || !IS_SYSCALL_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ if (!rule || !IS_SYSCALL_EVENT_RULE(rule) || !expression || strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_syscall_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_syscall_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
struct lttng_event_rule_kernel_syscall *syscall;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
return status;
}
extern enum lttng_event_rule_kernel_syscall_emission_site
-lttng_event_rule_kernel_syscall_get_emission_site(
- const struct lttng_event_rule *rule)
+lttng_event_rule_kernel_syscall_get_emission_site(const struct lttng_event_rule *rule)
{
enum lttng_event_rule_kernel_syscall_emission_site emission_site =
LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_UNKNOWN;
}
const char *lttng_event_rule_kernel_syscall_emission_site_str(
- enum lttng_event_rule_kernel_syscall_emission_site emission_site)
+ enum lttng_event_rule_kernel_syscall_emission_site emission_site)
{
switch (emission_site) {
case LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY:
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
#include <lttng/event.h>
return;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
free(tracepoint->pattern);
free(tracepoint->filter_expression);
free(tracepoint);
}
-static bool lttng_event_rule_kernel_tracepoint_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_kernel_tracepoint_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
/* Required field. */
if (!tracepoint->pattern) {
return valid;
}
-static int lttng_event_rule_kernel_tracepoint_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_kernel_tracepoint_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t pattern_len, filter_expression_len;
}
DBG("Serializing kernel tracepoint event rule.");
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
pattern_len = strlen(tracepoint->pattern) + 1;
if (tracepoint->filter_expression != NULL) {
- filter_expression_len =
- strlen(tracepoint->filter_expression) + 1;
+ filter_expression_len = strlen(tracepoint->filter_expression) + 1;
} else {
filter_expression_len = 0;
}
tracepoint_comm.pattern_len = pattern_len;
tracepoint_comm.filter_expression_len = filter_expression_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &tracepoint_comm,
- sizeof(tracepoint_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &tracepoint_comm, sizeof(tracepoint_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, tracepoint->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, tracepoint->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, tracepoint->filter_expression,
- filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, tracepoint->filter_expression, filter_expression_len);
if (ret) {
goto end;
}
return ret;
}
-static bool lttng_event_rule_kernel_tracepoint_is_equal(
- const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+static bool lttng_event_rule_kernel_tracepoint_is_equal(const struct lttng_event_rule *_a,
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_kernel_tracepoint *a, *b;
}
static enum lttng_error_code
-lttng_event_rule_kernel_tracepoint_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+lttng_event_rule_kernel_tracepoint_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
goto end;
}
- ret = run_as_generate_filter_bytecode(
- tracepoint->internal_filter.filter, creds,
- &bytecode);
+ ret = run_as_generate_filter_bytecode(tracepoint->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
return ret_code;
}
-static const char *lttng_event_rule_kernel_tracepoint_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_kernel_tracepoint_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_tracepoint *tracepoint;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
return tracepoint->internal_filter.filter;
}
static const struct lttng_bytecode *
-lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_tracepoint *tracepoint;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
return tracepoint->internal_filter.bytecode;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_kernel_tracepoint_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **_exclusions)
+lttng_event_rule_kernel_tracepoint_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
*_exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long lttng_event_rule_kernel_tracepoint_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_kernel_tracepoint_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
- struct lttng_event_rule_kernel_tracepoint *tp_rule = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ struct lttng_event_rule_kernel_tracepoint *tp_rule =
+ lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT, lttng_ht_seed);
hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
if (tp_rule->filter_expression) {
return hash;
}
-static enum lttng_error_code lttng_event_rule_kernel_tracepoint_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_kernel_tracepoint_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_KERNEL_TRACEPOINT_EVENT_RULE(rule));
- status = lttng_event_rule_kernel_tracepoint_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_kernel_tracepoint_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
/* Open event rule kernel tracepoint element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_kernel_tracepoint);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_kernel_tracepoint);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
tp_rule->parent.equal = lttng_event_rule_kernel_tracepoint_is_equal;
tp_rule->parent.destroy = lttng_event_rule_kernel_tracepoint_destroy;
tp_rule->parent.generate_filter_bytecode =
- lttng_event_rule_kernel_tracepoint_generate_filter_bytecode;
- tp_rule->parent.get_filter =
- lttng_event_rule_kernel_tracepoint_get_internal_filter;
+ lttng_event_rule_kernel_tracepoint_generate_filter_bytecode;
+ tp_rule->parent.get_filter = lttng_event_rule_kernel_tracepoint_get_internal_filter;
tp_rule->parent.get_filter_bytecode =
- lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode;
+ lttng_event_rule_kernel_tracepoint_get_internal_filter_bytecode;
tp_rule->parent.generate_exclusions =
- lttng_event_rule_kernel_tracepoint_generate_exclusions;
+ lttng_event_rule_kernel_tracepoint_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_kernel_tracepoint_hash;
tp_rule->parent.mi_serialize = lttng_event_rule_kernel_tracepoint_mi_serialize;
return rule;
}
-ssize_t lttng_event_rule_kernel_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t
+lttng_event_rule_kernel_tracepoint_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*tracepoint_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*tracepoint_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule kernel tracepoint: buffer too short to contain header.");
ret = -1;
offset += current_buffer_view.size;
/* Map the pattern. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, tracepoint_comm->pattern_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, tracepoint_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- tracepoint_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, tracepoint_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- tracepoint_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, tracepoint_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
filter_expression = current_buffer_view.data;
if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- tracepoint_comm->filter_expression_len)) {
+ filter_expression,
+ tracepoint_comm->filter_expression_len)) {
ret = -1;
goto end;
}
}
if (filter_expression) {
- status = lttng_event_rule_kernel_tracepoint_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_kernel_tracepoint_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule kernel tracepoint pattern.");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_tracepoint_set_name_pattern(struct lttng_event_rule *rule,
+ const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_KERNEL_TRACEPOINT_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_KERNEL_TRACEPOINT_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
pattern_copy = strdup(pattern);
if (!pattern_copy) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_tracepoint_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
if (!tracepoint->pattern) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_tracepoint_set_filter(struct lttng_event_rule *rule, const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
if (!rule || !IS_KERNEL_TRACEPOINT_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
expression_copy = strdup(expression);
if (!expression_copy) {
PERROR("Failed to copy filter expression");
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_tracepoint_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_tracepoint_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
struct lttng_event_rule_kernel_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_kernel_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_kernel_tracepoint::parent);
if (!tracepoint->filter_expression) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
#include <common/payload-view.hpp>
#include <common/payload.hpp>
#include <common/runas.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/kernel-uprobe-internal.hpp>
#include <lttng/userspace-probe-internal.hpp>
free(uprobe);
}
-static bool lttng_event_rule_kernel_uprobe_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_kernel_uprobe_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_kernel_uprobe *uprobe;
return valid;
}
-static int lttng_event_rule_kernel_uprobe_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_kernel_uprobe_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t name_len, header_offset, size_before_probe;
uprobe_comm.name_len = name_len;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &uprobe_comm, sizeof(uprobe_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &uprobe_comm, sizeof(uprobe_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, uprobe->name, name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, uprobe->name, name_len);
if (ret) {
goto end;
}
size_before_probe = payload->buffer.size;
/* This serialize return the size taken in the buffer. */
- ret = lttng_userspace_probe_location_serialize(
- uprobe->location, payload);
+ ret = lttng_userspace_probe_location_serialize(uprobe->location, payload);
if (ret < 0) {
goto end;
}
/* Update the header regarding the probe size. */
- header = (struct lttng_event_rule_kernel_uprobe_comm
- *) ((char *) payload->buffer.data +
- header_offset);
+ header = (struct lttng_event_rule_kernel_uprobe_comm *) ((char *) payload->buffer.data +
+ header_offset);
header->location_len = payload->buffer.size - size_before_probe;
ret = 0;
}
static bool lttng_event_rule_kernel_uprobe_is_equal(const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_kernel_uprobe *a, *b;
LTTNG_ASSERT(a->location);
LTTNG_ASSERT(b->location);
- is_equal = lttng_userspace_probe_location_is_equal(
- a->location, b->location);
+ is_equal = lttng_userspace_probe_location_is_equal(a->location, b->location);
end:
return is_equal;
}
static enum lttng_error_code lttng_event_rule_kernel_uprobe_generate_filter_bytecode(
- struct lttng_event_rule *rule __attribute__((unused)),
- const struct lttng_credentials *creds __attribute__((unused)))
+ struct lttng_event_rule *rule __attribute__((unused)),
+ const struct lttng_credentials *creds __attribute__((unused)))
{
/* Nothing to do. */
return LTTNG_OK;
}
-static const char *lttng_event_rule_kernel_uprobe_get_filter(
- const struct lttng_event_rule *rule __attribute__((unused)))
+static const char *lttng_event_rule_kernel_uprobe_get_filter(const struct lttng_event_rule *rule
+ __attribute__((unused)))
{
/* Unsupported. */
return NULL;
}
static const struct lttng_bytecode *
-lttng_event_rule_kernel_uprobe_get_filter_bytecode(
- const struct lttng_event_rule *rule __attribute__((unused)))
+lttng_event_rule_kernel_uprobe_get_filter_bytecode(const struct lttng_event_rule *rule
+ __attribute__((unused)))
{
/* Unsupported. */
return NULL;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_kernel_uprobe_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **exclusions)
+lttng_event_rule_kernel_uprobe_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **exclusions)
{
/* Unsupported. */
*exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long
-lttng_event_rule_kernel_uprobe_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_kernel_uprobe_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_kernel_uprobe *urule =
- lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_kernel_uprobe::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE, lttng_ht_seed);
hash ^= hash_key_str(urule->name, lttng_ht_seed);
hash ^= lttng_userspace_probe_location_hash(urule->location);
return hash;
}
-static
-int userspace_probe_set_location(
- struct lttng_event_rule_kernel_uprobe *uprobe,
- const struct lttng_userspace_probe_location *location)
+static int userspace_probe_set_location(struct lttng_event_rule_kernel_uprobe *uprobe,
+ const struct lttng_userspace_probe_location *location)
{
int ret;
struct lttng_userspace_probe_location *location_copy = NULL;
return ret;
}
-static enum lttng_error_code lttng_event_rule_kernel_uprobe_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_kernel_uprobe_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_UPROBE_EVENT_RULE(rule));
- status = lttng_event_rule_kernel_uprobe_get_event_name(
- rule, &event_name);
+ status = lttng_event_rule_kernel_uprobe_get_event_name(rule, &event_name);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(event_name);
LTTNG_ASSERT(location);
/* Open event rule kernel uprobe element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_kernel_uprobe);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_kernel_uprobe);
if (ret) {
goto mi_error;
}
/* Event name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_event_name, event_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_event_name, event_name);
if (ret) {
goto mi_error;
}
return ret_code;
}
-struct lttng_event_rule *lttng_event_rule_kernel_uprobe_create(
- const struct lttng_userspace_probe_location *location)
+struct lttng_event_rule *
+lttng_event_rule_kernel_uprobe_create(const struct lttng_userspace_probe_location *location)
{
struct lttng_event_rule *rule = NULL;
struct lttng_event_rule_kernel_uprobe *urule;
urule->parent.equal = lttng_event_rule_kernel_uprobe_is_equal;
urule->parent.destroy = lttng_event_rule_kernel_uprobe_destroy;
urule->parent.generate_filter_bytecode =
- lttng_event_rule_kernel_uprobe_generate_filter_bytecode;
+ lttng_event_rule_kernel_uprobe_generate_filter_bytecode;
urule->parent.get_filter = lttng_event_rule_kernel_uprobe_get_filter;
- urule->parent.get_filter_bytecode =
- lttng_event_rule_kernel_uprobe_get_filter_bytecode;
- urule->parent.generate_exclusions =
- lttng_event_rule_kernel_uprobe_generate_exclusions;
+ urule->parent.get_filter_bytecode = lttng_event_rule_kernel_uprobe_get_filter_bytecode;
+ urule->parent.generate_exclusions = lttng_event_rule_kernel_uprobe_generate_exclusions;
urule->parent.hash = lttng_event_rule_kernel_uprobe_hash;
urule->parent.mi_serialize = lttng_event_rule_kernel_uprobe_mi_serialize;
return rule;
}
-ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
const struct lttng_event_rule_kernel_uprobe_comm *uprobe_comm;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*uprobe_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*uprobe_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain header");
ret = -1;
offset += current_buffer_view.size;
/* Map the name. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, uprobe_comm->name_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, uprobe_comm->name_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
}
name = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, name,
- uprobe_comm->name_len)) {
+ if (!lttng_buffer_view_contains_string(¤t_buffer_view, name, uprobe_comm->name_len)) {
ret = -1;
goto end;
}
/* Map the location. */
{
struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- uprobe_comm->location_len);
+ lttng_payload_view_from_view(view, offset, uprobe_comm->location_len);
if (!lttng_payload_view_is_valid(¤t_payload_view)) {
ERR("Failed to initialize from malformed event rule uprobe: buffer too short to contain location");
goto end;
}
- ret = lttng_userspace_probe_location_create_from_payload(
- ¤t_payload_view, &location);
+ ret = lttng_userspace_probe_location_create_from_payload(¤t_payload_view,
+ &location);
if (ret < 0) {
ret = -1;
goto end;
return ret;
}
-
-enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_location(
- const struct lttng_event_rule *rule,
- const struct lttng_userspace_probe_location **location)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_uprobe_get_location(const struct lttng_event_rule *rule,
+ const struct lttng_userspace_probe_location **location)
{
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
}
struct lttng_userspace_probe_location *
-lttng_event_rule_kernel_uprobe_get_location_mutable(
- const struct lttng_event_rule *rule)
+lttng_event_rule_kernel_uprobe_get_location_mutable(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_uprobe *uprobe;
return uprobe->location;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_set_event_name(
- struct lttng_event_rule *rule, const char *name)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_uprobe_set_event_name(struct lttng_event_rule *rule, const char *name)
{
char *name_copy = NULL;
struct lttng_event_rule_kernel_uprobe *uprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name ||
- strlen(name) == 0) {
+ if (!rule || !IS_UPROBE_EVENT_RULE(rule) || !name || strlen(name) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_event_rule_status lttng_event_rule_kernel_uprobe_get_event_name(
- const struct lttng_event_rule *rule, const char **name)
+enum lttng_event_rule_status
+lttng_event_rule_kernel_uprobe_get_event_name(const struct lttng_event_rule *rule,
+ const char **name)
{
struct lttng_event_rule_kernel_uprobe *uprobe;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/log4j-logging-internal.hpp>
#include <lttng/event.h>
return;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
lttng_log_level_rule_destroy(log4j_logging->log_level_rule);
free(log4j_logging->pattern);
free(log4j_logging);
}
-static bool lttng_event_rule_log4j_logging_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_log4j_logging_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_log4j_logging *log4j_logging;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
/* Required field. */
if (!log4j_logging->pattern) {
return valid;
}
-static int lttng_event_rule_log4j_logging_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_log4j_logging_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t pattern_len, filter_expression_len, header_offset;
header_offset = payload->buffer.size;
DBG("Serializing log4j_logging event rule.");
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
pattern_len = strlen(log4j_logging->pattern) + 1;
if (log4j_logging->filter_expression != NULL) {
- filter_expression_len =
- strlen(log4j_logging->filter_expression) + 1;
+ filter_expression_len = strlen(log4j_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
}
log4j_logging_comm.pattern_len = pattern_len;
log4j_logging_comm.filter_expression_len = filter_expression_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &log4j_logging_comm,
- sizeof(log4j_logging_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &log4j_logging_comm, sizeof(log4j_logging_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, log4j_logging->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, log4j_logging->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, log4j_logging->filter_expression,
- filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, log4j_logging->filter_expression, filter_expression_len);
if (ret) {
goto end;
}
}
header = (typeof(header)) ((char *) payload->buffer.data + header_offset);
- header->log_level_rule_len =
- payload->buffer.size - size_before_log_level_rule;
+ header->log_level_rule_len = payload->buffer.size - size_before_log_level_rule;
end:
return ret;
}
-static bool lttng_event_rule_log4j_logging_is_equal(
- const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+static bool lttng_event_rule_log4j_logging_is_equal(const struct lttng_event_rule *_a,
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_log4j_logging *a, *b;
goto end;
}
- if (!lttng_log_level_rule_is_equal(
- a->log_level_rule, b->log_level_rule)) {
+ if (!lttng_log_level_rule_is_equal(a->log_level_rule, b->log_level_rule)) {
goto end;
}
*
* An event with NO loglevel and the name is * will return NULL.
*/
-static int generate_agent_filter(
- const struct lttng_event_rule *rule, char **_agent_filter)
+static int generate_agent_filter(const struct lttng_event_rule *rule, char **_agent_filter)
{
int err;
int ret = 0;
goto end;
}
-
/* Don't add filter for the '*' event. */
if (strcmp(pattern, "*") != 0) {
if (filter) {
- err = asprintf(&agent_filter,
- "(%s) && (logger_name == \"%s\")",
- filter, pattern);
+ err = asprintf(
+ &agent_filter, "(%s) && (logger_name == \"%s\")", filter, pattern);
} else {
- err = asprintf(&agent_filter, "logger_name == \"%s\"",
- pattern);
+ err = asprintf(&agent_filter, "logger_name == \"%s\"", pattern);
}
if (err < 0) {
}
}
- status = lttng_event_rule_log4j_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_OK) {
enum lttng_log_level_rule_status llr_status;
const char *op;
int level;
- switch (lttng_log_level_rule_get_type(log_level_rule))
- {
+ switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &level);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule, &level);
op = "==";
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &level);
+ log_level_rule, &level);
op = ">=";
break;
default:
char *new_filter;
err = asprintf(&new_filter,
- "(%s) && (int_loglevel %s %d)",
- agent_filter ? agent_filter : filter,
- op, level);
+ "(%s) && (int_loglevel %s %d)",
+ agent_filter ? agent_filter : filter,
+ op,
+ level);
if (agent_filter) {
free(agent_filter);
}
agent_filter = new_filter;
} else {
- err = asprintf(&agent_filter, "int_loglevel %s %d", op,
- level);
+ err = asprintf(&agent_filter, "int_loglevel %s %d", op, level);
}
if (err < 0) {
}
static enum lttng_error_code
-lttng_event_rule_log4j_logging_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+lttng_event_rule_log4j_logging_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule);
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
}
ret = run_as_generate_filter_bytecode(
- log4j_logging->internal_filter.filter, creds,
- &bytecode);
+ log4j_logging->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
return ret_code;
}
-static const char *lttng_event_rule_log4j_logging_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_log4j_logging_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
LTTNG_ASSERT(rule);
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
return log4j_logging->internal_filter.filter;
}
static const struct lttng_bytecode *
-lttng_event_rule_log4j_logging_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_log4j_logging_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
LTTNG_ASSERT(rule);
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
return log4j_logging->internal_filter.bytecode;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_log4j_logging_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **_exclusions)
+lttng_event_rule_log4j_logging_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
*_exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long lttng_event_rule_log4j_logging_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_log4j_logging_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_log4j_logging *tp_rule =
- lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING, lttng_ht_seed);
hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
if (tp_rule->filter_expression) {
return hash;
}
-static struct lttng_event *lttng_event_rule_log4j_logging_generate_lttng_event(
- const struct lttng_event_rule *rule)
+static struct lttng_event *
+lttng_event_rule_log4j_logging_generate_lttng_event(const struct lttng_event_rule *rule)
{
int ret;
const struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status;
const struct lttng_log_level_rule *log_level_rule;
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
local_event = zmalloc<lttng_event>();
if (!local_event) {
}
local_event->type = LTTNG_EVENT_TRACEPOINT;
- ret = lttng_strncpy(local_event->name, log4j_logging->pattern,
- sizeof(local_event->name));
+ ret = lttng_strncpy(local_event->name, log4j_logging->pattern, sizeof(local_event->name));
if (ret) {
ERR("Truncation occurred when copying event rule pattern to `lttng_event` structure: pattern = '%s'",
- log4j_logging->pattern);
+ log4j_logging->pattern);
goto error;
}
-
/* Map the log level rule to an equivalent lttng_loglevel. */
- status = lttng_event_rule_log4j_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
loglevel_value = 0;
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &loglevel_value);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule,
+ &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &loglevel_value);
+ log_level_rule, &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
break;
default:
return event;
}
-static enum lttng_error_code lttng_event_rule_log4j_logging_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_log4j_logging_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_LOG4J_LOGGING_EVENT_RULE(rule));
- status = lttng_event_rule_log4j_logging_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_log4j_logging_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
- status = lttng_event_rule_log4j_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(rule, &log_level_rule);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
/* Open event rule log4j logging element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_log4j_logging);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_log4j_logging);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter expression. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
/* Log level rule. */
if (log_level_rule) {
- ret_code = lttng_log_level_rule_mi_serialize(
- log_level_rule, writer);
+ ret_code = lttng_log_level_rule_mi_serialize(log_level_rule, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
tp_rule->parent.equal = lttng_event_rule_log4j_logging_is_equal;
tp_rule->parent.destroy = lttng_event_rule_log4j_logging_destroy;
tp_rule->parent.generate_filter_bytecode =
- lttng_event_rule_log4j_logging_generate_filter_bytecode;
- tp_rule->parent.get_filter =
- lttng_event_rule_log4j_logging_get_internal_filter;
+ lttng_event_rule_log4j_logging_generate_filter_bytecode;
+ tp_rule->parent.get_filter = lttng_event_rule_log4j_logging_get_internal_filter;
tp_rule->parent.get_filter_bytecode =
- lttng_event_rule_log4j_logging_get_internal_filter_bytecode;
- tp_rule->parent.generate_exclusions =
- lttng_event_rule_log4j_logging_generate_exclusions;
+ lttng_event_rule_log4j_logging_get_internal_filter_bytecode;
+ tp_rule->parent.generate_exclusions = lttng_event_rule_log4j_logging_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_log4j_logging_hash;
- tp_rule->parent.generate_lttng_event =
- lttng_event_rule_log4j_logging_generate_lttng_event;
+ tp_rule->parent.generate_lttng_event = lttng_event_rule_log4j_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_log4j_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
return rule;
}
-ssize_t lttng_event_rule_log4j_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_log4j_logging_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*log4j_logging_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*log4j_logging_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule log4j_logging: buffer too short to contain header.");
ret = -1;
offset += current_buffer_view.size;
/* Map the pattern. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, log4j_logging_comm->pattern_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, log4j_logging_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- log4j_logging_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, log4j_logging_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- log4j_logging_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, log4j_logging_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
filter_expression = current_buffer_view.data;
if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- log4j_logging_comm->filter_expression_len)) {
+ filter_expression,
+ log4j_logging_comm->filter_expression_len)) {
ret = -1;
goto end;
}
{
/* Map the log level rule. */
- struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- log4j_logging_comm->log_level_rule_len);
+ struct lttng_payload_view current_payload_view = lttng_payload_view_from_view(
+ view, offset, log4j_logging_comm->log_level_rule_len);
- ret = lttng_log_level_rule_create_from_payload(
- ¤t_payload_view, &log_level_rule);
+ ret = lttng_log_level_rule_create_from_payload(¤t_payload_view,
+ &log_level_rule);
if (ret < 0) {
ret = -1;
goto end;
}
if (filter_expression) {
- status = lttng_event_rule_log4j_logging_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_log4j_logging_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule log4j_logging pattern.");
ret = -1;
}
if (log_level_rule) {
- status = lttng_event_rule_log4j_logging_set_log_level_rule(
- rule, log_level_rule);
+ status = lttng_event_rule_log4j_logging_set_log_level_rule(rule, log_level_rule);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule log4j_logging log level rule.");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_log4j_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_LOG4J_LOGGING_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_LOG4J_LOGGING_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
pattern_copy = strdup(pattern);
if (!pattern_copy) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_log4j_logging_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
if (!log4j_logging->pattern) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status
+lttng_event_rule_log4j_logging_set_filter(struct lttng_event_rule *rule, const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_LOG4J_LOGGING_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ if (!rule || !IS_LOG4J_LOGGING_EVENT_RULE(rule) || !expression || strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
expression_copy = strdup(expression);
if (!expression_copy) {
PERROR("Failed to copy filter expression");
return status;
}
-enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_log4j_logging_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
if (!log4j_logging->filter_expression) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-static bool log_level_rule_valid(
- const struct lttng_log_level_rule *rule __attribute__((unused)))
+static bool log_level_rule_valid(const struct lttng_log_level_rule *rule __attribute__((unused)))
{
/*
* For both LOG4J custom log level are possible and can
return true;
}
-enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_log_level_rule(
- struct lttng_event_rule *rule,
- const struct lttng_log_level_rule *log_level_rule)
+enum lttng_event_rule_status
+lttng_event_rule_log4j_logging_set_log_level_rule(struct lttng_event_rule *rule,
+ const struct lttng_log_level_rule *log_level_rule)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
if (!log_level_rule_valid(log_level_rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_log_level_rule(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule
- )
+ const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule)
{
struct lttng_event_rule_log4j_logging *log4j_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- log4j_logging = lttng::utils::container_of(
- rule, <tng_event_rule_log4j_logging::parent);
+ log4j_logging = lttng::utils::container_of(rule, <tng_event_rule_log4j_logging::parent);
if (log4j_logging->log_level_rule == NULL) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/python-logging-internal.hpp>
#include <lttng/event.h>
return;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
lttng_log_level_rule_destroy(python_logging->log_level_rule);
free(python_logging->pattern);
free(python_logging);
}
-static bool lttng_event_rule_python_logging_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_python_logging_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_python_logging *python_logging;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
/* Required field. */
if (!python_logging->pattern) {
return valid;
}
-static int lttng_event_rule_python_logging_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_python_logging_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret;
size_t pattern_len, filter_expression_len, header_offset;
header_offset = payload->buffer.size;
DBG("Serializing python_logging event rule.");
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
pattern_len = strlen(python_logging->pattern) + 1;
if (python_logging->filter_expression != NULL) {
- filter_expression_len =
- strlen(python_logging->filter_expression) + 1;
+ filter_expression_len = strlen(python_logging->filter_expression) + 1;
} else {
filter_expression_len = 0;
}
python_logging_comm.pattern_len = pattern_len;
python_logging_comm.filter_expression_len = filter_expression_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &python_logging_comm,
- sizeof(python_logging_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &python_logging_comm, sizeof(python_logging_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, python_logging->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, python_logging->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, python_logging->filter_expression,
- filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, python_logging->filter_expression, filter_expression_len);
if (ret) {
goto end;
}
}
header = (typeof(header)) ((char *) payload->buffer.data + header_offset);
- header->log_level_rule_len =
- payload->buffer.size - size_before_log_level_rule;
+ header->log_level_rule_len = payload->buffer.size - size_before_log_level_rule;
end:
return ret;
}
-static bool lttng_event_rule_python_logging_is_equal(
- const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+static bool lttng_event_rule_python_logging_is_equal(const struct lttng_event_rule *_a,
+ const struct lttng_event_rule *_b)
{
bool is_equal = false;
struct lttng_event_rule_python_logging *a, *b;
goto end;
}
- if (!lttng_log_level_rule_is_equal(
- a->log_level_rule, b->log_level_rule)) {
+ if (!lttng_log_level_rule_is_equal(a->log_level_rule, b->log_level_rule)) {
goto end;
}
*
* An event with NO loglevel and the name is * will return NULL.
*/
-static int generate_agent_filter(
- const struct lttng_event_rule *rule, char **_agent_filter)
+static int generate_agent_filter(const struct lttng_event_rule *rule, char **_agent_filter)
{
int err;
int ret = 0;
goto end;
}
-
/* Don't add filter for the '*' event. */
if (strcmp(pattern, "*") != 0) {
if (filter) {
- err = asprintf(&agent_filter,
- "(%s) && (logger_name == \"%s\")",
- filter, pattern);
+ err = asprintf(
+ &agent_filter, "(%s) && (logger_name == \"%s\")", filter, pattern);
} else {
- err = asprintf(&agent_filter, "logger_name == \"%s\"",
- pattern);
+ err = asprintf(&agent_filter, "logger_name == \"%s\"", pattern);
}
if (err < 0) {
}
}
- status = lttng_event_rule_python_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_python_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_OK) {
enum lttng_log_level_rule_status llr_status;
const char *op;
int level;
- switch (lttng_log_level_rule_get_type(log_level_rule))
- {
+ switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &level);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule, &level);
op = "==";
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &level);
+ log_level_rule, &level);
op = ">=";
break;
default:
char *new_filter;
err = asprintf(&new_filter,
- "(%s) && (int_loglevel %s %d)",
- agent_filter ? agent_filter : filter,
- op, level);
+ "(%s) && (int_loglevel %s %d)",
+ agent_filter ? agent_filter : filter,
+ op,
+ level);
if (agent_filter) {
free(agent_filter);
}
agent_filter = new_filter;
} else {
- err = asprintf(&agent_filter, "int_loglevel %s %d", op,
- level);
+ err = asprintf(&agent_filter, "int_loglevel %s %d", op, level);
}
if (err < 0) {
}
static enum lttng_error_code
-lttng_event_rule_python_logging_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+lttng_event_rule_python_logging_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule);
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
status = lttng_event_rule_python_logging_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
}
ret = run_as_generate_filter_bytecode(
- python_logging->internal_filter.filter, creds,
- &bytecode);
+ python_logging->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
return ret_code;
}
-static const char *lttng_event_rule_python_logging_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_python_logging_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_python_logging *python_logging;
LTTNG_ASSERT(rule);
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
return python_logging->internal_filter.filter;
}
static const struct lttng_bytecode *
-lttng_event_rule_python_logging_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_python_logging_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_python_logging *python_logging;
LTTNG_ASSERT(rule);
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
return python_logging->internal_filter.bytecode;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_python_logging_generate_exclusions(
- const struct lttng_event_rule *rule __attribute__((unused)),
- struct lttng_event_exclusion **_exclusions)
+lttng_event_rule_python_logging_generate_exclusions(const struct lttng_event_rule *rule
+ __attribute__((unused)),
+ struct lttng_event_exclusion **_exclusions)
{
/* Unsupported. */
*_exclusions = NULL;
return LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_NONE;
}
-static unsigned long lttng_event_rule_python_logging_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_python_logging_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
struct lttng_event_rule_python_logging *tp_rule =
- lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING, lttng_ht_seed);
hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
if (tp_rule->filter_expression) {
return hash;
}
-static struct lttng_event *lttng_event_rule_python_logging_generate_lttng_event(
- const struct lttng_event_rule *rule)
+static struct lttng_event *
+lttng_event_rule_python_logging_generate_lttng_event(const struct lttng_event_rule *rule)
{
int ret;
const struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status;
const struct lttng_log_level_rule *log_level_rule;
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
local_event = zmalloc<lttng_event>();
if (!local_event) {
}
local_event->type = LTTNG_EVENT_TRACEPOINT;
- ret = lttng_strncpy(local_event->name, python_logging->pattern,
- sizeof(local_event->name));
+ ret = lttng_strncpy(local_event->name, python_logging->pattern, sizeof(local_event->name));
if (ret) {
ERR("Truncation occurred when copying event rule pattern to `lttng_event` structure: pattern = '%s'",
- python_logging->pattern);
+ python_logging->pattern);
goto error;
}
-
/* Map the log level rule to an equivalent lttng_loglevel. */
- status = lttng_event_rule_python_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_python_logging_get_log_level_rule(rule, &log_level_rule);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
loglevel_value = 0;
switch (lttng_log_level_rule_get_type(log_level_rule)) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &loglevel_value);
+ llr_status = lttng_log_level_rule_exactly_get_level(log_level_rule,
+ &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_SINGLE;
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &loglevel_value);
+ log_level_rule, &loglevel_value);
loglevel_type = LTTNG_EVENT_LOGLEVEL_RANGE;
break;
default:
return event;
}
-static enum lttng_error_code lttng_event_rule_python_logging_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_python_logging_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_PYTHON_LOGGING_EVENT_RULE(rule));
- status = lttng_event_rule_python_logging_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_python_logging_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_python_logging_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
- status = lttng_event_rule_python_logging_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_python_logging_get_log_level_rule(rule, &log_level_rule);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
/* Open event rule python logging element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_python_logging);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_python_logging);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter expression. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
/* Log level rule. */
if (log_level_rule) {
- ret_code = lttng_log_level_rule_mi_serialize(
- log_level_rule, writer);
+ ret_code = lttng_log_level_rule_mi_serialize(log_level_rule, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
tp_rule->parent.equal = lttng_event_rule_python_logging_is_equal;
tp_rule->parent.destroy = lttng_event_rule_python_logging_destroy;
tp_rule->parent.generate_filter_bytecode =
- lttng_event_rule_python_logging_generate_filter_bytecode;
- tp_rule->parent.get_filter =
- lttng_event_rule_python_logging_get_internal_filter;
+ lttng_event_rule_python_logging_generate_filter_bytecode;
+ tp_rule->parent.get_filter = lttng_event_rule_python_logging_get_internal_filter;
tp_rule->parent.get_filter_bytecode =
- lttng_event_rule_python_logging_get_internal_filter_bytecode;
- tp_rule->parent.generate_exclusions =
- lttng_event_rule_python_logging_generate_exclusions;
+ lttng_event_rule_python_logging_get_internal_filter_bytecode;
+ tp_rule->parent.generate_exclusions = lttng_event_rule_python_logging_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_python_logging_hash;
- tp_rule->parent.generate_lttng_event =
- lttng_event_rule_python_logging_generate_lttng_event;
+ tp_rule->parent.generate_lttng_event = lttng_event_rule_python_logging_generate_lttng_event;
tp_rule->parent.mi_serialize = lttng_event_rule_python_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
return rule;
}
-ssize_t lttng_event_rule_python_logging_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_python_logging_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
enum lttng_event_rule_status status;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*python_logging_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*python_logging_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule python_logging: buffer too short to contain header.");
ret = -1;
/* Map the pattern. */
current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, python_logging_comm->pattern_len);
+ &view->buffer, offset, python_logging_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- python_logging_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, python_logging_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- python_logging_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, python_logging_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
filter_expression = current_buffer_view.data;
if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- python_logging_comm->filter_expression_len)) {
+ filter_expression,
+ python_logging_comm->filter_expression_len)) {
ret = -1;
goto end;
}
{
/* Map the log level rule. */
- struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- python_logging_comm->log_level_rule_len);
+ struct lttng_payload_view current_payload_view = lttng_payload_view_from_view(
+ view, offset, python_logging_comm->log_level_rule_len);
- ret = lttng_log_level_rule_create_from_payload(
- ¤t_payload_view, &log_level_rule);
+ ret = lttng_log_level_rule_create_from_payload(¤t_payload_view,
+ &log_level_rule);
if (ret < 0) {
ret = -1;
goto end;
}
if (filter_expression) {
- status = lttng_event_rule_python_logging_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_python_logging_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule python_logging pattern.");
ret = -1;
}
if (log_level_rule) {
- status = lttng_event_rule_python_logging_set_log_level_rule(
- rule, log_level_rule);
+ status = lttng_event_rule_python_logging_set_log_level_rule(rule, log_level_rule);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule python_logging log level rule.");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_python_logging_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_python_logging_set_name_pattern(struct lttng_event_rule *rule, const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
pattern_copy = strdup(pattern);
if (!pattern_copy) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_python_logging_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_python_logging_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
if (!python_logging->pattern) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_python_logging_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status
+lttng_event_rule_python_logging_set_filter(struct lttng_event_rule *rule, const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
if (!rule || !IS_PYTHON_LOGGING_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
expression_copy = strdup(expression);
if (!expression_copy) {
PERROR("Failed to copy filter expression");
return status;
}
-enum lttng_event_rule_status lttng_event_rule_python_logging_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_python_logging_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
const struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
if (!python_logging->filter_expression) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-static bool log_level_rule_valid(
- const struct lttng_log_level_rule *rule __attribute__((unused)))
+static bool log_level_rule_valid(const struct lttng_log_level_rule *rule __attribute__((unused)))
{
/*
* For python, custom log level are possible, it is not clear if
}
enum lttng_event_rule_status lttng_event_rule_python_logging_set_log_level_rule(
- struct lttng_event_rule *rule,
- const struct lttng_log_level_rule *log_level_rule)
+ struct lttng_event_rule *rule, const struct lttng_log_level_rule *log_level_rule)
{
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
if (!log_level_rule_valid(log_level_rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
enum lttng_event_rule_status lttng_event_rule_python_logging_get_log_level_rule(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule
- )
+ const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule)
{
struct lttng_event_rule_python_logging *python_logging;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- python_logging = lttng::utils::container_of(
- rule, <tng_event_rule_python_logging::parent);
+ python_logging = lttng::utils::container_of(rule, <tng_event_rule_python_logging::parent);
if (python_logging->log_level_rule == NULL) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
#include <common/payload.hpp>
#include <common/runas.hpp>
#include <common/string-utils/string-utils.hpp>
+
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/user-tracepoint-internal.hpp>
#include <lttng/event.h>
return;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
lttng_log_level_rule_destroy(tracepoint->log_level_rule);
lttng_dynamic_pointer_array_reset(&tracepoint->exclusions);
free(tracepoint);
}
-static bool lttng_event_rule_user_tracepoint_validate(
- const struct lttng_event_rule *rule)
+static bool lttng_event_rule_user_tracepoint_validate(const struct lttng_event_rule *rule)
{
bool valid = false;
struct lttng_event_rule_user_tracepoint *tracepoint;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
/* Required field. */
if (!tracepoint->pattern) {
return valid;
}
-static int lttng_event_rule_user_tracepoint_serialize(
- const struct lttng_event_rule *rule,
- struct lttng_payload *payload)
+static int lttng_event_rule_user_tracepoint_serialize(const struct lttng_event_rule *rule,
+ struct lttng_payload *payload)
{
int ret, i;
size_t pattern_len, filter_expression_len, exclusions_len, header_offset;
header_offset = payload->buffer.size;
DBG("Serializing user tracepoint event rule.");
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
- status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &exclusion_count);
+ status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
+ rule, &exclusion_count);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
pattern_len = strlen(tracepoint->pattern) + 1;
if (tracepoint->filter_expression != NULL) {
- filter_expression_len =
- strlen(tracepoint->filter_expression) + 1;
+ filter_expression_len = strlen(tracepoint->filter_expression) + 1;
} else {
filter_expression_len = 0;
}
const char *exclusion;
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- rule, i, &exclusion);
+ rule, i, &exclusion);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
/* Length field. */
tracepoint_comm.exclusions_count = exclusion_count;
tracepoint_comm.exclusions_len = exclusions_len;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &tracepoint_comm,
- sizeof(tracepoint_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &tracepoint_comm, sizeof(tracepoint_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, tracepoint->pattern, pattern_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, tracepoint->pattern, pattern_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, tracepoint->filter_expression,
- filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, tracepoint->filter_expression, filter_expression_len);
if (ret) {
goto end;
}
}
header = (typeof(header)) ((char *) payload->buffer.data + header_offset);
- header->log_level_rule_len =
- payload->buffer.size - size_before_log_level_rule;
+ header->log_level_rule_len = payload->buffer.size - size_before_log_level_rule;
for (i = 0; i < exclusion_count; i++) {
size_t len;
const char *exclusion;
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- rule, i, &exclusion);
+ rule, i, &exclusion);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
len = strlen(exclusion) + 1;
/* Append exclusion length, includes the null terminator. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &len, sizeof(uint32_t));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &len, sizeof(uint32_t));
if (ret) {
goto end;
}
exclusions_appended_len += sizeof(uint32_t);
/* Include the '\0' in the payload. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, exclusion, len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, exclusion, len);
if (ret) {
goto end;
}
return ret;
}
-static bool lttng_event_rule_user_tracepoint_is_equal(
- const struct lttng_event_rule *_a,
- const struct lttng_event_rule *_b)
+static bool lttng_event_rule_user_tracepoint_is_equal(const struct lttng_event_rule *_a,
+ const struct lttng_event_rule *_b)
{
int i;
bool is_equal = false;
goto end;
}
- if (!lttng_log_level_rule_is_equal(
- a->log_level_rule, b->log_level_rule)) {
+ if (!lttng_log_level_rule_is_equal(a->log_level_rule, b->log_level_rule)) {
goto end;
}
const char *exclusion_a, *exclusion_b;
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- _a, i, &exclusion_a);
+ _a, i, &exclusion_a);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- _b, i, &exclusion_b);
+ _b, i, &exclusion_b);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
if (strcmp(exclusion_a, exclusion_b)) {
goto end;
}
static enum lttng_error_code
-lttng_event_rule_user_tracepoint_generate_filter_bytecode(
- struct lttng_event_rule *rule,
- const struct lttng_credentials *creds)
+lttng_event_rule_user_tracepoint_generate_filter_bytecode(struct lttng_event_rule *rule,
+ const struct lttng_credentials *creds)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter);
if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
goto end;
}
- ret = run_as_generate_filter_bytecode(
- tracepoint->internal_filter.filter, creds,
- &bytecode);
+ ret = run_as_generate_filter_bytecode(tracepoint->internal_filter.filter, creds, &bytecode);
if (ret) {
ret_code = LTTNG_ERR_FILTER_INVAL;
goto end;
return ret_code;
}
-static const char *lttng_event_rule_user_tracepoint_get_internal_filter(
- const struct lttng_event_rule *rule)
+static const char *
+lttng_event_rule_user_tracepoint_get_internal_filter(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
return tracepoint->internal_filter.filter;
}
static const struct lttng_bytecode *
-lttng_event_rule_user_tracepoint_get_internal_filter_bytecode(
- const struct lttng_event_rule *rule)
+lttng_event_rule_user_tracepoint_get_internal_filter_bytecode(const struct lttng_event_rule *rule)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
LTTNG_ASSERT(rule);
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
return tracepoint->internal_filter.bytecode;
}
static enum lttng_event_rule_generate_exclusions_status
-lttng_event_rule_user_tracepoint_generate_exclusions(
- const struct lttng_event_rule *rule,
- struct lttng_event_exclusion **_exclusions)
+lttng_event_rule_user_tracepoint_generate_exclusions(const struct lttng_event_rule *rule,
+ struct lttng_event_exclusion **_exclusions)
{
unsigned int nb_exclusions = 0, i;
struct lttng_event_exclusion *exclusions;
LTTNG_ASSERT(_exclusions);
event_rule_status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
- rule, &nb_exclusions);
+ rule, &nb_exclusions);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
if (nb_exclusions == 0) {
/* Nothing to do. */
goto end;
}
- exclusions = zmalloc<lttng_event_exclusion>(sizeof(struct lttng_event_exclusion) + (LTTNG_SYMBOL_NAME_LEN * nb_exclusions));
+ exclusions = zmalloc<lttng_event_exclusion>(sizeof(struct lttng_event_exclusion) +
+ (LTTNG_SYMBOL_NAME_LEN * nb_exclusions));
if (!exclusions) {
PERROR("Failed to allocate exclusions buffer");
ret_status = LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY;
const char *exclusion_str;
event_rule_status =
- lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- rule, i, &exclusion_str);
+ lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
+ rule, i, &exclusion_str);
LTTNG_ASSERT(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
- copy_ret = lttng_strncpy(
- LTTNG_EVENT_EXCLUSION_NAME_AT(exclusions, i),
- exclusion_str,
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusions, i)));
+ copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusions, i),
+ exclusion_str,
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusions, i)));
if (copy_ret) {
free(exclusions);
exclusions = NULL;
free(ptr);
}
-static unsigned long lttng_event_rule_user_tracepoint_hash(
- const struct lttng_event_rule *rule)
+static unsigned long lttng_event_rule_user_tracepoint_hash(const struct lttng_event_rule *rule)
{
unsigned long hash;
unsigned int i, exclusion_count;
enum lttng_event_rule_status status;
struct lttng_event_rule_user_tracepoint *tp_rule =
- lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
+ lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
- hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT,
- lttng_ht_seed);
+ hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT, lttng_ht_seed);
hash ^= hash_key_str(tp_rule->pattern, lttng_ht_seed);
if (tp_rule->filter_expression) {
hash ^= lttng_log_level_rule_hash(tp_rule->log_level_rule);
}
- status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule,
- &exclusion_count);
+ status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
+ rule, &exclusion_count);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
for (i = 0; i < exclusion_count; i++) {
const char *exclusion;
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- rule, i, &exclusion);
+ rule, i, &exclusion);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
hash ^= hash_key_str(exclusion, lttng_ht_seed);
}
return hash;
}
-static enum lttng_error_code lttng_event_rule_user_tracepoint_mi_serialize(
- const struct lttng_event_rule *rule, struct mi_writer *writer)
+static enum lttng_error_code
+lttng_event_rule_user_tracepoint_mi_serialize(const struct lttng_event_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(IS_USER_TRACEPOINT_EVENT_RULE(rule));
- status = lttng_event_rule_user_tracepoint_get_name_pattern(
- rule, &name_pattern);
+ status = lttng_event_rule_user_tracepoint_get_name_pattern(rule, &name_pattern);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
LTTNG_ASSERT(name_pattern);
status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
- status = lttng_event_rule_user_tracepoint_get_log_level_rule(
- rule, &log_level_rule);
+ status = lttng_event_rule_user_tracepoint_get_log_level_rule(rule, &log_level_rule);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK ||
- status == LTTNG_EVENT_RULE_STATUS_UNSET);
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
- rule, &exclusion_count);
+ rule, &exclusion_count);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
/* Open event rule user tracepoint element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_event_rule_user_tracepoint);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule_user_tracepoint);
if (ret) {
goto mi_error;
}
/* Name pattern. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_name_pattern, name_pattern);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_name_pattern, name_pattern);
if (ret) {
goto mi_error;
}
/* Filter expression. */
if (filter != NULL) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_filter_expression,
- filter);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_event_rule_filter_expression, filter);
if (ret) {
goto mi_error;
}
/* Log level rule. */
if (log_level_rule) {
- ret_code = lttng_log_level_rule_mi_serialize(
- log_level_rule, writer);
+ ret_code = lttng_log_level_rule_mi_serialize(log_level_rule, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
int i;
/* Open the exclusion list. */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions);
+ ret = mi_lttng_writer_open_element(
+ writer,
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions);
if (ret) {
goto mi_error;
}
for (i = 0; i < exclusion_count; i++) {
const char *exclusion;
- status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
+ status =
+ lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
rule, i, &exclusion);
LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion,
- exclusion);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion,
+ exclusion);
if (ret) {
goto mi_error;
}
tp_rule->parent.equal = lttng_event_rule_user_tracepoint_is_equal;
tp_rule->parent.destroy = lttng_event_rule_user_tracepoint_destroy;
tp_rule->parent.generate_filter_bytecode =
- lttng_event_rule_user_tracepoint_generate_filter_bytecode;
- tp_rule->parent.get_filter =
- lttng_event_rule_user_tracepoint_get_internal_filter;
+ lttng_event_rule_user_tracepoint_generate_filter_bytecode;
+ tp_rule->parent.get_filter = lttng_event_rule_user_tracepoint_get_internal_filter;
tp_rule->parent.get_filter_bytecode =
- lttng_event_rule_user_tracepoint_get_internal_filter_bytecode;
- tp_rule->parent.generate_exclusions =
- lttng_event_rule_user_tracepoint_generate_exclusions;
+ lttng_event_rule_user_tracepoint_get_internal_filter_bytecode;
+ tp_rule->parent.generate_exclusions = lttng_event_rule_user_tracepoint_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_user_tracepoint_hash;
tp_rule->parent.mi_serialize = lttng_event_rule_user_tracepoint_mi_serialize;
tp_rule->log_level_rule = NULL;
- lttng_dynamic_pointer_array_init(&tp_rule->exclusions,
- destroy_lttng_exclusions_element);
+ lttng_dynamic_pointer_array_init(&tp_rule->exclusions, destroy_lttng_exclusions_element);
/* Default pattern is '*'. */
status = lttng_event_rule_user_tracepoint_set_name_pattern(rule, "*");
return rule;
}
-ssize_t lttng_event_rule_user_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_rule **_event_rule)
+ssize_t lttng_event_rule_user_tracepoint_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_rule **_event_rule)
{
ssize_t ret, offset = 0;
int i;
goto end;
}
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*tracepoint_comm));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*tracepoint_comm));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ERR("Failed to initialize from malformed event rule tracepoint: buffer too short to contain header.");
ret = -1;
offset += current_buffer_view.size;
/* Map the pattern. */
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, tracepoint_comm->pattern_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, tracepoint_comm->pattern_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
}
pattern = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view, pattern,
- tracepoint_comm->pattern_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, pattern, tracepoint_comm->pattern_len)) {
ret = -1;
goto end;
}
}
/* Map the filter_expression. */
- current_buffer_view = lttng_buffer_view_from_view(&view->buffer, offset,
- tracepoint_comm->filter_expression_len);
+ current_buffer_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, tracepoint_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
filter_expression = current_buffer_view.data;
if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- filter_expression,
- tracepoint_comm->filter_expression_len)) {
+ filter_expression,
+ tracepoint_comm->filter_expression_len)) {
ret = -1;
goto end;
}
{
/* Map the log level rule. */
- struct lttng_payload_view current_payload_view =
- lttng_payload_view_from_view(view, offset,
- tracepoint_comm->log_level_rule_len);
+ struct lttng_payload_view current_payload_view = lttng_payload_view_from_view(
+ view, offset, tracepoint_comm->log_level_rule_len);
- ret = lttng_log_level_rule_create_from_payload(
- ¤t_payload_view, &log_level_rule);
+ ret = lttng_log_level_rule_create_from_payload(¤t_payload_view,
+ &log_level_rule);
if (ret < 0) {
ret = -1;
goto end;
skip_log_level_rule:
for (i = 0; i < tracepoint_comm->exclusions_count; i++) {
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*exclusion_len));
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*exclusion_len));
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
exclusion_len = (typeof(exclusion_len)) current_buffer_view.data;
offset += sizeof(*exclusion_len);
- current_buffer_view = lttng_buffer_view_from_view(
- &view->buffer, offset, *exclusion_len);
+ current_buffer_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, *exclusion_len);
if (!lttng_buffer_view_is_valid(¤t_buffer_view)) {
ret = -1;
goto end;
}
exclusion = current_buffer_view.data;
- if (!lttng_buffer_view_contains_string(¤t_buffer_view,
- exclusion, *exclusion_len)) {
+ if (!lttng_buffer_view_contains_string(
+ ¤t_buffer_view, exclusion, *exclusion_len)) {
ret = -1;
goto end;
}
- status = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(rule, exclusion);
+ status = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(rule,
+ exclusion);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to add event rule user tracepoint exclusion \"%s\".",
- exclusion);
+ exclusion);
ret = -1;
goto end;
}
}
if (filter_expression) {
- status = lttng_event_rule_user_tracepoint_set_filter(
- rule, filter_expression);
+ status = lttng_event_rule_user_tracepoint_set_filter(rule, filter_expression);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule user tracepoint pattern.");
ret = -1;
}
if (log_level_rule) {
- status = lttng_event_rule_user_tracepoint_set_log_level_rule(
- rule, log_level_rule);
+ status = lttng_event_rule_user_tracepoint_set_log_level_rule(rule, log_level_rule);
if (status != LTTNG_EVENT_RULE_STATUS_OK) {
ERR("Failed to set event rule user tracepoint log level rule.");
ret = -1;
return ret;
}
-enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_name_pattern(
- struct lttng_event_rule *rule, const char *pattern)
+enum lttng_event_rule_status
+lttng_event_rule_user_tracepoint_set_name_pattern(struct lttng_event_rule *rule,
+ const char *pattern)
{
char *pattern_copy = NULL;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule) || !pattern ||
- strlen(pattern) == 0) {
+ if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule) || !pattern || strlen(pattern) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
pattern_copy = strdup(pattern);
if (!pattern_copy) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern(
- const struct lttng_event_rule *rule, const char **pattern)
+enum lttng_event_rule_status
+lttng_event_rule_user_tracepoint_get_name_pattern(const struct lttng_event_rule *rule,
+ const char **pattern)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (!tracepoint->pattern) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_filter(
- struct lttng_event_rule *rule, const char *expression)
+enum lttng_event_rule_status
+lttng_event_rule_user_tracepoint_set_filter(struct lttng_event_rule *rule, const char *expression)
{
char *expression_copy = NULL;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule) || !expression ||
- strlen(expression) == 0) {
+ strlen(expression) == 0) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
expression_copy = strdup(expression);
if (!expression_copy) {
PERROR("Failed to copy filter expression");
return status;
}
-enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_filter(
- const struct lttng_event_rule *rule, const char **expression)
+enum lttng_event_rule_status
+lttng_event_rule_user_tracepoint_get_filter(const struct lttng_event_rule *rule,
+ const char **expression)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (!tracepoint->filter_expression) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
status = lttng_log_level_rule_exactly_get_level(rule, &level);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
- status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- rule, &level);
+ status = lttng_log_level_rule_at_least_as_severe_as_get_level(rule, &level);
break;
default:
abort();
}
enum lttng_event_rule_status lttng_event_rule_user_tracepoint_set_log_level_rule(
- struct lttng_event_rule *rule,
- const struct lttng_log_level_rule *log_level_rule)
+ struct lttng_event_rule *rule, const struct lttng_log_level_rule *log_level_rule)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (!log_level_rule_valid(log_level_rule)) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
}
enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_log_level_rule(
- const struct lttng_event_rule *rule,
- const struct lttng_log_level_rule **log_level_rule
- )
+ const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (tracepoint->log_level_rule == NULL) {
status = LTTNG_EVENT_RULE_STATUS_UNSET;
goto end;
return status;
}
-enum lttng_event_rule_status lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(
- struct lttng_event_rule *rule,
- const char *exclusion)
+enum lttng_event_rule_status
+lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(struct lttng_event_rule *rule,
+ const char *exclusion)
{
int ret;
char *exclusion_copy = NULL;
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
- if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule) ||
- !exclusion) {
+ if (!rule || !IS_USER_TRACEPOINT_EVENT_RULE(rule) || !exclusion) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (strlen(exclusion) >= LTTNG_SYMBOL_NAME_LEN) {
status = LTTNG_EVENT_RULE_STATUS_INVALID;
goto end;
}
- ret = lttng_dynamic_pointer_array_add_pointer(&tracepoint->exclusions,
- exclusion_copy);
+ ret = lttng_dynamic_pointer_array_add_pointer(&tracepoint->exclusions, exclusion_copy);
if (ret < 0) {
status = LTTNG_EVENT_RULE_STATUS_ERROR;
goto end;
}
enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
- const struct lttng_event_rule *rule, unsigned int *count)
+ const struct lttng_event_rule *rule, unsigned int *count)
{
struct lttng_event_rule_user_tracepoint *tracepoint;
enum lttng_event_rule_status status = LTTNG_EVENT_RULE_STATUS_OK;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
*count = lttng_dynamic_pointer_array_get_count(&tracepoint->exclusions);
end:
return status;
}
enum lttng_event_rule_status lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- const struct lttng_event_rule *rule,
- unsigned int index,
- const char **exclusion)
+ const struct lttng_event_rule *rule, unsigned int index, const char **exclusion)
{
unsigned int count;
struct lttng_event_rule_user_tracepoint *tracepoint;
goto end;
}
- tracepoint = lttng::utils::container_of(
- rule, <tng_event_rule_user_tracepoint::parent);
+ tracepoint = lttng::utils::container_of(rule, <tng_event_rule_user_tracepoint::parent);
if (lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(rule, &count) !=
- LTTNG_EVENT_RULE_STATUS_OK) {
+ LTTNG_EVENT_RULE_STATUS_OK) {
goto end;
}
goto end;
}
- *exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(
- &tracepoint->exclusions, index);
+ *exclusion = (const char *) lttng_dynamic_pointer_array_get_pointer(&tracepoint->exclusions,
+ index);
end:
return status;
}
goto end;
}
-static int lttng_event_probe_attr_serialize(
- const struct lttng_event_probe_attr *probe,
- struct lttng_payload *payload)
+static int lttng_event_probe_attr_serialize(const struct lttng_event_probe_attr *probe,
+ struct lttng_payload *payload)
{
int ret;
size_t symbol_name_len;
struct lttng_event_probe_attr_comm comm = {};
- symbol_name_len = lttng_strnlen(
- probe->symbol_name, sizeof(probe->symbol_name));
+ symbol_name_len = lttng_strnlen(probe->symbol_name, sizeof(probe->symbol_name));
if (symbol_name_len == sizeof(probe->symbol_name)) {
/* Not null-termintated. */
ret = -1;
comm.addr = probe->addr;
comm.offset = probe->addr;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret < 0) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, probe->symbol_name, symbol_name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, probe->symbol_name, symbol_name_len);
end:
return ret;
}
-static int lttng_event_function_attr_serialize(
- const struct lttng_event_function_attr *function,
- struct lttng_payload *payload)
+static int lttng_event_function_attr_serialize(const struct lttng_event_function_attr *function,
+ struct lttng_payload *payload)
{
int ret;
size_t symbol_name_len;
comm.symbol_name_len = 0;
- symbol_name_len = lttng_strnlen(
- function->symbol_name, sizeof(function->symbol_name));
+ symbol_name_len = lttng_strnlen(function->symbol_name, sizeof(function->symbol_name));
if (symbol_name_len == sizeof(function->symbol_name)) {
/* Not null-termintated. */
ret = -1;
comm.symbol_name_len = (uint32_t) symbol_name_len;
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret < 0) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- function->symbol_name, symbol_name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, function->symbol_name, symbol_name_len);
end:
return ret;
}
-static ssize_t lttng_event_probe_attr_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_probe_attr **probe_attr)
+static ssize_t
+lttng_event_probe_attr_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_probe_attr **probe_attr)
{
ssize_t ret, offset = 0;
const struct lttng_event_probe_attr_comm *comm;
struct lttng_event_probe_attr *local_attr = NULL;
- struct lttng_payload_view comm_view = lttng_payload_view_from_view(
- view, offset, sizeof(*comm));
+ struct lttng_payload_view comm_view =
+ lttng_payload_view_from_view(view, offset, sizeof(*comm));
if (!lttng_payload_view_is_valid(&comm_view)) {
ret = -1;
{
const char *name;
struct lttng_payload_view name_view =
- lttng_payload_view_from_view(view, offset,
- comm->symbol_name_len);
+ lttng_payload_view_from_view(view, offset, comm->symbol_name_len);
if (!lttng_payload_view_is_valid(&name_view)) {
ret = -1;
name = name_view.buffer.data;
- if (!lttng_buffer_view_contains_string(&name_view.buffer, name,
- comm->symbol_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &name_view.buffer, name, comm->symbol_name_len)) {
ret = -1;
goto end;
}
- ret = lttng_strncpy(local_attr->symbol_name, name,
- sizeof(local_attr->symbol_name));
+ ret = lttng_strncpy(local_attr->symbol_name, name, sizeof(local_attr->symbol_name));
if (ret) {
ret = -1;
goto end;
return ret;
}
-static ssize_t lttng_event_function_attr_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_function_attr **function_attr)
+static ssize_t
+lttng_event_function_attr_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_function_attr **function_attr)
{
ssize_t ret, offset = 0;
const struct lttng_event_function_attr_comm *comm;
struct lttng_event_function_attr *local_attr = NULL;
- struct lttng_payload_view comm_view = lttng_payload_view_from_view(
- view, offset, sizeof(*comm));
+ struct lttng_payload_view comm_view =
+ lttng_payload_view_from_view(view, offset, sizeof(*comm));
if (!lttng_payload_view_is_valid(&comm_view)) {
ret = -1;
{
const char *name;
struct lttng_payload_view name_view =
- lttng_payload_view_from_view(view, offset,
- comm->symbol_name_len);
+ lttng_payload_view_from_view(view, offset, comm->symbol_name_len);
if (!lttng_payload_view_is_valid(&name_view)) {
ret = -1;
name = name_view.buffer.data;
- if (!lttng_buffer_view_contains_string(&name_view.buffer, name,
- comm->symbol_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &name_view.buffer, name, comm->symbol_name_len)) {
ret = -1;
goto end;
}
- ret = lttng_strncpy(local_attr->symbol_name, name,
- sizeof(local_attr->symbol_name));
+ ret = lttng_strncpy(local_attr->symbol_name, name, sizeof(local_attr->symbol_name));
if (ret) {
ret = -1;
goto end;
return ret;
}
-static ssize_t lttng_event_exclusions_create_from_payload(
- struct lttng_payload_view *view,
- uint32_t count,
- struct lttng_event_exclusion **exclusions)
+static ssize_t lttng_event_exclusions_create_from_payload(struct lttng_payload_view *view,
+ uint32_t count,
+ struct lttng_event_exclusion **exclusions)
{
ssize_t ret, offset = 0;
const size_t size = (count * LTTNG_SYMBOL_NAME_LEN);
const struct lttng_event_exclusion_comm *comm;
struct lttng_event_exclusion *local_exclusions;
- local_exclusions = zmalloc<lttng_event_exclusion>(
- sizeof(struct lttng_event_exclusion) + size);
+ local_exclusions =
+ zmalloc<lttng_event_exclusion>(sizeof(struct lttng_event_exclusion) + size);
if (!local_exclusions) {
ret = -1;
goto end;
const char *string;
struct lttng_buffer_view string_view;
const struct lttng_buffer_view comm_view =
- lttng_buffer_view_from_view(&view->buffer,
- offset, sizeof(*comm));
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
if (!lttng_buffer_view_is_valid(&comm_view)) {
ret = -1;
comm = (typeof(comm)) comm_view.data;
offset += sizeof(*comm);
- string_view = lttng_buffer_view_from_view(
- &view->buffer, offset, comm->len);
+ string_view = lttng_buffer_view_from_view(&view->buffer, offset, comm->len);
if (!lttng_buffer_view_is_valid(&string_view)) {
ret = -1;
string = string_view.data;
- if (!lttng_buffer_view_contains_string(
- &string_view, string, comm->len)) {
+ if (!lttng_buffer_view_contains_string(&string_view, string, comm->len)) {
ret = -1;
goto end;
}
- ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(local_exclusions, i), string,
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(local_exclusions, i)));
+ ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(local_exclusions, i),
+ string,
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(local_exclusions, i)));
if (ret) {
ret = -1;
goto end;
}
ssize_t lttng_event_create_from_payload(struct lttng_payload_view *view,
- struct lttng_event **out_event,
- struct lttng_event_exclusion **out_exclusion,
- char **out_filter_expression,
- struct lttng_bytecode **out_bytecode)
+ struct lttng_event **out_event,
+ struct lttng_event_exclusion **out_exclusion,
+ char **out_filter_expression,
+ struct lttng_bytecode **out_bytecode)
{
ssize_t ret, offset = 0;
struct lttng_event *local_event = NULL;
const struct lttng_event_comm *event_comm;
struct lttng_event_function_attr *local_function_attr = NULL;
struct lttng_event_probe_attr *local_probe_attr = NULL;
- struct lttng_userspace_probe_location *local_userspace_probe_location =
- NULL;
+ struct lttng_userspace_probe_location *local_userspace_probe_location = NULL;
/*
* Only event is obligatory, the other output argument are optional and
{
struct lttng_payload_view comm_view =
- lttng_payload_view_from_view(view, offset,
- sizeof(*event_comm));
+ lttng_payload_view_from_view(view, offset, sizeof(*event_comm));
if (!lttng_payload_view_is_valid(&comm_view)) {
ret = -1;
{
const char *name;
const struct lttng_buffer_view name_view =
- lttng_buffer_view_from_view(&view->buffer,
- offset, event_comm->name_len);
+ lttng_buffer_view_from_view(&view->buffer, offset, event_comm->name_len);
if (!lttng_buffer_view_is_valid(&name_view)) {
ret = -1;
name = (const char *) name_view.data;
- if (!lttng_buffer_view_contains_string(
- &name_view, name, event_comm->name_len)) {
+ if (!lttng_buffer_view_contains_string(&name_view, name, event_comm->name_len)) {
ret = -1;
goto end;
}
- ret = lttng_strncpy(local_event->name, name,
- sizeof(local_event->name));
+ ret = lttng_strncpy(local_event->name, name, sizeof(local_event->name));
if (ret) {
ret = -1;
goto end;
{
struct lttng_payload_view exclusions_view =
- lttng_payload_view_from_view(
- view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
if (!lttng_payload_view_is_valid(&exclusions_view)) {
ret = -1;
goto end;
}
- ret = lttng_event_exclusions_create_from_payload(&exclusions_view,
- event_comm->exclusion_count, &local_exclusions);
+ ret = lttng_event_exclusions_create_from_payload(
+ &exclusions_view, event_comm->exclusion_count, &local_exclusions);
if (ret < 0) {
ret = -1;
goto end;
{
const char *filter_expression_buffer;
- struct lttng_buffer_view filter_expression_view =
- lttng_buffer_view_from_view(&view->buffer, offset,
- event_comm->filter_expression_len);
+ struct lttng_buffer_view filter_expression_view = lttng_buffer_view_from_view(
+ &view->buffer, offset, event_comm->filter_expression_len);
if (!lttng_buffer_view_is_valid(&filter_expression_view)) {
ret = -1;
filter_expression_buffer = filter_expression_view.data;
if (!lttng_buffer_view_contains_string(&filter_expression_view,
- filter_expression_buffer,
- event_comm->filter_expression_len)) {
+ filter_expression_buffer,
+ event_comm->filter_expression_len)) {
ret = -1;
goto end;
}
- local_filter_expression = lttng_strndup(
- filter_expression_buffer,
- event_comm->filter_expression_len);
+ local_filter_expression =
+ lttng_strndup(filter_expression_buffer, event_comm->filter_expression_len);
if (!local_filter_expression) {
ret = -1;
goto end;
/* Bytecode */
{
struct lttng_payload_view bytecode_view =
- lttng_payload_view_from_view(view, offset,
- event_comm->bytecode_len);
+ lttng_payload_view_from_view(view, offset, event_comm->bytecode_len);
if (!lttng_payload_view_is_valid(&bytecode_view)) {
ret = -1;
goto end;
}
- memcpy(local_bytecode, bytecode_view.buffer.data,
- event_comm->bytecode_len);
- if ((local_bytecode->len + sizeof(*local_bytecode)) !=
- event_comm->bytecode_len) {
+ memcpy(local_bytecode, bytecode_view.buffer.data, event_comm->bytecode_len);
+ if ((local_bytecode->len + sizeof(*local_bytecode)) != event_comm->bytecode_len) {
ret = -1;
goto end;
}
/* Fallthrough */
case LTTNG_EVENT_PROBE:
{
- struct lttng_payload_view probe_attr_view =
- lttng_payload_view_from_view(view, offset,
- event_comm->lttng_event_probe_attr_len);
+ struct lttng_payload_view probe_attr_view = lttng_payload_view_from_view(
+ view, offset, event_comm->lttng_event_probe_attr_len);
if (event_comm->lttng_event_probe_attr_len == 0) {
ret = -1;
goto end;
}
- ret = lttng_event_probe_attr_create_from_payload(
- &probe_attr_view, &local_probe_attr);
+ ret = lttng_event_probe_attr_create_from_payload(&probe_attr_view,
+ &local_probe_attr);
if (ret < 0 || ret != event_comm->lttng_event_probe_attr_len) {
ret = -1;
goto end;
}
/* Copy to the local event. */
- memcpy(&local_event->attr.probe, local_probe_attr,
- sizeof(local_event->attr.probe));
+ memcpy(&local_event->attr.probe, local_probe_attr, sizeof(local_event->attr.probe));
offset += ret;
break;
}
case LTTNG_EVENT_FUNCTION_ENTRY:
{
- struct lttng_payload_view function_attr_view =
- lttng_payload_view_from_view(view, offset,
- event_comm->lttng_event_function_attr_len);
+ struct lttng_payload_view function_attr_view = lttng_payload_view_from_view(
+ view, offset, event_comm->lttng_event_function_attr_len);
if (event_comm->lttng_event_function_attr_len == 0) {
ret = -1;
goto end;
}
- ret = lttng_event_function_attr_create_from_payload(
- &function_attr_view, &local_function_attr);
+ ret = lttng_event_function_attr_create_from_payload(&function_attr_view,
+ &local_function_attr);
if (ret < 0 || ret != event_comm->lttng_event_function_attr_len) {
ret = -1;
goto end;
}
/* Copy to the local event. */
- memcpy(&local_event->attr.ftrace, local_function_attr,
- sizeof(local_event->attr.ftrace));
+ memcpy(&local_event->attr.ftrace,
+ local_function_attr,
+ sizeof(local_event->attr.ftrace));
offset += ret;
case LTTNG_EVENT_USERSPACE_PROBE:
{
struct lttng_payload_view userspace_probe_location_view =
- lttng_payload_view_from_view(view, offset,
- event_comm->userspace_probe_location_len);
+ lttng_payload_view_from_view(
+ view, offset, event_comm->userspace_probe_location_len);
if (event_comm->userspace_probe_location_len == 0) {
ret = -1;
goto end;
}
- if (!lttng_payload_view_is_valid(
- &userspace_probe_location_view)) {
+ if (!lttng_payload_view_is_valid(&userspace_probe_location_view)) {
ret = -1;
goto end;
}
ret = lttng_userspace_probe_location_create_from_payload(
- &userspace_probe_location_view,
- &local_userspace_probe_location);
+ &userspace_probe_location_view, &local_userspace_probe_location);
if (ret < 0) {
WARN("Failed to create a userspace probe location from the received buffer");
ret = -1;
}
if (ret != event_comm->userspace_probe_location_len) {
- WARN("Userspace probe location from the received buffer is not the advertised length: header length = %" PRIu32 ", payload length = %zd", event_comm->userspace_probe_location_len, ret);
+ WARN("Userspace probe location from the received buffer is not the advertised length: header length = %" PRIu32
+ ", payload length = %zd",
+ event_comm->userspace_probe_location_len,
+ ret);
ret = -1;
goto end;
}
/* Attach the probe location to the event. */
- ret = lttng_event_set_userspace_probe_location(
- local_event, local_userspace_probe_location);
+ ret = lttng_event_set_userspace_probe_location(local_event,
+ local_userspace_probe_location);
if (ret) {
ret = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
}
int lttng_event_serialize(const struct lttng_event *event,
- unsigned int exclusion_count,
- char **exclusion_list,
- char *filter_expression,
- size_t bytecode_len,
- struct lttng_bytecode *bytecode,
- struct lttng_payload *payload)
+ unsigned int exclusion_count,
+ char **exclusion_list,
+ char *filter_expression,
+ size_t bytecode_len,
+ struct lttng_bytecode *bytecode,
+ struct lttng_payload *payload)
{
int ret;
unsigned int i;
event_comm.flags = (int32_t) event->flags;
if (filter_expression) {
- event_comm.filter_expression_len =
- strlen(filter_expression) + 1;
+ event_comm.filter_expression_len = strlen(filter_expression) + 1;
}
/* Header */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &event_comm, sizeof(event_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &event_comm, sizeof(event_comm));
if (ret) {
goto end;
}
/* Event name */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, event->name, name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, event->name, name_len);
if (ret) {
goto end;
}
/* Exclusions */
for (i = 0; i < exclusion_count; i++) {
- const size_t exclusion_len = lttng_strnlen(
- *(exclusion_list + i), LTTNG_SYMBOL_NAME_LEN);
+ const size_t exclusion_len =
+ lttng_strnlen(*(exclusion_list + i), LTTNG_SYMBOL_NAME_LEN);
struct lttng_event_exclusion_comm exclusion_header;
exclusion_header.len = (uint32_t) exclusion_len + 1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &exclusion_header, sizeof(exclusion_header));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &exclusion_header, sizeof(exclusion_header));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- *(exclusion_list + i), exclusion_len + 1);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, *(exclusion_list + i), exclusion_len + 1);
if (ret) {
goto end;
}
/* Filter expression and its bytecode */
if (filter_expression) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- filter_expression,
- event_comm.filter_expression_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, filter_expression, event_comm.filter_expression_len);
if (ret) {
goto end;
}
* for listing.
*/
if (bytecode) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- bytecode, bytecode_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, bytecode, bytecode_len);
if (ret) {
goto end;
}
goto end;
}
- header = (struct lttng_event_comm *) ((char *) payload->buffer.data +
- header_offset);
- header->lttng_event_probe_attr_len =
- payload->buffer.size - size_before_payload;
+ header =
+ (struct lttng_event_comm *) ((char *) payload->buffer.data + header_offset);
+ header->lttng_event_probe_attr_len = payload->buffer.size - size_before_payload;
break;
case LTTNG_EVENT_FUNCTION_ENTRY:
- ret = lttng_event_function_attr_serialize(
- &event->attr.ftrace, payload);
+ ret = lttng_event_function_attr_serialize(&event->attr.ftrace, payload);
if (ret) {
ret = -1;
goto end;
}
/* Update the lttng_event_function_attr len. */
- header = (struct lttng_event_comm *) ((char *) payload->buffer.data +
- header_offset);
- header->lttng_event_function_attr_len =
- payload->buffer.size - size_before_payload;
+ header =
+ (struct lttng_event_comm *) ((char *) payload->buffer.data + header_offset);
+ header->lttng_event_function_attr_len = payload->buffer.size - size_before_payload;
break;
case LTTNG_EVENT_USERSPACE_PROBE:
{
const struct lttng_event_extended *ev_ext =
- (const struct lttng_event_extended *)
- event->extended.ptr;
+ (const struct lttng_event_extended *) event->extended.ptr;
assert(event->extended.ptr);
assert(ev_ext->probe_location);
* lttng_userspace_probe_location_serialize returns the
* number of bytes that were appended to the buffer.
*/
- ret = lttng_userspace_probe_location_serialize(
- ev_ext->probe_location, payload);
+ ret = lttng_userspace_probe_location_serialize(ev_ext->probe_location,
+ payload);
if (ret < 0) {
goto end;
}
header = (struct lttng_event_comm *) ((char *) payload->buffer.data +
header_offset);
header->userspace_probe_location_len =
- payload->buffer.size - size_before_payload;
+ payload->buffer.size - size_before_payload;
}
break;
}
return ret;
}
-static ssize_t lttng_event_context_app_populate_from_payload(
- const struct lttng_payload_view *view,
- struct lttng_event_context *event_ctx)
+static ssize_t lttng_event_context_app_populate_from_payload(const struct lttng_payload_view *view,
+ struct lttng_event_context *event_ctx)
{
ssize_t ret, offset = 0;
const struct lttng_event_context_app_comm *comm;
char *provider_name = NULL, *context_name = NULL;
size_t provider_name_len, context_name_len;
- const struct lttng_buffer_view comm_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*comm));
+ const struct lttng_buffer_view comm_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
assert(event_ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
{
const char *name;
const struct lttng_buffer_view provider_name_view =
- lttng_buffer_view_from_view(&view->buffer,
- offset,
- provider_name_len);
+ lttng_buffer_view_from_view(&view->buffer, offset, provider_name_len);
if (!lttng_buffer_view_is_valid(&provider_name_view)) {
ret = -1;
name = provider_name_view.data;
- if (!lttng_buffer_view_contains_string(&provider_name_view,
- name, provider_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &provider_name_view, name, provider_name_len)) {
ret = -1;
goto end;
}
{
const char *name;
const struct lttng_buffer_view context_name_view =
- lttng_buffer_view_from_view(
- &view->buffer, offset,
- context_name_len);
+ lttng_buffer_view_from_view(&view->buffer, offset, context_name_len);
if (!lttng_buffer_view_is_valid(&context_name_view)) {
ret = -1;
name = context_name_view.data;
- if (!lttng_buffer_view_contains_string(&context_name_view, name,
- context_name_len)) {
+ if (!lttng_buffer_view_contains_string(&context_name_view, name, context_name_len)) {
ret = -1;
goto end;
}
return ret;
}
-static ssize_t lttng_event_context_perf_counter_populate_from_payload(
- const struct lttng_payload_view *view,
- struct lttng_event_context *event_ctx)
+static ssize_t
+lttng_event_context_perf_counter_populate_from_payload(const struct lttng_payload_view *view,
+ struct lttng_event_context *event_ctx)
{
int ret;
ssize_t consumed, offset = 0;
const struct lttng_event_context_perf_counter_comm *comm;
size_t name_len;
- const struct lttng_buffer_view comm_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*comm));
+ const struct lttng_buffer_view comm_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
assert(event_ctx->ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER ||
- event_ctx->ctx ==
- LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER ||
- event_ctx->ctx == LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER);
+ event_ctx->ctx == LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER ||
+ event_ctx->ctx == LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER);
if (!lttng_buffer_view_is_valid(&comm_view)) {
consumed = -1;
{
const char *name;
const struct lttng_buffer_view provider_name_view =
- lttng_buffer_view_from_view(
- &view->buffer, offset,
- name_len);
+ lttng_buffer_view_from_view(&view->buffer, offset, name_len);
if (!lttng_buffer_view_is_valid(&provider_name_view)) {
consumed = -1;
name = provider_name_view.data;
- if (!lttng_buffer_view_contains_string(
- &provider_name_view, name, name_len)) {
+ if (!lttng_buffer_view_contains_string(&provider_name_view, name, name_len)) {
consumed = -1;
goto end;
}
- ret = lttng_strncpy(event_ctx->u.perf_counter.name, name,
- sizeof(event_ctx->u.perf_counter.name));
+ ret = lttng_strncpy(event_ctx->u.perf_counter.name,
+ name,
+ sizeof(event_ctx->u.perf_counter.name));
if (ret) {
consumed = -1;
goto end;
return consumed;
}
-ssize_t lttng_event_context_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_context **event_ctx)
+ssize_t lttng_event_context_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_context **event_ctx)
{
ssize_t ret, offset = 0;
const struct lttng_event_context_comm *comm;
struct lttng_event_context *local_context = NULL;
- struct lttng_buffer_view comm_view = lttng_buffer_view_from_view(
- &view->buffer, offset, sizeof(*comm));
+ struct lttng_buffer_view comm_view =
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
assert(event_ctx);
assert(view);
{
struct lttng_payload_view subtype_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
switch (local_context->ctx) {
case LTTNG_EVENT_CONTEXT_APP_CONTEXT:
- ret = lttng_event_context_app_populate_from_payload(
- &subtype_view, local_context);
+ ret = lttng_event_context_app_populate_from_payload(&subtype_view,
+ local_context);
break;
case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
- ret = lttng_event_context_perf_counter_populate_from_payload(
- &subtype_view, local_context);
+ ret = lttng_event_context_perf_counter_populate_from_payload(&subtype_view,
+ local_context);
break;
default:
/* Nothing else to deserialize. */
return ret;
}
-static int lttng_event_context_app_serialize(
- struct lttng_event_context *context,
- struct lttng_payload *payload)
+static int lttng_event_context_app_serialize(struct lttng_event_context *context,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_event_context_app_comm comm = {};
comm.ctx_name_len = ctx_len;
/* Header */
- ret = lttng_dynamic_buffer_append(&payload->buffer, &comm,
- sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, provider_name,
- provider_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, provider_name, provider_len);
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, ctx_name,
- ctx_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, ctx_name, ctx_len);
if (ret) {
ret = -1;
goto end;
return ret;
}
-static int lttng_event_context_perf_counter_serialize(
- struct lttng_event_perf_counter_ctx *context,
- struct lttng_payload *payload)
+static int lttng_event_context_perf_counter_serialize(struct lttng_event_perf_counter_ctx *context,
+ struct lttng_payload *payload)
{
int ret;
struct lttng_event_context_perf_counter_comm comm = {};
comm.name_len += 1;
/* Header */
- ret = lttng_dynamic_buffer_append(&payload->buffer, &comm,
- sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
ret = -1;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer, context->name,
- comm.name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, context->name, comm.name_len);
if (ret) {
ret = -1;
goto end;
}
int lttng_event_context_serialize(struct lttng_event_context *context,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_event_context_comm context_comm;
context_comm.type = (uint32_t) context->ctx;
/* Header */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &context_comm, sizeof(context_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &context_comm, sizeof(context_comm));
if (ret) {
goto end;
}
case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
- ret = lttng_event_context_perf_counter_serialize(
- &context->u.perf_counter, payload);
+ ret = lttng_event_context_perf_counter_serialize(&context->u.perf_counter, payload);
break;
default:
/* Nothing else to serialize. */
* the extension field of the lttng_event struct and simply copies what it can
* to the internal struct lttng_event of a lttng_event_field.
*/
-static void lttng_event_field_populate_lttng_event_from_event(
- const struct lttng_event *src, struct lttng_event *destination)
+static void lttng_event_field_populate_lttng_event_from_event(const struct lttng_event *src,
+ struct lttng_event *destination)
{
memcpy(destination, src, sizeof(*destination));
destination->extended.ptr = NULL;
}
-ssize_t lttng_event_field_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_event_field **field)
+ssize_t lttng_event_field_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_event_field **field)
{
ssize_t ret, offset = 0;
struct lttng_event_field *local_event_field = NULL;
struct lttng_event *event = NULL;
const struct lttng_event_field_comm *comm;
- const char* name = NULL;
+ const char *name = NULL;
assert(field);
assert(view);
{
const struct lttng_buffer_view comm_view =
- lttng_buffer_view_from_view(
- &view->buffer, offset,
- sizeof(*comm));
+ lttng_buffer_view_from_view(&view->buffer, offset, sizeof(*comm));
if (!lttng_buffer_view_is_valid(&comm_view)) {
ret = -1;
/* Field name */
{
const struct lttng_buffer_view name_view =
- lttng_buffer_view_from_view(
- &view->buffer, offset,
- comm->name_len);
+ lttng_buffer_view_from_view(&view->buffer, offset, comm->name_len);
if (!lttng_buffer_view_is_valid(&name_view)) {
ret = -1;
name = name_view.data;
- if (!lttng_buffer_view_contains_string(&name_view,
- name_view.data, comm->name_len)) {
+ if (!lttng_buffer_view_contains_string(&name_view, name_view.data, comm->name_len)) {
ret = -1;
goto end;
}
/* Event */
{
struct lttng_payload_view event_view =
- lttng_payload_view_from_view(
- view, offset,
- comm->event_len);
+ lttng_payload_view_from_view(view, offset, comm->event_len);
if (!lttng_payload_view_is_valid(&event_view)) {
ret = -1;
goto end;
}
- ret = lttng_event_create_from_payload(&event_view, &event, NULL,
- NULL, NULL);
+ ret = lttng_event_create_from_payload(&event_view, &event, NULL, NULL, NULL);
if (ret != comm->event_len) {
ret = -1;
goto end;
assert(name);
assert(event);
- if (lttng_strncpy(local_event_field->field_name, name,
- sizeof(local_event_field->field_name))) {
+ if (lttng_strncpy(
+ local_event_field->field_name, name, sizeof(local_event_field->field_name))) {
ret = -1;
goto end;
}
- lttng_event_field_populate_lttng_event_from_event(
- event, &local_event_field->event);
+ lttng_event_field_populate_lttng_event_from_event(event, &local_event_field->event);
*field = local_event_field;
local_event_field = NULL;
}
int lttng_event_field_serialize(const struct lttng_event_field *field,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
size_t header_offset, size_before_event;
name_len += 1;
event_field_comm.type = field->type;
- event_field_comm.nowrite = (uint8_t)field->nowrite;
+ event_field_comm.nowrite = (uint8_t) field->nowrite;
event_field_comm.name_len = name_len;
/* Header */
ret = lttng_dynamic_buffer_append(
- &payload->buffer, &event_field_comm,
- sizeof(event_field_comm));
+ &payload->buffer, &event_field_comm, sizeof(event_field_comm));
if (ret) {
goto end;
}
/* Field name */
- ret = lttng_dynamic_buffer_append(&payload->buffer, field->field_name,
- name_len);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, field->field_name, name_len);
if (ret) {
goto end;
}
size_before_event = payload->buffer.size;
- ret = lttng_event_serialize(
- &field->event, 0, NULL, NULL, 0, 0, payload);
+ ret = lttng_event_serialize(&field->event, 0, NULL, NULL, 0, 0, payload);
if (ret) {
ret = -1;
goto end;
}
/* Update the event len. */
- header = (struct lttng_event_field_comm *)
- ((char *) payload->buffer.data +
- header_offset);
+ header = (struct lttng_event_field_comm *) ((char *) payload->buffer.data + header_offset);
header->event_len = payload->buffer.size - size_before_event;
end:
return ret;
}
-static enum lttng_error_code compute_flattened_size(
- struct lttng_dynamic_pointer_array *events, size_t *size)
+static enum lttng_error_code compute_flattened_size(struct lttng_dynamic_pointer_array *events,
+ size_t *size)
{
enum lttng_error_code ret_code;
int ret = 0;
for (i = 0; i < event_count; i++) {
int probe_storage_req = 0;
- const struct event_list_element *element = (const struct event_list_element *)
- lttng_dynamic_pointer_array_get_pointer(
- events, i);
+ const struct event_list_element *element =
+ (const struct event_list_element *) lttng_dynamic_pointer_array_get_pointer(
+ events, i);
const struct lttng_userspace_probe_location *location = NULL;
- location = lttng_event_get_userspace_probe_location(
- element->event);
+ location = lttng_event_get_userspace_probe_location(element->event);
if (location) {
- ret = lttng_userspace_probe_location_flatten(
- location, NULL);
+ ret = lttng_userspace_probe_location_flatten(location, NULL);
if (ret < 0) {
ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
}
if (element->exclusions) {
- storage_req += element->exclusions->count *
- LTTNG_SYMBOL_NAME_LEN;
+ storage_req += element->exclusions->count * LTTNG_SYMBOL_NAME_LEN;
}
/* Padding to ensure the flat probe is aligned. */
* - padding to align to 64-bits
* - flattened version of userspace_probe_location
*/
-static enum lttng_error_code flatten_lttng_events(
- struct lttng_dynamic_pointer_array *events,
- struct lttng_event **flattened_events)
+static enum lttng_error_code flatten_lttng_events(struct lttng_dynamic_pointer_array *events,
+ struct lttng_event **flattened_events)
{
enum lttng_error_code ret_code;
int ret, i;
* We must ensure that "local_flattened_events" is never resized so as
* to preserve the validity of the flattened objects.
*/
- ret = lttng_dynamic_buffer_set_capacity(
- &local_flattened_events, storage_req);
+ ret = lttng_dynamic_buffer_set_capacity(&local_flattened_events, storage_req);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Start by laying the struct lttng_event */
for (i = 0; i < nb_events; i++) {
- const struct event_list_element *element = (const struct event_list_element *)
- lttng_dynamic_pointer_array_get_pointer(
- events, i);
+ const struct event_list_element *element =
+ (const struct event_list_element *) lttng_dynamic_pointer_array_get_pointer(
+ events, i);
if (!element) {
ret_code = LTTNG_ERR_FATAL;
goto end;
}
- ret = lttng_dynamic_buffer_append(&local_flattened_events,
- element->event, sizeof(struct lttng_event));
+ ret = lttng_dynamic_buffer_append(
+ &local_flattened_events, element->event, sizeof(struct lttng_event));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
for (i = 0; i < nb_events; i++) {
- const struct event_list_element *element = (const struct event_list_element *)
- lttng_dynamic_pointer_array_get_pointer(events, i);
- struct lttng_event *event = (struct lttng_event *)
- (local_flattened_events.data + (sizeof(struct lttng_event) * i));
+ const struct event_list_element *element =
+ (const struct event_list_element *) lttng_dynamic_pointer_array_get_pointer(
+ events, i);
+ struct lttng_event *event =
+ (struct lttng_event *) (local_flattened_events.data +
+ (sizeof(struct lttng_event) * i));
struct lttng_event_extended *event_extended =
- (struct lttng_event_extended *)
- (local_flattened_events.data + local_flattened_events.size);
+ (struct lttng_event_extended *) (local_flattened_events.data +
+ local_flattened_events.size);
const struct lttng_userspace_probe_location *location = NULL;
assert(element);
/* Insert struct lttng_event_extended. */
ret = lttng_dynamic_buffer_set_size(&local_flattened_events,
- local_flattened_events.size +
- sizeof(*event_extended));
+ local_flattened_events.size +
+ sizeof(*event_extended));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
const size_t len = strlen(element->filter_expression) + 1;
event_extended->filter_expression =
- local_flattened_events.data +
- local_flattened_events.size;
+ local_flattened_events.data + local_flattened_events.size;
ret = lttng_dynamic_buffer_append(
- &local_flattened_events,
- element->filter_expression, len);
+ &local_flattened_events, element->filter_expression, len);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Insert exclusions. */
if (element->exclusions) {
- event_extended->exclusions.count =
- element->exclusions->count;
+ event_extended->exclusions.count = element->exclusions->count;
event_extended->exclusions.strings =
- local_flattened_events.data +
- local_flattened_events.size;
+ local_flattened_events.data + local_flattened_events.size;
- ret = lttng_dynamic_buffer_append(
- &local_flattened_events,
- element->exclusions->names,
- element->exclusions->count *
- LTTNG_SYMBOL_NAME_LEN);
+ ret = lttng_dynamic_buffer_append(&local_flattened_events,
+ element->exclusions->names,
+ element->exclusions->count *
+ LTTNG_SYMBOL_NAME_LEN);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
/* Insert padding to align to 64-bits. */
ret = lttng_dynamic_buffer_set_size(&local_flattened_events,
- lttng_align_ceil(local_flattened_events.size,
- sizeof(uint64_t)));
+ lttng_align_ceil(local_flattened_events.size,
+ sizeof(uint64_t)));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
- location = lttng_event_get_userspace_probe_location(
- element->event);
+ location = lttng_event_get_userspace_probe_location(element->event);
if (location) {
- event_extended->probe_location = (struct lttng_userspace_probe_location *)
- (local_flattened_events.data + local_flattened_events.size);
- ret = lttng_userspace_probe_location_flatten(
- location, &local_flattened_events);
+ event_extended->probe_location = (struct lttng_userspace_probe_location
+ *) (local_flattened_events.data +
+ local_flattened_events.size);
+ ret = lttng_userspace_probe_location_flatten(location,
+ &local_flattened_events);
if (ret < 0) {
ret_code = LTTNG_ERR_PROBE_LOCATION_INVAL;
goto end;
return ret_code;
}
-static enum lttng_error_code event_list_create_from_payload(
- struct lttng_payload_view *view,
- unsigned int count,
- struct lttng_dynamic_pointer_array *event_list)
+static enum lttng_error_code
+event_list_create_from_payload(struct lttng_payload_view *view,
+ unsigned int count,
+ struct lttng_dynamic_pointer_array *event_list)
{
enum lttng_error_code ret_code;
int ret;
for (i = 0; i < count; i++) {
ssize_t event_size;
struct lttng_payload_view event_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
struct event_list_element *element = zmalloc<event_list_element>();
if (!element) {
* Lifetime and management of the object is now bound to the
* array.
*/
- ret = lttng_dynamic_pointer_array_add_pointer(
- event_list, element);
+ ret = lttng_dynamic_pointer_array_add_pointer(event_list, element);
if (ret) {
event_list_destructor(element);
ret_code = LTTNG_ERR_NOMEM;
* care about it.
*/
event_size = lttng_event_create_from_payload(&event_view,
- &element->event,
- &element->exclusions,
- &element->filter_expression, NULL);
+ &element->event,
+ &element->exclusions,
+ &element->filter_expression,
+ NULL);
if (event_size < 0) {
ret_code = LTTNG_ERR_INVALID;
goto end;
}
enum lttng_error_code lttng_events_create_and_flatten_from_payload(
- struct lttng_payload_view *payload,
- unsigned int count,
- struct lttng_event **events)
+ struct lttng_payload_view *payload, unsigned int count, struct lttng_event **events)
{
enum lttng_error_code ret = LTTNG_OK;
struct lttng_dynamic_pointer_array local_events;
/* Deserialize the events. */
{
struct lttng_payload_view events_view =
- lttng_payload_view_from_view(payload, 0, -1);
+ lttng_payload_view_from_view(payload, 0, -1);
- ret = event_list_create_from_payload(
- &events_view, count, &local_events);
+ ret = event_list_create_from_payload(&events_view, count, &local_events);
if (ret != LTTNG_OK) {
goto end;
}
return ret;
}
-static enum lttng_error_code flatten_lttng_event_fields(
- struct lttng_dynamic_pointer_array *event_fields,
- struct lttng_event_field **flattened_event_fields)
+static enum lttng_error_code
+flatten_lttng_event_fields(struct lttng_dynamic_pointer_array *event_fields,
+ struct lttng_event_field **flattened_event_fields)
{
int ret, i;
enum lttng_error_code ret_code;
* We must ensure that "local_flattened_event_fields" is never resized
* so as to preserve the validity of the flattened objects.
*/
- ret = lttng_dynamic_buffer_set_capacity(
- &local_flattened_event_fields, storage_req);
+ ret = lttng_dynamic_buffer_set_capacity(&local_flattened_event_fields, storage_req);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
for (i = 0; i < nb_event_field; i++) {
const struct lttng_event_field *element =
- (const struct lttng_event_field *)
- lttng_dynamic_pointer_array_get_pointer(
- event_fields, i);
+ (const struct lttng_event_field *) lttng_dynamic_pointer_array_get_pointer(
+ event_fields, i);
if (!element) {
ret_code = LTTNG_ERR_FATAL;
goto end;
}
- ret = lttng_dynamic_buffer_append(&local_flattened_event_fields,
- element, sizeof(struct lttng_event_field));
+ ret = lttng_dynamic_buffer_append(
+ &local_flattened_event_fields, element, sizeof(struct lttng_event_field));
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
return ret_code;
}
-static enum lttng_error_code event_field_list_create_from_payload(
- struct lttng_payload_view *view,
- unsigned int count,
- struct lttng_dynamic_pointer_array **event_field_list)
+static enum lttng_error_code
+event_field_list_create_from_payload(struct lttng_payload_view *view,
+ unsigned int count,
+ struct lttng_dynamic_pointer_array **event_field_list)
{
enum lttng_error_code ret_code;
int ret, offset = 0;
ssize_t event_field_size;
struct lttng_event_field *field = NULL;
struct lttng_payload_view event_field_view =
- lttng_payload_view_from_view(view, offset, -1);
+ lttng_payload_view_from_view(view, offset, -1);
- event_field_size = lttng_event_field_create_from_payload(
- &event_field_view, &field);
+ event_field_size = lttng_event_field_create_from_payload(&event_field_view, &field);
if (event_field_size < 0) {
ret_code = LTTNG_ERR_INVALID;
goto end;
}
enum lttng_error_code lttng_event_fields_create_and_flatten_from_payload(
- struct lttng_payload_view *view,
- unsigned int count,
- struct lttng_event_field **fields)
+ struct lttng_payload_view *view, unsigned int count, struct lttng_event_field **fields)
{
enum lttng_error_code ret_code;
struct lttng_dynamic_pointer_array *local_event_fields = NULL;
- ret_code = event_field_list_create_from_payload(
- view, count, &local_event_fields);
+ ret_code = event_field_list_create_from_payload(view, count, &local_event_fields);
if (ret_code != LTTNG_OK) {
goto end;
}
*/
#include "exception.hpp"
-#include <sstream>
+
#include <common/error.hpp>
+#include <sstream>
+
namespace {
-std::string format_throw_location(
- const char *file_name, const char *function_name, unsigned int line_number)
+std::string
+format_throw_location(const char *file_name, const char *function_name, unsigned int line_number)
{
std::stringstream location;
} /* namespace */
lttng::ctl::error::error(lttng_error_code error_code,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
- runtime_error(std::string(error_get_str(error_code)), file_name, function_name, line_number),
- _error_code{error_code}
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
+ runtime_error(
+ std::string(error_get_str(error_code)), file_name, function_name, line_number),
+ _error_code{ error_code }
{
}
lttng::posix_error::posix_error(const std::string& msg,
- int errno_code,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ int errno_code,
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
std::system_error(errno_code,
- std::generic_category(),
- msg + " " + format_throw_location(file_name, function_name, line_number))
+ std::generic_category(),
+ msg + " " + format_throw_location(file_name, function_name, line_number))
{
}
lttng::runtime_error::runtime_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number))
{
}
lttng::unsupported_error::unsupported_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
std::runtime_error(msg + " " + format_throw_location(file_name, function_name, line_number))
{
}
lttng::communication_error::communication_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
runtime_error(msg, file_name, function_name, line_number)
{
}
lttng::protocol_error::protocol_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
communication_error(msg, file_name, function_name, line_number)
{
}
lttng::invalid_argument_error::invalid_argument_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
runtime_error(msg, file_name, function_name, line_number)
{
}
*
*/
-#include <unistd.h>
-#include <urcu/ref.h>
-
#include "fd-handle.hpp"
+
#include <common/error.hpp>
+#include <unistd.h>
+#include <urcu/ref.h>
+
struct fd_handle {
struct urcu_ref ref;
int fd;
ret = close(handle->fd);
if (ret == -1) {
PERROR("Failed to close file descriptor of fd_handle upon release: fd = %d",
- handle->fd);
+ handle->fd);
}
free(handle);
if (fd < 0) {
ERR("Attempted to create an fd_handle from an invalid file descriptor: fd = %d",
- fd);
+ fd);
goto end;
}
const int new_fd = dup(handle->fd);
if (new_fd < 0) {
- PERROR("Failed to duplicate file descriptor while copying fd_handle: fd = %d", handle->fd);
+ PERROR("Failed to duplicate file descriptor while copying fd_handle: fd = %d",
+ handle->fd);
goto end;
}
*
*/
-#include <urcu.h>
-#include <urcu/list.h>
-#include <urcu/rculfhash.h>
-
-#include <fcntl.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include "fd-tracker.hpp"
+#include "inode.hpp"
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/optional.hpp>
-#include "fd-tracker.hpp"
-#include "inode.hpp"
+#include <fcntl.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <urcu.h>
+#include <urcu/list.h>
+#include <urcu/rculfhash.h>
/* Tracker lock must be taken by the user. */
-#define TRACKED_COUNT(tracker) \
- (tracker->count.suspendable.active + \
- tracker->count.suspendable.suspended + \
- tracker->count.unsuspendable)
+#define TRACKED_COUNT(tracker) \
+ (tracker->count.suspendable.active + tracker->count.suspendable.suspended + \
+ tracker->count.unsuspendable)
/* Tracker lock must be taken by the user. */
-#define ACTIVE_COUNT(tracker) \
- (tracker->count.suspendable.active + tracker->count.unsuspendable)
+#define ACTIVE_COUNT(tracker) (tracker->count.suspendable.active + tracker->count.unsuspendable)
/* Tracker lock must be taken by the user. */
#define SUSPENDED_COUNT(tracker) (tracker->count.suspendable.suspended)
/* Tracker lock must be taken by the user. */
-#define SUSPENDABLE_COUNT(tracker) \
- (tracker->count.suspendable.active + \
- tracker->count.suspendable.suspended)
+#define SUSPENDABLE_COUNT(tracker) \
+ (tracker->count.suspendable.active + tracker->count.suspendable.suspended)
/* Tracker lock must be taken by the user. */
#define UNSUSPENDABLE_COUNT(tracker) (tracker->count.unsuspendable)
static int match_fd(struct cds_lfht_node *node, const void *key);
static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry);
-static struct unsuspendable_fd *unsuspendable_fd_create(
- const char *name, int fd);
+static struct unsuspendable_fd *unsuspendable_fd_create(const char *name, int fd);
static int open_from_properties(const struct lttng_directory_handle *dir_handle,
- const char *path, struct open_properties *properties);
+ const char *path,
+ struct open_properties *properties);
static void fs_handle_tracked_log(struct fs_handle_tracked *handle);
static int fs_handle_tracked_suspend(struct fs_handle_tracked *handle);
static int fs_handle_tracked_unlink(struct fs_handle *_handle);
static int fs_handle_tracked_close(struct fs_handle *_handle);
-static void fd_tracker_track(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle);
-static void fd_tracker_untrack(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle);
-static int fd_tracker_suspend_handles(
- struct fd_tracker *tracker, unsigned int count);
-static int fd_tracker_restore_handle(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle);
+static void fd_tracker_track(struct fd_tracker *tracker, struct fs_handle_tracked *handle);
+static void fd_tracker_untrack(struct fd_tracker *tracker, struct fs_handle_tracked *handle);
+static int fd_tracker_suspend_handles(struct fd_tracker *tracker, unsigned int count);
+static int fd_tracker_restore_handle(struct fd_tracker *tracker, struct fs_handle_tracked *handle);
/* Match function of the tracker's unsuspendable_fds hash table. */
static int match_fd(struct cds_lfht_node *node, const void *key)
{
- struct unsuspendable_fd *entry = lttng::utils::container_of(
- node, &unsuspendable_fd::tracker_node);
+ struct unsuspendable_fd *entry =
+ lttng::utils::container_of(node, &unsuspendable_fd::tracker_node);
- return hash_match_key_ulong(
- (void *) (unsigned long) entry->fd, (void *) key);
+ return hash_match_key_ulong((void *) (unsigned long) entry->fd, (void *) key);
}
static void delete_unsuspendable_fd(struct rcu_head *head)
{
- struct unsuspendable_fd *fd = caa_container_of(
- head, struct unsuspendable_fd, rcu_head);
+ struct unsuspendable_fd *fd = caa_container_of(head, struct unsuspendable_fd, rcu_head);
free(fd->name);
free(fd);
call_rcu(&entry->rcu_head, delete_unsuspendable_fd);
}
-static struct unsuspendable_fd *unsuspendable_fd_create(
- const char *name, int fd)
+static struct unsuspendable_fd *unsuspendable_fd_create(const char *name, int fd)
{
struct unsuspendable_fd *entry = zmalloc<unsuspendable_fd>();
lttng_inode_borrow_location(handle->inode, NULL, &path);
if (handle->fd >= 0) {
- DBG_NO_LOC(" %s [active, fd %d%s]", path, handle->fd,
- handle->in_use ? ", in use" : "");
+ DBG_NO_LOC(" %s [active, fd %d%s]",
+ path,
+ handle->fd,
+ handle->in_use ? ", in use" : "");
} else {
DBG_NO_LOC(" %s [suspended]", path);
}
const struct lttng_directory_handle *node_directory_handle;
pthread_mutex_lock(&handle->lock);
- lttng_inode_borrow_location(
- handle->inode, &node_directory_handle, &path);
+ lttng_inode_borrow_location(handle->inode, &node_directory_handle, &path);
LTTNG_ASSERT(handle->fd >= 0);
if (handle->in_use) {
/* This handle can't be suspended as it is currently in use. */
goto end;
}
- ret = lttng_directory_handle_stat(
- node_directory_handle, path, &fs_stat);
+ ret = lttng_directory_handle_stat(node_directory_handle, path, &fs_stat);
if (ret) {
- PERROR("Filesystem handle to %s cannot be suspended as stat() failed",
- path);
+ PERROR("Filesystem handle to %s cannot be suspended as stat() failed", path);
ret = -errno;
goto end;
}
if (fs_stat.st_ino != handle->ino) {
/* Don't suspend as the handle would not be restorable. */
- WARN("Filesystem handle to %s cannot be suspended as its inode changed",
- path);
+ WARN("Filesystem handle to %s cannot be suspended as its inode changed", path);
ret = -ENOENT;
goto end;
}
handle->offset = lseek(handle->fd, 0, SEEK_CUR);
if (handle->offset == -1) {
WARN("Filesystem handle to %s cannot be suspended as lseek() failed to sample its current position",
- path);
+ path);
ret = -errno;
goto end;
}
ret = close(handle->fd);
if (ret) {
- PERROR("Filesystem handle to %s cannot be suspended as close() failed",
- path);
+ PERROR("Filesystem handle to %s cannot be suspended as close() failed", path);
ret = -errno;
goto end;
}
DBG("Suspended filesystem handle to %s (fd %i) at position %" PRId64,
- path, handle->fd, handle->offset);
+ path,
+ handle->fd,
+ handle->offset);
handle->fd = -1;
end:
if (ret) {
const char *path;
const struct lttng_directory_handle *node_directory_handle;
- lttng_inode_borrow_location(
- handle->inode, &node_directory_handle, &path);
+ lttng_inode_borrow_location(handle->inode, &node_directory_handle, &path);
LTTNG_ASSERT(handle->fd == -1);
LTTNG_ASSERT(path);
- ret = open_from_properties(
- node_directory_handle, path, &handle->properties);
+ ret = open_from_properties(node_directory_handle, path, &handle->properties);
if (ret < 0) {
- PERROR("Failed to restore filesystem handle to %s, open() failed",
- path);
+ PERROR("Failed to restore filesystem handle to %s, open() failed", path);
ret = -errno;
goto end;
}
ret = lseek(fd, handle->offset, SEEK_SET);
if (ret < 0) {
- PERROR("Failed to restore filesystem handle to %s, lseek() failed",
- path);
+ PERROR("Failed to restore filesystem handle to %s, lseek() failed", path);
ret = -errno;
goto end;
}
DBG("Restored filesystem handle to %s (fd %i) at position %" PRId64,
- path, fd, handle->offset);
+ path,
+ fd,
+ handle->offset);
ret = 0;
handle->fd = fd;
fd = -1;
}
static int open_from_properties(const struct lttng_directory_handle *dir_handle,
- const char *path, struct open_properties *properties)
+ const char *path,
+ struct open_properties *properties)
{
int ret;
* thus it is ignored here.
*/
if ((properties->flags & O_CREAT) && properties->mode.is_set) {
- ret = lttng_directory_handle_open_file(dir_handle, path,
- properties->flags, properties->mode.value);
+ ret = lttng_directory_handle_open_file(
+ dir_handle, path, properties->flags, properties->mode.value);
} else {
- ret = lttng_directory_handle_open_file(dir_handle, path,
- properties->flags, 0);
+ ret = lttng_directory_handle_open_file(dir_handle, path, properties->flags, 0);
}
/*
* Some flags should not be used beyond the initial open() of a
return ret;
}
-struct fd_tracker *fd_tracker_create(const char *unlinked_file_path,
- unsigned int capacity)
+struct fd_tracker *fd_tracker_create(const char *unlinked_file_path, unsigned int capacity)
{
struct fd_tracker *tracker = zmalloc<fd_tracker>();
CDS_INIT_LIST_HEAD(&tracker->active_handles);
CDS_INIT_LIST_HEAD(&tracker->suspended_handles);
tracker->capacity = capacity;
- tracker->unsuspendable_fds = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ tracker->unsuspendable_fds = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!tracker->unsuspendable_fds) {
ERR("Failed to create fd-tracker's unsuspendable_fds hash table");
goto error;
goto error;
}
- tracker->unlinked_file_pool =
- lttng_unlinked_file_pool_create(unlinked_file_path);
+ tracker->unlinked_file_pool = lttng_unlinked_file_pool_create(unlinked_file_path);
if (!tracker->unlinked_file_pool) {
goto error;
}
DBG("File descriptor tracker created with a limit of %u simultaneously-opened FDs",
- capacity);
+ capacity);
end:
return tracker;
error:
DBG_NO_LOC(" capacity: %u", tracker->capacity);
DBG_NO_LOC(" Tracked suspendable file descriptors");
- cds_list_for_each_entry(
- handle, &tracker->active_handles, handles_list_node) {
+ cds_list_for_each_entry (handle, &tracker->active_handles, handles_list_node) {
fs_handle_tracked_log(handle);
}
- cds_list_for_each_entry(handle, &tracker->suspended_handles,
- handles_list_node) {
+ cds_list_for_each_entry (handle, &tracker->suspended_handles, handles_list_node) {
fs_handle_tracked_log(handle);
}
if (!SUSPENDABLE_COUNT(tracker)) {
DBG_NO_LOC(" Tracked unsuspendable file descriptors");
rcu_read_lock();
- cds_lfht_for_each_entry(tracker->unsuspendable_fds, &iter,
- unsuspendable_fd, tracker_node) {
+ cds_lfht_for_each_entry (
+ tracker->unsuspendable_fds, &iter, unsuspendable_fd, tracker_node) {
DBG_NO_LOC(" %s [active, fd %d]",
- unsuspendable_fd->name ?: "Unnamed",
- unsuspendable_fd->fd);
+ unsuspendable_fd->name ?: "Unnamed",
+ unsuspendable_fd->fd);
}
rcu_read_unlock();
if (!UNSUSPENDABLE_COUNT(tracker)) {
pthread_mutex_lock(&tracker->lock);
if (TRACKED_COUNT(tracker)) {
ERR("A file descriptor leak has been detected: %u tracked file descriptors are still being tracked",
- TRACKED_COUNT(tracker));
+ TRACKED_COUNT(tracker));
pthread_mutex_unlock(&tracker->lock);
fd_tracker_log(tracker);
ret = -1;
}
struct fs_handle *fd_tracker_open_fs_handle(struct fd_tracker *tracker,
- struct lttng_directory_handle *directory,
- const char *path,
- int flags,
- mode_t *mode)
+ struct lttng_directory_handle *directory,
+ const char *path,
+ int flags,
+ mode_t *mode)
{
int ret;
struct fs_handle_tracked *handle = NULL;
struct stat fd_stat;
- struct open_properties properties = {
- .flags = flags,
- .mode = {
- .is_set = !!mode,
- .value = static_cast<mode_t>(mode ? *mode : 0),
- }
- };
+ struct open_properties properties = { .flags = flags,
+ .mode = {
+ .is_set = !!mode,
+ .value =
+ static_cast<mode_t>(mode ? *mode : 0),
+ } };
pthread_mutex_lock(&tracker->lock);
if (ACTIVE_COUNT(tracker) == tracker->capacity) {
* the tracker's capacity.
*/
WARN("Cannot open file system handle, too many unsuspendable file descriptors are opened (%u)",
- tracker->count.unsuspendable);
+ tracker->count.unsuspendable);
goto end;
}
}
if (!handle) {
goto end;
}
- handle->parent = (typeof(handle->parent)) {
+ handle->parent = (typeof(handle->parent)){
.get_fd = fs_handle_tracked_get_fd,
.put_fd = fs_handle_tracked_put_fd,
.unlink = fs_handle_tracked_unlink,
handle->properties = properties;
- handle->inode = lttng_inode_registry_get_inode(tracker->inode_registry,
- directory, path, handle->fd,
- tracker->unlinked_file_pool);
+ handle->inode = lttng_inode_registry_get_inode(
+ tracker->inode_registry, directory, path, handle->fd, tracker->unlinked_file_pool);
if (!handle->inode) {
ERR("Failed to get lttng_inode corresponding to file %s", path);
goto error;
}
/* Caller must hold the tracker's lock. */
-static int fd_tracker_suspend_handles(
- struct fd_tracker *tracker, unsigned int count)
+static int fd_tracker_suspend_handles(struct fd_tracker *tracker, unsigned int count)
{
unsigned int left_to_close = count;
unsigned int attempts_left = tracker->count.suspendable.active;
struct fs_handle_tracked *handle, *tmp;
- cds_list_for_each_entry_safe(handle, tmp, &tracker->active_handles,
- handles_list_node) {
+ cds_list_for_each_entry_safe (handle, tmp, &tracker->active_handles, handles_list_node) {
int ret;
fd_tracker_untrack(tracker, handle);
}
int fd_tracker_open_unsuspendable_fd(struct fd_tracker *tracker,
- int *out_fds,
- const char **names,
- unsigned int fd_count,
- fd_open_cb open,
- void *user_data)
+ int *out_fds,
+ const char **names,
+ unsigned int fd_count,
+ fd_open_cb open,
+ void *user_data)
{
int ret, user_ret, i, fds_to_suspend;
unsigned int active_fds;
pthread_mutex_lock(&tracker->lock);
active_fds = ACTIVE_COUNT(tracker);
- fds_to_suspend = (int) active_fds + (int) fd_count -
- (int) tracker->capacity;
+ fds_to_suspend = (int) active_fds + (int) fd_count - (int) tracker->capacity;
if (fds_to_suspend > 0) {
if (fds_to_suspend <= tracker->count.suspendable.active) {
- ret = fd_tracker_suspend_handles(
- tracker, fds_to_suspend);
+ ret = fd_tracker_suspend_handles(tracker, fds_to_suspend);
if (ret) {
goto end_unlock;
}
* tracker's capacity.
*/
WARN("Cannot open unsuspendable fd, too many unsuspendable file descriptors are opened (%u)",
- tracker->count.unsuspendable);
+ tracker->count.unsuspendable);
ret = -EMFILE;
goto end_unlock;
}
* of unsuspendable fds.
*/
for (i = 0; i < fd_count; i++) {
- struct unsuspendable_fd *entry = unsuspendable_fd_create(
- names ? names[i] : NULL, out_fds[i]);
+ struct unsuspendable_fd *entry =
+ unsuspendable_fd_create(names ? names[i] : NULL, out_fds[i]);
if (!entry) {
ret = -1;
struct unsuspendable_fd *entry = entries[i];
node = cds_lfht_add_unique(tracker->unsuspendable_fds,
- hash_key_ulong((void *) (unsigned long)
- out_fds[i],
- seed.value),
- match_fd, (void *) (unsigned long) out_fds[i],
- &entry->tracker_node);
+ hash_key_ulong((void *) (unsigned long) out_fds[i],
+ seed.value),
+ match_fd,
+ (void *) (unsigned long) out_fds[i],
+ &entry->tracker_node);
if (node != &entry->tracker_node) {
ret = -EEXIST;
}
int fd_tracker_close_unsuspendable_fd(struct fd_tracker *tracker,
- int *fds_in,
- unsigned int fd_count,
- fd_close_cb close,
- void *user_data)
+ int *fds_in,
+ unsigned int fd_count,
+ fd_close_cb close,
+ void *user_data)
{
int i, ret, user_ret;
int *fds = NULL;
struct unsuspendable_fd *entry;
cds_lfht_lookup(tracker->unsuspendable_fds,
- hash_key_ulong((void *) (unsigned long) fds[i],
- seed.value),
- match_fd, (void *) (unsigned long) fds[i],
+ hash_key_ulong((void *) (unsigned long) fds[i], seed.value),
+ match_fd,
+ (void *) (unsigned long) fds[i],
&iter);
node = cds_lfht_iter_get_node(&iter);
if (!node) {
/* Unknown file descriptor. */
WARN("Untracked file descriptor %d passed to fd_tracker_close_unsuspendable_fd()",
- fds[i]);
+ fds[i]);
ret = -EINVAL;
goto end_unlock;
}
- entry = lttng::utils::container_of(
- node, &unsuspendable_fd::tracker_node);
+ entry = lttng::utils::container_of(node, &unsuspendable_fd::tracker_node);
cds_lfht_del(tracker->unsuspendable_fds, node);
unsuspendable_fd_destroy(entry);
}
/* Caller must have taken the tracker's and handle's locks. */
-static void fd_tracker_track(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle)
+static void fd_tracker_track(struct fd_tracker *tracker, struct fs_handle_tracked *handle)
{
if (handle->fd >= 0) {
tracker->count.suspendable.active++;
- cds_list_add_tail(&handle->handles_list_node,
- &tracker->active_handles);
+ cds_list_add_tail(&handle->handles_list_node, &tracker->active_handles);
} else {
tracker->count.suspendable.suspended++;
- cds_list_add_tail(&handle->handles_list_node,
- &tracker->suspended_handles);
+ cds_list_add_tail(&handle->handles_list_node, &tracker->suspended_handles);
}
}
/* Caller must have taken the tracker's and handle's locks. */
-static void fd_tracker_untrack(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle)
+static void fd_tracker_untrack(struct fd_tracker *tracker, struct fs_handle_tracked *handle)
{
if (handle->fd >= 0) {
tracker->count.suspendable.active--;
}
/* Caller must have taken the tracker's and handle's locks. */
-static int fd_tracker_restore_handle(
- struct fd_tracker *tracker, struct fs_handle_tracked *handle)
+static int fd_tracker_restore_handle(struct fd_tracker *tracker, struct fs_handle_tracked *handle)
{
int ret;
{
int ret;
struct fs_handle_tracked *handle =
- lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
+ lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
/*
* TODO This should be optimized as it is a fairly hot path.
static void fs_handle_tracked_put_fd(struct fs_handle *_handle)
{
struct fs_handle_tracked *handle =
- lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
+ lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
pthread_mutex_lock(&handle->lock);
handle->in_use = false;
{
int ret;
struct fs_handle_tracked *handle =
- lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
+ lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
pthread_mutex_lock(&handle->tracker->lock);
pthread_mutex_lock(&handle->lock);
int ret = 0;
const char *path = NULL;
struct fs_handle_tracked *handle =
- lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
+ lttng::utils::container_of(_handle, &fs_handle_tracked::parent);
struct lttng_directory_handle *inode_directory_handle = NULL;
if (!handle) {
* enough to not attempt to recursively acquire the tracker's
* lock twice.
*/
- inode_directory_handle =
- lttng_inode_get_location_directory_handle(
- handle->inode);
+ inode_directory_handle = lttng_inode_get_location_directory_handle(handle->inode);
}
fd_tracker_untrack(handle->tracker, handle);
if (handle->fd >= 0) {
*/
if (close(handle->fd)) {
PERROR("Failed to close the file descriptor (%d) of fs handle to %s, close() returned",
- handle->fd, path ? path : "Unknown");
+ handle->fd,
+ path ? path : "Unknown");
}
handle->fd = -1;
}
*
*/
+#include "inode.hpp"
+
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/hashtable/utils.hpp>
#include <common/optional.hpp>
#include <common/string-utils/format.hpp>
#include <common/utils.hpp>
-#include <inttypes.h>
+
#include <lttng/constant.h>
+
+#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <urcu/rculfhash.h>
#include <urcu/ref.h>
-#include "inode.hpp"
-
namespace {
struct inode_id {
dev_t device;
bool initialized;
unsigned long value;
} seed = {
- .lock = PTHREAD_MUTEX_INITIALIZER,
- .initialized = false,
- .value = 0,
+ .lock = PTHREAD_MUTEX_INITIALIZER,
+ .initialized = false,
+ .value = 0,
};
} /* namespace */
{
uint64_t device = id->device, inode_no = id->inode;
- return hash_key_u64(&device, seed.value) ^
- hash_key_u64(&inode_no, seed.value);
+ return hash_key_u64(&device, seed.value) ^ hash_key_u64(&inode_no, seed.value);
}
static int lttng_inode_match(struct cds_lfht_node *node, const void *key)
{
const struct inode_id *id = (inode_id *) key;
- const struct lttng_inode *inode = lttng::utils::container_of(
- node, <tng_inode::registry_node);
+ const struct lttng_inode *inode =
+ lttng::utils::container_of(node, <tng_inode::registry_node);
return inode->id.device == id->device && inode->id.inode == id->inode;
}
static void lttng_inode_free(struct rcu_head *head)
{
- struct lttng_inode *inode =
- lttng::utils::container_of(head, <tng_inode::rcu_head);
+ struct lttng_inode *inode = lttng::utils::container_of(head, <tng_inode::rcu_head);
free(inode);
}
-static int lttng_unlinked_file_pool_add_inode(
- struct lttng_unlinked_file_pool *pool,
- struct lttng_inode *inode)
+static int lttng_unlinked_file_pool_add_inode(struct lttng_unlinked_file_pool *pool,
+ struct lttng_inode *inode)
{
int ret;
const unsigned int unlinked_id = pool->next_id++;
char *inode_unlinked_name;
bool reference_acquired;
- DBG("Adding inode of %s to unlinked file pool as id %u",
- inode->location.path, unlinked_id);
+ DBG("Adding inode of %s to unlinked file pool as id %u", inode->location.path, unlinked_id);
ret = asprintf(&inode_unlinked_name, "%u", unlinked_id);
if (ret < 0) {
ERR("Failed to format unlinked inode name");
}
if (pool->file_count == 0) {
- DBG("Creating unlinked files directory at %s",
- pool->unlink_directory_path);
+ DBG("Creating unlinked files directory at %s", pool->unlink_directory_path);
LTTNG_ASSERT(!pool->unlink_directory_handle);
- ret = utils_mkdir(pool->unlink_directory_path,
- S_IRWXU | S_IRWXG, -1, -1);
+ ret = utils_mkdir(pool->unlink_directory_path, S_IRWXU | S_IRWXG, -1, -1);
if (ret) {
if (errno == EEXIST) {
/*
* error.
*/
DBG("Unlinked file directory \"%s\" already exists",
- pool->unlink_directory_path);
+ pool->unlink_directory_path);
} else {
PERROR("Failed to create unlinked files directory at %s",
- pool->unlink_directory_path);
+ pool->unlink_directory_path);
goto end;
}
}
- pool->unlink_directory_handle = lttng_directory_handle_create(
- pool->unlink_directory_path);
+ pool->unlink_directory_handle =
+ lttng_directory_handle_create(pool->unlink_directory_path);
if (!pool->unlink_directory_handle) {
ERR("Failed to create directory handle to unlinked file pool at %s",
- pool->unlink_directory_path);
+ pool->unlink_directory_path);
ret = -1;
goto end;
}
}
ret = lttng_directory_handle_rename(inode->location.directory_handle,
- inode->location.path, pool->unlink_directory_handle,
- inode_unlinked_name);
+ inode->location.path,
+ pool->unlink_directory_handle,
+ inode_unlinked_name);
if (ret) {
goto end;
}
lttng_directory_handle_put(inode->location.directory_handle);
inode->location.directory_handle = NULL;
- reference_acquired = lttng_directory_handle_get(
- pool->unlink_directory_handle);
+ reference_acquired = lttng_directory_handle_get(pool->unlink_directory_handle);
LTTNG_ASSERT(reference_acquired);
inode->location.directory_handle = pool->unlink_directory_handle;
return ret;
}
-static int lttng_unlinked_file_pool_remove_inode(
- struct lttng_unlinked_file_pool *pool,
- struct lttng_inode *inode)
+static int lttng_unlinked_file_pool_remove_inode(struct lttng_unlinked_file_pool *pool,
+ struct lttng_inode *inode)
{
int ret;
DBG("Removing inode with unlinked id %u from unlinked file pool",
- LTTNG_OPTIONAL_GET(inode->unlinked_id));
+ LTTNG_OPTIONAL_GET(inode->unlinked_id));
- ret = lttng_directory_handle_unlink_file(
- inode->location.directory_handle, inode->location.path);
+ ret = lttng_directory_handle_unlink_file(inode->location.directory_handle,
+ inode->location.path);
if (ret) {
PERROR("Failed to unlink file %s from unlinked file directory",
- inode->location.path);
+ inode->location.path);
goto end;
}
free(inode->location.path);
* error except through logging.
*/
PERROR("Failed to remove unlinked files directory at %s",
- pool->unlink_directory_path);
+ pool->unlink_directory_path);
}
lttng_directory_handle_put(pool->unlink_directory_handle);
pool->unlink_directory_handle = NULL;
LTTNG_ASSERT(inode->location.directory_handle);
LTTNG_ASSERT(inode->location.path);
- DBG("Removing %s from unlinked file pool",
- inode->location.path);
+ DBG("Removing %s from unlinked file pool", inode->location.path);
ret = lttng_unlinked_file_pool_remove_inode(inode->unlinked_file_pool, inode);
if (ret) {
PERROR("Failed to unlink %s", inode->location.path);
}
}
- lttng_directory_handle_put(
- inode->location.directory_handle);
+ lttng_directory_handle_put(inode->location.directory_handle);
inode->location.directory_handle = NULL;
free(inode->location.path);
inode->location.path = NULL;
urcu_ref_get(&inode->ref);
}
-struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
- const char *path)
+struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(const char *path)
{
struct lttng_unlinked_file_pool *pool = zmalloc<lttng_unlinked_file_pool>();
if (!path || *path != '/') {
ERR("Unlinked file pool must be created with an absolute path, path = \"%s\"",
- path ? path : "NULL");
+ path ? path : "NULL");
goto error;
}
return NULL;
}
-void lttng_unlinked_file_pool_destroy(
- struct lttng_unlinked_file_pool *pool)
+void lttng_unlinked_file_pool_destroy(struct lttng_unlinked_file_pool *pool)
{
if (!pool) {
return;
urcu_ref_put(&inode->ref, lttng_inode_release);
}
-struct lttng_directory_handle *
-lttng_inode_get_location_directory_handle(
- struct lttng_inode *inode)
+struct lttng_directory_handle *lttng_inode_get_location_directory_handle(struct lttng_inode *inode)
{
if (inode->location.directory_handle) {
- const bool reference_acquired = lttng_directory_handle_get(
- inode->location.directory_handle);
+ const bool reference_acquired =
+ lttng_directory_handle_get(inode->location.directory_handle);
LTTNG_ASSERT(reference_acquired);
}
}
void lttng_inode_borrow_location(struct lttng_inode *inode,
- const struct lttng_directory_handle **out_directory_handle,
- const char **out_path)
+ const struct lttng_directory_handle **out_directory_handle,
+ const char **out_path)
{
if (out_directory_handle) {
*out_directory_handle = inode->location.directory_handle;
}
}
-int lttng_inode_rename(
- struct lttng_inode *inode,
- struct lttng_directory_handle *old_directory_handle,
- const char *old_path,
- struct lttng_directory_handle *new_directory_handle,
- const char *new_path,
- bool overwrite)
+int lttng_inode_rename(struct lttng_inode *inode,
+ struct lttng_directory_handle *old_directory_handle,
+ const char *old_path,
+ struct lttng_directory_handle *new_directory_handle,
+ const char *new_path,
+ bool overwrite)
{
int ret = 0;
char *new_path_copy = strdup(new_path);
bool reference_acquired;
DBG("Performing rename of inode from %s to %s with %s directory handles",
- old_path, new_path,
- lttng_directory_handle_equals(old_directory_handle,
- new_directory_handle) ?
- "identical" :
- "different");
+ old_path,
+ new_path,
+ lttng_directory_handle_equals(old_directory_handle, new_directory_handle) ?
+ "identical" :
+ "different");
if (!new_path_copy) {
ret = -ENOMEM;
if (inode->unlink_pending) {
WARN("An attempt to rename an unlinked file from %s to %s has been performed",
- old_path, new_path);
+ old_path,
+ new_path);
ret = -ENOENT;
goto end;
}
/* Verify that file doesn't exist. */
struct stat statbuf;
- ret = lttng_directory_handle_stat(
- new_directory_handle, new_path, &statbuf);
+ ret = lttng_directory_handle_stat(new_directory_handle, new_path, &statbuf);
if (ret == 0) {
- ERR("Refusing to rename %s as the destination already exists",
- old_path);
+ ERR("Refusing to rename %s as the destination already exists", old_path);
ret = -EEXIST;
goto end;
} else if (ret < 0 && errno != ENOENT) {
}
}
- ret = lttng_directory_handle_rename(old_directory_handle, old_path,
- new_directory_handle, new_path);
+ ret = lttng_directory_handle_rename(
+ old_directory_handle, old_path, new_directory_handle, new_path);
if (ret) {
PERROR("Failed to rename file %s to %s", old_path, new_path);
ret = -errno;
if (inode->unlink_pending) {
WARN("An attempt to re-unlink %s has been performed, ignoring.",
- inode->location.path);
+ inode->location.path);
ret = -ENOENT;
goto end;
}
* Move to the temporary "deleted" directory until all
* references are released.
*/
- ret = lttng_unlinked_file_pool_add_inode(
- inode->unlinked_file_pool, inode);
+ ret = lttng_unlinked_file_pool_add_inode(inode->unlinked_file_pool, inode);
if (ret) {
PERROR("Failed to add inode \"%s\" to the unlinked file pool",
- inode->location.path);
+ inode->location.path);
goto end;
}
inode->unlink_pending = true;
}
static struct lttng_inode *lttng_inode_create(const struct inode_id *id,
- struct cds_lfht *ht,
- struct lttng_unlinked_file_pool *unlinked_file_pool,
- struct lttng_directory_handle *directory_handle,
- const char *path)
+ struct cds_lfht *ht,
+ struct lttng_unlinked_file_pool *unlinked_file_pool,
+ struct lttng_directory_handle *directory_handle,
+ const char *path)
{
struct lttng_inode *inode = NULL;
char *path_copy;
}
pthread_mutex_unlock(&seed.lock);
- registry->inodes = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ registry->inodes = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!registry->inodes) {
goto error;
}
return NULL;
}
-void lttng_inode_registry_destroy(
- struct lttng_inode_registry *registry)
+void lttng_inode_registry_destroy(struct lttng_inode_registry *registry)
{
if (!registry) {
return;
free(registry);
}
-struct lttng_inode *lttng_inode_registry_get_inode(
- struct lttng_inode_registry *registry,
- struct lttng_directory_handle *handle,
- const char *path,
- int fd,
- struct lttng_unlinked_file_pool *unlinked_file_pool)
+struct lttng_inode *
+lttng_inode_registry_get_inode(struct lttng_inode_registry *registry,
+ struct lttng_directory_handle *handle,
+ const char *path,
+ int fd,
+ struct lttng_unlinked_file_pool *unlinked_file_pool)
{
int ret;
struct stat statbuf;
id.inode = statbuf.st_ino;
rcu_read_lock();
- cds_lfht_lookup(registry->inodes, lttng_inode_id_hash(&id),
- lttng_inode_match, &id, &iter);
+ cds_lfht_lookup(registry->inodes, lttng_inode_id_hash(&id), lttng_inode_match, &id, &iter);
node = cds_lfht_iter_get_node(&iter);
if (node) {
- inode = lttng::utils::container_of(
- node, <tng_inode::registry_node);
+ inode = lttng::utils::container_of(node, <tng_inode::registry_node);
lttng_inode_get(inode);
goto end_unlock;
}
- inode = lttng_inode_create(&id, registry->inodes, unlinked_file_pool,
- handle, path);
+ inode = lttng_inode_create(&id, registry->inodes, unlinked_file_pool, handle, path);
if (!inode) {
goto end_unlock;
}
node = cds_lfht_add_unique(registry->inodes,
- lttng_inode_id_hash(&inode->id), lttng_inode_match,
- &inode->id, &inode->registry_node);
+ lttng_inode_id_hash(&inode->id),
+ lttng_inode_match,
+ &inode->id,
+ &inode->registry_node);
LTTNG_ASSERT(node == &inode->registry_node);
end_unlock:
rcu_read_unlock();
* must be tracked.
*/
int fd_tracker_util_poll_create(struct fd_tracker *tracker,
- const char *name,
- struct lttng_poll_event *events,
- int size,
- int flags)
+ const char *name,
+ struct lttng_poll_event *events,
+ int size,
+ int flags)
{
int out_fd;
struct create_args create_args = {
};
return fd_tracker_open_unsuspendable_fd(
- tracker, &out_fd, &name, 1, open_epoll, &create_args);
+ tracker, &out_fd, &name, 1, open_epoll, &create_args);
}
-int fd_tracker_util_poll_clean(
- struct fd_tracker *tracker, struct lttng_poll_event *events)
+int fd_tracker_util_poll_clean(struct fd_tracker *tracker, struct lttng_poll_event *events)
{
- return fd_tracker_close_unsuspendable_fd(
- tracker, &events->epfd, 1, close_epoll, events);
+ return fd_tracker_close_unsuspendable_fd(tracker, &events->epfd, 1, close_epoll, events);
}
#else /* HAVE_EPOLL */
* The epoll variant of the poll compat layer creates an unsuspendable fd which
* must be tracked.
*/
-int fd_tracker_util_poll_create(
- struct fd_tracker *tracker __attribute__((unused)),
- const char *name __attribute__((unused)),
- struct lttng_poll_event *events,
- int size,
- int flags __attribute__((unused)))
+int fd_tracker_util_poll_create(struct fd_tracker *tracker __attribute__((unused)),
+ const char *name __attribute__((unused)),
+ struct lttng_poll_event *events,
+ int size,
+ int flags __attribute__((unused)))
{
return lttng_poll_create(events, size, flags);
}
-int fd_tracker_util_poll_clean(
- struct fd_tracker *tracker __attribute__((unused)),
- struct lttng_poll_event *events)
+int fd_tracker_util_poll_clean(struct fd_tracker *tracker __attribute__((unused)),
+ struct lttng_poll_event *events)
{
lttng_poll_clean(events);
return 0;
#include <common/error.hpp>
#include <common/fd-tracker/utils.hpp>
#include <common/utils.hpp>
+
#include <lttng/constant.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-static
-int open_pipe_cloexec(void *data __attribute__((unused)), int *fds)
+static int open_pipe_cloexec(void *data __attribute__((unused)), int *fds)
{
return utils_create_pipe_cloexec(fds);
}
-static
-int close_pipe(void *data __attribute__((unused)), int *pipe)
+static int close_pipe(void *data __attribute__((unused)), int *pipe)
{
utils_close_pipe(pipe);
pipe[0] = pipe[1] = -1;
return close(*fd);
}
-int fd_tracker_util_pipe_open_cloexec(
- struct fd_tracker *tracker, const char *name, int *pipe)
+int fd_tracker_util_pipe_open_cloexec(struct fd_tracker *tracker, const char *name, int *pipe)
{
int ret;
const char *name_prefix;
goto end;
}
- ret = fd_tracker_open_unsuspendable_fd(tracker, pipe,
- (const char **) names, 2, open_pipe_cloexec, NULL);
+ ret = fd_tracker_open_unsuspendable_fd(
+ tracker, pipe, (const char **) names, 2, open_pipe_cloexec, NULL);
free(names[0]);
free(names[1]);
end:
int fd_tracker_util_pipe_close(struct fd_tracker *tracker, int *pipe)
{
- return fd_tracker_close_unsuspendable_fd(
- tracker, pipe, 2, close_pipe, NULL);
+ return fd_tracker_close_unsuspendable_fd(tracker, pipe, 2, close_pipe, NULL);
}
namespace {
};
} /* namespace */
-static
-int open_directory_handle(void *_args, int *out_fds)
+static int open_directory_handle(void *_args, int *out_fds)
{
int ret = 0;
struct open_directory_handle_args *args = (open_directory_handle_args *) _args;
struct lttng_directory_handle *new_handle = NULL;
new_handle = args->in_handle ?
- lttng_directory_handle_create_from_handle(
- args->path, args->in_handle) :
- lttng_directory_handle_create(args->path);
+ lttng_directory_handle_create_from_handle(args->path, args->in_handle) :
+ lttng_directory_handle_create(args->path);
if (!new_handle) {
ret = -errno;
goto end;
#else
abort();
#endif
-
}
end:
return ret;
}
#ifdef HAVE_DIRFD
-static
-int fd_close(void *unused __attribute__((unused)), int *in_fds)
+static int fd_close(void *unused __attribute__((unused)), int *in_fds)
{
const int ret = close(in_fds[0]);
return ret;
}
-static
-void directory_handle_destroy(
- struct lttng_directory_handle *handle, void *data)
+static void directory_handle_destroy(struct lttng_directory_handle *handle, void *data)
{
struct fd_tracker *tracker = (fd_tracker *) data;
- const int ret = fd_tracker_close_unsuspendable_fd(
- tracker, &handle->dirfd, 1, fd_close, NULL);
+ const int ret =
+ fd_tracker_close_unsuspendable_fd(tracker, &handle->dirfd, 1, fd_close, NULL);
if (ret) {
ERR("Failed to untrack directory handle file descriptor");
}
#endif
-struct lttng_directory_handle *fd_tracker_create_directory_handle(
- struct fd_tracker *tracker, const char *path)
+struct lttng_directory_handle *fd_tracker_create_directory_handle(struct fd_tracker *tracker,
+ const char *path)
{
- return fd_tracker_create_directory_handle_from_handle(
- tracker, NULL, path);
+ return fd_tracker_create_directory_handle_from_handle(tracker, NULL, path);
}
struct lttng_directory_handle *fd_tracker_create_directory_handle_from_handle(
- struct fd_tracker *tracker,
- struct lttng_directory_handle *in_handle,
- const char *path)
+ struct fd_tracker *tracker, struct lttng_directory_handle *in_handle, const char *path)
{
int ret;
int dirfd = -1;
char *handle_name = NULL;
char cwd_path[LTTNG_PATH_MAX] = "working directory";
struct lttng_directory_handle *new_handle = NULL;
- open_directory_handle_args open_args {};
+ open_directory_handle_args open_args{};
open_args.in_handle = in_handle;
open_args.path = path;
}
}
- ret = asprintf(&handle_name, "Directory handle to %s",
- path ? path : cwd_path);
+ ret = asprintf(&handle_name, "Directory handle to %s", path ? path : cwd_path);
if (ret < 0) {
PERROR("Failed to format directory handle name");
goto end;
}
- ret = fd_tracker_open_unsuspendable_fd(tracker, &dirfd,
- (const char **) &handle_name, 1, open_directory_handle,
- &open_args);
+ ret = fd_tracker_open_unsuspendable_fd(
+ tracker, &dirfd, (const char **) &handle_name, 1, open_directory_handle, &open_args);
if (ret && ret != ENOTSUP) {
- ERR("Failed to open directory handle to %s through the fd tracker", path ? path : cwd_path);
+ ERR("Failed to open directory handle to %s through the fd tracker",
+ path ? path : cwd_path);
}
new_handle = open_args.ret_handle;
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <common/compat/errno.hpp>
#include <common/bytecode/bytecode.hpp>
+#include <common/compat/errno.hpp>
#include <common/filter/filter-ast.hpp>
#include <common/filter/filter-parser.hpp>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
{
struct filter_parser_ctx *ctx;
int ret;
- int print_xml = 0, generate_ir = 0, generate_bytecode = 0,
- print_bytecode = 0;
+ int print_xml = 0, generate_ir = 0, generate_bytecode = 0, print_bytecode = 0;
int argidx;
for (argidx = 1; argidx < argc; argidx++) {
}
printf("done\n");
printf("Size of bytecode generated: %u bytes.\n",
- bytecode_get_len(&ctx->bytecode->b));
+ bytecode_get_len(&ctx->bytecode->b));
}
if (print_bytecode) {
bytecode_len = ctx->bytecode->b.reloc_table_offset;
printf("Bytecode:\n");
for (i = 0; i < bytecode_len; i++) {
- printf("0x%X ",
- ((uint8_t *) ctx->bytecode->b.data)[i]);
+ printf("0x%X ", ((uint8_t *) ctx->bytecode->b.data)[i]);
}
printf("\n");
printf("Reloc table:\n");
for (i = bytecode_len; i < len;) {
- printf("{ 0x%X, ",
- *(uint16_t *) &ctx->bytecode->b.data[i]);
+ printf("{ 0x%X, ", *(uint16_t *) &ctx->bytecode->b.data[i]);
i += sizeof(uint16_t);
printf("%s } ", &((char *) ctx->bytecode->b.data)[i]);
i += strlen(&((char *) ctx->bytecode->b.data)[i]) + 1;
*/
#include "filter.hpp"
+
#include <stddef.h>
struct bytecode_symbol_iterator {
size_t offset, len;
};
-struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(
- struct lttng_bytecode *bytecode)
+struct bytecode_symbol_iterator *bytecode_symbol_iterator_create(struct lttng_bytecode *bytecode)
{
struct bytecode_symbol_iterator *it = NULL;
ret = *((uint16_t *) (it->bytecode + it->offset));
end:
return ret;
- }
+}
-const char *bytecode_symbol_iterator_get_name(
- struct bytecode_symbol_iterator *it)
+const char *bytecode_symbol_iterator_get_name(struct bytecode_symbol_iterator *it)
{
const char *ret = NULL;
*
*/
-#include <stdlib.h>
-#include <string.h>
-#include <common/align.hpp>
-#include <common/compat/errno.hpp>
-#include <common/compat/string.hpp>
-
#include "common/align.hpp"
#include "common/bytecode/bytecode.hpp"
#include "common/compat/string.hpp"
#include "filter-ast.hpp"
#include "filter-ir.hpp"
-static
-int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx,
- struct ir_op *node);
+#include <common/align.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/string.hpp>
+
+#include <stdlib.h>
+#include <string.h>
+
+static int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx, struct ir_op *node);
-static
-int bytecode_patch(struct lttng_bytecode_alloc **fb,
- const void *data,
- uint16_t offset,
- uint32_t len)
+static int
+bytecode_patch(struct lttng_bytecode_alloc **fb, const void *data, uint16_t offset, uint32_t len)
{
if (offset >= (*fb)->b.len) {
return -EINVAL;
return 0;
}
-static
-int visit_node_root(struct filter_parser_ctx *ctx, struct ir_op *node)
+static int visit_node_root(struct filter_parser_ctx *ctx, struct ir_op *node)
{
int ret;
struct return_op insn;
* 0: no match
* < 0: error
*/
-static
-int load_expression_legacy_match(const struct ir_load_expression *exp,
- enum bytecode_op *op_type,
- char **symbol)
+static int load_expression_legacy_match(const struct ir_load_expression *exp,
+ enum bytecode_op *op_type,
+ char **symbol)
{
const struct ir_load_expression_op *op;
bool need_dot = false;
case IR_LOAD_EXPRESSION_GET_INDEX:
case IR_LOAD_EXPRESSION_LOAD_FIELD:
default:
- return 0; /* no match */
+ return 0; /* no match */
}
for (;;) {
op = op->next;
if (!op) {
- return 0; /* no match */
+ return 0; /* no match */
}
switch (op->type) {
case IR_LOAD_EXPRESSION_LOAD_FIELD:
}
break;
default:
- return 0; /* no match */
+ return 0; /* no match */
}
need_dot = true;
}
end:
- return 1; /* Legacy match */
+ return 1; /* Legacy match */
}
/*
* 0: no legacy match
* < 0: error
*/
-static
-int visit_node_load_expression_legacy(struct filter_parser_ctx *ctx,
- const struct ir_load_expression *exp,
- const struct ir_load_expression_op *op)
+static int visit_node_load_expression_legacy(struct filter_parser_ctx *ctx,
+ const struct ir_load_expression *exp,
+ const struct ir_load_expression_op *op)
{
struct load_op *insn = NULL;
- uint32_t insn_len = sizeof(struct load_op)
- + sizeof(struct field_ref);
+ uint32_t insn_len = sizeof(struct load_op) + sizeof(struct field_ref);
struct field_ref ref_offset;
uint32_t reloc_offset_u32;
uint16_t reloc_offset;
goto end;
}
/* append reloc */
- ret = bytecode_push(&ctx->bytecode_reloc, &reloc_offset,
- 1, sizeof(reloc_offset));
+ ret = bytecode_push(&ctx->bytecode_reloc, &reloc_offset, 1, sizeof(reloc_offset));
if (ret) {
goto end;
}
- ret = bytecode_push(&ctx->bytecode_reloc, symbol,
- 1, strlen(symbol) + 1);
+ ret = bytecode_push(&ctx->bytecode_reloc, symbol, 1, strlen(symbol) + 1);
if (ret) {
goto end;
}
- ret = 1; /* legacy */
+ ret = 1; /* legacy */
end:
free(insn);
free(symbol);
return ret;
}
-static
-int visit_node_load_expression(struct filter_parser_ctx *ctx,
- const struct ir_op *node)
+static int visit_node_load_expression(struct filter_parser_ctx *ctx, const struct ir_op *node)
{
struct ir_load_expression *exp;
struct ir_load_expression_op *op;
return ret;
}
if (ret > 0) {
- return 0; /* legacy */
+ return 0; /* legacy */
}
for (; op != NULL; op = op->next) {
}
case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
{
- ret = bytecode_push_get_app_context_root(
- &ctx->bytecode);
+ ret = bytecode_push_get_app_context_root(&ctx->bytecode);
if (ret) {
return ret;
}
case IR_LOAD_EXPRESSION_GET_SYMBOL:
{
- ret = bytecode_push_get_symbol(&ctx->bytecode,
- &ctx->bytecode_reloc, op->u.symbol);
+ ret = bytecode_push_get_symbol(
+ &ctx->bytecode, &ctx->bytecode_reloc, op->u.symbol);
if (ret) {
return ret;
}
case IR_LOAD_EXPRESSION_GET_INDEX:
{
- ret = bytecode_push_get_index_u64(
- &ctx->bytecode, op->u.index);
+ ret = bytecode_push_get_index_u64(&ctx->bytecode, op->u.index);
if (ret) {
return ret;
return 0;
}
-static
-int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node)
+static int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node)
{
int ret;
switch (node->data_type) {
case IR_DATA_UNKNOWN:
default:
- fprintf(stderr, "[error] Unknown data type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown data type in %s\n", __func__);
return -EINVAL;
case IR_DATA_STRING:
{
struct load_op *insn;
- uint32_t insn_len = sizeof(struct load_op)
- + strlen(node->u.load.u.string.value) + 1;
+ uint32_t insn_len =
+ sizeof(struct load_op) + strlen(node->u.load.u.string.value) + 1;
insn = (load_op *) calloc(insn_len, 1);
if (!insn)
case IR_DATA_NUMERIC:
{
struct load_op *insn;
- uint32_t insn_len = sizeof(struct load_op)
- + sizeof(struct literal_numeric);
+ uint32_t insn_len = sizeof(struct load_op) + sizeof(struct literal_numeric);
insn = (load_op *) calloc(insn_len, 1);
if (!insn)
case IR_DATA_FLOAT:
{
struct load_op *insn;
- uint32_t insn_len = sizeof(struct load_op)
- + sizeof(struct literal_double);
+ uint32_t insn_len = sizeof(struct load_op) + sizeof(struct literal_double);
insn = (load_op *) calloc(insn_len, 1);
if (!insn)
}
}
-static
-int visit_node_unary(struct filter_parser_ctx *ctx, struct ir_op *node)
+static int visit_node_unary(struct filter_parser_ctx *ctx, struct ir_op *node)
{
int ret;
struct unary_op insn;
switch (node->u.unary.type) {
case AST_UNARY_UNKNOWN:
default:
- fprintf(stderr, "[error] Unknown unary node type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown unary node type in %s\n", __func__);
return -EINVAL;
case AST_UNARY_PLUS:
/* Nothing to do. */
* Binary comparator nesting is disallowed. This allows fitting into
* only 2 registers.
*/
-static
-int visit_node_binary(struct filter_parser_ctx *ctx, struct ir_op *node)
+static int visit_node_binary(struct filter_parser_ctx *ctx, struct ir_op *node)
{
int ret;
struct binary_op insn;
switch (node->u.binary.type) {
case AST_OP_UNKNOWN:
default:
- fprintf(stderr, "[error] Unknown unary node type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown unary node type in %s\n", __func__);
return -EINVAL;
case AST_OP_AND:
case AST_OP_OR:
- fprintf(stderr, "[error] Unexpected logical node type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unexpected logical node type in %s\n", __func__);
return -EINVAL;
case AST_OP_MUL:
/*
* A logical op always return a s64 (1 or 0).
*/
-static
-int visit_node_logical(struct filter_parser_ctx *ctx, struct ir_op *node)
+static int visit_node_logical(struct filter_parser_ctx *ctx, struct ir_op *node)
{
int ret;
struct logical_op insn;
if (ret)
return ret;
/* Cast to s64 if float or field ref */
- if ((node->u.binary.left->data_type == IR_DATA_FIELD_REF
- || node->u.binary.left->data_type == IR_DATA_GET_CONTEXT_REF
- || node->u.binary.left->data_type == IR_DATA_EXPRESSION)
- || node->u.binary.left->data_type == IR_DATA_FLOAT) {
+ if ((node->u.binary.left->data_type == IR_DATA_FIELD_REF ||
+ node->u.binary.left->data_type == IR_DATA_GET_CONTEXT_REF ||
+ node->u.binary.left->data_type == IR_DATA_EXPRESSION) ||
+ node->u.binary.left->data_type == IR_DATA_FLOAT) {
struct cast_op cast_insn;
- if (node->u.binary.left->data_type == IR_DATA_FIELD_REF
- || node->u.binary.left->data_type == IR_DATA_GET_CONTEXT_REF
- || node->u.binary.left->data_type == IR_DATA_EXPRESSION) {
+ if (node->u.binary.left->data_type == IR_DATA_FIELD_REF ||
+ node->u.binary.left->data_type == IR_DATA_GET_CONTEXT_REF ||
+ node->u.binary.left->data_type == IR_DATA_EXPRESSION) {
cast_insn.op = BYTECODE_OP_CAST_TO_S64;
} else {
cast_insn.op = BYTECODE_OP_CAST_DOUBLE_TO_S64;
}
- ret = bytecode_push(&ctx->bytecode, &cast_insn,
- 1, sizeof(cast_insn));
+ ret = bytecode_push(&ctx->bytecode, &cast_insn, 1, sizeof(cast_insn));
if (ret)
return ret;
}
switch (node->u.logical.type) {
default:
- fprintf(stderr, "[error] Unknown node type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown node type in %s\n", __func__);
return -EINVAL;
case AST_OP_AND:
insn.op = BYTECODE_OP_OR;
break;
}
- insn.skip_offset = (uint16_t) -1UL; /* Temporary */
- ret = bytecode_push_logical(&ctx->bytecode, &insn, 1, sizeof(insn),
- &skip_offset_loc);
+ insn.skip_offset = (uint16_t) -1UL; /* Temporary */
+ ret = bytecode_push_logical(&ctx->bytecode, &insn, 1, sizeof(insn), &skip_offset_loc);
if (ret)
return ret;
/* Visit right child */
if (ret)
return ret;
/* Cast to s64 if float or field ref */
- if ((node->u.binary.right->data_type == IR_DATA_FIELD_REF
- || node->u.binary.right->data_type == IR_DATA_GET_CONTEXT_REF
- || node->u.binary.right->data_type == IR_DATA_EXPRESSION)
- || node->u.binary.right->data_type == IR_DATA_FLOAT) {
+ if ((node->u.binary.right->data_type == IR_DATA_FIELD_REF ||
+ node->u.binary.right->data_type == IR_DATA_GET_CONTEXT_REF ||
+ node->u.binary.right->data_type == IR_DATA_EXPRESSION) ||
+ node->u.binary.right->data_type == IR_DATA_FLOAT) {
struct cast_op cast_insn;
- if (node->u.binary.right->data_type == IR_DATA_FIELD_REF
- || node->u.binary.right->data_type == IR_DATA_GET_CONTEXT_REF
- || node->u.binary.right->data_type == IR_DATA_EXPRESSION) {
+ if (node->u.binary.right->data_type == IR_DATA_FIELD_REF ||
+ node->u.binary.right->data_type == IR_DATA_GET_CONTEXT_REF ||
+ node->u.binary.right->data_type == IR_DATA_EXPRESSION) {
cast_insn.op = BYTECODE_OP_CAST_TO_S64;
} else {
cast_insn.op = BYTECODE_OP_CAST_DOUBLE_TO_S64;
}
- ret = bytecode_push(&ctx->bytecode, &cast_insn,
- 1, sizeof(cast_insn));
+ ret = bytecode_push(&ctx->bytecode, &cast_insn, 1, sizeof(cast_insn));
if (ret)
return ret;
}
/* We now know where the logical op can skip. */
target_loc = (uint16_t) bytecode_get_len(&ctx->bytecode->b);
ret = bytecode_patch(&ctx->bytecode,
- &target_loc, /* Offset to jump to */
- skip_offset_loc, /* Where to patch */
- sizeof(uint16_t));
+ &target_loc, /* Offset to jump to */
+ skip_offset_loc, /* Where to patch */
+ sizeof(uint16_t));
return ret;
}
* Postorder traversal of the tree. We need the children result before
* we can evaluate the parent.
*/
-static
-int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx,
- struct ir_op *node)
+static int recursive_visit_gen_bytecode(struct filter_parser_ctx *ctx, struct ir_op *node)
{
switch (node->op) {
case IR_OP_UNKNOWN:
default:
- fprintf(stderr, "[error] Unknown node type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown node type in %s\n", __func__);
return -EINVAL;
case IR_OP_ROOT:
/* Finally, append symbol table to bytecode */
ctx->bytecode->b.reloc_table_offset = bytecode_get_len(&ctx->bytecode->b);
- return bytecode_push(&ctx->bytecode, ctx->bytecode_reloc->b.data,
- 1, bytecode_get_len(&ctx->bytecode_reloc->b));
+ return bytecode_push(&ctx->bytecode,
+ ctx->bytecode_reloc->b.data,
+ 1,
+ bytecode_get_len(&ctx->bytecode_reloc->b));
error:
filter_bytecode_free(ctx);
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
#include "filter-ast.hpp"
-#include "filter-parser.hpp"
#include "filter-ir.hpp"
+#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
#include <common/macros.hpp>
#include <common/string-utils/string-utils.hpp>
-static
-struct ir_op *generate_ir_recursive(struct filter_parser_ctx *ctx,
- struct filter_node *node, enum ir_side side);
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static struct ir_op *
+generate_ir_recursive(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side);
-static
-struct ir_op *make_op_root(struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_root(struct ir_op *child, enum ir_side side)
{
struct ir_op *op;
return op;
}
-static
-enum ir_load_string_type get_literal_string_type(const char *string)
+static enum ir_load_string_type get_literal_string_type(const char *string)
{
LTTNG_ASSERT(string);
return IR_LOAD_STRING_TYPE_PLAIN;
}
-static
-struct ir_op *make_op_load_string(const char *string, enum ir_side side)
+static struct ir_op *make_op_load_string(const char *string, enum ir_side side)
{
struct ir_op *op;
return op;
}
-static
-struct ir_op *make_op_load_numeric(int64_t v, enum ir_side side)
+static struct ir_op *make_op_load_numeric(int64_t v, enum ir_side side)
{
struct ir_op *op;
return op;
}
-static
-struct ir_op *make_op_load_float(double v, enum ir_side side)
+static struct ir_op *make_op_load_float(double v, enum ir_side side)
{
struct ir_op *op;
return op;
}
-static
-void free_load_expression(struct ir_load_expression *load_expression)
+static void free_load_expression(struct ir_load_expression *load_expression)
{
struct ir_load_expression_op *exp_op;
* Returns the first node of the chain, after initializing the next
* pointers.
*/
-static
-struct filter_node *load_expression_get_forward_chain(struct filter_node *node)
+static struct filter_node *load_expression_get_forward_chain(struct filter_node *node)
{
struct filter_node *prev_node;
return prev_node;
}
-static
-struct ir_load_expression *create_load_expression(struct filter_node *node)
+static struct ir_load_expression *create_load_expression(struct filter_node *node)
{
struct ir_load_expression *load_exp;
struct ir_load_expression_op *load_exp_op, *prev_op;
goto error;
/* Explore brackets from current node. */
- for (bracket_node = node->u.expression.next_bracket;
- bracket_node != NULL;
- bracket_node = bracket_node->u.expression.next_bracket) {
+ for (bracket_node = node->u.expression.next_bracket; bracket_node != NULL;
+ bracket_node = bracket_node->u.expression.next_bracket) {
prev_op = load_exp_op;
if (bracket_node->type != NODE_EXPRESSION ||
- bracket_node->u.expression.type != AST_EXP_CONSTANT) {
- fprintf(stderr, "[error] Expecting constant index in array expression\n");
- goto error;
- }
+ bracket_node->u.expression.type != AST_EXP_CONSTANT) {
+ fprintf(stderr,
+ "[error] Expecting constant index in array expression\n");
+ goto error;
+ }
load_exp_op = zmalloc<ir_load_expression_op>();
if (!load_exp_op)
goto error;
return NULL;
}
-static
-struct ir_op *make_op_load_expression(struct filter_node *node,
- enum ir_side side)
+static struct ir_op *make_op_load_expression(struct filter_node *node, enum ir_side side)
{
struct ir_op *op;
return NULL;
}
-static
-struct ir_op *make_op_unary(enum unary_op_type unary_op_type,
- const char *op_str, enum ir_op_signedness signedness,
- struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_unary(enum unary_op_type unary_op_type,
+ const char *op_str,
+ enum ir_op_signedness signedness,
+ struct ir_op *child,
+ enum ir_side side)
{
struct ir_op *op = NULL;
if (child->data_type == IR_DATA_STRING) {
- fprintf(stderr, "[error] unary operation '%s' not allowed on string literal\n", op_str);
+ fprintf(stderr,
+ "[error] unary operation '%s' not allowed on string literal\n",
+ op_str);
goto error;
}
/*
* unary + is pretty much useless.
*/
-static
-struct ir_op *make_op_unary_plus(struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_unary_plus(struct ir_op *child, enum ir_side side)
{
- return make_op_unary(AST_UNARY_PLUS, "+", child->signedness,
- child, side);
+ return make_op_unary(AST_UNARY_PLUS, "+", child->signedness, child, side);
}
-static
-struct ir_op *make_op_unary_minus(struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_unary_minus(struct ir_op *child, enum ir_side side)
{
- return make_op_unary(AST_UNARY_MINUS, "-", child->signedness,
- child, side);
+ return make_op_unary(AST_UNARY_MINUS, "-", child->signedness, child, side);
}
-static
-struct ir_op *make_op_unary_not(struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_unary_not(struct ir_op *child, enum ir_side side)
{
- return make_op_unary(AST_UNARY_NOT, "!", child->signedness,
- child, side);
+ return make_op_unary(AST_UNARY_NOT, "!", child->signedness, child, side);
}
-static
-struct ir_op *make_op_unary_bit_not(struct ir_op *child, enum ir_side side)
+static struct ir_op *make_op_unary_bit_not(struct ir_op *child, enum ir_side side)
{
- return make_op_unary(AST_UNARY_BIT_NOT, "~", child->signedness,
- child, side);
+ return make_op_unary(AST_UNARY_BIT_NOT, "~", child->signedness, child, side);
}
-static
-struct ir_op *make_op_binary_compare(enum op_type bin_op_type,
- const char *op_str, struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_compare(enum op_type bin_op_type,
+ const char *op_str,
+ struct ir_op *left,
+ struct ir_op *right,
+ enum ir_side side)
{
struct ir_op *op = NULL;
- if (left->data_type == IR_DATA_UNKNOWN
- || right->data_type == IR_DATA_UNKNOWN) {
+ if (left->data_type == IR_DATA_UNKNOWN || right->data_type == IR_DATA_UNKNOWN) {
fprintf(stderr, "[error] binary operation '%s' has unknown operand type\n", op_str);
goto error;
-
}
- if ((left->data_type == IR_DATA_STRING
- && (right->data_type == IR_DATA_NUMERIC || right->data_type == IR_DATA_FLOAT))
- || ((left->data_type == IR_DATA_NUMERIC || left->data_type == IR_DATA_FLOAT) &&
- right->data_type == IR_DATA_STRING)) {
+ if ((left->data_type == IR_DATA_STRING &&
+ (right->data_type == IR_DATA_NUMERIC || right->data_type == IR_DATA_FLOAT)) ||
+ ((left->data_type == IR_DATA_NUMERIC || left->data_type == IR_DATA_FLOAT) &&
+ right->data_type == IR_DATA_STRING)) {
fprintf(stderr, "[error] binary operation '%s' operand type mismatch\n", op_str);
goto error;
}
return NULL;
}
-static
-struct ir_op *make_op_binary_eq(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_eq(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_EQ, "==", left, right, side);
}
-static
-struct ir_op *make_op_binary_ne(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_ne(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_NE, "!=", left, right, side);
}
-static
-struct ir_op *make_op_binary_gt(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_gt(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_GT, ">", left, right, side);
}
-static
-struct ir_op *make_op_binary_lt(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_lt(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_LT, "<", left, right, side);
}
-static
-struct ir_op *make_op_binary_ge(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_ge(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_GE, ">=", left, right, side);
}
-static
-struct ir_op *make_op_binary_le(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_le(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_compare(AST_OP_LE, "<=", left, right, side);
}
-static
-struct ir_op *make_op_binary_logical(enum op_type bin_op_type,
- const char *op_str, struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_logical(enum op_type bin_op_type,
+ const char *op_str,
+ struct ir_op *left,
+ struct ir_op *right,
+ enum ir_side side)
{
struct ir_op *op = NULL;
- if (left->data_type == IR_DATA_UNKNOWN
- || right->data_type == IR_DATA_UNKNOWN) {
+ if (left->data_type == IR_DATA_UNKNOWN || right->data_type == IR_DATA_UNKNOWN) {
fprintf(stderr, "[error] binary operation '%s' has unknown operand type\n", op_str);
goto error;
-
}
- if (left->data_type == IR_DATA_STRING
- || right->data_type == IR_DATA_STRING) {
- fprintf(stderr, "[error] logical binary operation '%s' cannot have string operand\n", op_str);
+ if (left->data_type == IR_DATA_STRING || right->data_type == IR_DATA_STRING) {
+ fprintf(stderr,
+ "[error] logical binary operation '%s' cannot have string operand\n",
+ op_str);
goto error;
}
return NULL;
}
-static
-struct ir_op *make_op_binary_bitwise(enum op_type bin_op_type,
- const char *op_str, struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *make_op_binary_bitwise(enum op_type bin_op_type,
+ const char *op_str,
+ struct ir_op *left,
+ struct ir_op *right,
+ enum ir_side side)
{
struct ir_op *op = NULL;
- if (left->data_type == IR_DATA_UNKNOWN
- || right->data_type == IR_DATA_UNKNOWN) {
- fprintf(stderr, "[error] bitwise binary operation '%s' has unknown operand type\n", op_str);
+ if (left->data_type == IR_DATA_UNKNOWN || right->data_type == IR_DATA_UNKNOWN) {
+ fprintf(stderr,
+ "[error] bitwise binary operation '%s' has unknown operand type\n",
+ op_str);
goto error;
-
}
- if (left->data_type == IR_DATA_STRING
- || right->data_type == IR_DATA_STRING) {
- fprintf(stderr, "[error] bitwise binary operation '%s' cannot have string operand\n", op_str);
+ if (left->data_type == IR_DATA_STRING || right->data_type == IR_DATA_STRING) {
+ fprintf(stderr,
+ "[error] bitwise binary operation '%s' cannot have string operand\n",
+ op_str);
goto error;
}
- if (left->data_type == IR_DATA_FLOAT
- || right->data_type == IR_DATA_FLOAT) {
- fprintf(stderr, "[error] bitwise binary operation '%s' cannot have floating point operand\n", op_str);
+ if (left->data_type == IR_DATA_FLOAT || right->data_type == IR_DATA_FLOAT) {
+ fprintf(stderr,
+ "[error] bitwise binary operation '%s' cannot have floating point operand\n",
+ op_str);
goto error;
}
return NULL;
}
-static
-struct ir_op *make_op_binary_logical_and(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_logical_and(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_logical(AST_OP_AND, "&&", left, right, side);
}
-static
-struct ir_op *make_op_binary_logical_or(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_logical_or(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_logical(AST_OP_OR, "||", left, right, side);
}
-static
-struct ir_op *make_op_binary_bitwise_rshift(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_bitwise_rshift(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_bitwise(AST_OP_BIT_RSHIFT, ">>", left, right, side);
}
-static
-struct ir_op *make_op_binary_bitwise_lshift(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_bitwise_lshift(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_bitwise(AST_OP_BIT_LSHIFT, "<<", left, right, side);
}
-static
-struct ir_op *make_op_binary_bitwise_and(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_bitwise_and(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_bitwise(AST_OP_BIT_AND, "&", left, right, side);
}
-static
-struct ir_op *make_op_binary_bitwise_or(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_bitwise_or(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_bitwise(AST_OP_BIT_OR, "|", left, right, side);
}
-static
-struct ir_op *make_op_binary_bitwise_xor(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
+static struct ir_op *
+make_op_binary_bitwise_xor(struct ir_op *left, struct ir_op *right, enum ir_side side)
{
return make_op_binary_bitwise(AST_OP_BIT_XOR, "^", left, right, side);
}
-static
-void filter_free_ir_recursive(struct ir_op *op)
+static void filter_free_ir_recursive(struct ir_op *op)
{
if (!op)
return;
switch (op->op) {
case IR_OP_UNKNOWN:
default:
- fprintf(stderr, "[error] Unknown op type in %s\n",
- __func__);
+ fprintf(stderr, "[error] Unknown op type in %s\n", __func__);
break;
case IR_OP_ROOT:
filter_free_ir_recursive(op->u.root.child);
case IR_DATA_STRING:
free(op->u.load.u.string.value);
break;
- case IR_DATA_FIELD_REF: /* fall-through */
+ case IR_DATA_FIELD_REF: /* fall-through */
case IR_DATA_GET_CONTEXT_REF:
free(op->u.load.u.ref);
break;
free(op);
}
-static
-struct ir_op *make_expression(struct filter_parser_ctx *ctx,
- struct filter_node *node, enum ir_side side)
+static struct ir_op *
+make_expression(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side)
{
switch (node->u.expression.type) {
case AST_EXP_UNKNOWN:
case AST_EXP_STRING:
return make_op_load_string(node->u.expression.u.string, side);
case AST_EXP_CONSTANT:
- return make_op_load_numeric(node->u.expression.u.constant,
- side);
+ return make_op_load_numeric(node->u.expression.u.constant, side);
case AST_EXP_FLOAT_CONSTANT:
- return make_op_load_float(node->u.expression.u.float_constant,
- side);
+ return make_op_load_float(node->u.expression.u.float_constant, side);
case AST_EXP_IDENTIFIER:
case AST_EXP_GLOBAL_IDENTIFIER:
return make_op_load_expression(node, side);
case AST_EXP_NESTED:
- return generate_ir_recursive(ctx, node->u.expression.u.child,
- side);
+ return generate_ir_recursive(ctx, node->u.expression.u.child, side);
}
}
-static
-struct ir_op *make_op(struct filter_parser_ctx *ctx,
- struct filter_node *node, enum ir_side side)
+static struct ir_op *
+make_op(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side)
{
struct ir_op *op = NULL, *lchild, *rchild;
const char *op_str = "?";
return op;
error_not_supported:
- fprintf(stderr, "[error] %s: binary operation '%s' not supported\n",
- __func__, op_str);
+ fprintf(stderr, "[error] %s: binary operation '%s' not supported\n", __func__, op_str);
return NULL;
}
-static
-struct ir_op *make_unary_op(struct filter_parser_ctx *ctx,
- struct filter_node *node, enum ir_side side)
+static struct ir_op *
+make_unary_op(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side)
{
switch (node->u.unary_op.type) {
case AST_UNARY_UNKNOWN:
{
struct ir_op *op, *child;
- child = generate_ir_recursive(ctx, node->u.unary_op.child,
- side);
+ child = generate_ir_recursive(ctx, node->u.unary_op.child, side);
if (!child)
return NULL;
op = make_op_unary_plus(child, side);
{
struct ir_op *op, *child;
- child = generate_ir_recursive(ctx, node->u.unary_op.child,
- side);
+ child = generate_ir_recursive(ctx, node->u.unary_op.child, side);
if (!child)
return NULL;
op = make_op_unary_minus(child, side);
{
struct ir_op *op, *child;
- child = generate_ir_recursive(ctx, node->u.unary_op.child,
- side);
+ child = generate_ir_recursive(ctx, node->u.unary_op.child, side);
if (!child)
return NULL;
op = make_op_unary_not(child, side);
{
struct ir_op *op, *child;
- child = generate_ir_recursive(ctx, node->u.unary_op.child,
- side);
+ child = generate_ir_recursive(ctx, node->u.unary_op.child, side);
if (!child)
return NULL;
op = make_op_unary_bit_not(child, side);
return NULL;
}
-static
-struct ir_op *generate_ir_recursive(struct filter_parser_ctx *ctx,
- struct filter_node *node, enum ir_side side)
+static struct ir_op *
+generate_ir_recursive(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side)
{
switch (node->type) {
case NODE_UNKNOWN:
{
struct ir_op *op, *child;
- child = generate_ir_recursive(ctx, node->u.root.child,
- side);
+ child = generate_ir_recursive(ctx, node->u.root.child, side);
if (!child)
return NULL;
op = make_op_root(child, side);
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
+#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
-#include "filter-ast.hpp"
-#include "filter-parser.hpp"
-#include "filter-ir.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-static
-int check_bin_comparator(struct ir_op *node)
+static int check_bin_comparator(struct ir_op *node)
{
switch (node->op) {
case IR_OP_UNKNOWN:
{
int ret;
- if (node->u.binary.left->data_type == IR_DATA_STRING
- || node->u.binary.right->data_type
- == IR_DATA_STRING) {
- if (node->u.binary.type != AST_OP_EQ
- && node->u.binary.type != AST_OP_NE) {
- fprintf(stderr, "[error] Only '==' and '!=' comparators are allowed for strings\n");
+ if (node->u.binary.left->data_type == IR_DATA_STRING ||
+ node->u.binary.right->data_type == IR_DATA_STRING) {
+ if (node->u.binary.type != AST_OP_EQ && node->u.binary.type != AST_OP_NE) {
+ fprintf(stderr,
+ "[error] Only '==' and '!=' comparators are allowed for strings\n");
return -EINVAL;
}
}
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
#include "filter-ast.hpp"
-#include "filter-parser.hpp"
#include "filter-ir.hpp"
+#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
#include <common/macros.hpp>
-static
-int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
{
switch (node->op) {
case IR_OP_UNKNOWN:
return -EINVAL;
case IR_OP_ROOT:
- return check_bin_op_nesting_recursive(node->u.root.child,
- nesting);
+ return check_bin_op_nesting_recursive(node->u.root.child, nesting);
case IR_OP_LOAD:
return 0;
case IR_OP_UNARY:
- return check_bin_op_nesting_recursive(node->u.unary.child,
- nesting);
+ return check_bin_op_nesting_recursive(node->u.unary.child, nesting);
case IR_OP_BINARY:
{
int ret;
- ret = check_bin_op_nesting_recursive(node->u.binary.left,
- nesting + 1);
+ ret = check_bin_op_nesting_recursive(node->u.binary.left, nesting + 1);
if (ret)
return ret;
- return check_bin_op_nesting_recursive(node->u.binary.right,
- nesting + 1);
+ return check_bin_op_nesting_recursive(node->u.binary.right, nesting + 1);
}
case IR_OP_LOGICAL:
{
int ret;
- ret = check_bin_op_nesting_recursive(node->u.logical.left,
- nesting);
+ ret = check_bin_op_nesting_recursive(node->u.logical.left, nesting);
if (ret)
return ret;
- return check_bin_op_nesting_recursive(node->u.logical.right,
- nesting);
+ return check_bin_op_nesting_recursive(node->u.logical.right, nesting);
}
}
}
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
+#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
#include <common/macros.hpp>
#include <common/string-utils/string-utils.hpp>
-#include "filter-ast.hpp"
-#include "filter-parser.hpp"
-#include "filter-ir.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-static
-int normalize_glob_patterns(struct ir_op *node)
+static int normalize_glob_patterns(struct ir_op *node)
{
switch (node->op) {
case IR_OP_UNKNOWN:
case IR_OP_LOAD:
{
if (node->data_type == IR_DATA_STRING) {
- enum ir_load_string_type type =
- node->u.load.u.string.type;
+ enum ir_load_string_type type = node->u.load.u.string.type;
if (type == IR_LOAD_STRING_TYPE_GLOB_STAR_END ||
- type == IR_LOAD_STRING_TYPE_GLOB_STAR) {
+ type == IR_LOAD_STRING_TYPE_GLOB_STAR) {
LTTNG_ASSERT(node->u.load.u.string.value);
- strutils_normalize_star_glob_pattern(
- node->u.load.u.string.value);
+ strutils_normalize_star_glob_pattern(node->u.load.u.string.value);
}
}
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
+#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
#include <common/macros.hpp>
-#include "filter-ast.hpp"
-#include "filter-parser.hpp"
-#include "filter-ir.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-static
-int validate_globbing(struct ir_op *node)
+static int validate_globbing(struct ir_op *node)
{
int ret;
struct ir_op *right = node->u.binary.right;
if (left->op == IR_OP_LOAD && right->op == IR_OP_LOAD &&
- left->data_type == IR_DATA_STRING &&
- right->data_type == IR_DATA_STRING) {
+ left->data_type == IR_DATA_STRING && right->data_type == IR_DATA_STRING) {
/* Test 1. */
if (left->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR &&
- right->u.load.u.string.type != IR_LOAD_STRING_TYPE_PLAIN) {
+ right->u.load.u.string.type != IR_LOAD_STRING_TYPE_PLAIN) {
fprintf(stderr, "[error] Cannot compare two globbing patterns\n");
return -1;
}
if (right->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR &&
- left->u.load.u.string.type != IR_LOAD_STRING_TYPE_PLAIN) {
+ left->u.load.u.string.type != IR_LOAD_STRING_TYPE_PLAIN) {
fprintf(stderr, "[error] Cannot compare two globbing patterns\n");
return -1;
}
}
if ((left->op == IR_OP_LOAD && left->data_type == IR_DATA_STRING) ||
- (right->op == IR_OP_LOAD && right->data_type == IR_DATA_STRING)) {
- if ((left->op == IR_OP_LOAD && left->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR) ||
- (right->op == IR_OP_LOAD && right->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR)) {
+ (right->op == IR_OP_LOAD && right->data_type == IR_DATA_STRING)) {
+ if ((left->op == IR_OP_LOAD &&
+ left->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR) ||
+ (right->op == IR_OP_LOAD &&
+ right->u.load.u.string.type == IR_LOAD_STRING_TYPE_GLOB_STAR)) {
/* Test 2. */
if (node->u.binary.type != AST_OP_EQ &&
- node->u.binary.type != AST_OP_NE) {
- fprintf(stderr, "[error] Only the `==` and `!=` operators are allowed with a globbing pattern\n");
+ node->u.binary.type != AST_OP_NE) {
+ fprintf(stderr,
+ "[error] Only the `==` and `!=` operators are allowed with a globbing pattern\n");
return -1;
}
}
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
+#include "filter-ast.hpp"
+#include "filter-ir.hpp"
+#include "filter-parser.hpp"
-#include <common/macros.hpp>
#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
-#include "filter-ast.hpp"
-#include "filter-parser.hpp"
-#include "filter-ir.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
enum parse_char_result {
PARSE_CHAR_UNKNOWN = -2,
PARSE_CHAR_NORMAL = 0,
};
-static
-enum parse_char_result parse_char(const char **p)
+static enum parse_char_result parse_char(const char **p)
{
switch (**p) {
case '\\':
}
}
-static
-int validate_string(struct ir_op *node)
+static int validate_string(struct ir_op *node)
{
switch (node->op) {
case IR_OP_UNKNOWN:
switch (res) {
case PARSE_CHAR_UNKNOWN:
ret = -EINVAL;
- fprintf(stderr,
- "Unsupported escape character detected.\n");
+ fprintf(stderr, "Unsupported escape character detected.\n");
goto end_load;
case PARSE_CHAR_NORMAL:
default:
}
}
}
-end_load:
+ end_load:
return ret;
}
case IR_OP_UNARY:
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
#include "filter-ast.hpp"
#include "filter-parser.hpp"
#include <common/compat/errno.hpp>
#include <common/macros.hpp>
-#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args)
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-static
-int recursive_visit_print(struct filter_node *node, FILE *stream, int indent);
+#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ##args)
-static
-void print_tabs(FILE *fd, int depth)
+static int recursive_visit_print(struct filter_node *node, FILE *stream, int indent);
+
+static void print_tabs(FILE *fd, int depth)
{
int i;
fprintf(fd, "\t");
}
-static
-int recursive_visit_print_expression(struct filter_node *node,
- FILE *stream, int indent)
+static int recursive_visit_print_expression(struct filter_node *node, FILE *stream, int indent)
{
struct filter_node *iter_node;
return -EINVAL;
case AST_EXP_STRING:
print_tabs(stream, indent);
- fprintf(stream, "<string value=\"%s\"/>\n",
- node->u.expression.u.string);
+ fprintf(stream, "<string value=\"%s\"/>\n", node->u.expression.u.string);
break;
case AST_EXP_CONSTANT:
print_tabs(stream, indent);
- fprintf(stream, "<constant value=\"%" PRIu64 "\"/>\n",
+ fprintf(stream,
+ "<constant value=\"%" PRIu64 "\"/>\n",
node->u.expression.u.constant);
break;
case AST_EXP_FLOAT_CONSTANT:
print_tabs(stream, indent);
- fprintf(stream, "<float_constant value=\"%lg\"/>\n",
+ fprintf(stream,
+ "<float_constant value=\"%lg\"/>\n",
node->u.expression.u.float_constant);
break;
- case AST_EXP_IDENTIFIER: /* fall-through */
+ case AST_EXP_IDENTIFIER: /* fall-through */
case AST_EXP_GLOBAL_IDENTIFIER:
print_tabs(stream, indent);
- fprintf(stream, "<%s value=\"%s\"/>\n",
- node->u.expression.type == AST_EXP_IDENTIFIER ?
- "identifier" : "global_identifier",
+ fprintf(stream,
+ "<%s value=\"%s\"/>\n",
+ node->u.expression.type == AST_EXP_IDENTIFIER ? "identifier" :
+ "global_identifier",
node->u.expression.u.identifier);
iter_node = node->u.expression.next;
while (iter_node) {
print_tabs(stream, indent);
fprintf(stream, "<bracket>\n");
- if (recursive_visit_print_expression(iter_node,
- stream, indent + 1)) {
+ if (recursive_visit_print_expression(iter_node, stream, indent + 1)) {
return -EINVAL;
}
print_tabs(stream, indent);
fprintf(stream, "</bracket>\n");
iter_node = iter_node->u.expression.next;
-
}
break;
case AST_EXP_NESTED:
- return recursive_visit_print(node->u.expression.u.child,
- stream, indent + 1);
+ return recursive_visit_print(node->u.expression.u.child, stream, indent + 1);
}
return 0;
}
-
-static
-int recursive_visit_print(struct filter_node *node, FILE *stream, int indent)
+static int recursive_visit_print(struct filter_node *node, FILE *stream, int indent)
{
int ret;
case NODE_ROOT:
print_tabs(stream, indent);
fprintf(stream, "<root>\n");
- ret = recursive_visit_print(node->u.root.child, stream,
- indent + 1);
+ ret = recursive_visit_print(node->u.root.child, stream, indent + 1);
print_tabs(stream, indent);
fprintf(stream, "</root>\n");
return ret;
case NODE_EXPRESSION:
print_tabs(stream, indent);
fprintf(stream, "<expression>\n");
- ret = recursive_visit_print_expression(node, stream,
- indent + 1);
+ ret = recursive_visit_print_expression(node, stream, indent + 1);
print_tabs(stream, indent);
fprintf(stream, "</expression>\n");
return ret;
break;
}
fprintf(stream, ">\n");
- ret = recursive_visit_print(node->u.op.lchild,
- stream, indent + 1);
+ ret = recursive_visit_print(node->u.op.lchild, stream, indent + 1);
if (ret)
return ret;
- ret = recursive_visit_print(node->u.op.rchild,
- stream, indent + 1);
+ ret = recursive_visit_print(node->u.op.rchild, stream, indent + 1);
if (ret)
return ret;
print_tabs(stream, indent);
break;
}
fprintf(stream, ">\n");
- ret = recursive_visit_print(node->u.unary_op.child,
- stream, indent + 1);
+ ret = recursive_visit_print(node->u.unary_op.child, stream, indent + 1);
print_tabs(stream, indent);
fprintf(stream, "</unary_op>\n");
return ret;
return 0;
}
-int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream,
- int indent)
+int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream, int indent)
{
return recursive_visit_print(&ctx->ast->root, stream, indent);
}
*/
#define _LGPL_SOURCE
+#include "futex.hpp"
+
+#include <common/common.hpp>
+
#include <limits.h>
#include <unistd.h>
#include <urcu.h>
#include <urcu/futex.h>
-#include <common/common.hpp>
-
-#include "futex.hpp"
-
/*
* This futex wait/wake scheme only works for N wakers / 1 waiters. Hence the
* "nto1" added to all function signature.
{
if (active) {
uatomic_set(futex, 1);
- if (futex_async(futex, FUTEX_WAKE,
- INT_MAX, NULL, NULL, 0) < 0) {
+ if (futex_async(futex, FUTEX_WAKE, INT_MAX, NULL, NULL, 0) < 0) {
PERROR("futex_async");
abort();
}
goto end;
case EINTR:
/* Retry if interrupted by signal. */
- break; /* Get out of switch. Check again. */
+ break; /* Get out of switch. Check again. */
default:
/* Unexpected error. */
PERROR("futex_async");
*/
#define _LGPL_SOURCE
-#include <string.h>
-#include <urcu.h>
-#include <urcu/compiler.h>
+#include "hashtable.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/defaults.hpp>
-#include "hashtable.hpp"
-#include "utils.hpp"
+#include <string.h>
+#include <urcu.h>
+#include <urcu/compiler.h>
/* seed_lock protects both seed_init and lttng_ht_seed. */
static pthread_mutex_t seed_lock = PTHREAD_MUTEX_INITIALIZER;
return hash_match_key_two_u64((void *) &match_node->key, (void *) key);
}
-static inline
-const char *lttng_ht_type_str(enum lttng_ht_type type)
+static inline const char *lttng_ht_type_str(enum lttng_ht_type type)
{
switch (type) {
case LTTNG_HT_TYPE_STRING:
goto error;
}
- ht->ht = cds_lfht_new(size, min_hash_alloc_size, max_hash_buckets_size,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ ht->ht = cds_lfht_new(size,
+ min_hash_alloc_size,
+ max_hash_buckets_size,
+ CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING,
+ NULL);
/*
* There is already an assert in the RCU hashtable code so if the ht is
* NULL here there is a *huge* problem.
goto error;
}
- DBG3("Created hashtable size %lu at %p of type %s", size, ht->ht,
- lttng_ht_type_str(type));
+ DBG3("Created hashtable size %lu at %p of type %s", size, ht->ht, lttng_ht_type_str(type));
return ht;
/*
* Init lttng ht node unsigned long.
*/
-void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node,
- unsigned long key)
+void lttng_ht_node_init_ulong(struct lttng_ht_node_ulong *node, unsigned long key)
{
LTTNG_ASSERT(node);
/*
* Init lttng ht node uint64_t.
*/
-void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node,
- uint64_t key)
+void lttng_ht_node_init_u64(struct lttng_ht_node_u64 *node, uint64_t key)
{
LTTNG_ASSERT(node);
/*
* Init lttng ht node with two uint64_t.
*/
-void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node,
- uint64_t key1, uint64_t key2)
+void lttng_ht_node_init_two_u64(struct lttng_ht_node_two_u64 *node, uint64_t key1, uint64_t key2)
{
LTTNG_ASSERT(node);
/*
* Lookup function in hashtable.
*/
-void lttng_ht_lookup(struct lttng_ht *ht, const void *key,
- struct lttng_ht_iter *iter)
+void lttng_ht_lookup(struct lttng_ht *ht, const void *key, struct lttng_ht_iter *iter)
{
LTTNG_ASSERT(ht);
LTTNG_ASSERT(ht->ht);
- cds_lfht_lookup(ht->ht, ht->hash_fct(key, lttng_ht_seed),
- ht->match_fct, key, &iter->iter);
+ cds_lfht_lookup(ht->ht, ht->hash_fct(key, lttng_ht_seed), ht->match_fct, key, &iter->iter);
}
/*
* Add unique string node to hashtable.
*/
-void lttng_ht_add_unique_str(struct lttng_ht *ht,
- struct lttng_ht_node_str *node)
+void lttng_ht_add_unique_str(struct lttng_ht *ht, struct lttng_ht_node_str *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
- node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(node->key, lttng_ht_seed),
- ht->match_fct, node->key, &node->node);
+ node_ptr = cds_lfht_add_unique(ht->ht,
+ ht->hash_fct(node->key, lttng_ht_seed),
+ ht->match_fct,
+ node->key,
+ &node->node);
rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
/*
* Add string node to hashtable.
*/
-void lttng_ht_add_str(struct lttng_ht *ht,
- struct lttng_ht_node_str *node)
+void lttng_ht_add_str(struct lttng_ht *ht, struct lttng_ht_node_str *node)
{
LTTNG_ASSERT(ht);
LTTNG_ASSERT(ht->ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
- cds_lfht_add(ht->ht, ht->hash_fct(node->key, lttng_ht_seed),
- &node->node);
+ cds_lfht_add(ht->ht, ht->hash_fct(node->key, lttng_ht_seed), &node->node);
rcu_read_unlock();
}
/* RCU read lock protects from ABA. */
rcu_read_lock();
- cds_lfht_add(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed),
- &node->node);
+ cds_lfht_add(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed), &node->node);
rcu_read_unlock();
}
/* RCU read lock protects from ABA. */
rcu_read_lock();
- cds_lfht_add(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed),
- &node->node);
+ cds_lfht_add(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed), &node->node);
rcu_read_unlock();
}
/*
* Add unique unsigned long node to hashtable.
*/
-void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
- struct lttng_ht_node_ulong *node)
+void lttng_ht_add_unique_ulong(struct lttng_ht *ht, struct lttng_ht_node_ulong *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct,
- (void *) node->key, &node->node);
+ ht->hash_fct((void *) node->key, lttng_ht_seed),
+ ht->match_fct,
+ (void *) node->key,
+ &node->node);
rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
/*
* Add unique uint64_t node to hashtable.
*/
-void lttng_ht_add_unique_u64(struct lttng_ht *ht,
- struct lttng_ht_node_u64 *node)
+void lttng_ht_add_unique_u64(struct lttng_ht *ht, struct lttng_ht_node_u64 *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct,
- &node->key, &node->node);
+ ht->hash_fct(&node->key, lttng_ht_seed),
+ ht->match_fct,
+ &node->key,
+ &node->node);
rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
/*
* Add unique two uint64_t node to hashtable.
*/
-void lttng_ht_add_unique_two_u64(struct lttng_ht *ht,
- struct lttng_ht_node_two_u64 *node)
+void lttng_ht_add_unique_two_u64(struct lttng_ht *ht, struct lttng_ht_node_two_u64 *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
- ht->hash_fct((void *) &node->key, lttng_ht_seed), ht->match_fct,
- (void *) &node->key, &node->node);
+ ht->hash_fct((void *) &node->key, lttng_ht_seed),
+ ht->match_fct,
+ (void *) &node->key,
+ &node->node);
rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
* Add replace unsigned long node to hashtable.
*/
struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht,
- struct lttng_ht_node_ulong *node)
+ struct lttng_ht_node_ulong *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
node_ptr = cds_lfht_add_replace(ht->ht,
- ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct,
- (void *) node->key, &node->node);
+ ht->hash_fct((void *) node->key, lttng_ht_seed),
+ ht->match_fct,
+ (void *) node->key,
+ &node->node);
rcu_read_unlock();
if (!node_ptr) {
return NULL;
* Add replace unsigned long node to hashtable.
*/
struct lttng_ht_node_u64 *lttng_ht_add_replace_u64(struct lttng_ht *ht,
- struct lttng_ht_node_u64 *node)
+ struct lttng_ht_node_u64 *node)
{
struct cds_lfht_node *node_ptr;
LTTNG_ASSERT(ht);
/* RCU read lock protects from ABA. */
rcu_read_lock();
node_ptr = cds_lfht_add_replace(ht->ht,
- ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct,
- &node->key, &node->node);
+ ht->hash_fct(&node->key, lttng_ht_seed),
+ ht->match_fct,
+ &node->key,
+ &node->node);
rcu_read_unlock();
if (!node_ptr) {
return NULL;
/*
* Return lttng ht string node from iterator.
*/
-struct lttng_ht_node_str *lttng_ht_iter_get_node_str(
- struct lttng_ht_iter *iter)
+struct lttng_ht_node_str *lttng_ht_iter_get_node_str(struct lttng_ht_iter *iter)
{
struct cds_lfht_node *node;
/*
* Return lttng ht unsigned long node from iterator.
*/
-struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(
- struct lttng_ht_iter *iter)
+struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(struct lttng_ht_iter *iter)
{
struct cds_lfht_node *node;
/*
* Return lttng ht unsigned long node from iterator.
*/
-struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(
- struct lttng_ht_iter *iter)
+struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(struct lttng_ht_iter *iter)
{
struct cds_lfht_node *node;
/*
* Return lttng ht stream and index id node from iterator.
*/
-struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(
- struct lttng_ht_iter *iter)
+struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(struct lttng_ht_iter *iter)
{
struct cds_lfht_node *node;
*/
#define _LGPL_SOURCE
-#include <stdint.h> /* defines uint32_t etc */
-#include <stdio.h> /* defines printf for tests */
-#include <string.h>
-#include <sys/param.h> /* attempt to define endianness */
-#include <time.h> /* defines time_t for timings in the test */
-#include <urcu/compiler.h>
-
#include "utils.hpp"
-#include <common/compat/endian.hpp> /* attempt to define endianness */
+
#include <common/common.hpp>
+#include <common/compat/endian.hpp> /* attempt to define endianness */
#include <common/hashtable/hashtable.hpp>
+#include <stdint.h> /* defines uint32_t etc */
+#include <stdio.h> /* defines printf for tests */
+#include <string.h>
+#include <sys/param.h> /* attempt to define endianness */
+#include <time.h> /* defines time_t for timings in the test */
+#include <urcu/compiler.h>
+
/*
* My best guess at if you are big-endian or little-endian. This may
* need adjustment.
*/
-#if (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && \
- BYTE_ORDER == LITTLE_ENDIAN) || \
- (defined(i386) || defined(__i386__) || defined(__i486__) || \
- defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL))
-# define HASH_LITTLE_ENDIAN 1
-# define HASH_BIG_ENDIAN 0
-#elif (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && \
- BYTE_ORDER == BIG_ENDIAN) || \
- (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 1
+#if (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && BYTE_ORDER == LITTLE_ENDIAN) || \
+ (defined(i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || \
+ defined(__i686__) || defined(vax) || defined(MIPSEL))
+#define HASH_LITTLE_ENDIAN 1
+#define HASH_BIG_ENDIAN 0
+#elif (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
+ (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
+#define HASH_LITTLE_ENDIAN 0
+#define HASH_BIG_ENDIAN 1
#else
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 0
+#define HASH_LITTLE_ENDIAN 0
+#define HASH_BIG_ENDIAN 0
#endif
-#define hashsize(n) ((uint32_t)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+#define hashsize(n) ((uint32_t) 1 << (n))
+#define hashmask(n) (hashsize(n) - 1)
+#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
/*
* mix -- mix 3 32-bit values reversibly.
* on, and rotates are much kinder to the top and bottom bits, so I used
* rotates.
*/
-#define mix(a,b,c) \
-{ \
- a -= c; a ^= rot(c, 4); c += b; \
- b -= a; b ^= rot(a, 6); a += c; \
- c -= b; c ^= rot(b, 8); b += a; \
- a -= c; a ^= rot(c,16); c += b; \
- b -= a; b ^= rot(a,19); a += c; \
- c -= b; c ^= rot(b, 4); b += a; \
-}
+#define mix(a, b, c) \
+ { \
+ a -= c; \
+ a ^= rot(c, 4); \
+ c += b; \
+ b -= a; \
+ b ^= rot(a, 6); \
+ a += c; \
+ c -= b; \
+ c ^= rot(b, 8); \
+ b += a; \
+ a -= c; \
+ a ^= rot(c, 16); \
+ c += b; \
+ b -= a; \
+ b ^= rot(a, 19); \
+ a += c; \
+ c -= b; \
+ c ^= rot(b, 4); \
+ b += a; \
+ }
/*
* final -- final mixing of 3 32-bit values (a,b,c) into c
* 10 8 15 26 3 22 24
* 11 8 15 26 3 22 24
*/
-#define final(a,b,c) \
-{ \
- c ^= b; c -= rot(b,14); \
- a ^= c; a -= rot(c,11); \
- b ^= a; b -= rot(a,25); \
- c ^= b; c -= rot(b,16); \
- a ^= c; a -= rot(c,4); \
- b ^= a; b -= rot(a,14); \
- c ^= b; c -= rot(b,24); \
-}
+#define final(a, b, c) \
+ { \
+ c ^= b; \
+ c -= rot(b, 14); \
+ a ^= c; \
+ a -= rot(c, 11); \
+ b ^= a; \
+ b -= rot(a, 25); \
+ c ^= b; \
+ c -= rot(b, 16); \
+ a ^= c; \
+ a -= rot(c, 4); \
+ b ^= a; \
+ b -= rot(a, 14); \
+ c ^= b; \
+ c -= rot(b, 24); \
+ }
/*
* k - the key, an array of uint32_t values
* length - the length of the key, in uint32_ts
* initval - the previous hash, or an arbitrary value
*/
-static uint32_t __attribute__((unused)) hashword(const uint32_t *k,
- size_t length, uint32_t initval)
+static uint32_t __attribute__((unused)) hashword(const uint32_t *k, size_t length, uint32_t initval)
{
uint32_t a, b, c;
}
/*----------------------------------- handle the last 3 uint32_t's */
- switch (length) { /* all the case statements fall through */
- case 3: c += k[2]; /* fall through */
- case 2: b += k[1]; /* fall through */
- case 1: a += k[0];
+ switch (length) { /* all the case statements fall through */
+ case 3:
+ c += k[2]; /* fall through */
+ case 2:
+ b += k[1]; /* fall through */
+ case 1:
+ a += k[0];
final(a, b, c);
- case 0: /* case 0: nothing left to add */
+ case 0: /* case 0: nothing left to add */
break;
}
/*---------------------------------------------- report the result */
return c;
}
-
/*
* hashword2() -- same as hashword(), but take two seeds and return two 32-bit
* values. pc and pb must both be nonnull, and *pc and *pb must both be
* initialized with seeds. If you pass in (*pb)==0, the output (*pc) will be
* the same as the return value from hashword().
*/
-static void __attribute__((unused)) hashword2(const uint32_t *k, size_t length,
- uint32_t *pc, uint32_t *pb)
+static void __attribute__((unused))
+hashword2(const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb)
{
uint32_t a, b, c;
}
switch (length) {
- case 3 :
+ case 3:
c += k[2];
/* fall through */
- case 2 :
+ case 2:
b += k[1];
/* fall through */
- case 1 :
+ case 1:
a += k[0];
final(a, b, c);
/* fall through */
- case 0: /* case 0: nothing left to add */
+ case 0: /* case 0: nothing left to add */
break;
}
* acceptable. Do NOT use for cryptographic purposes.
*/
LTTNG_NO_SANITIZE_ADDRESS
-__attribute__((unused))
-static uint32_t hashlittle(const void *key,
- size_t length, uint32_t initval)
+__attribute__((unused)) static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
{
- uint32_t a,b,c;
+ uint32_t a, b, c;
union {
const void *ptr;
size_t i;
- } u; /* needed for Mac Powerbook G4 */
+ } u; /* needed for Mac Powerbook G4 */
/* Set up the internal state */
- a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
+ a = b = c = 0xdeadbeef + ((uint32_t) length) + initval;
u.ptr = key;
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
- const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
+ const uint32_t *k = (const uint32_t *) key; /* read 32-bit chunks */
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
while (length > 12) {
a += k[0];
b += k[1];
c += k[2];
- mix(a,b,c);
+ mix(a, b, c);
length -= 12;
k += 3;
}
#ifndef VALGRIND
switch (length) {
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
- case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
- case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
- case 6 : b+=k[1]&0xffff; a+=k[0]; break;
- case 5 : b+=k[1]&0xff; a+=k[0]; break;
- case 4 : a+=k[0]; break;
- case 3 : a+=k[0]&0xffffff; break;
- case 2 : a+=k[0]&0xffff; break;
- case 1 : a+=k[0]&0xff; break;
- case 0 : return c; /* zero length strings require no mixing */
+ case 12:
+ c += k[2];
+ b += k[1];
+ a += k[0];
+ break;
+ case 11:
+ c += k[2] & 0xffffff;
+ b += k[1];
+ a += k[0];
+ break;
+ case 10:
+ c += k[2] & 0xffff;
+ b += k[1];
+ a += k[0];
+ break;
+ case 9:
+ c += k[2] & 0xff;
+ b += k[1];
+ a += k[0];
+ break;
+ case 8:
+ b += k[1];
+ a += k[0];
+ break;
+ case 7:
+ b += k[1] & 0xffffff;
+ a += k[0];
+ break;
+ case 6:
+ b += k[1] & 0xffff;
+ a += k[0];
+ break;
+ case 5:
+ b += k[1] & 0xff;
+ a += k[0];
+ break;
+ case 4:
+ a += k[0];
+ break;
+ case 3:
+ a += k[0] & 0xffffff;
+ break;
+ case 2:
+ a += k[0] & 0xffff;
+ break;
+ case 1:
+ a += k[0] & 0xff;
+ break;
+ case 0:
+ return c; /* zero length strings require no mixing */
}
#else /* make valgrind happy */
const uint8_t *k8;
- k8 = (const uint8_t *)k;
+ k8 = (const uint8_t *) k;
switch (length) {
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
- case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
- case 9 : c+=k8[8]; /* fall through */
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
- case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
- case 5 : b+=k8[4]; /* fall through */
- case 4 : a+=k[0]; break;
- case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
- case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
- case 1 : a+=k8[0]; break;
- case 0 : return c;
+ case 12:
+ c += k[2];
+ b += k[1];
+ a += k[0];
+ break;
+ case 11:
+ c += ((uint32_t) k8[10]) << 16; /* fall through */
+ case 10:
+ c += ((uint32_t) k8[9]) << 8; /* fall through */
+ case 9:
+ c += k8[8]; /* fall through */
+ case 8:
+ b += k[1];
+ a += k[0];
+ break;
+ case 7:
+ b += ((uint32_t) k8[6]) << 16; /* fall through */
+ case 6:
+ b += ((uint32_t) k8[5]) << 8; /* fall through */
+ case 5:
+ b += k8[4]; /* fall through */
+ case 4:
+ a += k[0];
+ break;
+ case 3:
+ a += ((uint32_t) k8[2]) << 16; /* fall through */
+ case 2:
+ a += ((uint32_t) k8[1]) << 8; /* fall through */
+ case 1:
+ a += k8[0];
+ break;
+ case 0:
+ return c;
}
#endif /* !valgrind */
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
- const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
+ const uint16_t *k = (const uint16_t *) key; /* read 16-bit chunks */
const uint8_t *k8;
/*--------------- all but last block: aligned reads and different mixing */
while (length > 12) {
- a += k[0] + (((uint32_t)k[1])<<16);
- b += k[2] + (((uint32_t)k[3])<<16);
- c += k[4] + (((uint32_t)k[5])<<16);
- mix(a,b,c);
+ a += k[0] + (((uint32_t) k[1]) << 16);
+ b += k[2] + (((uint32_t) k[3]) << 16);
+ c += k[4] + (((uint32_t) k[5]) << 16);
+ mix(a, b, c);
length -= 12;
k += 6;
}
- k8 = (const uint8_t *)k;
+ k8 = (const uint8_t *) k;
switch (length) {
case 12:
- c+=k[4]+(((uint32_t)k[5])<<16);
- b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
+ c += k[4] + (((uint32_t) k[5]) << 16);
+ b += k[2] + (((uint32_t) k[3]) << 16);
+ a += k[0] + (((uint32_t) k[1]) << 16);
break;
case 11:
- c+=((uint32_t)k8[10])<<16; /* fall through */
+ c += ((uint32_t) k8[10]) << 16; /* fall through */
case 10:
- c+=k[4];
- b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
+ c += k[4];
+ b += k[2] + (((uint32_t) k[3]) << 16);
+ a += k[0] + (((uint32_t) k[1]) << 16);
break;
case 9:
- c+=k8[8]; /* fall through */
+ c += k8[8]; /* fall through */
case 8:
- b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
+ b += k[2] + (((uint32_t) k[3]) << 16);
+ a += k[0] + (((uint32_t) k[1]) << 16);
break;
case 7:
- b+=((uint32_t)k8[6])<<16; /* fall through */
+ b += ((uint32_t) k8[6]) << 16; /* fall through */
case 6:
- b+=k[2];
- a+=k[0]+(((uint32_t)k[1])<<16);
+ b += k[2];
+ a += k[0] + (((uint32_t) k[1]) << 16);
break;
case 5:
- b+=k8[4]; /* fall through */
+ b += k8[4]; /* fall through */
case 4:
- a+=k[0]+(((uint32_t)k[1])<<16);
+ a += k[0] + (((uint32_t) k[1]) << 16);
break;
case 3:
- a+=((uint32_t)k8[2])<<16; /* fall through */
+ a += ((uint32_t) k8[2]) << 16; /* fall through */
case 2:
- a+=k[0];
+ a += k[0];
break;
case 1:
- a+=k8[0];
+ a += k8[0];
break;
case 0:
- return c; /* zero length requires no mixing */
+ return c; /* zero length requires no mixing */
}
- } else { /* need to read the key one byte at a time */
- const uint8_t *k = (const uint8_t *)key;
+ } else { /* need to read the key one byte at a time */
+ const uint8_t *k = (const uint8_t *) key;
while (length > 12) {
a += k[0];
- a += ((uint32_t)k[1])<<8;
- a += ((uint32_t)k[2])<<16;
- a += ((uint32_t)k[3])<<24;
+ a += ((uint32_t) k[1]) << 8;
+ a += ((uint32_t) k[2]) << 16;
+ a += ((uint32_t) k[3]) << 24;
b += k[4];
- b += ((uint32_t)k[5])<<8;
- b += ((uint32_t)k[6])<<16;
- b += ((uint32_t)k[7])<<24;
+ b += ((uint32_t) k[5]) << 8;
+ b += ((uint32_t) k[6]) << 16;
+ b += ((uint32_t) k[7]) << 24;
c += k[8];
- c += ((uint32_t)k[9])<<8;
- c += ((uint32_t)k[10])<<16;
- c += ((uint32_t)k[11])<<24;
- mix(a,b,c);
+ c += ((uint32_t) k[9]) << 8;
+ c += ((uint32_t) k[10]) << 16;
+ c += ((uint32_t) k[11]) << 24;
+ mix(a, b, c);
length -= 12;
k += 12;
}
- switch(length) { /* all the case statements fall through */
- case 12: c+=((uint32_t)k[11])<<24; /* fall through */
- case 11: c+=((uint32_t)k[10])<<16; /* fall through */
- case 10: c+=((uint32_t)k[9])<<8; /* fall through */
- case 9: c+=k[8]; /* fall through */
- case 8: b+=((uint32_t)k[7])<<24; /* fall through */
- case 7: b+=((uint32_t)k[6])<<16; /* fall through */
- case 6: b+=((uint32_t)k[5])<<8; /* fall through */
- case 5: b+=k[4]; /* fall through */
- case 4: a+=((uint32_t)k[3])<<24; /* fall through */
- case 3: a+=((uint32_t)k[2])<<16; /* fall through */
- case 2: a+=((uint32_t)k[1])<<8; /* fall through */
+ switch (length) { /* all the case statements fall through */
+ case 12:
+ c += ((uint32_t) k[11]) << 24; /* fall through */
+ case 11:
+ c += ((uint32_t) k[10]) << 16; /* fall through */
+ case 10:
+ c += ((uint32_t) k[9]) << 8; /* fall through */
+ case 9:
+ c += k[8]; /* fall through */
+ case 8:
+ b += ((uint32_t) k[7]) << 24; /* fall through */
+ case 7:
+ b += ((uint32_t) k[6]) << 16; /* fall through */
+ case 6:
+ b += ((uint32_t) k[5]) << 8; /* fall through */
+ case 5:
+ b += k[4]; /* fall through */
+ case 4:
+ a += ((uint32_t) k[3]) << 24; /* fall through */
+ case 3:
+ a += ((uint32_t) k[2]) << 16; /* fall through */
+ case 2:
+ a += ((uint32_t) k[1]) << 8; /* fall through */
case 1:
- a+=k[0];
+ a += k[0];
break;
case 0:
return c;
}
}
- final(a,b,c);
+ final(a, b, c);
return c;
}
*/
unsigned long hash_key_two_u64(const void *key, unsigned long seed)
{
- const struct lttng_ht_two_u64 *k =
- (const struct lttng_ht_two_u64 *) key;
+ const struct lttng_ht_two_u64 *k = (const struct lttng_ht_two_u64 *) key;
return hash_key_u64(&k->key1, seed) ^ hash_key_u64(&k->key2, seed);
}
*/
int hash_match_key_two_u64(const void *key1, const void *key2)
{
- const struct lttng_ht_two_u64 *k1 =
- (const struct lttng_ht_two_u64 *) key1;
- const struct lttng_ht_two_u64 *k2 =
- (const struct lttng_ht_two_u64 *) key2;
+ const struct lttng_ht_two_u64 *k1 = (const struct lttng_ht_two_u64 *) key1;
+ const struct lttng_ht_two_u64 *k2 = (const struct lttng_ht_two_u64 *) key2;
- if (hash_match_key_u64(&k1->key1, &k2->key1) &&
- hash_match_key_u64(&k1->key2, &k2->key2)) {
+ if (hash_match_key_u64(&k1->key1, &k2->key1) && hash_match_key_u64(&k1->key2, &k2->key2)) {
return 1;
}
*/
#define _LGPL_SOURCE
-#include <algorithm>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <lttng/health-internal.hpp>
+#include <algorithm>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
/*
* An application-specific error state for unregistered thread keeps
* track of thread errors. A thread reporting a health error, normally
/*
* Initialize health check subsytem.
*/
-static
-void health_init(struct health_app *ha)
+static void health_init(struct health_app *ha)
{
/*
* Get the maximum value between the default delta value and the TCP
* timeout with a safety net of the default health check delta.
*/
ha->time_delta.tv_sec = std::max<unsigned long>(
- lttcomm_inet_tcp_timeout + DEFAULT_HEALTH_CHECK_DELTA_S,
- ha->time_delta.tv_sec);
- DBG("Health check time delta in seconds set to %lu",
- ha->time_delta.tv_sec);
+ lttcomm_inet_tcp_timeout + DEFAULT_HEALTH_CHECK_DELTA_S, ha->time_delta.tv_sec);
+ DBG("Health check time delta in seconds set to %lu", ha->time_delta.tv_sec);
}
struct health_app *health_app_create(int nr_types)
/*
* Set time difference in res from time_a and time_b.
*/
-static void time_diff(const struct timespec *time_a,
- const struct timespec *time_b, struct timespec *res)
+static void
+time_diff(const struct timespec *time_a, const struct timespec *time_b, struct timespec *res)
{
if (time_a->tv_nsec - time_b->tv_nsec < 0) {
res->tv_sec = time_a->tv_sec - time_b->tv_sec - 1;
* Return true if time_a - time_b > diff, else false.
*/
static int time_diff_gt(const struct timespec *time_a,
- const struct timespec *time_b, const struct timespec *diff)
+ const struct timespec *time_b,
+ const struct timespec *diff)
{
struct timespec res;
state->last = current;
memcpy(&state->last_time, ¤t_time, sizeof(current_time));
} else {
- if (time_diff_gt(¤t_time, &state->last_time,
- &ha->time_delta)) {
+ if (time_diff_gt(¤t_time, &state->last_time, &ha->time_delta)) {
if (current == last && !HEALTH_IS_IN_POLL(current)) {
/* error */
retval = 0;
}
end:
- DBG("Health state current %lu, last %lu, ret %d",
- current, last, ret);
+ DBG("Health state current %lu, last %lu, ret %d", current, last, ret);
return retval;
}
state_lock(ha);
- cds_list_for_each_entry(state, &ha->list, node) {
+ cds_list_for_each_entry (state, &ha->list, node) {
int ret;
if (state->type != type) {
end:
state_unlock(ha);
- DBG("Health check for type %d is %s", (int) type,
- (retval == 0) ? "BAD" : "GOOD");
+ DBG("Health check for type %d is %s", (int) type, (retval == 0) ? "BAD" : "GOOD");
return retval;
}
* the node from the global list.
*/
if (uatomic_read(&URCU_TLS(health_state).flags) & HEALTH_ERROR) {
- uatomic_set(&ha->flags[URCU_TLS(health_state).type],
- HEALTH_ERROR);
+ uatomic_set(&ha->flags[URCU_TLS(health_state).type], HEALTH_ERROR);
}
cds_list_del(&URCU_TLS(health_state).node);
state_unlock(ha);
*
*/
-#include <inttypes.h>
+#include "error.hpp"
+#include "index-allocator.hpp"
+#include "macros.hpp"
+#include <inttypes.h>
#include <urcu.h>
#include <urcu/list.h>
-#include "macros.hpp"
-#include "error.hpp"
-
-#include "index-allocator.hpp"
-
struct lttng_index_allocator {
struct cds_list_head unused_list;
uint64_t size;
};
} /* namespace */
-struct lttng_index_allocator *lttng_index_allocator_create(
- uint64_t index_count)
+struct lttng_index_allocator *lttng_index_allocator_create(uint64_t index_count)
{
struct lttng_index_allocator *allocator = NULL;
return allocator->nb_allocated_indexes;
}
-enum lttng_index_allocator_status lttng_index_allocator_alloc(
- struct lttng_index_allocator *allocator,
- uint64_t *allocated_index)
+enum lttng_index_allocator_status
+lttng_index_allocator_alloc(struct lttng_index_allocator *allocator, uint64_t *allocated_index)
{
- enum lttng_index_allocator_status status =
- LTTNG_INDEX_ALLOCATOR_STATUS_OK;
+ enum lttng_index_allocator_status status = LTTNG_INDEX_ALLOCATOR_STATUS_OK;
if (cds_list_empty(&allocator->unused_list)) {
if (allocator->position >= allocator->size) {
} else {
struct lttng_index *index;
- index = cds_list_first_entry(&allocator->unused_list,
- typeof(*index), head);
+ index = cds_list_first_entry(&allocator->unused_list, typeof(*index), head);
cds_list_del(&index->head);
*allocated_index = index->index;
free(index);
return status;
}
-enum lttng_index_allocator_status lttng_index_allocator_release(
- struct lttng_index_allocator *allocator, uint64_t idx)
+enum lttng_index_allocator_status
+lttng_index_allocator_release(struct lttng_index_allocator *allocator, uint64_t idx)
{
struct lttng_index *index = NULL;
- enum lttng_index_allocator_status status =
- LTTNG_INDEX_ALLOCATOR_STATUS_OK;
+ enum lttng_index_allocator_status status = LTTNG_INDEX_ALLOCATOR_STATUS_OK;
LTTNG_ASSERT(idx < allocator->size);
}
if (lttng_index_allocator_get_index_count(allocator) > 0) {
- WARN("Destroying index allocator with %" PRIu64
- " slot indexes still in use",
- lttng_index_allocator_get_index_count(allocator));
+ WARN("Destroying index allocator with %" PRIu64 " slot indexes still in use",
+ lttng_index_allocator_get_index_count(allocator));
}
- cds_list_for_each_entry_safe(index, tmp_index,
- &allocator->unused_list, head) {
+ cds_list_for_each_entry_safe (index, tmp_index, &allocator->unused_list, head) {
cds_list_del(&index->head);
free(index);
}
*/
#define _LGPL_SOURCE
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
+#include "index.hpp"
-#include <lttng/constant.h>
#include <common/common.hpp>
-#include <common/defaults.hpp>
#include <common/compat/endian.hpp>
+#include <common/defaults.hpp>
#include <common/utils.hpp>
-#include "index.hpp"
+#include <lttng/constant.h>
-#define WRITE_FILE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC)
-#define READ_ONLY_FILE_FLAGS O_RDONLY
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define WRITE_FILE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC)
+#define READ_ONLY_FILE_FLAGS O_RDONLY
-static enum lttng_trace_chunk_status _lttng_index_file_create_from_trace_chunk(
- struct lttng_trace_chunk *chunk,
- const char *channel_path, const char *stream_name,
- uint64_t stream_file_size, uint64_t stream_file_index,
- uint32_t index_major, uint32_t index_minor,
- bool unlink_existing_file,
- int flags, bool expect_no_file, struct lttng_index_file **file)
+static enum lttng_trace_chunk_status
+_lttng_index_file_create_from_trace_chunk(struct lttng_trace_chunk *chunk,
+ const char *channel_path,
+ const char *stream_name,
+ uint64_t stream_file_size,
+ uint64_t stream_file_index,
+ uint32_t index_major,
+ uint32_t index_minor,
+ bool unlink_existing_file,
+ int flags,
+ bool expect_no_file,
+ struct lttng_index_file **file)
{
struct lttng_index_file *index_file;
enum lttng_trace_chunk_status chunk_status;
} else {
separator = "/";
}
- ret = snprintf(index_directory_path, sizeof(index_directory_path),
- "%s%s" DEFAULT_INDEX_DIR, channel_path, separator);
+ ret = snprintf(index_directory_path,
+ sizeof(index_directory_path),
+ "%s%s" DEFAULT_INDEX_DIR,
+ channel_path,
+ separator);
if (ret < 0 || ret >= sizeof(index_directory_path)) {
ERR("Failed to format index directory path");
chunk_status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto error;
}
- ret = utils_stream_file_path(index_directory_path, stream_name,
- stream_file_size, stream_file_index,
- DEFAULT_INDEX_FILE_SUFFIX,
- index_file_path, sizeof(index_file_path));
+ ret = utils_stream_file_path(index_directory_path,
+ stream_name,
+ stream_file_size,
+ stream_file_index,
+ DEFAULT_INDEX_FILE_SUFFIX,
+ index_file_path,
+ sizeof(index_file_path));
if (ret) {
chunk_status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto error;
* same name afterwards.
*/
chunk_status = (lttng_trace_chunk_status) lttng_trace_chunk_unlink_file(
- chunk, index_file_path);
+ chunk, index_file_path);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK &&
- !(chunk_status == LTTNG_TRACE_CHUNK_STATUS_ERROR &&
- errno == ENOENT)) {
+ !(chunk_status == LTTNG_TRACE_CHUNK_STATUS_ERROR && errno == ENOENT)) {
goto error;
}
}
- chunk_status = lttng_trace_chunk_open_fs_handle(chunk, index_file_path,
- flags, mode, &fs_handle, expect_no_file);
+ chunk_status = lttng_trace_chunk_open_fs_handle(
+ chunk, index_file_path, flags, mode, &fs_handle, expect_no_file);
if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
goto error;
}
}
if (index_major != be32toh(hdr.index_major)) {
ERR("Index major number mismatch: %u, expect %u",
- be32toh(hdr.index_major), index_major);
+ be32toh(hdr.index_major),
+ index_major);
chunk_status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto error;
}
if (index_minor != be32toh(hdr.index_minor)) {
ERR("Index minor number mismatch: %u, expect %u",
- be32toh(hdr.index_minor), index_minor);
+ be32toh(hdr.index_minor),
+ index_minor);
chunk_status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto error;
}
return chunk_status;
}
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
- struct lttng_trace_chunk *chunk,
- const char *channel_path, const char *stream_name,
- uint64_t stream_file_size, uint64_t stream_file_index,
- uint32_t index_major, uint32_t index_minor,
- bool unlink_existing_file, struct lttng_index_file **file)
+enum lttng_trace_chunk_status
+lttng_index_file_create_from_trace_chunk(struct lttng_trace_chunk *chunk,
+ const char *channel_path,
+ const char *stream_name,
+ uint64_t stream_file_size,
+ uint64_t stream_file_index,
+ uint32_t index_major,
+ uint32_t index_minor,
+ bool unlink_existing_file,
+ struct lttng_index_file **file)
{
- return _lttng_index_file_create_from_trace_chunk(chunk, channel_path,
- stream_name, stream_file_size, stream_file_index,
- index_major, index_minor, unlink_existing_file,
- WRITE_FILE_FLAGS, false, file);
+ return _lttng_index_file_create_from_trace_chunk(chunk,
+ channel_path,
+ stream_name,
+ stream_file_size,
+ stream_file_index,
+ index_major,
+ index_minor,
+ unlink_existing_file,
+ WRITE_FILE_FLAGS,
+ false,
+ file);
}
-enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
- struct lttng_trace_chunk *chunk,
- const char *channel_path, const char *stream_name,
- uint64_t stream_file_size, uint64_t stream_file_index,
- uint32_t index_major, uint32_t index_minor,
- bool expect_no_file, struct lttng_index_file **file)
+enum lttng_trace_chunk_status
+lttng_index_file_create_from_trace_chunk_read_only(struct lttng_trace_chunk *chunk,
+ const char *channel_path,
+ const char *stream_name,
+ uint64_t stream_file_size,
+ uint64_t stream_file_index,
+ uint32_t index_major,
+ uint32_t index_minor,
+ bool expect_no_file,
+ struct lttng_index_file **file)
{
- return _lttng_index_file_create_from_trace_chunk(chunk, channel_path,
- stream_name, stream_file_size, stream_file_index,
- index_major, index_minor, false,
- READ_ONLY_FILE_FLAGS, expect_no_file, file);
+ return _lttng_index_file_create_from_trace_chunk(chunk,
+ channel_path,
+ stream_name,
+ stream_file_size,
+ stream_file_index,
+ index_major,
+ index_minor,
+ false,
+ READ_ONLY_FILE_FLAGS,
+ expect_no_file,
+ file);
}
/*
* Return 0 on success, -1 on error.
*/
int lttng_index_file_write(const struct lttng_index_file *index_file,
- const struct ctf_packet_index *element)
+ const struct ctf_packet_index *element)
{
ssize_t ret;
- const size_t len = index_file->element_len;;
+ const size_t len = index_file->element_len;
+ ;
LTTNG_ASSERT(index_file);
LTTNG_ASSERT(element);
* Return 0 on success, -1 on error.
*/
int lttng_index_file_read(const struct lttng_index_file *index_file,
- struct ctf_packet_index *element)
+ struct ctf_packet_index *element)
{
ssize_t ret;
const size_t len = index_file->element_len;
static void lttng_index_file_release(struct urcu_ref *ref)
{
- struct lttng_index_file *index_file = caa_container_of(ref,
- struct lttng_index_file, ref);
+ struct lttng_index_file *index_file = caa_container_of(ref, struct lttng_index_file, ref);
if (fs_handle_close(index_file->file)) {
PERROR("close index fd");
#include <common/ini-config/ini.hpp>
#include <common/macros.hpp>
#include <common/utils.hpp>
+
#include <ctype.h>
LTTNG_EXPORT const char *config_str_yes = "yes";
namespace {
struct handler_filter_args {
- const char* section;
+ const char *section;
config_entry_handler_cb handler;
void *user_data;
};
} /* namespace */
static int config_entry_handler_filter(struct handler_filter_args *args,
- const char *section, const char *name, const char *value)
+ const char *section,
+ const char *name,
+ const char *value)
{
int ret = 0;
struct config_entry entry = { section, name, value };
return ret;
}
-int config_get_section_entries(const char *override_path, const char *section,
- config_entry_handler_cb handler, void *user_data)
+int config_get_section_entries(const char *override_path,
+ const char *section,
+ config_entry_handler_cb handler,
+ void *user_data)
{
int ret = 0;
const char *path;
* continue and try the next possible conf. file.
*/
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
}
if (path) {
char fullpath[PATH_MAX];
- ret = snprintf(fullpath, sizeof(fullpath),
- DEFAULT_DAEMON_HOME_CONFIGPATH, path);
+ ret = snprintf(fullpath, sizeof(fullpath), DEFAULT_DAEMON_HOME_CONFIGPATH, path);
if (ret < 0) {
PERROR("snprintf user conf. path");
goto error;
* continue and try the next possible conf. file.
*/
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
}
}
if (config_file) {
DBG("Loading daemon command line conf file at %s", override_path);
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
} else {
- ERR("Failed to open daemon configuration file at %s",
- override_path);
+ ERR("Failed to open daemon configuration file at %s", override_path);
ret = -ENOENT;
goto error;
}
lower_str[i] = tolower(value[i]);
}
- if (!strcmp(lower_str, config_str_yes) ||
- !strcmp(lower_str, config_str_true) ||
- !strcmp(lower_str, config_str_on)) {
+ if (!strcmp(lower_str, config_str_yes) || !strcmp(lower_str, config_str_true) ||
+ !strcmp(lower_str, config_str_on)) {
ret = 1;
- } else if (!strcmp(lower_str, config_str_no) ||
- !strcmp(lower_str, config_str_false) ||
- !strcmp(lower_str, config_str_off)) {
+ } else if (!strcmp(lower_str, config_str_no) || !strcmp(lower_str, config_str_false) ||
+ !strcmp(lower_str, config_str_off)) {
ret = 0;
} else {
ret = -1;
* http://code.google.com/p/inih/
*/
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
+#include "ini.hpp"
+
#include <common/common.hpp>
-#include "ini.hpp"
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
#if !INI_USE_STACK
#include <stdlib.h>
#endif
#define MAX_SECTION 50
-#define MAX_NAME 50
+#define MAX_NAME 50
/* Strip whitespace chars off end of given string, in place. Return s. */
-static char* rstrip(char* s)
+static char *rstrip(char *s)
{
- char* p = s + strlen(s);
+ char *p = s + strlen(s);
- while (p > s && isspace((unsigned char)(*--p)))
+ while (p > s && isspace((unsigned char) (*--p)))
*p = '\0';
return s;
}
/* Return pointer to first non-whitespace char in given string. */
-static char* lskip(const char* s)
+static char *lskip(const char *s)
{
- while (*s && isspace((unsigned char)(*s)))
+ while (*s && isspace((unsigned char) (*s)))
s++;
- return (char*)s;
+ return (char *) s;
}
/*
* null at end of string if neither found. ';' must be prefixed by a whitespace
* character to register as a comment.
*/
-static char* find_char_or_comment(const char* s, char c)
+static char *find_char_or_comment(const char *s, char c)
{
int was_whitespace = 0;
while (*s && *s != c && !(was_whitespace && *s == ';')) {
- was_whitespace = isspace((unsigned char)(*s));
+ was_whitespace = isspace((unsigned char) (*s));
s++;
}
- return (char*)s;
+ return (char *) s;
}
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
-static char* strncpy0(char* dest, const char* src, size_t size)
+static char *strncpy0(char *dest, const char *src, size_t size)
{
strncpy(dest, src, size - 1);
dest[size - 1] = '\0';
}
/* See documentation in header file. */
-int ini_parse_file(FILE* file, ini_entry_handler handler, void* user)
+int ini_parse_file(FILE *file, ini_entry_handler handler, void *user)
{
/* Uses a fair bit of stack (use heap instead if you need to) */
#if INI_USE_STACK
char line[INI_MAX_LINE];
#else
- char* line;
+ char *line;
#endif
char section[MAX_SECTION] = "";
char prev_name[MAX_NAME] = "";
- char* start;
- char* end;
- char* name;
- char* value;
+ char *start;
+ char *end;
+ char *name;
+ char *value;
int lineno = 0;
int error = 0;
start = line;
#if INI_ALLOW_BOM
- if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
- (unsigned char)start[1] == 0xBB &&
- (unsigned char)start[2] == 0xBF) {
+ if (lineno == 1 && (unsigned char) start[0] == 0xEF &&
+ (unsigned char) start[1] == 0xBB && (unsigned char) start[2] == 0xBF) {
start += 3;
}
#endif
* continuation of previous name's value
* (as per Python ConfigParser).
*/
- if (handler(user, section, prev_name, start) < 0 &&
- !error) {
+ if (handler(user, section, prev_name, start) < 0 && !error) {
error = lineno;
}
}
*end = '\0';
strncpy0(section, start + 1, sizeof(section));
*prev_name = '\0';
- }
- else if (!error) {
+ } else if (!error) {
/* No ']' found on section line */
error = lineno;
}
- }
- else if (*start && *start != ';') {
+ } else if (*start && *start != ';') {
/* Not a comment, must be a name[=:]value pair */
end = find_char_or_comment(start, '=');
if (*end != '=') {
* handler
*/
strncpy0(prev_name, name, sizeof(prev_name));
- if (handler(user, section, name, value) < 0 &&
- !error) {
+ if (handler(user, section, name, value) < 0 && !error) {
error = lineno;
}
- }
- else if (!error) {
+ } else if (!error) {
/* No '=' or ':' found on name[=:]value line */
error = lineno;
}
}
/* See documentation in header file. */
-int ini_parse(const char* filename, ini_entry_handler handler, void* user)
+int ini_parse(const char *filename, ini_entry_handler handler, void *user)
{
- FILE* file;
+ FILE *file;
int error;
file = fopen(filename, "r");
*/
#define _LGPL_SOURCE
-#include <poll.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <stdint.h>
+#include "kernel-consumer.hpp"
-#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <common/buffer-view.hpp>
#include <common/common.hpp>
-#include <common/kernel-ctl/kernel-ctl.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/sessiond-comm/relayd.hpp>
-#include <common/compat/fcntl.hpp>
#include <common/compat/endian.hpp>
-#include <common/pipe.hpp>
-#include <common/relayd/relayd.hpp>
-#include <common/utils.hpp>
+#include <common/compat/fcntl.hpp>
#include <common/consumer/consumer-stream.hpp>
-#include <common/index/index.hpp>
#include <common/consumer/consumer-timer.hpp>
-#include <common/optional.hpp>
-#include <common/buffer-view.hpp>
#include <common/consumer/consumer.hpp>
#include <common/consumer/metadata-bucket.hpp>
+#include <common/index/index.hpp>
+#include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/optional.hpp>
+#include <common/pipe.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
-#include "kernel-consumer.hpp"
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <inttypes.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
extern struct lttng_consumer_global_data the_consumer_data;
extern int consumer_poll_timeout;
*
* Returns 0 on success, < 0 on error.
*/
-int lttng_kconsumer_sample_snapshot_positions(
- struct lttng_consumer_stream *stream)
+int lttng_kconsumer_sample_snapshot_positions(struct lttng_consumer_stream *stream)
{
LTTNG_ASSERT(stream);
*
* Returns 0 on success, < 0 on error
*/
-int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos)
+int lttng_kconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos)
{
int ret;
int infd = stream->wait_fd;
*
* Returns 0 on success, < 0 on error
*/
-int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
- unsigned long *pos)
+int lttng_kconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream, unsigned long *pos)
{
int ret;
int infd = stream->wait_fd;
return ret;
}
-static
-int get_current_subbuf_addr(struct lttng_consumer_stream *stream,
- const char **addr)
+static int get_current_subbuf_addr(struct lttng_consumer_stream *stream, const char **addr)
{
int ret;
unsigned long mmap_offset;
*
* Returns 0 on success, < 0 on error
*/
-static int lttng_kconsumer_snapshot_channel(
- struct lttng_consumer_channel *channel,
- uint64_t key, char *path, uint64_t relayd_id,
- uint64_t nb_packets_per_stream)
+static int lttng_kconsumer_snapshot_channel(struct lttng_consumer_channel *channel,
+ uint64_t key,
+ char *path,
+ uint64_t relayd_id,
+ uint64_t nb_packets_per_stream)
{
int ret;
struct lttng_consumer_stream *stream;
/* Splice is not supported yet for channel snapshot. */
if (channel->output != CONSUMER_CHANNEL_MMAP) {
ERR("Unsupported output type for channel \"%s\": mmap output is required to record a snapshot",
- channel->name);
+ channel->name);
ret = -1;
goto end;
}
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
unsigned long consumed_pos, produced_pos;
health_code_update();
goto error_close_stream_output;
}
} else {
- ret = consumer_stream_create_output_files(stream,
- false);
+ ret = consumer_stream_create_output_files(stream, false);
if (ret < 0) {
goto error_close_stream_output;
}
- DBG("Kernel consumer snapshot stream (%" PRIu64 ")",
- stream->key);
+ DBG("Kernel consumer snapshot stream (%" PRIu64 ")", stream->key);
}
ret = kernctl_buffer_flush_empty(stream->wait_fd);
goto error_close_stream_output;
}
- consumed_pos = consumer_get_consume_start_pos(consumed_pos,
- produced_pos, nb_packets_per_stream,
- stream->max_sb_size);
+ consumed_pos = consumer_get_consume_start_pos(
+ consumed_pos, produced_pos, nb_packets_per_stream, stream->max_sb_size);
while ((long) (consumed_pos - produced_pos) < 0) {
ssize_t read_len;
goto error_put_subbuf;
}
- subbuf_view = lttng_buffer_view_init(
- subbuf_addr, 0, padded_len);
+ subbuf_view = lttng_buffer_view_init(subbuf_addr, 0, padded_len);
read_len = lttng_consumer_on_read_subbuffer_mmap(
- stream, &subbuf_view,
- padded_len - len);
+ stream, &subbuf_view, padded_len - len);
/*
* We write the padded len in local tracefiles but the data len
* when using a relay. Display the error but continue processing
if (relayd_id != (uint64_t) -1ULL) {
if (read_len != len) {
ERR("Error sending to the relay (ret: %zd != len: %lu)",
- read_len, len);
+ read_len,
+ len);
}
} else {
if (read_len != padded_len) {
ERR("Error writing to tracefile (ret: %zd != len: %lu)",
- read_len, padded_len);
+ read_len,
+ padded_len);
}
}
*
* Returns 0 on success, < 0 on error
*/
-static int lttng_kconsumer_snapshot_metadata(
- struct lttng_consumer_channel *metadata_channel,
- uint64_t key, char *path, uint64_t relayd_id,
- struct lttng_consumer_local_data *ctx)
+static int lttng_kconsumer_snapshot_metadata(struct lttng_consumer_channel *metadata_channel,
+ uint64_t key,
+ char *path,
+ uint64_t relayd_id,
+ struct lttng_consumer_local_data *ctx)
{
int ret, use_relayd = 0;
ssize_t ret_read;
LTTNG_ASSERT(ctx);
- DBG("Kernel consumer snapshot metadata with key %" PRIu64 " at path %s",
- key, path);
+ DBG("Kernel consumer snapshot metadata with key %" PRIu64 " at path %s", key, path);
rcu_read_lock();
goto error_snapshot;
}
} else {
- ret = consumer_stream_create_output_files(metadata_stream,
- false);
+ ret = consumer_stream_create_output_files(metadata_stream, false);
if (ret < 0) {
goto error_snapshot;
}
ret_read = lttng_consumer_read_subbuffer(metadata_stream, ctx, true);
if (ret_read < 0) {
- ERR("Kernel snapshot reading metadata subbuffer (ret: %zd)",
- ret_read);
+ ERR("Kernel snapshot reading metadata subbuffer (ret: %zd)", ret_read);
ret = ret_read;
goto error_snapshot;
}
* Return 1 on success else a negative value or 0.
*/
int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll)
+ int sock,
+ struct pollfd *consumer_sockpoll)
{
int ret_func;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
ret_recv = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg));
if (ret_recv != sizeof(msg)) {
if (ret_recv > 0) {
- lttng_consumer_send_error(ctx,
- LTTCOMM_CONSUMERD_ERROR_RECV_CMD);
+ lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD);
ret_recv = -1;
}
return ret_recv;
{
uint32_t major = msg.u.relayd_sock.major;
uint32_t minor = msg.u.relayd_sock.minor;
- enum lttcomm_sock_proto protocol = (enum lttcomm_sock_proto)
- msg.u.relayd_sock.relayd_socket_protocol;
+ enum lttcomm_sock_proto protocol =
+ (enum lttcomm_sock_proto) msg.u.relayd_sock.relayd_socket_protocol;
/* Session daemon status message are handled in the following call. */
consumer_add_relayd_socket(msg.u.relayd_sock.net_index,
- msg.u.relayd_sock.type, ctx, sock,
- consumer_sockpoll, msg.u.relayd_sock.session_id,
- msg.u.relayd_sock.relayd_session_id, major,
- minor, protocol);
+ msg.u.relayd_sock.type,
+ ctx,
+ sock,
+ consumer_sockpoll,
+ msg.u.relayd_sock.session_id,
+ msg.u.relayd_sock.relayd_session_id,
+ major,
+ minor,
+ protocol);
goto end_nosignal;
}
case LTTNG_CONSUMER_ADD_CHANNEL:
health_code_update();
DBG("consumer_add_channel %" PRIu64, msg.u.channel.channel_key);
- new_channel = consumer_allocate_channel(msg.u.channel.channel_key,
- msg.u.channel.session_id,
- msg.u.channel.chunk_id.is_set ?
- &chunk_id : NULL,
- msg.u.channel.pathname,
- msg.u.channel.name,
- msg.u.channel.relayd_id, msg.u.channel.output,
- msg.u.channel.tracefile_size,
- msg.u.channel.tracefile_count, 0,
- msg.u.channel.monitor,
- msg.u.channel.live_timer_interval,
- msg.u.channel.is_live,
- NULL, NULL);
+ new_channel =
+ consumer_allocate_channel(msg.u.channel.channel_key,
+ msg.u.channel.session_id,
+ msg.u.channel.chunk_id.is_set ? &chunk_id : NULL,
+ msg.u.channel.pathname,
+ msg.u.channel.name,
+ msg.u.channel.relayd_id,
+ msg.u.channel.output,
+ msg.u.channel.tracefile_size,
+ msg.u.channel.tracefile_count,
+ 0,
+ msg.u.channel.monitor,
+ msg.u.channel.live_timer_interval,
+ msg.u.channel.is_live,
+ NULL,
+ NULL);
if (new_channel == NULL) {
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
goto end_nosignal;
health_code_update();
if (ctx->on_recv_channel != NULL) {
- int ret_recv_channel =
- ctx->on_recv_channel(new_channel);
+ int ret_recv_channel = ctx->on_recv_channel(new_channel);
if (ret_recv_channel == 0) {
- ret_add_channel = consumer_add_channel(
- new_channel, ctx);
+ ret_add_channel = consumer_add_channel(new_channel, ctx);
} else if (ret_recv_channel < 0) {
goto end_nosignal;
}
} else {
- ret_add_channel =
- consumer_add_channel(new_channel, ctx);
+ ret_add_channel = consumer_add_channel(new_channel, ctx);
}
- if (msg.u.channel.type == CONSUMER_CHANNEL_TYPE_DATA &&
- !ret_add_channel) {
+ if (msg.u.channel.type == CONSUMER_CHANNEL_TYPE_DATA && !ret_add_channel) {
int monitor_start_ret;
DBG("Consumer starting monitor timer");
- consumer_timer_live_start(new_channel,
- msg.u.channel.live_timer_interval);
+ consumer_timer_live_start(new_channel, msg.u.channel.live_timer_interval);
monitor_start_ret = consumer_timer_monitor_start(
- new_channel,
- msg.u.channel.monitor_timer_interval);
+ new_channel, msg.u.channel.monitor_timer_interval);
if (monitor_start_ret < 0) {
ERR("Starting channel monitoring timer failed");
goto end_nosignal;
/* If we received an error in add_channel, we need to report it. */
if (ret_add_channel < 0) {
- ret_send_status = consumer_send_status_msg(
- sock, ret_add_channel);
+ ret_send_status = consumer_send_status_msg(sock, ret_add_channel);
if (ret_send_status < 0) {
goto error_fatal;
}
health_code_update();
pthread_mutex_lock(&channel->lock);
- new_stream = consumer_stream_create(
- channel,
- channel->key,
- fd,
- channel->name,
- channel->relayd_id,
- channel->session_id,
- channel->trace_chunk,
- msg.u.stream.cpu,
- &alloc_ret,
- channel->type,
- channel->monitor);
+ new_stream = consumer_stream_create(channel,
+ channel->key,
+ fd,
+ channel->name,
+ channel->relayd_id,
+ channel->session_id,
+ channel->trace_chunk,
+ msg.u.stream.cpu,
+ &alloc_ret,
+ channel->type,
+ channel->monitor);
if (new_stream == NULL) {
switch (alloc_ret) {
case -ENOMEM:
}
new_stream->wait_fd = fd;
- ret_get_max_subbuf_size = kernctl_get_max_subbuf_size(
- new_stream->wait_fd, &new_stream->max_sb_size);
+ ret_get_max_subbuf_size =
+ kernctl_get_max_subbuf_size(new_stream->wait_fd, &new_stream->max_sb_size);
if (ret_get_max_subbuf_size < 0) {
pthread_mutex_unlock(&channel->lock);
ERR("Failed to get kernel maximal subbuffer size");
goto error_add_stream_nosignal;
}
- consumer_stream_update_channel_attributes(new_stream,
- channel);
+ consumer_stream_update_channel_attributes(new_stream, channel);
/*
* We've just assigned the channel to the stream so increment the
/* Do not monitor this stream. */
if (!channel->monitor) {
DBG("Kernel consumer add stream %s in no monitor mode with "
- "relayd id %" PRIu64, new_stream->name,
- new_stream->net_seq_idx);
+ "relayd id %" PRIu64,
+ new_stream->name,
+ new_stream->net_seq_idx);
cds_list_add(&new_stream->send_node, &channel->streams.head);
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
if (new_stream->net_seq_idx != (uint64_t) -1ULL) {
int ret_send_relayd_stream;
- ret_send_relayd_stream = consumer_send_relayd_stream(
- new_stream, new_stream->chan->pathname);
+ ret_send_relayd_stream =
+ consumer_send_relayd_stream(new_stream, new_stream->chan->pathname);
if (ret_send_relayd_stream < 0) {
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
int ret_send_relayd_streams_sent;
ret_send_relayd_streams_sent =
- consumer_send_relayd_streams_sent(
- new_stream->net_seq_idx);
+ consumer_send_relayd_streams_sent(new_stream->net_seq_idx);
if (ret_send_relayd_streams_sent < 0) {
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
health_code_update();
- ret_pipe_write = lttng_pipe_write(
- stream_pipe, &new_stream, sizeof(new_stream));
+ ret_pipe_write = lttng_pipe_write(stream_pipe, &new_stream, sizeof(new_stream));
if (ret_pipe_write < 0) {
ERR("Consumer write %s stream to pipe %d",
- new_stream->metadata_flag ? "metadata" : "data",
- lttng_pipe_get_writefd(stream_pipe));
+ new_stream->metadata_flag ? "metadata" : "data",
+ lttng_pipe_get_writefd(stream_pipe));
if (new_stream->metadata_flag) {
consumer_del_stream_for_metadata(new_stream);
} else {
}
DBG("Kernel consumer ADD_STREAM %s (fd: %d) %s with relayd id %" PRIu64,
- new_stream->name, fd, new_stream->chan->pathname, new_stream->relayd_stream_id);
-end_add_stream:
+ new_stream->name,
+ fd,
+ new_stream->chan->pathname,
+ new_stream->relayd_stream_id);
+ end_add_stream:
break;
-error_add_stream_nosignal:
+ error_add_stream_nosignal:
goto end_nosignal;
-error_add_stream_fatal:
+ error_add_stream_fatal:
goto error_fatal;
}
case LTTNG_CONSUMER_STREAMS_SENT:
* We could not find the channel. Can happen if cpu hotplug
* happens while tearing down.
*/
- ERR("Unable to find channel key %" PRIu64,
- msg.u.sent_streams.channel_key);
+ ERR("Unable to find channel key %" PRIu64, msg.u.sent_streams.channel_key);
ret_code = LTTCOMM_CONSUMERD_CHAN_NOT_FOUND;
}
* Send status code to session daemon.
*/
ret_send_status = consumer_send_status_msg(sock, ret_code);
- if (ret_send_status < 0 ||
- ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
+ if (ret_send_status < 0 || ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
/* Somehow, the session daemon is not responding anymore. */
goto error_streams_sent_nosignal;
}
if (msg.u.sent_streams.net_seq_idx != (uint64_t) -1ULL) {
int ret_send_relay_streams;
- ret_send_relay_streams = consumer_send_relayd_streams_sent(
- msg.u.sent_streams.net_seq_idx);
+ ret_send_relay_streams =
+ consumer_send_relayd_streams_sent(msg.u.sent_streams.net_seq_idx);
if (ret_send_relay_streams < 0) {
goto error_streams_sent_nosignal;
}
channel->streams_sent_to_relayd = true;
}
-end_error_streams_sent:
+ end_error_streams_sent:
break;
-error_streams_sent_nosignal:
+ error_streams_sent_nosignal:
goto end_nosignal;
}
case LTTNG_CONSUMER_UPDATE_STREAM:
health_code_update();
/* Send back returned value to session daemon */
- ret_send = lttcomm_send_unix_sock(sock, &ret_data_pending,
- sizeof(ret_data_pending));
+ ret_send =
+ lttcomm_send_unix_sock(sock, &ret_data_pending, sizeof(ret_data_pending));
if (ret_send < 0) {
PERROR("send data pending ret code");
goto error_fatal;
int ret_snapshot;
ret_snapshot = lttng_kconsumer_snapshot_metadata(
- channel, key,
- msg.u.snapshot_channel.pathname,
- msg.u.snapshot_channel.relayd_id,
- ctx);
+ channel,
+ key,
+ msg.u.snapshot_channel.pathname,
+ msg.u.snapshot_channel.relayd_id,
+ ctx);
if (ret_snapshot < 0) {
ERR("Snapshot metadata failed");
ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED;
int ret_snapshot;
ret_snapshot = lttng_kconsumer_snapshot_channel(
- channel, key,
- msg.u.snapshot_channel.pathname,
- msg.u.snapshot_channel.relayd_id,
- msg.u.snapshot_channel
- .nb_packets_per_stream);
+ channel,
+ key,
+ msg.u.snapshot_channel.pathname,
+ msg.u.snapshot_channel.relayd_id,
+ msg.u.snapshot_channel.nb_packets_per_stream);
if (ret_snapshot < 0) {
ERR("Snapshot channel failed");
ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED;
LTTNG_ASSERT(!uatomic_sub_return(&channel->refcount, 1));
consumer_del_channel(channel);
-end_destroy_channel:
+ end_destroy_channel:
goto end_nosignal;
}
case LTTNG_CONSUMER_DISCARDED_EVENTS:
uint64_t id = msg.u.discarded_events.session_id;
uint64_t key = msg.u.discarded_events.channel_key;
- DBG("Kernel consumer discarded events command for session id %"
- PRIu64 ", channel key %" PRIu64, id, key);
+ DBG("Kernel consumer discarded events command for session id %" PRIu64
+ ", channel key %" PRIu64,
+ id,
+ key);
channel = consumer_find_channel(key);
if (!channel) {
- ERR("Kernel consumer discarded events channel %"
- PRIu64 " not found", key);
+ ERR("Kernel consumer discarded events channel %" PRIu64 " not found", key);
count = 0;
} else {
count = channel->discarded_events;
uint64_t id = msg.u.lost_packets.session_id;
uint64_t key = msg.u.lost_packets.channel_key;
- DBG("Kernel consumer lost packets command for session id %"
- PRIu64 ", channel key %" PRIu64, id, key);
+ DBG("Kernel consumer lost packets command for session id %" PRIu64
+ ", channel key %" PRIu64,
+ id,
+ key);
channel = consumer_find_channel(key);
if (!channel) {
- ERR("Kernel consumer lost packets channel %"
- PRIu64 " not found", key);
+ ERR("Kernel consumer lost packets channel %" PRIu64 " not found", key);
count = 0;
} else {
count = channel->lost_packets;
goto error_fatal;
}
- ret_recv = lttcomm_recv_fds_unix_sock(
- sock, &channel_monitor_pipe, 1);
+ ret_recv = lttcomm_recv_fds_unix_sock(sock, &channel_monitor_pipe, 1);
if (ret_recv != sizeof(channel_monitor_pipe)) {
ERR("Failed to receive channel monitor pipe");
goto error_fatal;
DBG("Received channel monitor pipe (%d)", channel_monitor_pipe);
ret_set_channel_monitor_pipe =
- consumer_timer_thread_set_channel_monitor_pipe(
- channel_monitor_pipe);
+ consumer_timer_thread_set_channel_monitor_pipe(channel_monitor_pipe);
if (!ret_set_channel_monitor_pipe) {
int flags;
int ret_fcntl;
}
flags = ret_fcntl;
- ret_fcntl = fcntl(channel_monitor_pipe, F_SETFL,
- flags | O_NONBLOCK);
+ ret_fcntl = fcntl(channel_monitor_pipe, F_SETFL, flags | O_NONBLOCK);
if (ret_fcntl == -1) {
PERROR("fcntl set O_NONBLOCK flag of the channel monitoring pipe");
goto error_fatal;
int ret_rotate_channel;
ret_rotate_channel = lttng_consumer_rotate_channel(
- channel, key,
- msg.u.rotate_channel.relayd_id);
+ channel, key, msg.u.rotate_channel.relayd_id);
if (ret_rotate_channel < 0) {
ERR("Rotate channel failed");
ret_code = LTTCOMM_CONSUMERD_ROTATION_FAIL;
/* Rotate the streams that are ready right now. */
int ret_rotate;
- ret_rotate = lttng_consumer_rotate_ready_streams(
- channel, key);
+ ret_rotate = lttng_consumer_rotate_ready_streams(channel, key);
if (ret_rotate < 0) {
ERR("Rotate ready streams failed");
}
}
break;
-error_rotate_channel:
+ error_rotate_channel:
goto end_nosignal;
}
case LTTNG_CONSUMER_CLEAR_CHANNEL:
} else {
int ret_clear_channel;
- ret_clear_channel =
- lttng_consumer_clear_channel(channel);
+ ret_clear_channel = lttng_consumer_clear_channel(channel);
if (ret_clear_channel) {
ERR("Clear channel failed");
ret_code = (lttcomm_return_code) ret_clear_channel;
int ret_send_status;
lttng_uuid sessiond_uuid;
- std::copy(std::begin(msg.u.init.sessiond_uuid), std::end(msg.u.init.sessiond_uuid),
- sessiond_uuid.begin());
+ std::copy(std::begin(msg.u.init.sessiond_uuid),
+ std::end(msg.u.init.sessiond_uuid),
+ sessiond_uuid.begin());
- ret_code = lttng_consumer_init_command(ctx,
- sessiond_uuid);
+ ret_code = lttng_consumer_init_command(ctx, sessiond_uuid);
health_code_update();
ret_send_status = consumer_send_status_msg(sock, ret_code);
if (ret_send_status < 0) {
case LTTNG_CONSUMER_CREATE_TRACE_CHUNK:
{
const struct lttng_credentials credentials = {
- .uid = LTTNG_OPTIONAL_INIT_VALUE(msg.u.create_trace_chunk.credentials.value.uid),
- .gid = LTTNG_OPTIONAL_INIT_VALUE(msg.u.create_trace_chunk.credentials.value.gid),
+ .uid = LTTNG_OPTIONAL_INIT_VALUE(
+ msg.u.create_trace_chunk.credentials.value.uid),
+ .gid = LTTNG_OPTIONAL_INIT_VALUE(
+ msg.u.create_trace_chunk.credentials.value.gid),
};
- const bool is_local_trace =
- !msg.u.create_trace_chunk.relayd_id.is_set;
- const uint64_t relayd_id =
- msg.u.create_trace_chunk.relayd_id.value;
- const char *chunk_override_name =
- *msg.u.create_trace_chunk.override_name ?
- msg.u.create_trace_chunk.override_name :
- NULL;
+ const bool is_local_trace = !msg.u.create_trace_chunk.relayd_id.is_set;
+ const uint64_t relayd_id = msg.u.create_trace_chunk.relayd_id.value;
+ const char *chunk_override_name = *msg.u.create_trace_chunk.override_name ?
+ msg.u.create_trace_chunk.override_name :
+ NULL;
struct lttng_directory_handle *chunk_directory_handle = NULL;
/*
ssize_t ret_recv;
/* Acnowledge the reception of the command. */
- ret_send_status = consumer_send_status_msg(
- sock, LTTCOMM_CONSUMERD_SUCCESS);
+ ret_send_status = consumer_send_status_msg(sock, LTTCOMM_CONSUMERD_SUCCESS);
if (ret_send_status < 0) {
/* Somehow, the session daemon is not responding anymore. */
goto end_nosignal;
}
- ret_recv = lttcomm_recv_fds_unix_sock(
- sock, &chunk_dirfd, 1);
+ ret_recv = lttcomm_recv_fds_unix_sock(sock, &chunk_dirfd, 1);
if (ret_recv != sizeof(chunk_dirfd)) {
ERR("Failed to receive trace chunk directory file descriptor");
goto error_fatal;
}
- DBG("Received trace chunk directory fd (%d)",
- chunk_dirfd);
- chunk_directory_handle = lttng_directory_handle_create_from_dirfd(
- chunk_dirfd);
+ DBG("Received trace chunk directory fd (%d)", chunk_dirfd);
+ chunk_directory_handle =
+ lttng_directory_handle_create_from_dirfd(chunk_dirfd);
if (!chunk_directory_handle) {
ERR("Failed to initialize chunk directory handle from directory file descriptor");
if (close(chunk_dirfd)) {
}
ret_code = lttng_consumer_create_trace_chunk(
- !is_local_trace ? &relayd_id : NULL,
- msg.u.create_trace_chunk.session_id,
- msg.u.create_trace_chunk.chunk_id,
- (time_t) msg.u.create_trace_chunk
- .creation_timestamp,
- chunk_override_name,
- msg.u.create_trace_chunk.credentials.is_set ?
- &credentials :
- NULL,
- chunk_directory_handle);
+ !is_local_trace ? &relayd_id : NULL,
+ msg.u.create_trace_chunk.session_id,
+ msg.u.create_trace_chunk.chunk_id,
+ (time_t) msg.u.create_trace_chunk.creation_timestamp,
+ chunk_override_name,
+ msg.u.create_trace_chunk.credentials.is_set ? &credentials : NULL,
+ chunk_directory_handle);
lttng_directory_handle_put(chunk_directory_handle);
goto end_msg_sessiond;
}
case LTTNG_CONSUMER_CLOSE_TRACE_CHUNK:
{
enum lttng_trace_chunk_command_type close_command =
- (lttng_trace_chunk_command_type) msg.u.close_trace_chunk.close_command.value;
- const uint64_t relayd_id =
- msg.u.close_trace_chunk.relayd_id.value;
+ (lttng_trace_chunk_command_type) msg.u.close_trace_chunk.close_command.value;
+ const uint64_t relayd_id = msg.u.close_trace_chunk.relayd_id.value;
struct lttcomm_consumer_close_trace_chunk_reply reply;
char path[LTTNG_PATH_MAX];
ssize_t ret_send;
ret_code = lttng_consumer_close_trace_chunk(
- msg.u.close_trace_chunk.relayd_id.is_set ?
- &relayd_id :
- NULL,
- msg.u.close_trace_chunk.session_id,
- msg.u.close_trace_chunk.chunk_id,
- (time_t) msg.u.close_trace_chunk.close_timestamp,
- msg.u.close_trace_chunk.close_command.is_set ?
- &close_command :
- NULL, path);
+ msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.close_trace_chunk.session_id,
+ msg.u.close_trace_chunk.chunk_id,
+ (time_t) msg.u.close_trace_chunk.close_timestamp,
+ msg.u.close_trace_chunk.close_command.is_set ? &close_command : NULL,
+ path);
reply.ret_code = ret_code;
reply.path_length = strlen(path) + 1;
ret_send = lttcomm_send_unix_sock(sock, &reply, sizeof(reply));
if (ret_send != sizeof(reply)) {
goto error_fatal;
}
- ret_send = lttcomm_send_unix_sock(
- sock, path, reply.path_length);
+ ret_send = lttcomm_send_unix_sock(sock, path, reply.path_length);
if (ret_send != reply.path_length) {
goto error_fatal;
}
}
case LTTNG_CONSUMER_TRACE_CHUNK_EXISTS:
{
- const uint64_t relayd_id =
- msg.u.trace_chunk_exists.relayd_id.value;
+ const uint64_t relayd_id = msg.u.trace_chunk_exists.relayd_id.value;
ret_code = lttng_consumer_trace_chunk_exists(
- msg.u.trace_chunk_exists.relayd_id.is_set ?
- &relayd_id : NULL,
- msg.u.trace_chunk_exists.session_id,
- msg.u.trace_chunk_exists.chunk_id);
+ msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.trace_chunk_exists.session_id,
+ msg.u.trace_chunk_exists.chunk_id);
goto end_msg_sessiond;
}
case LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS:
{
const uint64_t key = msg.u.open_channel_packets.key;
- struct lttng_consumer_channel *channel =
- consumer_find_channel(key);
+ struct lttng_consumer_channel *channel = consumer_find_channel(key);
if (channel) {
pthread_mutex_lock(&channel->lock);
*
* Metadata stream lock MUST be acquired.
*/
-enum sync_metadata_status lttng_kconsumer_sync_metadata(
- struct lttng_consumer_stream *metadata)
+enum sync_metadata_status lttng_kconsumer_sync_metadata(struct lttng_consumer_stream *metadata)
{
int ret;
enum sync_metadata_status status;
return status;
}
-static
-int extract_common_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+static int extract_common_subbuffer_info(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuf)
{
int ret;
- ret = kernctl_get_subbuf_size(
- stream->wait_fd, &subbuf->info.data.subbuf_size);
+ ret = kernctl_get_subbuf_size(stream->wait_fd, &subbuf->info.data.subbuf_size);
if (ret) {
goto end;
}
- ret = kernctl_get_padded_subbuf_size(
- stream->wait_fd, &subbuf->info.data.padded_subbuf_size);
+ ret = kernctl_get_padded_subbuf_size(stream->wait_fd,
+ &subbuf->info.data.padded_subbuf_size);
if (ret) {
goto end;
}
return ret;
}
-static
-int extract_metadata_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+static int extract_metadata_subbuffer_info(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuf)
{
int ret;
goto end;
}
- ret = kernctl_get_metadata_version(
- stream->wait_fd, &subbuf->info.metadata.version);
+ ret = kernctl_get_metadata_version(stream->wait_fd, &subbuf->info.metadata.version);
if (ret) {
goto end;
}
return ret;
}
-static
-int extract_data_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+static int extract_data_subbuffer_info(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuf)
{
int ret;
goto end;
}
- ret = kernctl_get_packet_size(
- stream->wait_fd, &subbuf->info.data.packet_size);
+ ret = kernctl_get_packet_size(stream->wait_fd, &subbuf->info.data.packet_size);
if (ret < 0) {
PERROR("Failed to get sub-buffer packet size");
goto end;
}
- ret = kernctl_get_content_size(
- stream->wait_fd, &subbuf->info.data.content_size);
+ ret = kernctl_get_content_size(stream->wait_fd, &subbuf->info.data.content_size);
if (ret < 0) {
PERROR("Failed to get sub-buffer content size");
goto end;
}
- ret = kernctl_get_timestamp_begin(
- stream->wait_fd, &subbuf->info.data.timestamp_begin);
+ ret = kernctl_get_timestamp_begin(stream->wait_fd, &subbuf->info.data.timestamp_begin);
if (ret < 0) {
PERROR("Failed to get sub-buffer begin timestamp");
goto end;
}
- ret = kernctl_get_timestamp_end(
- stream->wait_fd, &subbuf->info.data.timestamp_end);
+ ret = kernctl_get_timestamp_end(stream->wait_fd, &subbuf->info.data.timestamp_end);
if (ret < 0) {
PERROR("Failed to get sub-buffer end timestamp");
goto end;
}
- ret = kernctl_get_events_discarded(
- stream->wait_fd, &subbuf->info.data.events_discarded);
+ ret = kernctl_get_events_discarded(stream->wait_fd, &subbuf->info.data.events_discarded);
if (ret) {
PERROR("Failed to get sub-buffer events discarded count");
goto end;
}
ret = kernctl_get_sequence_number(stream->wait_fd,
- &subbuf->info.data.sequence_number.value);
+ &subbuf->info.data.sequence_number.value);
if (ret) {
/* May not be supported by older LTTng-modules. */
if (ret != -ENOTTY) {
subbuf->info.data.sequence_number.is_set = true;
}
- ret = kernctl_get_stream_id(
- stream->wait_fd, &subbuf->info.data.stream_id);
+ ret = kernctl_get_stream_id(stream->wait_fd, &subbuf->info.data.stream_id);
if (ret < 0) {
PERROR("Failed to get stream id");
goto end;
}
- ret = kernctl_get_instance_id(stream->wait_fd,
- &subbuf->info.data.stream_instance_id.value);
+ ret = kernctl_get_instance_id(stream->wait_fd, &subbuf->info.data.stream_instance_id.value);
if (ret) {
/* May not be supported by older LTTng-modules. */
if (ret != -ENOTTY) {
return ret;
}
-static
-enum get_next_subbuffer_status get_subbuffer_common(
- struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status get_subbuffer_common(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer)
{
int ret;
enum get_next_subbuffer_status status;
status = GET_NEXT_SUBBUFFER_STATUS_OK;
break;
case -ENODATA:
- case -EAGAIN:
+ case -EAGAIN:
/*
* The caller only expects -ENODATA when there is no data to
* read, but the kernel tracer returns -EAGAIN when there is
goto end;
}
- ret = stream->read_subbuffer_ops.extract_subbuffer_info(
- stream, subbuffer);
+ ret = stream->read_subbuffer_ops.extract_subbuffer_info(stream, subbuffer);
if (ret) {
status = GET_NEXT_SUBBUFFER_STATUS_ERROR;
}
return status;
}
-static
-enum get_next_subbuffer_status get_next_subbuffer_splice(
- struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status
+get_next_subbuffer_splice(struct lttng_consumer_stream *stream, struct stream_subbuffer *subbuffer)
{
- const enum get_next_subbuffer_status status =
- get_subbuffer_common(stream, subbuffer);
+ const enum get_next_subbuffer_status status = get_subbuffer_common(stream, subbuffer);
if (status != GET_NEXT_SUBBUFFER_STATUS_OK) {
goto end;
return status;
}
-static
-enum get_next_subbuffer_status get_next_subbuffer_mmap(
- struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status get_next_subbuffer_mmap(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer)
{
int ret;
enum get_next_subbuffer_status status;
goto end;
}
- subbuffer->buffer.buffer = lttng_buffer_view_init(
- addr, 0, subbuffer->info.data.padded_subbuf_size);
+ subbuffer->buffer.buffer =
+ lttng_buffer_view_init(addr, 0, subbuffer->info.data.padded_subbuf_size);
end:
return status;
}
-static
-enum get_next_subbuffer_status get_next_subbuffer_metadata_check(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status
+get_next_subbuffer_metadata_check(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer)
{
int ret;
const char *addr;
bool coherent;
enum get_next_subbuffer_status status;
- ret = kernctl_get_next_subbuf_metadata_check(stream->wait_fd,
- &coherent);
+ ret = kernctl_get_next_subbuf_metadata_check(stream->wait_fd, &coherent);
if (ret) {
goto end;
}
- ret = stream->read_subbuffer_ops.extract_subbuffer_info(
- stream, subbuffer);
+ ret = stream->read_subbuffer_ops.extract_subbuffer_info(stream, subbuffer);
if (ret) {
goto end;
}
goto end;
}
- subbuffer->buffer.buffer = lttng_buffer_view_init(
- addr, 0, subbuffer->info.data.padded_subbuf_size);
+ subbuffer->buffer.buffer =
+ lttng_buffer_view_init(addr, 0, subbuffer->info.data.padded_subbuf_size);
DBG("Got metadata packet with padded_subbuf_size = %lu, coherent = %s",
- subbuffer->info.metadata.padded_subbuf_size,
- coherent ? "true" : "false");
+ subbuffer->info.metadata.padded_subbuf_size,
+ coherent ? "true" : "false");
end:
/*
* The caller only expects -ENODATA when there is no data to read, but
return status;
}
-static
-int put_next_subbuffer(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer __attribute__((unused)))
+static int put_next_subbuffer(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer __attribute__((unused)))
{
const int ret = kernctl_put_next_subbuf(stream->wait_fd);
return ret;
}
-static
-bool is_get_next_check_metadata_available(int tracer_fd)
+static bool is_get_next_check_metadata_available(int tracer_fd)
{
const int ret = kernctl_get_next_subbuf_metadata_check(tracer_fd, NULL);
const bool available = ret != -ENOTTY;
return available;
}
-static
-int signal_metadata(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx __attribute__((unused)))
+static int signal_metadata(struct lttng_consumer_stream *stream,
+ struct lttng_consumer_local_data *ctx __attribute__((unused)))
{
ASSERT_LOCKED(stream->metadata_rdv_lock);
return pthread_cond_broadcast(&stream->metadata_rdv) ? -errno : 0;
}
-static
-int lttng_kconsumer_set_stream_ops(
- struct lttng_consumer_stream *stream)
+static int lttng_kconsumer_set_stream_ops(struct lttng_consumer_stream *stream)
{
int ret = 0;
if (is_get_next_check_metadata_available(stream->wait_fd)) {
DBG("Kernel tracer supports get_next_subbuffer_metadata_check, metadata will be accumulated until a coherent state is reached");
stream->read_subbuffer_ops.get_next_subbuffer =
- get_next_subbuffer_metadata_check;
- ret = consumer_stream_enable_metadata_bucketization(
- stream);
+ get_next_subbuffer_metadata_check;
+ ret = consumer_stream_enable_metadata_bucketization(stream);
if (ret) {
goto end;
}
if (!stream->read_subbuffer_ops.get_next_subbuffer) {
if (stream->chan->output == CONSUMER_CHANNEL_MMAP) {
- stream->read_subbuffer_ops.get_next_subbuffer =
- get_next_subbuffer_mmap;
+ stream->read_subbuffer_ops.get_next_subbuffer = get_next_subbuffer_mmap;
} else {
- stream->read_subbuffer_ops.get_next_subbuffer =
- get_next_subbuffer_splice;
+ stream->read_subbuffer_ops.get_next_subbuffer = get_next_subbuffer_splice;
}
}
if (stream->metadata_flag) {
- stream->read_subbuffer_ops.extract_subbuffer_info =
- extract_metadata_subbuffer_info;
+ stream->read_subbuffer_ops.extract_subbuffer_info = extract_metadata_subbuffer_info;
} else {
- stream->read_subbuffer_ops.extract_subbuffer_info =
- extract_data_subbuffer_info;
+ stream->read_subbuffer_ops.extract_subbuffer_info = extract_data_subbuffer_info;
if (stream->chan->is_live) {
- stream->read_subbuffer_ops.send_live_beacon =
- consumer_flush_kernel_index;
+ stream->read_subbuffer_ops.send_live_beacon = consumer_flush_kernel_index;
}
}
* no current trace chunk on the parent channel.
*/
if (stream->net_seq_idx == (uint64_t) -1ULL && stream->chan->monitor &&
- stream->chan->trace_chunk) {
+ stream->chan->trace_chunk) {
ret = consumer_stream_create_output_files(stream, true);
if (ret) {
goto error;
}
stream->mmap_len = (size_t) mmap_len;
- stream->mmap_base = mmap(NULL, stream->mmap_len, PROT_READ,
- MAP_PRIVATE, stream->wait_fd, 0);
+ stream->mmap_base =
+ mmap(NULL, stream->mmap_len, PROT_READ, MAP_PRIVATE, stream->wait_fd, 0);
if (stream->mmap_base == MAP_FAILED) {
PERROR("Error mmaping");
ret = -1;
/* There is still data so let's put back this subbuffer. */
ret = kernctl_put_subbuf(stream->wait_fd);
LTTNG_ASSERT(ret == 0);
- ret = 1; /* Data is pending */
+ ret = 1; /* Data is pending */
goto end;
}
#include "lttng/tracker.h"
#define _LGPL_SOURCE
#define __USE_LINUX_IOCTL_DEFS
-#include <sys/ioctl.h>
-#include <string.h>
+#include "kernel-ctl.hpp"
+#include "kernel-ioctl.hpp"
+
#include <common/align.hpp>
-#include <common/macros.hpp>
#include <common/compat/errno.hpp>
-#include <stdarg.h>
+#include <common/macros.hpp>
#include <common/time.hpp>
-#include "kernel-ctl.hpp"
-#include "kernel-ioctl.hpp"
+#include <stdarg.h>
+#include <string.h>
+#include <sys/ioctl.h>
#define LTTNG_IOCTL_CHECK(fildes, request, ...) \
({ \
int _ioctl_ret = ioctl(fildes, request, ##__VA_ARGS__); \
- LTTNG_ASSERT(_ioctl_ret <= 0); \
+ LTTNG_ASSERT(_ioctl_ret <= 0); \
!_ioctl_ret ? 0 : -errno; \
})
* and new request codes.
* It returns the return value of the ioctl executed.
*/
-static inline int compat_ioctl_no_arg(int fd, unsigned long oldname,
- unsigned long newname)
+static inline int compat_ioctl_no_arg(int fd, unsigned long oldname, unsigned long newname)
{
int ret;
int kernctl_create_session(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_SESSION,
- LTTNG_KERNEL_ABI_SESSION);
+ return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_SESSION, LTTNG_KERNEL_ABI_SESSION);
}
/* open the metadata global channel */
*/
memcpy(old_channel.padding, chops->padding, sizeof(chops->padding));
- return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_METADATA,
- &old_channel);
+ return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_METADATA, &old_channel);
}
memset(&channel, 0, sizeof(channel));
*/
memcpy(old_channel.padding, chops->padding, sizeof(chops->padding));
- return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_CHANNEL,
- &old_channel);
+ return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_CHANNEL, &old_channel);
}
channel.overwrite = chops->overwrite;
int kernctl_track_pid(int fd, int pid)
{
- int ret = LTTNG_IOCTL_CHECK(
- fd, LTTNG_KERNEL_ABI_SESSION_TRACK_PID, pid);
+ int ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_TRACK_PID, pid);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID, pid);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_PID, pid);
}
return ret;
int kernctl_untrack_pid(int fd, int pid)
{
- int ret = LTTNG_IOCTL_CHECK(
- fd, LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID, pid);
+ int ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_UNTRACK_PID, pid);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID, pid);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_PID, pid);
}
return ret;
return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_PIDS);
}
-static enum lttng_kernel_abi_tracker_type get_kernel_tracker_type(
- enum lttng_process_attr process_attr)
+static enum lttng_kernel_abi_tracker_type
+get_kernel_tracker_type(enum lttng_process_attr process_attr)
{
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_TRACK_ID, &args);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID, &args);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_SESSION_TRACK_ID, &args);
}
return ret;
ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_UNTRACK_ID, &args);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID, &args);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_SESSION_UNTRACK_ID, &args);
}
return ret;
return -1;
}
- ret = LTTNG_IOCTL_NO_CHECK(
- fd, LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS, &args);
+ ret = LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_LIST_TRACKER_IDS, &args);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_NO_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS,
- &args);
+ ret = LTTNG_IOCTL_NO_CHECK(
+ fd, LTTNG_KERNEL_ABI_OLD_SESSION_LIST_TRACKER_IDS, &args);
}
return ret;
goto end;
}
- ret = LTTNG_IOCTL_CHECK(
- fd, LTTNG_KERNEL_ABI_SESSION_SET_NAME, &session_name);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_SET_NAME, &session_name);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME,
- &session_name);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_SESSION_SET_NAME, &session_name);
}
end:
int ret;
struct lttng_kernel_abi_session_creation_time creation_time;
- ret = time_to_iso8601_str(time, creation_time.iso8601,
- sizeof(creation_time.iso8601));
+ ret = time_to_iso8601_str(time, creation_time.iso8601, sizeof(creation_time.iso8601));
if (ret) {
goto end;
}
- ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME,
- &creation_time);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_SESSION_SET_CREATION_TIME, &creation_time);
if (ret == -ENOSYS) {
- ret = LTTNG_IOCTL_CHECK(fd,
- LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME,
- &creation_time);
+ ret = LTTNG_IOCTL_CHECK(
+ fd, LTTNG_KERNEL_ABI_OLD_SESSION_SET_CREATION_TIME, &creation_time);
}
end:
int kernctl_create_stream(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_STREAM,
- LTTNG_KERNEL_ABI_STREAM);
+ return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_STREAM, LTTNG_KERNEL_ABI_STREAM);
}
int kernctl_create_event(int fd, struct lttng_kernel_abi_event *ev)
old_event.u.kprobe.addr = ev->u.kprobe.addr;
old_event.u.kprobe.offset = ev->u.kprobe.offset;
memcpy(old_event.u.kprobe.symbol_name,
- ev->u.kprobe.symbol_name,
- sizeof(old_event.u.kprobe.symbol_name));
+ ev->u.kprobe.symbol_name,
+ sizeof(old_event.u.kprobe.symbol_name));
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
old_event.u.kretprobe.addr = ev->u.kretprobe.addr;
old_event.u.kretprobe.offset = ev->u.kretprobe.offset;
memcpy(old_event.u.kretprobe.symbol_name,
- ev->u.kretprobe.symbol_name,
- sizeof(old_event.u.kretprobe.symbol_name));
+ ev->u.kretprobe.symbol_name,
+ sizeof(old_event.u.kretprobe.symbol_name));
break;
case LTTNG_KERNEL_ABI_FUNCTION:
memcpy(old_event.u.ftrace.symbol_name,
- ev->u.ftrace.symbol_name,
- sizeof(old_event.u.ftrace.symbol_name));
+ ev->u.ftrace.symbol_name,
+ sizeof(old_event.u.ftrace.symbol_name));
break;
default:
break;
}
- return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_EVENT,
- &old_event);
+ return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_OLD_EVENT, &old_event);
}
return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_EVENT, ev);
}
old_ctx.ctx = ctx->ctx;
/* only type that uses the union */
if (ctx->ctx == LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER) {
- old_ctx.u.perf_counter.type =
- ctx->u.perf_counter.type;
- old_ctx.u.perf_counter.config =
- ctx->u.perf_counter.config;
+ old_ctx.u.perf_counter.type = ctx->u.perf_counter.type;
+ old_ctx.u.perf_counter.config = ctx->u.perf_counter.config;
memcpy(old_ctx.u.perf_counter.name,
- ctx->u.perf_counter.name,
- sizeof(old_ctx.u.perf_counter.name));
+ ctx->u.perf_counter.name,
+ sizeof(old_ctx.u.perf_counter.name));
}
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_CONTEXT,
- &old_ctx);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_OLD_CONTEXT, &old_ctx);
}
return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_CONTEXT, ctx);
}
-
/* Enable event, channel and session LTTNG_IOCTL_CHECK */
int kernctl_enable(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_ENABLE,
- LTTNG_KERNEL_ABI_ENABLE);
+ return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_ENABLE, LTTNG_KERNEL_ABI_ENABLE);
}
/* Disable event, channel and session LTTNG_IOCTL_CHECK */
int kernctl_disable(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_DISABLE,
- LTTNG_KERNEL_ABI_DISABLE);
+ return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_DISABLE, LTTNG_KERNEL_ABI_DISABLE);
}
int kernctl_start_session(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_SESSION_START,
- LTTNG_KERNEL_ABI_SESSION_START);
+ return compat_ioctl_no_arg(
+ fd, LTTNG_KERNEL_ABI_OLD_SESSION_START, LTTNG_KERNEL_ABI_SESSION_START);
}
int kernctl_stop_session(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_SESSION_STOP,
- LTTNG_KERNEL_ABI_SESSION_STOP);
+ return compat_ioctl_no_arg(
+ fd, LTTNG_KERNEL_ABI_OLD_SESSION_STOP, LTTNG_KERNEL_ABI_SESSION_STOP);
}
int kernctl_create_event_notifier_group(int fd)
{
- return LTTNG_IOCTL_NO_CHECK(fd,
- LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE);
+ return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_CREATE);
}
int kernctl_create_event_notifier_group_notification_fd(int group_fd)
{
return LTTNG_IOCTL_NO_CHECK(group_fd,
- LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD);
+ LTTNG_KERNEL_ABI_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD);
}
-int kernctl_create_event_notifier_group_error_counter(int group_fd,
- const struct lttng_kernel_abi_counter_conf *error_counter_conf)
+int kernctl_create_event_notifier_group_error_counter(
+ int group_fd, const struct lttng_kernel_abi_counter_conf *error_counter_conf)
{
- return LTTNG_IOCTL_NO_CHECK(group_fd, LTTNG_KERNEL_ABI_COUNTER,
- error_counter_conf);
+ return LTTNG_IOCTL_NO_CHECK(group_fd, LTTNG_KERNEL_ABI_COUNTER, error_counter_conf);
}
int kernctl_counter_get_aggregate_value(int counter_fd,
- struct lttng_kernel_abi_counter_aggregate *value)
+ struct lttng_kernel_abi_counter_aggregate *value)
{
- return LTTNG_IOCTL_NO_CHECK(counter_fd, LTTNG_KERNEL_ABI_COUNTER_AGGREGATE,
- value);
+ return LTTNG_IOCTL_NO_CHECK(counter_fd, LTTNG_KERNEL_ABI_COUNTER_AGGREGATE, value);
}
-int kernctl_counter_clear(int counter_fd,
- struct lttng_kernel_abi_counter_clear *clear)
+int kernctl_counter_clear(int counter_fd, struct lttng_kernel_abi_counter_clear *clear)
{
- return LTTNG_IOCTL_NO_CHECK(counter_fd, LTTNG_KERNEL_ABI_COUNTER_CLEAR,
- clear);
+ return LTTNG_IOCTL_NO_CHECK(counter_fd, LTTNG_KERNEL_ABI_COUNTER_CLEAR, clear);
}
int kernctl_create_event_notifier(int group_fd,
- const struct lttng_kernel_abi_event_notifier *event_notifier)
+ const struct lttng_kernel_abi_event_notifier *event_notifier)
{
- return LTTNG_IOCTL_NO_CHECK(group_fd,
- LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE, event_notifier);
+ return LTTNG_IOCTL_NO_CHECK(
+ group_fd, LTTNG_KERNEL_ABI_EVENT_NOTIFIER_CREATE, event_notifier);
}
int kernctl_capture(int fd, const struct lttng_bytecode *capture)
int kernctl_tracepoint_list(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST,
- LTTNG_KERNEL_ABI_TRACEPOINT_LIST);
+ return compat_ioctl_no_arg(
+ fd, LTTNG_KERNEL_ABI_OLD_TRACEPOINT_LIST, LTTNG_KERNEL_ABI_TRACEPOINT_LIST);
}
int kernctl_syscall_list(int fd)
return ret;
}
-int kernctl_tracer_abi_version(int fd,
- struct lttng_kernel_abi_tracer_abi_version *v)
+int kernctl_tracer_abi_version(int fd, struct lttng_kernel_abi_tracer_abi_version *v)
{
return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_TRACER_ABI_VERSION, v);
}
int kernctl_wait_quiescent(int fd)
{
- return compat_ioctl_no_arg(fd, LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT,
- LTTNG_KERNEL_ABI_WAIT_QUIESCENT);
+ return compat_ioctl_no_arg(
+ fd, LTTNG_KERNEL_ABI_OLD_WAIT_QUIESCENT, LTTNG_KERNEL_ABI_WAIT_QUIESCENT);
}
int kernctl_buffer_flush(int fd)
int kernctl_get_next_subbuf_metadata_check(int fd, bool *consistent)
{
- return LTTNG_IOCTL_NO_CHECK(fd,
- LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK,
- consistent);
+ return LTTNG_IOCTL_NO_CHECK(
+ fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK, consistent);
}
/* returns the version of the metadata. */
int kernctl_get_metadata_version(int fd, uint64_t *version)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION,
- version);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION, version);
}
int kernctl_metadata_cache_dump(int fd)
/* returns the length to mmap. */
int kernctl_get_mmap_len(int fd, unsigned long *len)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN,
- len);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN, len);
}
/* returns the maximum size for sub-buffers. */
int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE,
- len);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
}
/*
/* returns the offset of the subbuffer belonging to the mmap reader. */
int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET,
- off);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET, off);
}
/* returns the size of the current sub-buffer, without padding (for mmap). */
int kernctl_get_subbuf_size(int fd, unsigned long *len)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE,
- len);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE, len);
}
/* returns the size of the current sub-buffer, without padding (for mmap). */
int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE,
- len);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
}
/* Get exclusive read access to the next sub-buffer that can be read. */
return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF);
}
-
/* Release exclusive sub-buffer access, move consumer forward. */
int kernctl_put_next_subbuf(int fd)
{
/* Get the consumer position (iteration start) */
int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED,
- pos);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
}
/* Get the producer position (iteration end) */
int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED,
- pos);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
}
/* Get exclusive read access to the specified sub-buffer position */
int kernctl_get_subbuf(int fd, unsigned long *len)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF,
- len);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF, len);
}
/* Release exclusive sub-buffer access */
/* Returns the timestamp begin of the current sub-buffer. */
int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN,
- timestamp_begin);
+ return LTTNG_IOCTL_CHECK(
+ fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_BEGIN, timestamp_begin);
}
/* Returns the timestamp end of the current sub-buffer. */
int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END,
- timestamp_end);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_TIMESTAMP_END, timestamp_end);
}
/* Returns the number of discarded events in the current sub-buffer. */
int kernctl_get_events_discarded(int fd, uint64_t *events_discarded)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED,
- events_discarded);
+ return LTTNG_IOCTL_CHECK(
+ fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_EVENTS_DISCARDED, events_discarded);
}
/* Returns the content size in the current sub-buffer. */
int kernctl_get_content_size(int fd, uint64_t *content_size)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE,
- content_size);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_CONTENT_SIZE, content_size);
}
/* Returns the packet size in the current sub-buffer. */
int kernctl_get_packet_size(int fd, uint64_t *packet_size)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE,
- packet_size);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_PACKET_SIZE, packet_size);
}
/* Returns the stream id of the current sub-buffer. */
int kernctl_get_stream_id(int fd, uint64_t *stream_id)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID,
- stream_id);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_STREAM_ID, stream_id);
}
/* Returns the current timestamp. */
int kernctl_get_current_timestamp(int fd, uint64_t *ts)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP,
- ts);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_CURRENT_TIMESTAMP, ts);
}
/* Returns the packet sequence number of the current sub-buffer. */
int kernctl_get_sequence_number(int fd, uint64_t *seq)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM,
- seq);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_GET_SEQ_NUM, seq);
}
/* Returns the stream instance id. */
int kernctl_get_instance_id(int fd, uint64_t *id)
{
- return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID,
- id);
+ return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ABI_RING_BUFFER_INSTANCE_ID, id);
}
*/
#include "lttng/lttng-error.h"
+
#include <common/error.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/hashtable/utils.hpp>
#include <common/mi-lttng.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
-#include <fcntl.h>
+
#include <lttng/constant.h>
#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
+
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-static
-int lttng_kernel_probe_location_address_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload);
-
-static
-int lttng_kernel_probe_location_symbol_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload);
-
-static
-bool lttng_kernel_probe_location_address_is_equal(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b);
-
-static
-bool lttng_kernel_probe_location_symbol_is_equal(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b);
-
-static
-unsigned long lttng_kernel_probe_location_address_hash(
- const struct lttng_kernel_probe_location *location);
-
-static
-unsigned long lttng_kernel_probe_location_symbol_hash(
- const struct lttng_kernel_probe_location *location);
-
-static
-enum lttng_error_code lttng_kernel_probe_location_address_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer);
-
-static
-enum lttng_error_code lttng_kernel_probe_location_symbol_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer);
-
-enum lttng_kernel_probe_location_type lttng_kernel_probe_location_get_type(
- const struct lttng_kernel_probe_location *location)
+static int
+lttng_kernel_probe_location_address_serialize(const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload);
+
+static int
+lttng_kernel_probe_location_symbol_serialize(const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload);
+
+static bool
+lttng_kernel_probe_location_address_is_equal(const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b);
+
+static bool
+lttng_kernel_probe_location_symbol_is_equal(const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b);
+
+static unsigned long
+lttng_kernel_probe_location_address_hash(const struct lttng_kernel_probe_location *location);
+
+static unsigned long
+lttng_kernel_probe_location_symbol_hash(const struct lttng_kernel_probe_location *location);
+
+static enum lttng_error_code
+lttng_kernel_probe_location_address_mi_serialize(const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
+static enum lttng_error_code
+lttng_kernel_probe_location_symbol_mi_serialize(const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
+enum lttng_kernel_probe_location_type
+lttng_kernel_probe_location_get_type(const struct lttng_kernel_probe_location *location)
{
- return location ? location->type :
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_UNKNOWN;
+ return location ? location->type : LTTNG_KERNEL_PROBE_LOCATION_TYPE_UNKNOWN;
}
-static
-void lttng_kernel_probe_location_address_destroy(
- struct lttng_kernel_probe_location *location)
+static void
+lttng_kernel_probe_location_address_destroy(struct lttng_kernel_probe_location *location)
{
LTTNG_ASSERT(location);
free(location);
}
-static
-void lttng_kernel_probe_location_symbol_destroy(
- struct lttng_kernel_probe_location *location)
+static void lttng_kernel_probe_location_symbol_destroy(struct lttng_kernel_probe_location *location)
{
struct lttng_kernel_probe_location_symbol *location_symbol = NULL;
LTTNG_ASSERT(location);
- location_symbol = lttng::utils::container_of(location,
- <tng_kernel_probe_location_symbol::parent);
+ location_symbol =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_symbol::parent);
LTTNG_ASSERT(location_symbol);
free(location);
}
-void lttng_kernel_probe_location_destroy(
- struct lttng_kernel_probe_location *location)
+void lttng_kernel_probe_location_destroy(struct lttng_kernel_probe_location *location)
{
if (!location) {
return;
}
}
-struct lttng_kernel_probe_location *
-lttng_kernel_probe_location_address_create(uint64_t address)
+struct lttng_kernel_probe_location *lttng_kernel_probe_location_address_create(uint64_t address)
{
struct lttng_kernel_probe_location *ret = NULL;
struct lttng_kernel_probe_location_address *location;
}
struct lttng_kernel_probe_location *
-lttng_kernel_probe_location_symbol_create(const char *symbol_name,
- uint64_t offset)
+lttng_kernel_probe_location_symbol_create(const char *symbol_name, uint64_t offset)
{
char *symbol_name_copy = NULL;
struct lttng_kernel_probe_location *ret = NULL;
}
enum lttng_kernel_probe_location_status
-lttng_kernel_probe_location_address_get_address(
- const struct lttng_kernel_probe_location *location,
- uint64_t *offset)
+lttng_kernel_probe_location_address_get_address(const struct lttng_kernel_probe_location *location,
+ uint64_t *offset)
{
- enum lttng_kernel_probe_location_status ret =
- LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK;
+ enum lttng_kernel_probe_location_status ret = LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK;
struct lttng_kernel_probe_location_address *address_location;
LTTNG_ASSERT(offset);
- if (!location || lttng_kernel_probe_location_get_type(location) !=
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS) {
+ if (!location ||
+ lttng_kernel_probe_location_get_type(location) !=
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
ret = LTTNG_KERNEL_PROBE_LOCATION_STATUS_INVALID;
goto end;
}
- address_location = lttng::utils::container_of(location,
- <tng_kernel_probe_location_address::parent);
+ address_location =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_address::parent);
*offset = address_location->address;
end:
return ret;
}
-const char *lttng_kernel_probe_location_symbol_get_name(
- const struct lttng_kernel_probe_location *location)
+const char *
+lttng_kernel_probe_location_symbol_get_name(const struct lttng_kernel_probe_location *location)
{
const char *ret = NULL;
struct lttng_kernel_probe_location_symbol *symbol_location;
- if (!location || lttng_kernel_probe_location_get_type(location) !=
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET) {
+ if (!location ||
+ lttng_kernel_probe_location_get_type(location) !=
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- symbol_location = lttng::utils::container_of(location,
- <tng_kernel_probe_location_symbol::parent);
+ symbol_location =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_symbol::parent);
ret = symbol_location->symbol_name;
end:
return ret;
}
enum lttng_kernel_probe_location_status
-lttng_kernel_probe_location_symbol_get_offset(
- const struct lttng_kernel_probe_location *location,
- uint64_t *offset)
+lttng_kernel_probe_location_symbol_get_offset(const struct lttng_kernel_probe_location *location,
+ uint64_t *offset)
{
- enum lttng_kernel_probe_location_status ret =
- LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK;
+ enum lttng_kernel_probe_location_status ret = LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK;
struct lttng_kernel_probe_location_symbol *symbol_location;
LTTNG_ASSERT(offset);
- if (!location || lttng_kernel_probe_location_get_type(location) !=
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET) {
+ if (!location ||
+ lttng_kernel_probe_location_get_type(location) !=
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
ret = LTTNG_KERNEL_PROBE_LOCATION_STATUS_INVALID;
goto end;
}
- symbol_location = lttng::utils::container_of(location,
- <tng_kernel_probe_location_symbol::parent);
+ symbol_location =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_symbol::parent);
*offset = symbol_location->offset;
end:
return ret;
}
-static
-int lttng_kernel_probe_location_symbol_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload)
+static int
+lttng_kernel_probe_location_symbol_serialize(const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload)
{
int ret;
size_t symbol_name_len;
}
LTTNG_ASSERT(lttng_kernel_probe_location_get_type(location) ==
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
original_payload_size = payload->buffer.size;
- location_symbol = lttng::utils::container_of(location,
- <tng_kernel_probe_location_symbol::parent);
+ location_symbol =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_symbol::parent);
if (!location_symbol->symbol_name) {
ret = -LTTNG_ERR_INVALID;
location_symbol_comm.symbol_len = symbol_name_len + 1;
location_symbol_comm.offset = location_symbol->offset;
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_symbol_comm, sizeof(location_symbol_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_symbol_comm, sizeof(location_symbol_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_symbol->symbol_name,
- location_symbol_comm.symbol_len);
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, location_symbol->symbol_name, location_symbol_comm.symbol_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int lttng_kernel_probe_location_address_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload)
+static int
+lttng_kernel_probe_location_address_serialize(const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload)
{
int ret;
size_t original_payload_size;
LTTNG_ASSERT(location);
LTTNG_ASSERT(lttng_kernel_probe_location_get_type(location) ==
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
original_payload_size = payload->buffer.size;
- location_address = lttng::utils::container_of(location,
- <tng_kernel_probe_location_address::parent);
+ location_address =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_address::parent);
location_address_comm.address = location_address->address;
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_address_comm,
- sizeof(location_address_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_address_comm, sizeof(location_address_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-int lttng_kernel_probe_location_serialize(
- const struct lttng_kernel_probe_location *location,
- struct lttng_payload *payload)
+int lttng_kernel_probe_location_serialize(const struct lttng_kernel_probe_location *location,
+ struct lttng_payload *payload)
{
int ret;
size_t original_payload_size;
original_payload_size = payload->buffer.size;
location_generic_comm.type = (int8_t) location->type;
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_generic_comm,
- sizeof(location_generic_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_generic_comm, sizeof(location_generic_comm));
if (ret) {
goto end;
}
return ret;
}
-static
-int lttng_kernel_probe_location_symbol_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_kernel_probe_location **location)
+static int lttng_kernel_probe_location_symbol_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_kernel_probe_location **location)
{
struct lttng_kernel_probe_location_symbol_comm *location_symbol_comm;
const char *symbol_name_src;
goto end;
}
- location_symbol_comm =
- (typeof(location_symbol_comm)) view->buffer.data;
+ location_symbol_comm = (typeof(location_symbol_comm)) view->buffer.data;
- expected_size = sizeof(*location_symbol_comm) +
- location_symbol_comm->symbol_len;
+ expected_size = sizeof(*location_symbol_comm) + location_symbol_comm->symbol_len;
if (view->buffer.size < expected_size) {
ret = -LTTNG_ERR_INVALID;
symbol_name_src = view->buffer.data + sizeof(*location_symbol_comm);
- if (!lttng_buffer_view_contains_string(&view->buffer, symbol_name_src,
- location_symbol_comm->symbol_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, symbol_name_src, location_symbol_comm->symbol_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- *location = lttng_kernel_probe_location_symbol_create(
- symbol_name_src, location_symbol_comm->offset);
+ *location = lttng_kernel_probe_location_symbol_create(symbol_name_src,
+ location_symbol_comm->offset);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-ssize_t lttng_kernel_probe_location_address_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_kernel_probe_location **location)
+static ssize_t lttng_kernel_probe_location_address_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_kernel_probe_location **location)
{
struct lttng_kernel_probe_location_address_comm *location_address_comm;
ssize_t ret = 0;
goto end;
}
- location_address_comm =
- (typeof(location_address_comm)) view->buffer.data;
+ location_address_comm = (typeof(location_address_comm)) view->buffer.data;
*location = lttng_kernel_probe_location_address_create(location_address_comm->address);
if (!(*location)) {
return ret;
}
-ssize_t lttng_kernel_probe_location_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_kernel_probe_location **location)
+ssize_t
+lttng_kernel_probe_location_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_kernel_probe_location **location)
{
enum lttng_kernel_probe_location_type type;
ssize_t consumed = 0;
ssize_t ret;
const struct lttng_kernel_probe_location_comm *probe_location_comm;
const struct lttng_payload_view probe_location_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*probe_location_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*probe_location_comm));
LTTNG_ASSERT(view);
LTTNG_ASSERT(location);
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_kernel_probe_location_symbol_create_from_payload(
- &location_view, location);
+ ret = lttng_kernel_probe_location_symbol_create_from_payload(&location_view,
+ location);
break;
}
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_kernel_probe_location_address_create_from_payload(
- &location_view, location);
+ ret = lttng_kernel_probe_location_address_create_from_payload(&location_view,
+ location);
break;
}
default:
return ret;
}
-static
-unsigned long lttng_kernel_probe_location_address_hash(
- const struct lttng_kernel_probe_location *location)
+static unsigned long
+lttng_kernel_probe_location_address_hash(const struct lttng_kernel_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS,
- lttng_ht_seed);
- struct lttng_kernel_probe_location_address *address_location = lttng::utils::container_of(
- location, <tng_kernel_probe_location_address::parent);
+ unsigned long hash =
+ hash_key_ulong((void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS, lttng_ht_seed);
+ struct lttng_kernel_probe_location_address *address_location =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_address::parent);
hash ^= hash_key_u64(&address_location->address, lttng_ht_seed);
return hash;
}
-static
-bool lttng_kernel_probe_location_address_is_equal(
- const struct lttng_kernel_probe_location *_a,
- const struct lttng_kernel_probe_location *_b)
+static bool
+lttng_kernel_probe_location_address_is_equal(const struct lttng_kernel_probe_location *_a,
+ const struct lttng_kernel_probe_location *_b)
{
bool is_equal = false;
struct lttng_kernel_probe_location_address *a, *b;
return is_equal;
}
-static
-unsigned long lttng_kernel_probe_location_symbol_hash(
- const struct lttng_kernel_probe_location *location)
+static unsigned long
+lttng_kernel_probe_location_symbol_hash(const struct lttng_kernel_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, lttng_ht_seed);
- struct lttng_kernel_probe_location_symbol *symbol_location = lttng::utils::container_of(
- location, <tng_kernel_probe_location_symbol::parent);
+ unsigned long hash = hash_key_ulong((void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET,
+ lttng_ht_seed);
+ struct lttng_kernel_probe_location_symbol *symbol_location =
+ lttng::utils::container_of(location, <tng_kernel_probe_location_symbol::parent);
hash ^= hash_key_str(symbol_location->symbol_name, lttng_ht_seed);
hash ^= hash_key_u64(&symbol_location->offset, lttng_ht_seed);
return hash;
}
-static
-bool lttng_kernel_probe_location_symbol_is_equal(
- const struct lttng_kernel_probe_location *_a,
- const struct lttng_kernel_probe_location *_b)
+static bool
+lttng_kernel_probe_location_symbol_is_equal(const struct lttng_kernel_probe_location *_a,
+ const struct lttng_kernel_probe_location *_b)
{
bool is_equal = false;
struct lttng_kernel_probe_location_symbol *a, *b;
- a = lttng::utils::container_of(_a,
- <tng_kernel_probe_location_symbol::parent);
- b = lttng::utils::container_of(_b,
- <tng_kernel_probe_location_symbol::parent);
+ a = lttng::utils::container_of(_a, <tng_kernel_probe_location_symbol::parent);
+ b = lttng::utils::container_of(_b, <tng_kernel_probe_location_symbol::parent);
LTTNG_ASSERT(a->symbol_name);
LTTNG_ASSERT(b->symbol_name);
return is_equal;
}
-bool lttng_kernel_probe_location_is_equal(
- const struct lttng_kernel_probe_location *a,
- const struct lttng_kernel_probe_location *b)
+bool lttng_kernel_probe_location_is_equal(const struct lttng_kernel_probe_location *a,
+ const struct lttng_kernel_probe_location *b)
{
bool is_equal = false;
}
static struct lttng_kernel_probe_location *
-lttng_kernel_probe_location_symbol_copy(
- const struct lttng_kernel_probe_location *location)
+lttng_kernel_probe_location_symbol_copy(const struct lttng_kernel_probe_location *location)
{
struct lttng_kernel_probe_location *new_location = NULL;
enum lttng_kernel_probe_location_status status;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
- /* Get probe location offset */
+ /* Get probe location offset */
status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
if (status != LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK) {
ERR("Get kernel probe location offset failed.");
}
/* Create the probe_location */
- new_location = lttng_kernel_probe_location_symbol_create(
- symbol_name, offset);
+ new_location = lttng_kernel_probe_location_symbol_create(symbol_name, offset);
goto end;
return new_location;
}
static struct lttng_kernel_probe_location *
-lttng_kernel_probe_location_address_copy(
- const struct lttng_kernel_probe_location *location)
+lttng_kernel_probe_location_address_copy(const struct lttng_kernel_probe_location *location)
{
struct lttng_kernel_probe_location *new_location = NULL;
enum lttng_kernel_probe_location_status status;
return new_location;
}
-struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy(
- const struct lttng_kernel_probe_location *location)
+struct lttng_kernel_probe_location *
+lttng_kernel_probe_location_copy(const struct lttng_kernel_probe_location *location)
{
struct lttng_kernel_probe_location *new_location = NULL;
enum lttng_kernel_probe_location_type type;
type = lttng_kernel_probe_location_get_type(location);
switch (type) {
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS:
- new_location =
- lttng_kernel_probe_location_address_copy(location);
+ new_location = lttng_kernel_probe_location_address_copy(location);
if (!new_location) {
goto err;
}
break;
case LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET:
- new_location =
- lttng_kernel_probe_location_symbol_copy(location);
+ new_location = lttng_kernel_probe_location_symbol_copy(location);
if (!new_location) {
goto err;
}
return new_location;
}
-unsigned long lttng_kernel_probe_location_hash(
- const struct lttng_kernel_probe_location *location)
+unsigned long lttng_kernel_probe_location_hash(const struct lttng_kernel_probe_location *location)
{
return location->hash(location);
}
-static
-enum lttng_error_code lttng_kernel_probe_location_address_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_kernel_probe_location_address_mi_serialize(const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
- status = lttng_kernel_probe_location_address_get_address(
- location, &address);
+ status = lttng_kernel_probe_location_address_get_address(location, &address);
LTTNG_ASSERT(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
/* Open kernel probe location address element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_kernel_probe_location_address);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_kernel_probe_location_address);
if (ret) {
goto mi_error;
}
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_kernel_probe_location_address_address,
- address);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_kernel_probe_location_address_address, address);
if (ret) {
goto mi_error;
}
return ret_code;
}
-static
-enum lttng_error_code lttng_kernel_probe_location_symbol_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer)
+static enum lttng_error_code
+lttng_kernel_probe_location_symbol_mi_serialize(const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
- LTTNG_ASSERT(location->type ==
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
+ LTTNG_ASSERT(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
name = lttng_kernel_probe_location_symbol_get_name(location);
LTTNG_ASSERT(name);
- status = lttng_kernel_probe_location_symbol_get_offset(
- location, &offset);
+ status = lttng_kernel_probe_location_symbol_get_offset(location, &offset);
LTTNG_ASSERT(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
/* Open kernel probe location symbol offset element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_kernel_probe_location_symbol_offset);
+ mi_lttng_element_kernel_probe_location_symbol_offset);
if (ret) {
goto mi_error;
}
/* Name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_kernel_probe_location_symbol_offset_name,
- name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_kernel_probe_location_symbol_offset_name, name);
if (ret) {
goto mi_error;
}
/* Offset. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_kernel_probe_location_symbol_offset_offset,
- offset);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_kernel_probe_location_symbol_offset_offset, offset);
if (ret) {
goto mi_error;
}
return ret_code;
}
-enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
- const struct lttng_kernel_probe_location *location,
- struct mi_writer *writer)
+enum lttng_error_code
+lttng_kernel_probe_location_mi_serialize(const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
/* Open kernel probe location element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_kernel_probe_location);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_kernel_probe_location);
if (ret) {
goto mi_error;
}
*
*/
-#include <lttng/location-internal.hpp>
+#include <common/error.hpp>
#include <common/macros.hpp>
+
+#include <lttng/location-internal.hpp>
+
#include <stdlib.h>
-#include <common/error.hpp>
-static
-struct lttng_trace_archive_location *lttng_trace_archive_location_create(
- enum lttng_trace_archive_location_type type)
+static struct lttng_trace_archive_location *
+lttng_trace_archive_location_create(enum lttng_trace_archive_location_type type)
{
struct lttng_trace_archive_location *location;
return location;
}
-static
-void trace_archive_location_destroy_ref(struct urcu_ref *ref)
+static void trace_archive_location_destroy_ref(struct urcu_ref *ref)
{
struct lttng_trace_archive_location *location =
- lttng::utils::container_of(ref, <tng_trace_archive_location::ref);
+ lttng::utils::container_of(ref, <tng_trace_archive_location::ref);
switch (location->type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
urcu_ref_put(&location->ref, trace_archive_location_destroy_ref);
}
-struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(
- const char *absolute_path)
+struct lttng_trace_archive_location *
+lttng_trace_archive_location_local_create(const char *absolute_path)
{
struct lttng_trace_archive_location *location = NULL;
goto end;
}
- location = lttng_trace_archive_location_create(
- LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL);
+ location = lttng_trace_archive_location_create(LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL);
if (!location) {
goto end;
}
}
struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
- const char *host,
- enum lttng_trace_archive_location_relay_protocol_type protocol,
- uint16_t control_port, uint16_t data_port,
- const char *relative_path)
+ const char *host,
+ enum lttng_trace_archive_location_relay_protocol_type protocol,
+ uint16_t control_port,
+ uint16_t data_port,
+ const char *relative_path)
{
struct lttng_trace_archive_location *location = NULL;
goto end;
}
- location = lttng_trace_archive_location_create(
- LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY);
+ location = lttng_trace_archive_location_create(LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY);
if (!location) {
goto end;
}
return NULL;
}
-ssize_t lttng_trace_archive_location_create_from_buffer(
- const struct lttng_buffer_view *view,
- struct lttng_trace_archive_location **location)
+ssize_t
+lttng_trace_archive_location_create_from_buffer(const struct lttng_buffer_view *view,
+ struct lttng_trace_archive_location **location)
{
size_t offset = 0;
const struct lttng_trace_archive_location_comm *location_comm;
struct lttng_buffer_view location_comm_view;
- location_comm_view = lttng_buffer_view_from_view(view, 0,
- sizeof(*location_comm));
+ location_comm_view = lttng_buffer_view_from_view(view, 0, sizeof(*location_comm));
if (!lttng_buffer_view_is_valid(&location_comm_view)) {
goto error;
}
switch ((enum lttng_trace_archive_location_type) location_comm->type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
{
- const struct lttng_buffer_view absolute_path_view =
- lttng_buffer_view_from_view(view, offset,
- location_comm->types.local.absolute_path_len);
+ const struct lttng_buffer_view absolute_path_view = lttng_buffer_view_from_view(
+ view, offset, location_comm->types.local.absolute_path_len);
if (!lttng_buffer_view_is_valid(&absolute_path_view)) {
goto error;
}
offset += absolute_path_view.size;
- *location = lttng_trace_archive_location_local_create(
- absolute_path_view.data);
+ *location = lttng_trace_archive_location_local_create(absolute_path_view.data);
if (!*location) {
goto error;
}
}
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY:
{
- const struct lttng_buffer_view hostname_view =
- lttng_buffer_view_from_view(view, offset,
- location_comm->types.relay.hostname_len);
+ const struct lttng_buffer_view hostname_view = lttng_buffer_view_from_view(
+ view, offset, location_comm->types.relay.hostname_len);
const struct lttng_buffer_view relative_path_view =
- lttng_buffer_view_from_view(view,
- offset + hostname_view.size,
- location_comm->types.relay.relative_path_len);
+ lttng_buffer_view_from_view(view,
+ offset + hostname_view.size,
+ location_comm->types.relay.relative_path_len);
if (!lttng_buffer_view_is_valid(&hostname_view) ||
- !lttng_buffer_view_is_valid(
- &relative_path_view)) {
+ !lttng_buffer_view_is_valid(&relative_path_view)) {
goto error;
}
offset += hostname_view.size + relative_path_view.size;
*location = lttng_trace_archive_location_relay_create(
- hostname_view.data,
- (enum lttng_trace_archive_location_relay_protocol_type) location_comm->types.relay.protocol,
- location_comm->types.relay.ports.control,
- location_comm->types.relay.ports.data,
- relative_path_view.data);
+ hostname_view.data,
+ (enum lttng_trace_archive_location_relay_protocol_type)
+ location_comm->types.relay.protocol,
+ location_comm->types.relay.ports.control,
+ location_comm->types.relay.ports.data,
+ relative_path_view.data);
if (!*location) {
goto error;
}
return -1;
}
-ssize_t lttng_trace_archive_location_serialize(
- const struct lttng_trace_archive_location *location,
- struct lttng_dynamic_buffer *buffer)
+ssize_t lttng_trace_archive_location_serialize(const struct lttng_trace_archive_location *location,
+ struct lttng_dynamic_buffer *buffer)
{
int ret;
struct lttng_trace_archive_location_comm location_comm;
switch (location->type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
location_comm.types.local.absolute_path_len =
- strlen(location->types.local.absolute_path) + 1;
+ strlen(location->types.local.absolute_path) + 1;
break;
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY:
- location_comm.types.relay.hostname_len =
- strlen(location->types.relay.host) + 1;
- location_comm.types.relay.protocol =
- (int8_t) location->types.relay.protocol;
- location_comm.types.relay.ports.control =
- location->types.relay.ports.control;
- location_comm.types.relay.ports.data =
- location->types.relay.ports.data;
+ location_comm.types.relay.hostname_len = strlen(location->types.relay.host) + 1;
+ location_comm.types.relay.protocol = (int8_t) location->types.relay.protocol;
+ location_comm.types.relay.ports.control = location->types.relay.ports.control;
+ location_comm.types.relay.ports.data = location->types.relay.ports.data;
location_comm.types.relay.relative_path_len =
- strlen(location->types.relay.relative_path) + 1;
+ strlen(location->types.relay.relative_path) + 1;
break;
default:
abort();
}
- ret = lttng_dynamic_buffer_append(buffer, &location_comm,
- sizeof(location_comm));
+ ret = lttng_dynamic_buffer_append(buffer, &location_comm, sizeof(location_comm));
if (ret) {
goto error;
}
switch (location->type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
ret = lttng_dynamic_buffer_append(buffer,
- location->types.local.absolute_path,
- location_comm.types.local.absolute_path_len);
+ location->types.local.absolute_path,
+ location_comm.types.local.absolute_path_len);
if (ret) {
goto error;
}
break;
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY:
- ret = lttng_dynamic_buffer_append(buffer,
- location->types.relay.host,
- location_comm.types.relay.hostname_len);
+ ret = lttng_dynamic_buffer_append(
+ buffer, location->types.relay.host, location_comm.types.relay.hostname_len);
if (ret) {
goto error;
}
ret = lttng_dynamic_buffer_append(buffer,
- location->types.relay.relative_path,
- location_comm.types.relay.relative_path_len);
+ location->types.relay.relative_path,
+ location_comm.types.relay.relative_path_len);
if (ret) {
goto error;
}
return -1;
}
-enum lttng_trace_archive_location_type lttng_trace_archive_location_get_type(
- const struct lttng_trace_archive_location *location)
+enum lttng_trace_archive_location_type
+lttng_trace_archive_location_get_type(const struct lttng_trace_archive_location *location)
{
enum lttng_trace_archive_location_type type;
return type;
}
-enum lttng_trace_archive_location_status
-lttng_trace_archive_location_local_get_absolute_path(
- const struct lttng_trace_archive_location *location,
- const char **absolute_path)
+enum lttng_trace_archive_location_status lttng_trace_archive_location_local_get_absolute_path(
+ const struct lttng_trace_archive_location *location, const char **absolute_path)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
if (!location || !absolute_path ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL) {
+ location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
}
enum lttng_trace_archive_location_status
-lttng_trace_archive_location_relay_get_host(
- const struct lttng_trace_archive_location *location,
- const char **relay_host)
+lttng_trace_archive_location_relay_get_host(const struct lttng_trace_archive_location *location,
+ const char **relay_host)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
- if (!location || !relay_host ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
+ if (!location || !relay_host || location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_trace_archive_location_status
-lttng_trace_archive_location_relay_get_relative_path(
- const struct lttng_trace_archive_location *location,
- const char **relative_path)
+enum lttng_trace_archive_location_status lttng_trace_archive_location_relay_get_relative_path(
+ const struct lttng_trace_archive_location *location, const char **relative_path)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
if (!location || !relative_path ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
+ location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_trace_archive_location_status
-lttng_trace_archive_location_relay_get_control_port(
- const struct lttng_trace_archive_location *location,
- uint16_t *control_port)
+enum lttng_trace_archive_location_status lttng_trace_archive_location_relay_get_control_port(
+ const struct lttng_trace_archive_location *location, uint16_t *control_port)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
if (!location || !control_port ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
+ location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_trace_archive_location_status
-lttng_trace_archive_location_relay_get_data_port(
- const struct lttng_trace_archive_location *location,
- uint16_t *data_port)
+enum lttng_trace_archive_location_status lttng_trace_archive_location_relay_get_data_port(
+ const struct lttng_trace_archive_location *location, uint16_t *data_port)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
- if (!location || !data_port ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
+ if (!location || !data_port || location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
return status;
}
-enum lttng_trace_archive_location_status
-lttng_trace_archive_location_relay_get_protocol_type(
- const struct lttng_trace_archive_location *location,
- enum lttng_trace_archive_location_relay_protocol_type *protocol)
+enum lttng_trace_archive_location_status lttng_trace_archive_location_relay_get_protocol_type(
+ const struct lttng_trace_archive_location *location,
+ enum lttng_trace_archive_location_relay_protocol_type *protocol)
{
- enum lttng_trace_archive_location_status status =
- LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
+ enum lttng_trace_archive_location_status status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK;
- if (!location || !protocol ||
- location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
+ if (!location || !protocol || location->type != LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY) {
status = LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_INVALID;
goto end;
}
#include <common/hashtable/utils.hpp>
#include <common/macros.hpp>
#include <common/mi-lttng.hpp>
+
#include <lttng/log-level-rule-internal.hpp>
#include <lttng/log-level-rule.h>
+
#include <stdbool.h>
#include <stdlib.h>
static bool is_log_level_rule_exactly_type(const struct lttng_log_level_rule *rule)
{
- enum lttng_log_level_rule_type type =
- lttng_log_level_rule_get_type(rule);
+ enum lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule);
return type == LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY;
}
static bool is_log_level_rule_at_least_as_severe_type(const struct lttng_log_level_rule *rule)
{
-
- enum lttng_log_level_rule_type type =
- lttng_log_level_rule_get_type(rule);
+ enum lttng_log_level_rule_type type = lttng_log_level_rule_get_type(rule);
return type == LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS;
}
-enum lttng_log_level_rule_type lttng_log_level_rule_get_type(
- const struct lttng_log_level_rule *rule)
+enum lttng_log_level_rule_type
+lttng_log_level_rule_get_type(const struct lttng_log_level_rule *rule)
{
return rule ? rule->type : LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN;
}
-struct lttng_log_level_rule *lttng_log_level_rule_exactly_create(
- int level)
+struct lttng_log_level_rule *lttng_log_level_rule_exactly_create(int level)
{
struct lttng_log_level_rule *rule = NULL;
return rule;
}
-enum lttng_log_level_rule_status lttng_log_level_rule_exactly_get_level(
- const struct lttng_log_level_rule *rule, int *level)
+enum lttng_log_level_rule_status
+lttng_log_level_rule_exactly_get_level(const struct lttng_log_level_rule *rule, int *level)
{
- enum lttng_log_level_rule_status status =
- LTTNG_LOG_LEVEL_RULE_STATUS_OK;
+ enum lttng_log_level_rule_status status = LTTNG_LOG_LEVEL_RULE_STATUS_OK;
if (!rule || !level || !is_log_level_rule_exactly_type(rule)) {
status = LTTNG_LOG_LEVEL_RULE_STATUS_INVALID;
return status;
}
-struct lttng_log_level_rule *
-lttng_log_level_rule_at_least_as_severe_as_create(int level)
+struct lttng_log_level_rule *lttng_log_level_rule_at_least_as_severe_as_create(int level)
{
struct lttng_log_level_rule *rule = NULL;
}
enum lttng_log_level_rule_status
-lttng_log_level_rule_at_least_as_severe_as_get_level(
- const struct lttng_log_level_rule *rule, int *level)
+lttng_log_level_rule_at_least_as_severe_as_get_level(const struct lttng_log_level_rule *rule,
+ int *level)
{
enum lttng_log_level_rule_status status = LTTNG_LOG_LEVEL_RULE_STATUS_OK;
- if (!rule || !level ||
- !is_log_level_rule_at_least_as_severe_type(rule)) {
+ if (!rule || !level || !is_log_level_rule_at_least_as_severe_type(rule)) {
status = LTTNG_LOG_LEVEL_RULE_STATUS_INVALID;
goto end;
}
free(log_level_rule);
}
-ssize_t lttng_log_level_rule_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_log_level_rule **_rule)
+ssize_t lttng_log_level_rule_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_log_level_rule **_rule)
{
ssize_t ret;
size_t offset = 0;
struct lttng_log_level_rule *rule = NULL;
const struct lttng_log_level_rule_comm *comm =
- (const struct lttng_log_level_rule_comm *)
- view->buffer.data;
+ (const struct lttng_log_level_rule_comm *) view->buffer.data;
offset += sizeof(*comm);
rule = lttng_log_level_rule_exactly_create((int) comm->level);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
- rule = lttng_log_level_rule_at_least_as_severe_as_create(
- (int) comm->level);
+ rule = lttng_log_level_rule_at_least_as_severe_as_create((int) comm->level);
break;
default:
abort();
}
int lttng_log_level_rule_serialize(const struct lttng_log_level_rule *rule,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_log_level_rule_comm comm;
-
if (!rule) {
ret = 0;
goto end;
comm.level = (int32_t) rule->level;
DBG("Serializing log level rule of type %d", rule->type);
- ret = lttng_dynamic_buffer_append(&payload->buffer, &comm,
- sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
goto end;
}
}
bool lttng_log_level_rule_is_equal(const struct lttng_log_level_rule *a,
- const struct lttng_log_level_rule *b)
+ const struct lttng_log_level_rule *b)
{
bool is_equal = false;
return is_equal;
}
-struct lttng_log_level_rule *lttng_log_level_rule_copy(
- const struct lttng_log_level_rule *source)
+struct lttng_log_level_rule *lttng_log_level_rule_copy(const struct lttng_log_level_rule *source)
{
struct lttng_log_level_rule *copy = NULL;
return copy;
}
-void lttng_log_level_rule_to_loglevel(
- const struct lttng_log_level_rule *log_level_rule,
- enum lttng_loglevel_type *loglevel_type,
- int *loglevel_value)
+void lttng_log_level_rule_to_loglevel(const struct lttng_log_level_rule *log_level_rule,
+ enum lttng_loglevel_type *loglevel_type,
+ int *loglevel_value)
{
LTTNG_ASSERT(log_level_rule);
*loglevel_value = log_level_rule->level;
}
-unsigned long lttng_log_level_rule_hash(
- const struct lttng_log_level_rule *log_level_rule)
+unsigned long lttng_log_level_rule_hash(const struct lttng_log_level_rule *log_level_rule)
{
unsigned long hash;
enum lttng_log_level_rule_status llr_status;
switch (type) {
case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
- llr_status = lttng_log_level_rule_exactly_get_level(
- log_level_rule, &log_level_value);
+ llr_status =
+ lttng_log_level_rule_exactly_get_level(log_level_rule, &log_level_value);
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
- llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- log_level_rule, &log_level_value);
+ llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(log_level_rule,
+ &log_level_value);
break;
default:
abort();
hash = hash_key_ulong((void *) (unsigned long) type, lttng_ht_seed);
- hash ^= hash_key_ulong((void *) (unsigned long) log_level_value,
- lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) (unsigned long) log_level_value, lttng_ht_seed);
return hash;
}
-enum lttng_error_code lttng_log_level_rule_mi_serialize(
- const struct lttng_log_level_rule *rule,
- struct mi_writer *writer)
+enum lttng_error_code lttng_log_level_rule_mi_serialize(const struct lttng_log_level_rule *rule,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
break;
case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
element_str = mi_lttng_element_log_level_rule_at_least_as_severe_as;
- status = lttng_log_level_rule_at_least_as_severe_as_get_level(
- rule, &level);
+ status = lttng_log_level_rule_at_least_as_severe_as_get_level(rule, &level);
break;
default:
abort();
LTTNG_ASSERT(status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
/* Open log level rule element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_log_level_rule);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_log_level_rule);
if (ret) {
goto mi_error;
}
/* Level. */
ret = mi_lttng_writer_write_element_signed_int(
- writer, mi_lttng_element_log_level_rule_level, level);
+ writer, mi_lttng_element_log_level_rule_level, level);
if (ret) {
goto mi_error;
}
*
*/
-#include <algorithm>
#include <common/compat/endian.hpp>
#include <common/error.hpp>
#include <common/lttng-elf.hpp>
#include <common/macros.hpp>
#include <common/readwrite.hpp>
+
+#include <algorithm>
+#include <elf.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
-#include <elf.h>
-
-#define BUF_LEN 4096
-#define TEXT_SECTION_NAME ".text"
-#define SYMBOL_TAB_SECTION_NAME ".symtab"
-#define STRING_TAB_SECTION_NAME ".strtab"
+#define BUF_LEN 4096
+#define TEXT_SECTION_NAME ".text"
+#define SYMBOL_TAB_SECTION_NAME ".symtab"
+#define STRING_TAB_SECTION_NAME ".strtab"
#define DYNAMIC_SYMBOL_TAB_SECTION_NAME ".dynsym"
#define DYNAMIC_STRING_TAB_SECTION_NAME ".dynstr"
-#define NOTE_STAPSDT_SECTION_NAME ".note.stapsdt"
-#define NOTE_STAPSDT_NAME "stapsdt"
-#define NOTE_STAPSDT_TYPE 3
-#define MAX_SECTION_DATA_SIZE 512 * 1024 * 1024
+#define NOTE_STAPSDT_SECTION_NAME ".note.stapsdt"
+#define NOTE_STAPSDT_NAME "stapsdt"
+#define NOTE_STAPSDT_TYPE 3
+#define MAX_SECTION_DATA_SIZE 512 * 1024 * 1024
#if BYTE_ORDER == LITTLE_ENDIAN
#define NATIVE_ELF_ENDIANNESS ELFDATA2LSB
#define NATIVE_ELF_ENDIANNESS ELFDATA2MSB
#endif
-#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t)x) + 3) & ~0x03)
-
-#define bswap(x) \
- do { \
- switch (sizeof(x)) { \
- case 8: \
- x = be64toh((uint64_t)x); \
- break; \
- case 4: \
- x = be32toh((uint32_t)x); \
- break; \
- case 2: \
- x = be16toh((uint16_t)x); \
- break; \
- case 1: \
- break; \
- default: \
- abort(); \
- } \
+#define next_4bytes_boundary(x) (typeof(x)) ((((uint64_t) x) + 3) & ~0x03)
+
+#define bswap(x) \
+ do { \
+ switch (sizeof(x)) { \
+ case 8: \
+ x = be64toh((uint64_t) x); \
+ break; \
+ case 4: \
+ x = be32toh((uint32_t) x); \
+ break; \
+ case 2: \
+ x = be16toh((uint16_t) x); \
+ break; \
+ case 1: \
+ break; \
+ default: \
+ abort(); \
+ } \
} while (0)
-#define bswap_shdr(shdr) \
- do { \
- bswap((shdr).sh_name); \
- bswap((shdr).sh_type); \
- bswap((shdr).sh_flags); \
- bswap((shdr).sh_addr); \
+#define bswap_shdr(shdr) \
+ do { \
+ bswap((shdr).sh_name); \
+ bswap((shdr).sh_type); \
+ bswap((shdr).sh_flags); \
+ bswap((shdr).sh_addr); \
bswap((shdr).sh_offset); \
- bswap((shdr).sh_size); \
- bswap((shdr).sh_link); \
- bswap((shdr).sh_info); \
+ bswap((shdr).sh_size); \
+ bswap((shdr).sh_link); \
+ bswap((shdr).sh_info); \
bswap((shdr).sh_addralign); \
bswap((shdr).sh_entsize); \
} while (0)
-#define bswap_ehdr(ehdr) \
- do { \
- bswap((ehdr).e_type); \
- bswap((ehdr).e_machine); \
- bswap((ehdr).e_version); \
- bswap((ehdr).e_entry); \
- bswap((ehdr).e_phoff); \
- bswap((ehdr).e_shoff); \
- bswap((ehdr).e_flags); \
- bswap((ehdr).e_ehsize); \
- bswap((ehdr).e_phentsize); \
- bswap((ehdr).e_phnum); \
- bswap((ehdr).e_shentsize); \
- bswap((ehdr).e_shnum); \
- bswap((ehdr).e_shstrndx); \
+#define bswap_ehdr(ehdr) \
+ do { \
+ bswap((ehdr).e_type); \
+ bswap((ehdr).e_machine); \
+ bswap((ehdr).e_version); \
+ bswap((ehdr).e_entry); \
+ bswap((ehdr).e_phoff); \
+ bswap((ehdr).e_shoff); \
+ bswap((ehdr).e_flags); \
+ bswap((ehdr).e_ehsize); \
+ bswap((ehdr).e_phentsize); \
+ bswap((ehdr).e_phnum); \
+ bswap((ehdr).e_shentsize); \
+ bswap((ehdr).e_shnum); \
+ bswap((ehdr).e_shstrndx); \
} while (0)
-#define copy_shdr(src_shdr, dst_shdr) \
- do { \
- (dst_shdr).sh_name = (src_shdr).sh_name; \
- (dst_shdr).sh_type = (src_shdr).sh_type; \
- (dst_shdr).sh_flags = (src_shdr).sh_flags; \
- (dst_shdr).sh_addr = (src_shdr).sh_addr; \
- (dst_shdr).sh_offset = (src_shdr).sh_offset; \
- (dst_shdr).sh_size = (src_shdr).sh_size; \
- (dst_shdr).sh_link = (src_shdr).sh_link; \
- (dst_shdr).sh_info = (src_shdr).sh_info; \
- (dst_shdr).sh_addralign = (src_shdr).sh_addralign; \
- (dst_shdr).sh_entsize = (src_shdr).sh_entsize; \
+#define copy_shdr(src_shdr, dst_shdr) \
+ do { \
+ (dst_shdr).sh_name = (src_shdr).sh_name; \
+ (dst_shdr).sh_type = (src_shdr).sh_type; \
+ (dst_shdr).sh_flags = (src_shdr).sh_flags; \
+ (dst_shdr).sh_addr = (src_shdr).sh_addr; \
+ (dst_shdr).sh_offset = (src_shdr).sh_offset; \
+ (dst_shdr).sh_size = (src_shdr).sh_size; \
+ (dst_shdr).sh_link = (src_shdr).sh_link; \
+ (dst_shdr).sh_info = (src_shdr).sh_info; \
+ (dst_shdr).sh_addralign = (src_shdr).sh_addralign; \
+ (dst_shdr).sh_entsize = (src_shdr).sh_entsize; \
} while (0)
-#define copy_ehdr(src_ehdr, dst_ehdr) \
- do { \
- (dst_ehdr).e_type = (src_ehdr).e_type; \
- (dst_ehdr).e_machine = (src_ehdr).e_machine; \
- (dst_ehdr).e_version = (src_ehdr).e_version; \
- (dst_ehdr).e_entry = (src_ehdr).e_entry; \
- (dst_ehdr).e_phoff = (src_ehdr).e_phoff; \
- (dst_ehdr).e_shoff = (src_ehdr).e_shoff; \
- (dst_ehdr).e_flags = (src_ehdr).e_flags; \
- (dst_ehdr).e_ehsize = (src_ehdr).e_ehsize; \
- (dst_ehdr).e_phentsize = (src_ehdr).e_phentsize; \
- (dst_ehdr).e_phnum = (src_ehdr).e_phnum; \
- (dst_ehdr).e_shentsize = (src_ehdr).e_shentsize; \
- (dst_ehdr).e_shnum = (src_ehdr).e_shnum; \
- (dst_ehdr).e_shstrndx = (src_ehdr).e_shstrndx; \
+#define copy_ehdr(src_ehdr, dst_ehdr) \
+ do { \
+ (dst_ehdr).e_type = (src_ehdr).e_type; \
+ (dst_ehdr).e_machine = (src_ehdr).e_machine; \
+ (dst_ehdr).e_version = (src_ehdr).e_version; \
+ (dst_ehdr).e_entry = (src_ehdr).e_entry; \
+ (dst_ehdr).e_phoff = (src_ehdr).e_phoff; \
+ (dst_ehdr).e_shoff = (src_ehdr).e_shoff; \
+ (dst_ehdr).e_flags = (src_ehdr).e_flags; \
+ (dst_ehdr).e_ehsize = (src_ehdr).e_ehsize; \
+ (dst_ehdr).e_phentsize = (src_ehdr).e_phentsize; \
+ (dst_ehdr).e_phnum = (src_ehdr).e_phnum; \
+ (dst_ehdr).e_shentsize = (src_ehdr).e_shentsize; \
+ (dst_ehdr).e_shnum = (src_ehdr).e_shnum; \
+ (dst_ehdr).e_shstrndx = (src_ehdr).e_shstrndx; \
} while (0)
-#define copy_sym(src_sym, dst_sym) \
- do { \
- dst_sym.st_name = src_sym.st_name; \
- dst_sym.st_info = src_sym.st_info; \
- dst_sym.st_other = src_sym.st_other; \
- dst_sym.st_shndx = src_sym.st_shndx; \
- dst_sym.st_value = src_sym.st_value; \
- dst_sym.st_size = src_sym.st_size; \
+#define copy_sym(src_sym, dst_sym) \
+ do { \
+ dst_sym.st_name = src_sym.st_name; \
+ dst_sym.st_info = src_sym.st_info; \
+ dst_sym.st_other = src_sym.st_other; \
+ dst_sym.st_shndx = src_sym.st_shndx; \
+ dst_sym.st_value = src_sym.st_value; \
+ dst_sym.st_size = src_sym.st_size; \
} while (0)
#ifndef ELFCLASSNUM
*/
struct lttng_elf_sym {
uint32_t st_name;
- uint8_t st_info;
- uint8_t st_other;
+ uint8_t st_info;
+ uint8_t st_other;
uint16_t st_shndx;
uint64_t st_value;
uint64_t st_size;
struct lttng_elf_ehdr *ehdr;
};
-static inline
-int is_elf_32_bit(struct lttng_elf *elf)
+static inline int is_elf_32_bit(struct lttng_elf *elf)
{
return elf->bitness == ELFCLASS32;
}
-static inline
-int is_elf_native_endian(struct lttng_elf *elf)
+static inline int is_elf_native_endian(struct lttng_elf *elf)
{
return elf->endianness == NATIVE_ELF_ENDIANNESS;
}
-static
-int populate_section_header(struct lttng_elf * elf, struct lttng_elf_shdr *shdr,
- uint32_t index)
+static int
+populate_section_header(struct lttng_elf *elf, struct lttng_elf_shdr *shdr, uint32_t index)
{
int ret = 0;
off_t offset;
/* Compute the offset of the section in the file */
- offset = (off_t) elf->ehdr->e_shoff
- + (off_t) index * elf->ehdr->e_shentsize;
+ offset = (off_t) elf->ehdr->e_shoff + (off_t) index * elf->ehdr->e_shentsize;
if (lseek(elf->fd, offset, SEEK_SET) < 0) {
PERROR("Error seeking to the beginning of ELF section header");
return ret;
}
-static
-int populate_elf_header(struct lttng_elf *elf)
+static int populate_elf_header(struct lttng_elf *elf)
{
int ret = 0;
*
* 0 is returned on succes, -1 on failure.
*/
-static
-int lttng_elf_get_section_hdr(struct lttng_elf *elf,
- uint16_t index, struct lttng_elf_shdr *out_header)
+static int
+lttng_elf_get_section_hdr(struct lttng_elf *elf, uint16_t index, struct lttng_elf_shdr *out_header)
{
int ret = 0;
*
* If no name is found, NULL is returned.
*/
-static
-char *lttng_elf_get_section_name(struct lttng_elf *elf, off_t offset)
+static char *lttng_elf_get_section_name(struct lttng_elf *elf, off_t offset)
{
char *name = NULL;
- size_t name_length = 0, to_read; /* name_length does not include \0 */
+ size_t name_length = 0, to_read; /* name_length does not include \0 */
if (!elf) {
goto error;
* We found the length of the section name, now seek back to the
* beginning of the name and copy it in the newly allocated buffer.
*/
- name = calloc<char>((name_length + 1)); /* + 1 for \0 */
+ name = calloc<char>((name_length + 1)); /* + 1 for \0 */
if (!name) {
PERROR("Error allocating ELF section name buffer");
goto error;
return NULL;
}
-static
-int lttng_elf_validate_and_populate(struct lttng_elf *elf)
+static int lttng_elf_validate_and_populate(struct lttng_elf *elf)
{
uint8_t version;
uint8_t e_ident[EI_NIDENT];
*
* Return a pointer to the instance on success, NULL on failure.
*/
-static
-struct lttng_elf *lttng_elf_create(int fd)
+static struct lttng_elf *lttng_elf_create(int fd)
{
struct lttng_elf_shdr section_names_shdr;
struct lttng_elf *elf = NULL;
goto error;
}
- ret = lttng_elf_get_section_hdr(
- elf, elf->ehdr->e_shstrndx, §ion_names_shdr);
+ ret = lttng_elf_get_section_hdr(elf, elf->ehdr->e_shstrndx, §ion_names_shdr);
if (ret) {
goto error;
}
/*
* Destroy the given lttng_elf instance.
*/
-static
-void lttng_elf_destroy(struct lttng_elf *elf)
+static void lttng_elf_destroy(struct lttng_elf *elf)
{
if (!elf) {
return;
free(elf);
}
-static
-int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf,
- const char *section_name, struct lttng_elf_shdr *section_hdr)
+static int lttng_elf_get_section_hdr_by_name(struct lttng_elf *elf,
+ const char *section_name,
+ struct lttng_elf_shdr *section_hdr)
{
int i;
char *curr_section_name;
for (i = 0; i < elf->ehdr->e_shnum; ++i) {
bool name_equal;
- int ret = lttng_elf_get_section_hdr(elf, i, section_hdr);
+ int ret = lttng_elf_get_section_hdr(elf, i, section_hdr);
if (ret) {
break;
}
- curr_section_name = lttng_elf_get_section_name(elf,
- section_hdr->sh_name);
+ curr_section_name = lttng_elf_get_section_name(elf, section_hdr->sh_name);
if (!curr_section_name) {
continue;
}
return LTTNG_ERR_ELF_PARSING;
}
-static
-char *lttng_elf_get_section_data(struct lttng_elf *elf,
- struct lttng_elf_shdr *shdr)
+static char *lttng_elf_get_section_data(struct lttng_elf *elf, struct lttng_elf_shdr *shdr)
{
int ret;
off_t section_offset;
}
if (shdr->sh_size > max_alloc_size) {
- ERR("ELF section size exceeds maximal allowed size of %zu bytes",
- max_alloc_size);
+ ERR("ELF section size exceeds maximal allowed size of %zu bytes", max_alloc_size);
goto error;
}
data = calloc<char>(shdr->sh_size);
*
* Returns the offset on success or non-zero in case of failure.
*/
-static
-int lttng_elf_convert_addr_in_text_to_offset(struct lttng_elf *elf_handle,
- size_t addr, uint64_t *offset)
+static int lttng_elf_convert_addr_in_text_to_offset(struct lttng_elf *elf_handle,
+ size_t addr,
+ uint64_t *offset)
{
int ret = 0;
off_t text_section_offset;
}
/* Get a pointer to the .text section header. */
- ret = lttng_elf_get_section_hdr_by_name(elf_handle,
- TEXT_SECTION_NAME, &text_section_hdr);
+ ret = lttng_elf_get_section_hdr_by_name(elf_handle, TEXT_SECTION_NAME, &text_section_hdr);
if (ret) {
DBG("Text section not found in binary.");
ret = LTTNG_ERR_ELF_PARSING;
text_section_offset = text_section_hdr.sh_offset;
text_section_addr_beg = text_section_hdr.sh_addr;
- text_section_addr_end =
- text_section_addr_beg + text_section_hdr.sh_size;
+ text_section_addr_end = text_section_addr_beg + text_section_hdr.sh_size;
/*
* Verify that the address is within the .text section boundaries.
*/
if (addr < text_section_addr_beg || addr > text_section_addr_end) {
DBG("Address found is outside of the .text section addr=0x%zx, "
- ".text section=[0x%jd - 0x%jd].", addr, (intmax_t)text_section_addr_beg,
- (intmax_t)text_section_addr_end);
+ ".text section=[0x%jd - 0x%jd].",
+ addr,
+ (intmax_t) text_section_addr_beg,
+ (intmax_t) text_section_addr_end);
ret = LTTNG_ERR_ELF_PARSING;
goto error;
}
struct lttng_elf_shdr strtab_hdr;
struct lttng_elf *elf = NULL;
- if (!symbol || !offset ) {
+ if (!symbol || !offset) {
ret = LTTNG_ERR_ELF_PARSING;
goto end;
}
* try to get the dynamic symbol table. All symbols in the dynamic
* symbol tab are in the (normal) symbol table if it exists.
*/
- ret = lttng_elf_get_section_hdr_by_name(elf, SYMBOL_TAB_SECTION_NAME,
- &symtab_hdr);
+ ret = lttng_elf_get_section_hdr_by_name(elf, SYMBOL_TAB_SECTION_NAME, &symtab_hdr);
if (ret) {
DBG("Cannot get ELF Symbol Table section. Trying to get ELF Dynamic Symbol Table section.");
/* Get the dynamic symbol table section header. */
- ret = lttng_elf_get_section_hdr_by_name(elf, DYNAMIC_SYMBOL_TAB_SECTION_NAME,
- &symtab_hdr);
+ ret = lttng_elf_get_section_hdr_by_name(
+ elf, DYNAMIC_SYMBOL_TAB_SECTION_NAME, &symtab_hdr);
if (ret) {
DBG("Cannot get ELF Symbol Table nor Dynamic Symbol Table sections.");
ret = LTTNG_ERR_ELF_PARSING;
}
/* Get the string table section header. */
- ret = lttng_elf_get_section_hdr_by_name(elf, string_table_name,
- &strtab_hdr);
+ ret = lttng_elf_get_section_hdr_by_name(elf, string_table_name, &strtab_hdr);
if (ret) {
DBG("Cannot get ELF string table section.");
goto free_symbol_table_data;
* Compare with the search symbol. If there is a match set the address
* output parameter and return success.
*/
- if (strcmp(symbol, curr_sym_str) == 0 ) {
+ if (strcmp(symbol, curr_sym_str) == 0) {
sym_found = 1;
addr = curr_sym.st_value;
break;
goto free_string_table_data;
}
-
free_string_table_data:
free(string_table_data);
free_symbol_table_data:
* the SDT probes are.
* On failure, returns -1.
*/
-int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
- const char *probe_name, uint64_t **offsets, uint32_t *nb_probes)
+int lttng_elf_get_sdt_probe_offsets(int fd,
+ const char *provider_name,
+ const char *probe_name,
+ uint64_t **offsets,
+ uint32_t *nb_probes)
{
int ret = 0, nb_match = 0;
struct lttng_elf_shdr stap_note_section_hdr;
}
/* Get the stap note section header. */
- ret = lttng_elf_get_section_hdr_by_name(elf, NOTE_STAPSDT_SECTION_NAME,
- &stap_note_section_hdr);
+ ret = lttng_elf_get_section_hdr_by_name(
+ elf, NOTE_STAPSDT_SECTION_NAME, &stap_note_section_hdr);
if (ret) {
DBG("Cannot get ELF stap note section.");
goto destroy_elf_error;
}
/* Get the data associated with the stap note section. */
- stap_note_section_data =
- lttng_elf_get_section_data(elf, &stap_note_section_hdr);
+ stap_note_section_data = lttng_elf_get_section_data(elf, &stap_note_section_hdr);
if (stap_note_section_data == NULL) {
DBG("Cannot get ELF stap note section data.");
ret = LTTNG_ERR_ELF_PARSING;
while (1) {
curr_data_ptr = next_note_ptr;
/* Check if we have reached the end of the note section. */
- if (curr_data_ptr >=
- curr_note_section_begin +
- stap_note_section_hdr.sh_size) {
+ if (curr_data_ptr >= curr_note_section_begin + stap_note_section_hdr.sh_size) {
*nb_probes = nb_match;
*offsets = probe_locs;
ret = 0;
break;
}
/* Get name size field. */
- name_size = next_4bytes_boundary(*(uint32_t*) curr_data_ptr);
+ name_size = next_4bytes_boundary(*(uint32_t *) curr_data_ptr);
curr_data_ptr += sizeof(uint32_t);
/* Sanity check; a zero name_size is reserved. */
if (name_size == 0) {
DBG("Invalid name size field in SDT probe descriptions"
- "section.");
+ "section.");
ret = -1;
goto realloc_error;
}
/* Get description size field. */
- desc_size = next_4bytes_boundary(*(uint32_t*) curr_data_ptr);
+ desc_size = next_4bytes_boundary(*(uint32_t *) curr_data_ptr);
curr_data_ptr += sizeof(uint32_t);
/* Get type field. */
* name and the descriptor. To move to the next note, we move
* the pointer according to those values.
*/
- next_note_ptr = next_note_ptr +
- (3 * sizeof(uint32_t)) + desc_size + name_size;
+ next_note_ptr = next_note_ptr + (3 * sizeof(uint32_t)) + desc_size + name_size;
/*
* Move ptr to the end of the name string (we don't need it)
* and go to the next 4 byte alignement.
*/
if (note_type != NOTE_STAPSDT_TYPE ||
- strncmp(curr_data_ptr, NOTE_STAPSDT_NAME, name_size) != 0) {
+ strncmp(curr_data_ptr, NOTE_STAPSDT_NAME, name_size) != 0) {
continue;
}
/* Check if the provider and probe name match */
if (strcmp(provider_name, curr_provider) == 0 &&
- strcmp(probe_name, curr_probe) == 0) {
+ strcmp(probe_name, curr_probe) == 0) {
int new_size;
/*
* Use the virtual address of the probe to compute the offset of
* this probe from the beginning of the executable file.
*/
- ret = lttng_elf_convert_addr_in_text_to_offset(elf,
- curr_probe_location, &curr_probe_offset);
+ ret = lttng_elf_convert_addr_in_text_to_offset(
+ elf, curr_probe_location, &curr_probe_offset);
if (ret) {
DBG("Conversion error in SDT.");
goto realloc_error;
#include "lttng/tracker.h"
#define _LGPL_SOURCE
#include "mi-lttng.hpp"
+
#include <common/config/session-config.hpp>
#include <common/defaults.hpp>
#include <common/tracker.hpp>
+
#include <lttng/channel.h>
#include <lttng/snapshot-internal.hpp>
-
#define MI_SCHEMA_MAJOR_VERSION 4
#define MI_SCHEMA_MINOR_VERSION 1
/* Machine interface namespace URI */
-const char * const mi_lttng_xmlns = "xmlns";
-const char * const mi_lttng_xmlns_xsi = "xmlns:xsi";
-const char * const mi_lttng_w3_schema_uri = "http://www.w3.org/2001/XMLSchema-instance";
-const char * const mi_lttng_schema_location = "xsi:schemaLocation";
-const char * const mi_lttng_schema_location_uri =
- DEFAULT_LTTNG_MI_NAMESPACE " "
- "https://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION)
- "/lttng-mi-" XSTR(MI_SCHEMA_MAJOR_VERSION) "."
- XSTR(MI_SCHEMA_MINOR_VERSION) ".xsd";
-const char * const mi_lttng_schema_version = "schemaVersion";
-const char * const mi_lttng_schema_version_value = XSTR(MI_SCHEMA_MAJOR_VERSION)
- "." XSTR(MI_SCHEMA_MINOR_VERSION);
+const char *const mi_lttng_xmlns = "xmlns";
+const char *const mi_lttng_xmlns_xsi = "xmlns:xsi";
+const char *const mi_lttng_w3_schema_uri = "http://www.w3.org/2001/XMLSchema-instance";
+const char *const mi_lttng_schema_location = "xsi:schemaLocation";
+const char *const mi_lttng_schema_location_uri = DEFAULT_LTTNG_MI_NAMESPACE
+ " "
+ "https://lttng.org/xml/schemas/lttng-mi/" XSTR(MI_SCHEMA_MAJOR_VERSION) "/lttng-mi-" XSTR(
+ MI_SCHEMA_MAJOR_VERSION) "." XSTR(MI_SCHEMA_MINOR_VERSION) ".xsd";
+const char *const mi_lttng_schema_version = "schemaVersion";
+const char *const mi_lttng_schema_version_value =
+ XSTR(MI_SCHEMA_MAJOR_VERSION) "." XSTR(MI_SCHEMA_MINOR_VERSION);
/* Strings related to command */
-const char * const mi_lttng_element_command = "command";
-const char * const mi_lttng_element_command_action = "snapshot_action";
-const char * const mi_lttng_element_command_add_context = "add-context";
+const char *const mi_lttng_element_command = "command";
+const char *const mi_lttng_element_command_action = "snapshot_action";
+const char *const mi_lttng_element_command_add_context = "add-context";
const char *const mi_lttng_element_command_add_trigger = "add-trigger";
-const char * const mi_lttng_element_command_create = "create";
-const char * const mi_lttng_element_command_destroy = "destroy";
-const char * const mi_lttng_element_command_disable_channel = "disable-channel";
-const char * const mi_lttng_element_command_disable_event = "disable-event";
-const char * const mi_lttng_element_command_enable_channels = "enable-channel";
-const char * const mi_lttng_element_command_enable_event = "enable-event";
-const char * const mi_lttng_element_command_list = "list";
+const char *const mi_lttng_element_command_create = "create";
+const char *const mi_lttng_element_command_destroy = "destroy";
+const char *const mi_lttng_element_command_disable_channel = "disable-channel";
+const char *const mi_lttng_element_command_disable_event = "disable-event";
+const char *const mi_lttng_element_command_enable_channels = "enable-channel";
+const char *const mi_lttng_element_command_enable_event = "enable-event";
+const char *const mi_lttng_element_command_list = "list";
const char *const mi_lttng_element_command_list_trigger = "list-trigger";
-const char * const mi_lttng_element_command_load = "load";
-const char * const mi_lttng_element_command_metadata = "metadata";
-const char * const mi_lttng_element_command_metadata_action = "metadata_action";
-const char * const mi_lttng_element_command_regenerate = "regenerate";
-const char * const mi_lttng_element_command_regenerate_action = "regenerate_action";
-const char * const mi_lttng_element_command_name = "name";
-const char * const mi_lttng_element_command_output = "output";
+const char *const mi_lttng_element_command_load = "load";
+const char *const mi_lttng_element_command_metadata = "metadata";
+const char *const mi_lttng_element_command_metadata_action = "metadata_action";
+const char *const mi_lttng_element_command_regenerate = "regenerate";
+const char *const mi_lttng_element_command_regenerate_action = "regenerate_action";
+const char *const mi_lttng_element_command_name = "name";
+const char *const mi_lttng_element_command_output = "output";
const char *const mi_lttng_element_command_remove_trigger = "remove-trigger";
-const char * const mi_lttng_element_command_save = "save";
-const char * const mi_lttng_element_command_set_session = "set-session";
-const char * const mi_lttng_element_command_snapshot = "snapshot";
-const char * const mi_lttng_element_command_snapshot_add = "add_snapshot";
-const char * const mi_lttng_element_command_snapshot_del = "del_snapshot";
-const char * const mi_lttng_element_command_snapshot_list = "list_snapshot";
-const char * const mi_lttng_element_command_snapshot_record = "record_snapshot";
-const char * const mi_lttng_element_command_start = "start";
-const char * const mi_lttng_element_command_stop = "stop";
-const char * const mi_lttng_element_command_success = "success";
-const char * const mi_lttng_element_command_track = "track";
-const char * const mi_lttng_element_command_untrack = "untrack";
-const char * const mi_lttng_element_command_version = "version";
-const char * const mi_lttng_element_command_rotate = "rotate";
-const char * const mi_lttng_element_command_enable_rotation = "enable-rotation";
-const char * const mi_lttng_element_command_disable_rotation = "disable-rotation";
-const char * const mi_lttng_element_command_clear = "clear";
+const char *const mi_lttng_element_command_save = "save";
+const char *const mi_lttng_element_command_set_session = "set-session";
+const char *const mi_lttng_element_command_snapshot = "snapshot";
+const char *const mi_lttng_element_command_snapshot_add = "add_snapshot";
+const char *const mi_lttng_element_command_snapshot_del = "del_snapshot";
+const char *const mi_lttng_element_command_snapshot_list = "list_snapshot";
+const char *const mi_lttng_element_command_snapshot_record = "record_snapshot";
+const char *const mi_lttng_element_command_start = "start";
+const char *const mi_lttng_element_command_stop = "stop";
+const char *const mi_lttng_element_command_success = "success";
+const char *const mi_lttng_element_command_track = "track";
+const char *const mi_lttng_element_command_untrack = "untrack";
+const char *const mi_lttng_element_command_version = "version";
+const char *const mi_lttng_element_command_rotate = "rotate";
+const char *const mi_lttng_element_command_enable_rotation = "enable-rotation";
+const char *const mi_lttng_element_command_disable_rotation = "disable-rotation";
+const char *const mi_lttng_element_command_clear = "clear";
/* Strings related to version command */
-const char * const mi_lttng_element_version = "version";
-const char * const mi_lttng_element_version_commit = "commit";
-const char * const mi_lttng_element_version_description = "description";
-const char * const mi_lttng_element_version_license = "license";
-const char * const mi_lttng_element_version_major = "major";
-const char * const mi_lttng_element_version_minor = "minor";
-const char * const mi_lttng_element_version_patch_level = "patchLevel";
-const char * const mi_lttng_element_version_str = "string";
-const char * const mi_lttng_element_version_web = "url";
+const char *const mi_lttng_element_version = "version";
+const char *const mi_lttng_element_version_commit = "commit";
+const char *const mi_lttng_element_version_description = "description";
+const char *const mi_lttng_element_version_license = "license";
+const char *const mi_lttng_element_version_major = "major";
+const char *const mi_lttng_element_version_minor = "minor";
+const char *const mi_lttng_element_version_patch_level = "patchLevel";
+const char *const mi_lttng_element_version_str = "string";
+const char *const mi_lttng_element_version_web = "url";
/* String related to a lttng_event_field */
-const char * const mi_lttng_element_event_field = "event_field";
-const char * const mi_lttng_element_event_fields = "event_fields";
+const char *const mi_lttng_element_event_field = "event_field";
+const char *const mi_lttng_element_event_fields = "event_fields";
/* String related to lttng_event_perf_counter_ctx */
-const char * const mi_lttng_element_perf_counter_context = "perf";
+const char *const mi_lttng_element_perf_counter_context = "perf";
/* Strings related to pid */
-const char * const mi_lttng_element_pid_id = "id";
+const char *const mi_lttng_element_pid_id = "id";
/* Strings related to save command */
-const char * const mi_lttng_element_save = "save";
+const char *const mi_lttng_element_save = "save";
/* Strings related to load command */
-const char * const mi_lttng_element_load = "load";
-const char * const mi_lttng_element_load_overrides = "overrides";
-const char * const mi_lttng_element_load_override_url = "url";
+const char *const mi_lttng_element_load = "load";
+const char *const mi_lttng_element_load_overrides = "overrides";
+const char *const mi_lttng_element_load_override_url = "url";
/* General elements of mi_lttng */
-const char * const mi_lttng_element_empty = "";
-const char * const mi_lttng_element_id = "id";
-const char * const mi_lttng_element_nowrite = "nowrite";
-const char * const mi_lttng_element_success = "success";
-const char * const mi_lttng_element_type_enum = "ENUM";
-const char * const mi_lttng_element_type_float = "FLOAT";
-const char * const mi_lttng_element_type_integer = "INTEGER";
-const char * const mi_lttng_element_type_other = "OTHER";
-const char * const mi_lttng_element_type_string = "STRING";
+const char *const mi_lttng_element_empty = "";
+const char *const mi_lttng_element_id = "id";
+const char *const mi_lttng_element_nowrite = "nowrite";
+const char *const mi_lttng_element_success = "success";
+const char *const mi_lttng_element_type_enum = "ENUM";
+const char *const mi_lttng_element_type_float = "FLOAT";
+const char *const mi_lttng_element_type_integer = "INTEGER";
+const char *const mi_lttng_element_type_other = "OTHER";
+const char *const mi_lttng_element_type_string = "STRING";
/* String related to loglevel */
-const char * const mi_lttng_loglevel_str_alert = "TRACE_ALERT";
-const char * const mi_lttng_loglevel_str_crit = "TRACE_CRIT";
-const char * const mi_lttng_loglevel_str_debug = "TRACE_DEBUG";
-const char * const mi_lttng_loglevel_str_debug_function = "TRACE_DEBUG_FUNCTION";
-const char * const mi_lttng_loglevel_str_debug_line = "TRACE_DEBUG_LINE";
-const char * const mi_lttng_loglevel_str_debug_module = "TRACE_DEBUG_MODULE";
-const char * const mi_lttng_loglevel_str_debug_process = "TRACE_DEBUG_PROCESS";
-const char * const mi_lttng_loglevel_str_debug_program = "TRACE_DEBUG_PROGRAM";
-const char * const mi_lttng_loglevel_str_debug_system = "TRACE_DEBUG_SYSTEM";
-const char * const mi_lttng_loglevel_str_debug_unit = "TRACE_DEBUG_UNIT";
-const char * const mi_lttng_loglevel_str_emerg = "TRACE_EMERG";
-const char * const mi_lttng_loglevel_str_err = "TRACE_ERR";
-const char * const mi_lttng_loglevel_str_info = "TRACE_INFO";
-const char * const mi_lttng_loglevel_str_notice = "TRACE_NOTICE";
-const char * const mi_lttng_loglevel_str_unknown = "UNKNOWN";
-const char * const mi_lttng_loglevel_str_warning = "TRACE_WARNING";
+const char *const mi_lttng_loglevel_str_alert = "TRACE_ALERT";
+const char *const mi_lttng_loglevel_str_crit = "TRACE_CRIT";
+const char *const mi_lttng_loglevel_str_debug = "TRACE_DEBUG";
+const char *const mi_lttng_loglevel_str_debug_function = "TRACE_DEBUG_FUNCTION";
+const char *const mi_lttng_loglevel_str_debug_line = "TRACE_DEBUG_LINE";
+const char *const mi_lttng_loglevel_str_debug_module = "TRACE_DEBUG_MODULE";
+const char *const mi_lttng_loglevel_str_debug_process = "TRACE_DEBUG_PROCESS";
+const char *const mi_lttng_loglevel_str_debug_program = "TRACE_DEBUG_PROGRAM";
+const char *const mi_lttng_loglevel_str_debug_system = "TRACE_DEBUG_SYSTEM";
+const char *const mi_lttng_loglevel_str_debug_unit = "TRACE_DEBUG_UNIT";
+const char *const mi_lttng_loglevel_str_emerg = "TRACE_EMERG";
+const char *const mi_lttng_loglevel_str_err = "TRACE_ERR";
+const char *const mi_lttng_loglevel_str_info = "TRACE_INFO";
+const char *const mi_lttng_loglevel_str_notice = "TRACE_NOTICE";
+const char *const mi_lttng_loglevel_str_unknown = "UNKNOWN";
+const char *const mi_lttng_loglevel_str_warning = "TRACE_WARNING";
/* String related to loglevel JUL */
-const char * const mi_lttng_loglevel_str_jul_all = "JUL_ALL";
-const char * const mi_lttng_loglevel_str_jul_config = "JUL_CONFIG";
-const char * const mi_lttng_loglevel_str_jul_fine = "JUL_FINE";
-const char * const mi_lttng_loglevel_str_jul_finer = "JUL_FINER";
-const char * const mi_lttng_loglevel_str_jul_finest = "JUL_FINEST";
-const char * const mi_lttng_loglevel_str_jul_info = "JUL_INFO";
-const char * const mi_lttng_loglevel_str_jul_off = "JUL_OFF";
-const char * const mi_lttng_loglevel_str_jul_severe = "JUL_SEVERE";
-const char * const mi_lttng_loglevel_str_jul_warning = "JUL_WARNING";
+const char *const mi_lttng_loglevel_str_jul_all = "JUL_ALL";
+const char *const mi_lttng_loglevel_str_jul_config = "JUL_CONFIG";
+const char *const mi_lttng_loglevel_str_jul_fine = "JUL_FINE";
+const char *const mi_lttng_loglevel_str_jul_finer = "JUL_FINER";
+const char *const mi_lttng_loglevel_str_jul_finest = "JUL_FINEST";
+const char *const mi_lttng_loglevel_str_jul_info = "JUL_INFO";
+const char *const mi_lttng_loglevel_str_jul_off = "JUL_OFF";
+const char *const mi_lttng_loglevel_str_jul_severe = "JUL_SEVERE";
+const char *const mi_lttng_loglevel_str_jul_warning = "JUL_WARNING";
/* String related to loglevel LOG4J */
-const char * const mi_lttng_loglevel_str_log4j_off = "LOG4J_OFF";
-const char * const mi_lttng_loglevel_str_log4j_fatal = "LOG4J_FATAL";
-const char * const mi_lttng_loglevel_str_log4j_error = "LOG4J_ERROR";
-const char * const mi_lttng_loglevel_str_log4j_warn = "LOG4J_WARN";
-const char * const mi_lttng_loglevel_str_log4j_info = "LOG4J_INFO";
-const char * const mi_lttng_loglevel_str_log4j_debug = "LOG4J_DEBUG";
-const char * const mi_lttng_loglevel_str_log4j_trace = "LOG4J_TRACE";
-const char * const mi_lttng_loglevel_str_log4j_all = "LOG4J_ALL";
+const char *const mi_lttng_loglevel_str_log4j_off = "LOG4J_OFF";
+const char *const mi_lttng_loglevel_str_log4j_fatal = "LOG4J_FATAL";
+const char *const mi_lttng_loglevel_str_log4j_error = "LOG4J_ERROR";
+const char *const mi_lttng_loglevel_str_log4j_warn = "LOG4J_WARN";
+const char *const mi_lttng_loglevel_str_log4j_info = "LOG4J_INFO";
+const char *const mi_lttng_loglevel_str_log4j_debug = "LOG4J_DEBUG";
+const char *const mi_lttng_loglevel_str_log4j_trace = "LOG4J_TRACE";
+const char *const mi_lttng_loglevel_str_log4j_all = "LOG4J_ALL";
/* String related to loglevel Python */
-const char * const mi_lttng_loglevel_str_python_critical = "PYTHON_CRITICAL";
-const char * const mi_lttng_loglevel_str_python_error = "PYTHON_ERROR";
-const char * const mi_lttng_loglevel_str_python_warning = "PYTHON_WARNING";
-const char * const mi_lttng_loglevel_str_python_info = "PYTHON_INFO";
-const char * const mi_lttng_loglevel_str_python_debug = "PYTHON_DEBUG";
-const char * const mi_lttng_loglevel_str_python_notset = "PYTHON_NOTSET";
+const char *const mi_lttng_loglevel_str_python_critical = "PYTHON_CRITICAL";
+const char *const mi_lttng_loglevel_str_python_error = "PYTHON_ERROR";
+const char *const mi_lttng_loglevel_str_python_warning = "PYTHON_WARNING";
+const char *const mi_lttng_loglevel_str_python_info = "PYTHON_INFO";
+const char *const mi_lttng_loglevel_str_python_debug = "PYTHON_DEBUG";
+const char *const mi_lttng_loglevel_str_python_notset = "PYTHON_NOTSET";
/* String related to loglevel type */
-const char * const mi_lttng_loglevel_type_all = "ALL";
-const char * const mi_lttng_loglevel_type_range = "RANGE";
-const char * const mi_lttng_loglevel_type_single = "SINGLE";
-const char * const mi_lttng_loglevel_type_unknown = "UNKNOWN";
+const char *const mi_lttng_loglevel_type_all = "ALL";
+const char *const mi_lttng_loglevel_type_range = "RANGE";
+const char *const mi_lttng_loglevel_type_single = "SINGLE";
+const char *const mi_lttng_loglevel_type_unknown = "UNKNOWN";
/* String related to a lttng_snapshot_output */
-const char * const mi_lttng_element_snapshot_ctrl_url = "ctrl_url";
-const char * const mi_lttng_element_snapshot_data_url = "data_url";
-const char * const mi_lttng_element_snapshot_max_size = "max_size";
-const char * const mi_lttng_element_snapshot_n_ptr = "n_ptr";
-const char * const mi_lttng_element_snapshot_session_name = "session_name";
-const char * const mi_lttng_element_snapshots = "snapshots";
+const char *const mi_lttng_element_snapshot_ctrl_url = "ctrl_url";
+const char *const mi_lttng_element_snapshot_data_url = "data_url";
+const char *const mi_lttng_element_snapshot_max_size = "max_size";
+const char *const mi_lttng_element_snapshot_n_ptr = "n_ptr";
+const char *const mi_lttng_element_snapshot_session_name = "session_name";
+const char *const mi_lttng_element_snapshots = "snapshots";
/* String related to track/untrack command */
-const char * const mi_lttng_element_track_untrack_all_wildcard = "*";
+const char *const mi_lttng_element_track_untrack_all_wildcard = "*";
-const char * const mi_lttng_element_session_name = "session_name";
+const char *const mi_lttng_element_session_name = "session_name";
/* String related to rotate command */
-const char * const mi_lttng_element_rotation = "rotation";
-const char * const mi_lttng_element_rotate_status = "status";
-const char * const mi_lttng_element_rotation_schedule = "rotation_schedule";
-const char * const mi_lttng_element_rotation_schedules = "rotation_schedules";
-const char * const mi_lttng_element_rotation_schedule_result = "rotation_schedule_result";
-const char * const mi_lttng_element_rotation_schedule_results = "rotation_schedule_results";
-const char * const mi_lttng_element_rotation_schedule_periodic = "periodic";
-const char * const mi_lttng_element_rotation_schedule_periodic_time_us = "time_us";
-const char * const mi_lttng_element_rotation_schedule_size_threshold = "size_threshold";
-const char * const mi_lttng_element_rotation_schedule_size_threshold_bytes = "bytes";
-const char * const mi_lttng_element_rotation_state = "state";
-const char * const mi_lttng_element_rotation_location = "location";
-const char * const mi_lttng_element_rotation_location_local = "local";
-const char * const mi_lttng_element_rotation_location_local_absolute_path = "absolute_path";
-const char * const mi_lttng_element_rotation_location_relay = "relay";
-const char * const mi_lttng_element_rotation_location_relay_host = "host";
-const char * const mi_lttng_element_rotation_location_relay_control_port = "control_port";
-const char * const mi_lttng_element_rotation_location_relay_data_port = "data_port";
-const char * const mi_lttng_element_rotation_location_relay_protocol = "protocol";
-const char * const mi_lttng_element_rotation_location_relay_relative_path = "relative_path";
+const char *const mi_lttng_element_rotation = "rotation";
+const char *const mi_lttng_element_rotate_status = "status";
+const char *const mi_lttng_element_rotation_schedule = "rotation_schedule";
+const char *const mi_lttng_element_rotation_schedules = "rotation_schedules";
+const char *const mi_lttng_element_rotation_schedule_result = "rotation_schedule_result";
+const char *const mi_lttng_element_rotation_schedule_results = "rotation_schedule_results";
+const char *const mi_lttng_element_rotation_schedule_periodic = "periodic";
+const char *const mi_lttng_element_rotation_schedule_periodic_time_us = "time_us";
+const char *const mi_lttng_element_rotation_schedule_size_threshold = "size_threshold";
+const char *const mi_lttng_element_rotation_schedule_size_threshold_bytes = "bytes";
+const char *const mi_lttng_element_rotation_state = "state";
+const char *const mi_lttng_element_rotation_location = "location";
+const char *const mi_lttng_element_rotation_location_local = "local";
+const char *const mi_lttng_element_rotation_location_local_absolute_path = "absolute_path";
+const char *const mi_lttng_element_rotation_location_relay = "relay";
+const char *const mi_lttng_element_rotation_location_relay_host = "host";
+const char *const mi_lttng_element_rotation_location_relay_control_port = "control_port";
+const char *const mi_lttng_element_rotation_location_relay_data_port = "data_port";
+const char *const mi_lttng_element_rotation_location_relay_protocol = "protocol";
+const char *const mi_lttng_element_rotation_location_relay_relative_path = "relative_path";
/* String related to enum lttng_rotation_state */
-const char * const mi_lttng_rotation_state_str_ongoing = "ONGOING";
-const char * const mi_lttng_rotation_state_str_completed = "COMPLETED";
-const char * const mi_lttng_rotation_state_str_expired = "EXPIRED";
-const char * const mi_lttng_rotation_state_str_error = "ERROR";
+const char *const mi_lttng_rotation_state_str_ongoing = "ONGOING";
+const char *const mi_lttng_rotation_state_str_completed = "COMPLETED";
+const char *const mi_lttng_rotation_state_str_expired = "EXPIRED";
+const char *const mi_lttng_rotation_state_str_error = "ERROR";
/* String related to enum lttng_trace_archive_location_relay_protocol_type */
-const char * const mi_lttng_rotation_location_relay_protocol_str_tcp = "TCP";
+const char *const mi_lttng_rotation_location_relay_protocol_str_tcp = "TCP";
/* String related to rate_policy elements */
const char *const mi_lttng_element_rate_policy = "rate_policy";
-const char *const mi_lttng_element_rate_policy_every_n =
- "rate_policy_every_n";
-const char *const mi_lttng_element_rate_policy_once_after_n =
- "rate_policy_once_after_n";
+const char *const mi_lttng_element_rate_policy_every_n = "rate_policy_every_n";
+const char *const mi_lttng_element_rate_policy_once_after_n = "rate_policy_once_after_n";
-const char *const mi_lttng_element_rate_policy_every_n_interval =
- "interval";
-const char
- *const mi_lttng_element_rate_policy_once_after_n_threshold =
- "threshold";
+const char *const mi_lttng_element_rate_policy_every_n_interval = "interval";
+const char *const mi_lttng_element_rate_policy_once_after_n_threshold = "threshold";
/* String related to action elements */
const char *const mi_lttng_element_action = "action";
const char *const mi_lttng_element_action_list = "action_list";
const char *const mi_lttng_element_action_notify = "action_notify";
-const char *const mi_lttng_element_action_start_session =
- "action_start_session";
-const char *const mi_lttng_element_action_stop_session =
- "action_stop_session";
-const char *const mi_lttng_element_action_rotate_session =
- "action_rotate_session";
-const char *const mi_lttng_element_action_snapshot_session =
- "action_snapshot_session";
-const char *const mi_lttng_element_action_snapshot_session_output =
- "output";
+const char *const mi_lttng_element_action_start_session = "action_start_session";
+const char *const mi_lttng_element_action_stop_session = "action_stop_session";
+const char *const mi_lttng_element_action_rotate_session = "action_rotate_session";
+const char *const mi_lttng_element_action_snapshot_session = "action_snapshot_session";
+const char *const mi_lttng_element_action_snapshot_session_output = "output";
/* String related to condition */
const char *const mi_lttng_element_condition = "condition";
-const char *const mi_lttng_element_condition_buffer_usage_high =
- "condition_buffer_usage_high";
-const char *const mi_lttng_element_condition_buffer_usage_low =
- "condition_buffer_usage_low";
-const char *const mi_lttng_element_condition_event_rule_matches =
- "condition_event_rule_matches";
+const char *const mi_lttng_element_condition_buffer_usage_high = "condition_buffer_usage_high";
+const char *const mi_lttng_element_condition_buffer_usage_low = "condition_buffer_usage_low";
+const char *const mi_lttng_element_condition_event_rule_matches = "condition_event_rule_matches";
const char *const mi_lttng_element_condition_session_consumed_size =
- "condition_session_consumed_size";
-const char *const mi_lttng_element_condition_session_rotation =
- "condition_session_rotation";
-const char
- *const mi_lttng_element_condition_session_rotation_completed =
- "condition_session_rotation_completed";
-const char
- *const mi_lttng_element_condition_session_rotation_ongoing =
- "condition_session_rotation_ongoing";
-
-const char *const mi_lttng_element_condition_channel_name =
- "channel_name";
-const char *const mi_lttng_element_condition_threshold_bytes =
- "threshold_bytes";
-const char *const mi_lttng_element_condition_threshold_ratio =
- "threshold_ratio";
+ "condition_session_consumed_size";
+const char *const mi_lttng_element_condition_session_rotation = "condition_session_rotation";
+const char *const mi_lttng_element_condition_session_rotation_completed =
+ "condition_session_rotation_completed";
+const char *const mi_lttng_element_condition_session_rotation_ongoing =
+ "condition_session_rotation_ongoing";
+
+const char *const mi_lttng_element_condition_channel_name = "channel_name";
+const char *const mi_lttng_element_condition_threshold_bytes = "threshold_bytes";
+const char *const mi_lttng_element_condition_threshold_ratio = "threshold_ratio";
/* String related to capture descriptor */
-const char *const mi_lttng_element_capture_descriptor =
- "capture_descriptor";
-const char *const mi_lttng_element_capture_descriptors =
- "capture_descriptors";
+const char *const mi_lttng_element_capture_descriptor = "capture_descriptor";
+const char *const mi_lttng_element_capture_descriptors = "capture_descriptors";
/* String related to event expression */
const char *const mi_lttng_element_event_expr = "event_expr";
-const char *const mi_lttng_element_event_expr_payload_field =
- "event_expr_payload_field";
+const char *const mi_lttng_element_event_expr_payload_field = "event_expr_payload_field";
const char *const mi_lttng_element_event_expr_channel_context_field =
- "event_expr_channel_context_field";
-const char
- *const mi_lttng_element_event_expr_app_specific_context_field =
- "event_expr_app_specific_context_field";
+ "event_expr_channel_context_field";
+const char *const mi_lttng_element_event_expr_app_specific_context_field =
+ "event_expr_app_specific_context_field";
const char *const mi_lttng_element_event_expr_array_field_element =
- "event_expr_array_field_element";
-const char *const mi_lttng_element_event_expr_provider_name =
- "provider_name";
-const char *const mi_lttng_element_event_expr_type_name =
- "type_name";
+ "event_expr_array_field_element";
+const char *const mi_lttng_element_event_expr_provider_name = "provider_name";
+const char *const mi_lttng_element_event_expr_type_name = "type_name";
const char *const mi_lttng_element_event_expr_index = "index";
/* String related to event rule */
const char *const mi_lttng_element_event_rule = "event_rule";
/* String related to lttng_event_rule_type */
-const char *const mi_lttng_element_event_rule_event_name =
- "event_name";
-const char *const mi_lttng_element_event_rule_name_pattern =
- "name_pattern";
-const char *const mi_lttng_element_event_rule_filter_expression =
- "filter_expression";
-
-const char *const mi_lttng_element_event_rule_jul_logging =
- "event_rule_jul_logging";
-const char *const mi_lttng_element_event_rule_kernel_kprobe =
- "event_rule_kernel_kprobe";
-const char *const mi_lttng_element_event_rule_kernel_syscall =
- "event_rule_kernel_syscall";
-const char *const mi_lttng_element_event_rule_kernel_tracepoint =
- "event_rule_kernel_tracepoint";
-const char *const mi_lttng_element_event_rule_kernel_uprobe =
- "event_rule_kernel_uprobe";
-const char *const mi_lttng_element_event_rule_log4j_logging =
- "event_rule_log4j_logging";
-const char *const mi_lttng_element_event_rule_python_logging =
- "event_rule_python_logging";
-const char *const mi_lttng_element_event_rule_user_tracepoint =
- "event_rule_user_tracepoint";
+const char *const mi_lttng_element_event_rule_event_name = "event_name";
+const char *const mi_lttng_element_event_rule_name_pattern = "name_pattern";
+const char *const mi_lttng_element_event_rule_filter_expression = "filter_expression";
+
+const char *const mi_lttng_element_event_rule_jul_logging = "event_rule_jul_logging";
+const char *const mi_lttng_element_event_rule_kernel_kprobe = "event_rule_kernel_kprobe";
+const char *const mi_lttng_element_event_rule_kernel_syscall = "event_rule_kernel_syscall";
+const char *const mi_lttng_element_event_rule_kernel_tracepoint = "event_rule_kernel_tracepoint";
+const char *const mi_lttng_element_event_rule_kernel_uprobe = "event_rule_kernel_uprobe";
+const char *const mi_lttng_element_event_rule_log4j_logging = "event_rule_log4j_logging";
+const char *const mi_lttng_element_event_rule_python_logging = "event_rule_python_logging";
+const char *const mi_lttng_element_event_rule_user_tracepoint = "event_rule_user_tracepoint";
/* String related to lttng_event_rule_kernel_syscall. */
-const char *const
- mi_lttng_element_event_rule_kernel_syscall_emission_site =
- "emission_site";
+const char *const mi_lttng_element_event_rule_kernel_syscall_emission_site = "emission_site";
/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
-const char *const
- mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit =
- "entry+exit";
-const char
- *const mi_lttng_event_rule_kernel_syscall_emission_site_entry =
- "entry";
-const char *const
- mi_lttng_event_rule_kernel_syscall_emission_site_exit = "exit";
+const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit = "entry+exit";
+const char *const mi_lttng_event_rule_kernel_syscall_emission_site_entry = "entry";
+const char *const mi_lttng_event_rule_kernel_syscall_emission_site_exit = "exit";
/* String related to lttng_event_rule_user_tracepoint */
-const char *const
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions =
- "name_pattern_exclusions";
-const char *const
- mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion =
- "name_pattern_exclusion";
+const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions =
+ "name_pattern_exclusions";
+const char *const mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion =
+ "name_pattern_exclusion";
/* String related to log level rule. */
-const char *const mi_lttng_element_log_level_rule =
- "log_level_rule";
-const char *const mi_lttng_element_log_level_rule_exactly =
- "log_level_rule_exactly";
-const char
- *const mi_lttng_element_log_level_rule_at_least_as_severe_as =
- "log_level_rule_at_least_as_severe_as";
+const char *const mi_lttng_element_log_level_rule = "log_level_rule";
+const char *const mi_lttng_element_log_level_rule_exactly = "log_level_rule_exactly";
+const char *const mi_lttng_element_log_level_rule_at_least_as_severe_as =
+ "log_level_rule_at_least_as_severe_as";
const char *const mi_lttng_element_log_level_rule_level = "level";
/* String related to kernel probe location. */
-const char *const mi_lttng_element_kernel_probe_location =
- "kernel_probe_location";
-const char
- *const mi_lttng_element_kernel_probe_location_symbol_offset =
- "kernel_probe_location_symbol_offset";
-const char *const
- mi_lttng_element_kernel_probe_location_symbol_offset_name =
- "name";
-const char *const
- mi_lttng_element_kernel_probe_location_symbol_offset_offset =
- "offset";
-
-const char *const mi_lttng_element_kernel_probe_location_address =
- "kernel_probe_location_address";
-const char
- *const mi_lttng_element_kernel_probe_location_address_address =
- "address";
+const char *const mi_lttng_element_kernel_probe_location = "kernel_probe_location";
+const char *const mi_lttng_element_kernel_probe_location_symbol_offset =
+ "kernel_probe_location_symbol_offset";
+const char *const mi_lttng_element_kernel_probe_location_symbol_offset_name = "name";
+const char *const mi_lttng_element_kernel_probe_location_symbol_offset_offset = "offset";
+
+const char *const mi_lttng_element_kernel_probe_location_address = "kernel_probe_location_address";
+const char *const mi_lttng_element_kernel_probe_location_address_address = "address";
/* String related to userspace probe location. */
-const char *const mi_lttng_element_userspace_probe_location =
- "userspace_probe_location";
-const char
- *const mi_lttng_element_userspace_probe_location_binary_path =
- "binary_path";
-const char
- *const mi_lttng_element_userspace_probe_location_function =
- "userspace_probe_location_function";
-const char
- *const mi_lttng_element_userspace_probe_location_function_name =
- "name";
-const char
- *const mi_lttng_element_userspace_probe_location_lookup_method =
- "userspace_probe_location_lookup_method";
-const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_function_default =
- "userspace_probe_location_lookup_method_function_default";
-const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_function_elf =
- "userspace_probe_location_lookup_method_function_elf";
-const char *const
- mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt =
- "userspace_probe_location_lookup_method_tracepoint_sdt";
-const char
- *const mi_lttng_element_userspace_probe_location_tracepoint =
- "userspace_probe_location_tracepoint";
-const char *const
- mi_lttng_element_userspace_probe_location_tracepoint_probe_name =
- "probe_name";
-const char *const
- mi_lttng_element_userspace_probe_location_tracepoint_provider_name =
- "provider_name";
+const char *const mi_lttng_element_userspace_probe_location = "userspace_probe_location";
+const char *const mi_lttng_element_userspace_probe_location_binary_path = "binary_path";
+const char *const mi_lttng_element_userspace_probe_location_function =
+ "userspace_probe_location_function";
+const char *const mi_lttng_element_userspace_probe_location_function_name = "name";
+const char *const mi_lttng_element_userspace_probe_location_lookup_method =
+ "userspace_probe_location_lookup_method";
+const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_default =
+ "userspace_probe_location_lookup_method_function_default";
+const char *const mi_lttng_element_userspace_probe_location_lookup_method_function_elf =
+ "userspace_probe_location_lookup_method_function_elf";
+const char *const mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt =
+ "userspace_probe_location_lookup_method_tracepoint_sdt";
+const char *const mi_lttng_element_userspace_probe_location_tracepoint =
+ "userspace_probe_location_tracepoint";
+const char *const mi_lttng_element_userspace_probe_location_tracepoint_probe_name = "probe_name";
+const char *const mi_lttng_element_userspace_probe_location_tracepoint_provider_name =
+ "provider_name";
/* String related to enum
* lttng_userspace_probe_location_function_instrumentation_type */
-const char *const
- mi_lttng_element_userspace_probe_location_function_instrumentation_type =
- "instrumentation_type";
-const char *const
- mi_lttng_userspace_probe_location_function_instrumentation_type_entry =
- "ENTRY";
+const char *const mi_lttng_element_userspace_probe_location_function_instrumentation_type =
+ "instrumentation_type";
+const char *const mi_lttng_userspace_probe_location_function_instrumentation_type_entry = "ENTRY";
/* String related to trigger */
const char *const mi_lttng_element_triggers = "triggers";
const char *const mi_lttng_element_trigger_owner_uid = "owner_uid";
/* String related to error_query. */
-const char *const mi_lttng_element_error_query_result =
- "error_query_result";
-const char *const mi_lttng_element_error_query_result_counter =
- "error_query_result_counter";
-const char *const
- mi_lttng_element_error_query_result_counter_value = "value";
-const char *const mi_lttng_element_error_query_result_description =
- "description";
-const char *const mi_lttng_element_error_query_result_name =
- "name";
-const char *const mi_lttng_element_error_query_result_type =
- "type";
-const char *const mi_lttng_element_error_query_results =
- "error_query_results";
+const char *const mi_lttng_element_error_query_result = "error_query_result";
+const char *const mi_lttng_element_error_query_result_counter = "error_query_result_counter";
+const char *const mi_lttng_element_error_query_result_counter_value = "value";
+const char *const mi_lttng_element_error_query_result_description = "description";
+const char *const mi_lttng_element_error_query_result_name = "name";
+const char *const mi_lttng_element_error_query_result_type = "type";
+const char *const mi_lttng_element_error_query_results = "error_query_results";
/* String related to add-context command */
-const char * const mi_lttng_element_context_symbol = "symbol";
+const char *const mi_lttng_element_context_symbol = "symbol";
/* Deprecated symbols preserved for ABI compatibility. */
LTTNG_EXPORT const char *mi_lttng_context_type_perf_counter;
}
}
-static
-const char *mi_lttng_eventtype_string(enum lttng_event_type value)
+static const char *mi_lttng_eventtype_string(enum lttng_event_type value)
{
switch (value) {
case LTTNG_EVENT_ALL:
}
}
-static
-const char *mi_lttng_event_contexttype_string(enum lttng_event_context_type val)
+static const char *mi_lttng_event_contexttype_string(enum lttng_event_context_type val)
{
switch (val) {
case LTTNG_EVENT_CONTEXT_PID:
const char *mi_lttng_eventfieldtype_string(enum lttng_event_field_type val)
{
switch (val) {
- case(LTTNG_EVENT_FIELD_INTEGER):
+ case (LTTNG_EVENT_FIELD_INTEGER):
return mi_lttng_element_type_integer;
- case(LTTNG_EVENT_FIELD_ENUM):
+ case (LTTNG_EVENT_FIELD_ENUM):
return mi_lttng_element_type_enum;
- case(LTTNG_EVENT_FIELD_FLOAT):
+ case (LTTNG_EVENT_FIELD_FLOAT):
return mi_lttng_element_type_float;
- case(LTTNG_EVENT_FIELD_STRING):
+ case (LTTNG_EVENT_FIELD_STRING):
return mi_lttng_element_type_string;
default:
return mi_lttng_element_type_other;
}
const char *mi_lttng_trace_archive_location_relay_protocol_type_string(
- enum lttng_trace_archive_location_relay_protocol_type value)
+ enum lttng_trace_archive_location_relay_protocol_type value)
{
switch (value) {
case LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP:
* A command is always the MI's root node, it must declare the current
* namespace and schema URIs and the schema's version.
*/
- ret = config_writer_open_element(writer->writer,
- mi_lttng_element_command);
+ ret = config_writer_open_element(writer->writer, mi_lttng_element_command);
if (ret) {
goto end;
}
- ret = config_writer_write_attribute(writer->writer,
- mi_lttng_xmlns, DEFAULT_LTTNG_MI_NAMESPACE);
+ ret = config_writer_write_attribute(
+ writer->writer, mi_lttng_xmlns, DEFAULT_LTTNG_MI_NAMESPACE);
if (ret) {
goto end;
}
- ret = config_writer_write_attribute(writer->writer,
- mi_lttng_xmlns_xsi, mi_lttng_w3_schema_uri);
+ ret = config_writer_write_attribute(
+ writer->writer, mi_lttng_xmlns_xsi, mi_lttng_w3_schema_uri);
if (ret) {
goto end;
}
- ret = config_writer_write_attribute(writer->writer,
- mi_lttng_schema_location,
- mi_lttng_schema_location_uri);
+ ret = config_writer_write_attribute(
+ writer->writer, mi_lttng_schema_location, mi_lttng_schema_location_uri);
if (ret) {
goto end;
}
- ret = config_writer_write_attribute(writer->writer,
- mi_lttng_schema_version,
- mi_lttng_schema_version_value);
+ ret = config_writer_write_attribute(
+ writer->writer, mi_lttng_schema_version, mi_lttng_schema_version_value);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_command_name, command);
+ ret = mi_lttng_writer_write_element_string(writer, mi_lttng_element_command_name, command);
end:
return ret;
}
return mi_lttng_writer_close_element(writer);
}
-int mi_lttng_writer_open_element(struct mi_writer *writer,
- const char *element_name)
+int mi_lttng_writer_open_element(struct mi_writer *writer, const char *element_name)
{
return config_writer_open_element(writer->writer, element_name);
}
return config_writer_close_element(writer->writer);
}
-int mi_lttng_close_multi_element(struct mi_writer *writer,
- unsigned int nb_element)
+int mi_lttng_close_multi_element(struct mi_writer *writer, unsigned int nb_element)
{
int ret, i;
}
int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,
- const char *element_name, uint64_t value)
+ const char *element_name,
+ uint64_t value)
{
- return config_writer_write_element_unsigned_int(writer->writer,
- element_name, value);
+ return config_writer_write_element_unsigned_int(writer->writer, element_name, value);
}
int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,
- const char *element_name, int64_t value)
+ const char *element_name,
+ int64_t value)
{
- return config_writer_write_element_signed_int(writer->writer,
- element_name, value);
+ return config_writer_write_element_signed_int(writer->writer, element_name, value);
}
int mi_lttng_writer_write_element_bool(struct mi_writer *writer,
- const char *element_name, int value)
+ const char *element_name,
+ int value)
{
- return config_writer_write_element_bool(writer->writer,
- element_name, value);
+ return config_writer_write_element_bool(writer->writer, element_name, value);
}
int mi_lttng_writer_write_element_string(struct mi_writer *writer,
- const char *element_name, const char *value)
+ const char *element_name,
+ const char *value)
{
- return config_writer_write_element_string(writer->writer,
- element_name, value);
+ return config_writer_write_element_string(writer->writer, element_name, value);
}
int mi_lttng_writer_write_element_double(struct mi_writer *writer,
- const char *element_name,
- double value)
+ const char *element_name,
+ double value)
{
- return config_writer_write_element_double(
- writer->writer, element_name, value);
+ return config_writer_write_element_double(writer->writer, element_name, value);
}
-int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version_data *version,
- const char *lttng_description, const char *lttng_license)
+int mi_lttng_version(struct mi_writer *writer,
+ struct mi_lttng_version_data *version,
+ const char *lttng_description,
+ const char *lttng_license)
{
int ret;
}
/* Version string (contain info like rc etc.) */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_version_str, version->version);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_version_str, version->version);
if (ret) {
goto end;
}
/* Major version number */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_version_major, version->version_major);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_version_major, version->version_major);
if (ret) {
goto end;
}
/* Minor version number */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_version_minor, version->version_minor);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_version_minor, version->version_minor);
if (ret) {
goto end;
}
/* Commit version number */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_version_commit, version->version_commit);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_version_commit, version->version_commit);
if (ret) {
goto end;
}
/* Patch number */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_version_patch_level, version->version_patchlevel);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_version_patch_level, version->version_patchlevel);
if (ret) {
goto end;
}
/* Name of the version */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, version->version_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, version->version_name);
if (ret) {
goto end;
}
/* Description mostly related to beer... */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_version_description, lttng_description);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_version_description, lttng_description);
if (ret) {
goto end;
}
/* url */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_version_web, version->package_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_version_web, version->package_url);
if (ret) {
goto end;
}
/* License: free as in free beer...no...*speech* */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_version_license, lttng_license);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_version_license, lttng_license);
if (ret) {
goto end;
}
return mi_lttng_writer_open_element(writer, config_element_sessions);
}
-int mi_lttng_session(struct mi_writer *writer,
- struct lttng_session *session, int is_open)
+int mi_lttng_session(struct mi_writer *writer, struct lttng_session *session, int is_open)
{
int ret;
LTTNG_ASSERT(session);
/* Open sessions element */
- ret = mi_lttng_writer_open_element(writer,
- config_element_session);
+ ret = mi_lttng_writer_open_element(writer, config_element_session);
if (ret) {
goto end;
}
/* Name of the session */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, session->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session->name);
if (ret) {
goto end;
}
/* Path */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_path, session->path);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_path, session->path);
if (ret) {
goto end;
}
/* Enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- config_element_enabled, session->enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, session->enabled);
if (ret) {
goto end;
}
/* Snapshot mode */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_snapshot_mode, session->snapshot_mode);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_snapshot_mode, session->snapshot_mode);
if (ret) {
goto end;
}
/* Live timer interval in usec */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_live_timer_interval,
- session->live_timer_interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_live_timer_interval, session->live_timer_interval);
if (ret) {
goto end;
}
}
end:
return ret;
-
}
int mi_lttng_domains_open(struct mi_writer *writer)
return mi_lttng_writer_open_element(writer, config_element_domains);
}
-int mi_lttng_domain(struct mi_writer *writer,
- struct lttng_domain *domain, int is_open)
+int mi_lttng_domain(struct mi_writer *writer, struct lttng_domain *domain, int is_open)
{
int ret = 0;
const char *str_domain;
/* Domain Type */
str_domain = mi_lttng_domaintype_string(domain->type);
- ret = mi_lttng_writer_write_element_string(writer, config_element_type,
- str_domain);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_type, str_domain);
if (ret) {
goto end;
}
/* Buffer Type */
- str_buffer= mi_lttng_buffertype_string(domain->buf_type);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_buffer_type, str_buffer);
+ str_buffer = mi_lttng_buffertype_string(domain->buf_type);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_buffer_type, str_buffer);
if (ret) {
goto end;
}
end:
return ret;
-
}
int mi_lttng_channels_open(struct mi_writer *writer)
return mi_lttng_writer_open_element(writer, config_element_channels);
}
-int mi_lttng_channel(struct mi_writer *writer,
- struct lttng_channel *channel, int is_open)
+int mi_lttng_channel(struct mi_writer *writer, struct lttng_channel *channel, int is_open)
{
int ret = 0;
}
/* Name */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- channel->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, channel->name);
if (ret) {
goto end;
}
/* Enabled ? */
- ret = mi_lttng_writer_write_element_bool(writer,
- config_element_enabled, channel->enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, channel->enabled);
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_channel_attr(struct mi_writer *writer,
- struct lttng_channel_attr *attr)
+int mi_lttng_channel_attr(struct mi_writer *writer, struct lttng_channel_attr *attr)
{
int ret = 0;
- struct lttng_channel *chan = caa_container_of(attr,
- struct lttng_channel, attr);
+ struct lttng_channel *chan = caa_container_of(attr, struct lttng_channel, attr);
uint64_t discarded_events, lost_packets, monitor_timer_interval;
int64_t blocking_timeout;
goto end;
}
- ret = lttng_channel_get_monitor_timer_interval(chan,
- &monitor_timer_interval);
+ ret = lttng_channel_get_monitor_timer_interval(chan, &monitor_timer_interval);
if (ret) {
goto end;
}
- ret = lttng_channel_get_blocking_timeout(chan,
- &blocking_timeout);
+ ret = lttng_channel_get_blocking_timeout(chan, &blocking_timeout);
if (ret) {
goto end;
}
}
/* Overwrite */
- ret = mi_lttng_writer_write_element_string(writer,
+ ret = mi_lttng_writer_write_element_string(
+ writer,
config_element_overwrite_mode,
- attr->overwrite ? config_overwrite_mode_overwrite :
- config_overwrite_mode_discard);
+ attr->overwrite ? config_overwrite_mode_overwrite : config_overwrite_mode_discard);
if (ret) {
goto end;
}
/* Sub buffer size in byte */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_subbuf_size, attr->subbuf_size);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_subbuf_size, attr->subbuf_size);
if (ret) {
goto end;
}
/* Number of subbuffer (power of two) */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_num_subbuf,
- attr->num_subbuf);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_num_subbuf, attr->num_subbuf);
if (ret) {
goto end;
}
/* Switch timer interval in usec */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_switch_timer_interval,
- attr->switch_timer_interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_switch_timer_interval, attr->switch_timer_interval);
if (ret) {
goto end;
}
/* Read timer interval in usec */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_read_timer_interval,
- attr->read_timer_interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_read_timer_interval, attr->read_timer_interval);
if (ret) {
goto end;
}
/* Monitor timer interval in usec */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_monitor_timer_interval,
- monitor_timer_interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_monitor_timer_interval, monitor_timer_interval);
if (ret) {
goto end;
}
/* Retry timeout in usec */
- ret = mi_lttng_writer_write_element_signed_int(writer,
- config_element_blocking_timeout,
- blocking_timeout);
+ ret = mi_lttng_writer_write_element_signed_int(
+ writer, config_element_blocking_timeout, blocking_timeout);
if (ret) {
goto end;
}
/* Event output */
ret = mi_lttng_writer_write_element_string(writer,
- config_element_output_type,
- attr->output == LTTNG_EVENT_SPLICE ?
- config_output_type_splice : config_output_type_mmap);
+ config_element_output_type,
+ attr->output == LTTNG_EVENT_SPLICE ?
+ config_output_type_splice :
+ config_output_type_mmap);
if (ret) {
goto end;
}
/* Tracefile size in bytes */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_tracefile_size, attr->tracefile_size);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_size, attr->tracefile_size);
if (ret) {
goto end;
}
/* Count of tracefiles */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_tracefile_count,
- attr->tracefile_count);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_tracefile_count, attr->tracefile_count);
if (ret) {
goto end;
}
/* Live timer interval in usec*/
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_live_timer_interval,
- attr->live_timer_interval);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_live_timer_interval, attr->live_timer_interval);
if (ret) {
goto end;
}
/* Discarded events */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_discarded_events,
- discarded_events);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_discarded_events, discarded_events);
if (ret) {
goto end;
}
/* Lost packets */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_lost_packets,
- lost_packets);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_lost_packets, lost_packets);
if (ret) {
goto end;
}
}
end:
return ret;
-
}
-int mi_lttng_event_common_attributes(struct mi_writer *writer,
- struct lttng_event *event)
+int mi_lttng_event_common_attributes(struct mi_writer *writer, struct lttng_event *event)
{
int ret;
const char *filter_expression;
}
/* Event name */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, event->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, event->name);
if (ret) {
goto end;
}
/* Event type */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_type, mi_lttng_eventtype_string(event->type));
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_type, mi_lttng_eventtype_string(event->type));
if (ret) {
goto end;
}
/* Is event enabled */
- ret = mi_lttng_writer_write_element_bool(writer,
- config_element_enabled, event->enabled);
+ ret = mi_lttng_writer_write_element_bool(writer, config_element_enabled, event->enabled);
if (ret) {
goto end;
}
}
if (filter_expression) {
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_filter_expression,
- filter_expression);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_filter_expression, filter_expression);
if (ret) {
goto end;
}
return ret;
}
-static int write_event_exclusions(struct mi_writer *writer,
- struct lttng_event *event)
+static int write_event_exclusions(struct mi_writer *writer, struct lttng_event *event)
{
int i;
int ret;
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_exclusion, name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_exclusion, name);
if (ret) {
/* Close exclusions */
mi_lttng_writer_close_element(writer);
}
int mi_lttng_event_tracepoint_loglevel(struct mi_writer *writer,
- struct lttng_event *event, enum lttng_domain_type domain)
+ struct lttng_event *event,
+ enum lttng_domain_type domain)
{
int ret;
/* Event loglevel */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_loglevel,
- mi_lttng_loglevel_string(event->loglevel, domain));
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_loglevel, mi_lttng_loglevel_string(event->loglevel, domain));
if (ret) {
goto end;
}
/* Log level type */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_loglevel_type,
- mi_lttng_logleveltype_string(event->loglevel_type));
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_loglevel_type,
+ mi_lttng_logleveltype_string(event->loglevel_type));
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer,
- struct lttng_event *event)
+int mi_lttng_event_tracepoint_no_loglevel(struct mi_writer *writer, struct lttng_event *event)
{
/* event exclusion filter */
return write_event_exclusions(writer, event);
}
-int mi_lttng_event_function_probe(struct mi_writer *writer,
- struct lttng_event *event)
+int mi_lttng_event_function_probe(struct mi_writer *writer, struct lttng_event *event)
{
int ret;
if (event->attr.probe.addr != 0) {
/* event probe address */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_address, event->attr.probe.addr);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_address, event->attr.probe.addr);
if (ret) {
goto end;
}
} else {
/* event probe offset */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_offset, event->attr.probe.offset);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_offset, event->attr.probe.offset);
if (ret) {
goto end;
}
/* event probe symbol_name */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_symbol_name, event->attr.probe.symbol_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_symbol_name, event->attr.probe.symbol_name);
if (ret) {
goto end;
}
return ret;
}
-static
-int mi_lttng_event_userspace_probe(struct mi_writer *writer,
- struct lttng_event *event)
+static int mi_lttng_event_userspace_probe(struct mi_writer *writer, struct lttng_event *event)
{
int ret;
const struct lttng_userspace_probe_location *location;
const char *function_name;
const char *binary_path;
- ret = mi_lttng_writer_open_element(writer,
- config_element_userspace_probe_function_attributes);
+ ret = mi_lttng_writer_open_element(
+ writer, config_element_userspace_probe_function_attributes);
if (ret) {
goto end;
}
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_function_elf);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_function_elf);
if (ret) {
goto end;
}
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_function_default);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_function_default);
if (ret) {
goto end;
}
}
binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_location_binary_path, binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto end;
}
function_name = lttng_userspace_probe_location_function_get_function_name(location);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_function_location_function_name,
- function_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_function_location_function_name,
+ function_name);
if (ret) {
goto end;
}
const char *probe_name, *provider_name;
const char *binary_path;
- ret = mi_lttng_writer_open_element(writer,
- config_element_userspace_probe_function_attributes);
+ ret = mi_lttng_writer_open_element(
+ writer, config_element_userspace_probe_function_attributes);
if (ret) {
goto end;
}
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_lookup,
- config_element_userspace_probe_lookup_tracepoint_sdt);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_lookup,
+ config_element_userspace_probe_lookup_tracepoint_sdt);
if (ret) {
goto end;
}
}
binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto end;
}
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_tracepoint_location_provider_name,
- provider_name);
+ provider_name =
+ lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_tracepoint_location_provider_name,
+ provider_name);
if (ret) {
goto end;
}
probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_userspace_probe_tracepoint_location_probe_name, probe_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ config_element_userspace_probe_tracepoint_location_probe_name,
+ probe_name);
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_event_function_entry(struct mi_writer *writer,
- struct lttng_event *event)
+int mi_lttng_event_function_entry(struct mi_writer *writer, struct lttng_event *event)
{
int ret;
}
/* event probe symbol_name */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_symbol_name, event->attr.ftrace.symbol_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_symbol_name, event->attr.ftrace.symbol_name);
if (ret) {
goto end;
}
}
int mi_lttng_event(struct mi_writer *writer,
- struct lttng_event *event, int is_open, enum lttng_domain_type domain)
+ struct lttng_event *event,
+ int is_open,
+ enum lttng_domain_type domain)
{
int ret;
int mi_lttng_trackers_open(struct mi_writer *writer)
{
- return mi_lttng_writer_open_element(
- writer, config_element_process_attr_trackers);
+ return mi_lttng_writer_open_element(writer, config_element_process_attr_trackers);
}
static int get_tracker_elements(enum lttng_process_attr process_attr,
- const char **element_process_attr_tracker,
- const char **element_process_attr_value)
+ const char **element_process_attr_tracker,
+ const char **element_process_attr_value)
{
int ret = 0;
switch (process_attr) {
case LTTNG_PROCESS_ATTR_PROCESS_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_pid;
- *element_process_attr_value =
- config_element_process_attr_pid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_pid;
+ *element_process_attr_value = config_element_process_attr_pid_value;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_vpid;
- *element_process_attr_value =
- config_element_process_attr_vpid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_vpid;
+ *element_process_attr_value = config_element_process_attr_vpid_value;
break;
case LTTNG_PROCESS_ATTR_USER_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_uid;
- *element_process_attr_value =
- config_element_process_attr_uid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_uid;
+ *element_process_attr_value = config_element_process_attr_uid_value;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_vuid;
- *element_process_attr_value =
- config_element_process_attr_vuid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_vuid;
+ *element_process_attr_value = config_element_process_attr_vuid_value;
break;
case LTTNG_PROCESS_ATTR_GROUP_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_gid;
- *element_process_attr_value =
- config_element_process_attr_gid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_gid;
+ *element_process_attr_value = config_element_process_attr_gid_value;
break;
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
- *element_process_attr_tracker =
- config_element_process_attr_tracker_vgid;
- *element_process_attr_value =
- config_element_process_attr_vgid_value;
+ *element_process_attr_tracker = config_element_process_attr_tracker_vgid;
+ *element_process_attr_value = config_element_process_attr_vgid_value;
break;
default:
ret = LTTNG_ERR_SAVE_IO_FAIL;
return ret;
}
-int mi_lttng_process_attribute_tracker_open(
- struct mi_writer *writer, enum lttng_process_attr process_attr)
+int mi_lttng_process_attribute_tracker_open(struct mi_writer *writer,
+ enum lttng_process_attr process_attr)
{
int ret;
const char *element_tracker, *element_value;
- ret = get_tracker_elements(
- process_attr, &element_tracker, &element_value);
+ ret = get_tracker_elements(process_attr, &element_tracker, &element_value);
if (ret) {
return ret;
}
* TODO: move the listing of pid for user agent to process semantic on
* mi api bump. The use of process element break the mi api.
*/
-int mi_lttng_pid(struct mi_writer *writer,
- pid_t pid,
- const char *name,
- int is_open)
+int mi_lttng_pid(struct mi_writer *writer, pid_t pid, const char *name, int is_open)
{
int ret;
}
/* Writing pid number */
- ret = mi_lttng_writer_write_element_signed_int(writer,
- mi_lttng_element_pid_id, (int)pid);
+ ret = mi_lttng_writer_write_element_signed_int(writer, mi_lttng_element_pid_id, (int) pid);
if (ret) {
goto end;
}
/* Writing name of the process */
if (name) {
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, name);
if (ret) {
goto end;
}
int mi_lttng_process_attr_values_open(struct mi_writer *writer)
{
- return mi_lttng_writer_open_element(
- writer, config_element_process_attr_values);
+ return mi_lttng_writer_open_element(writer, config_element_process_attr_values);
}
int mi_lttng_all_process_attribute_value(struct mi_writer *writer,
- enum lttng_process_attr process_attr,
- bool is_open)
+ enum lttng_process_attr process_attr,
+ bool is_open)
{
int ret;
const char *element_id_tracker, *element_target_id;
- ret = get_tracker_elements(
- process_attr, &element_id_tracker, &element_target_id);
+ ret = get_tracker_elements(process_attr, &element_id_tracker, &element_target_id);
if (ret) {
return ret;
}
}
int mi_lttng_integral_process_attribute_value(struct mi_writer *writer,
- enum lttng_process_attr process_attr,
- int64_t value,
- bool is_open)
+ enum lttng_process_attr process_attr,
+ int64_t value,
+ bool is_open)
{
int ret;
const char *element_id_tracker, *element_target_id;
- ret = get_tracker_elements(
- process_attr, &element_id_tracker, &element_target_id);
+ ret = get_tracker_elements(process_attr, &element_id_tracker, &element_target_id);
if (ret) {
return ret;
}
}
ret = mi_lttng_writer_write_element_signed_int(
- writer, config_element_process_attr_id, value);
+ writer, config_element_process_attr_id, value);
if (ret) {
goto end;
}
}
int mi_lttng_string_process_attribute_value(struct mi_writer *writer,
- enum lttng_process_attr process_attr,
- const char *value,
- bool is_open)
+ enum lttng_process_attr process_attr,
+ const char *value,
+ bool is_open)
{
int ret;
const char *element_id_tracker, *element_target_id;
- ret = get_tracker_elements(
- process_attr, &element_id_tracker, &element_target_id);
+ ret = get_tracker_elements(process_attr, &element_id_tracker, &element_target_id);
if (ret) {
return ret;
}
goto end;
}
- ret = mi_lttng_writer_write_element_string(
- writer, config_element_name, value);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, value);
if (ret) {
goto end;
}
return mi_lttng_writer_open_element(writer, mi_lttng_element_event_fields);
}
-int mi_lttng_event_field(struct mi_writer *writer,
- struct lttng_event_field *field)
+int mi_lttng_event_field(struct mi_writer *writer, struct lttng_event_field *field)
{
int ret;
}
/* Name */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- field->field_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, field->field_name);
if (ret) {
goto end;
}
/* Type */
- ret = mi_lttng_writer_write_element_string(writer, config_element_type,
- mi_lttng_eventfieldtype_string(field->type));
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_type, mi_lttng_eventfieldtype_string(field->type));
if (ret) {
goto end;
}
/* nowrite */
- ret = mi_lttng_writer_write_element_signed_int(writer,
- mi_lttng_element_nowrite, field->nowrite);
+ ret = mi_lttng_writer_write_element_signed_int(
+ writer, mi_lttng_element_nowrite, field->nowrite);
if (ret) {
goto end;
}
}
int mi_lttng_perf_counter_context(struct mi_writer *writer,
- struct lttng_event_perf_counter_ctx *perf_context)
+ struct lttng_event_perf_counter_ctx *perf_context)
{
int ret;
/* Open perf_counter_context */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_perf_counter_context);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_perf_counter_context);
if (ret) {
goto end;
}
/* Type */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_type, perf_context->type);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_type, perf_context->type);
if (ret) {
goto end;
}
/* Config */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- config_element_config, perf_context->config);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, config_element_config, perf_context->config);
if (ret) {
goto end;
}
/* Name of the perf counter */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, perf_context->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, perf_context->name);
if (ret) {
goto end;
}
return ret;
}
-static
-int mi_lttng_app_context(struct mi_writer *writer,
- const char *provider_name, const char *ctx_name)
+static int
+mi_lttng_app_context(struct mi_writer *writer, const char *provider_name, const char *ctx_name)
{
int ret;
/* Open app */
- ret = mi_lttng_writer_open_element(writer,
- config_element_context_app);
+ ret = mi_lttng_writer_open_element(writer, config_element_context_app);
if (ret) {
goto end;
}
/* provider_name */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_context_app_provider_name,
- provider_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_context_app_provider_name, provider_name);
if (ret) {
goto end;
}
/* ctx_name */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_context_app_ctx_name, ctx_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_context_app_ctx_name, ctx_name);
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_context(struct mi_writer *writer,
- struct lttng_event_context *context, int is_open)
+int mi_lttng_context(struct mi_writer *writer, struct lttng_event_context *context, int is_open)
{
int ret;
/* Open context */
- ret = mi_lttng_writer_open_element(writer , config_element_context);
+ ret = mi_lttng_writer_open_element(writer, config_element_context);
if (ret) {
goto end;
}
case LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER:
case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
{
- struct lttng_event_perf_counter_ctx *perf_context =
- &context->u.perf_counter;
- ret = mi_lttng_perf_counter_context(writer, perf_context);
+ struct lttng_event_perf_counter_ctx *perf_context = &context->u.perf_counter;
+ ret = mi_lttng_perf_counter_context(writer, perf_context);
if (ret) {
goto end;
}
}
case LTTNG_EVENT_CONTEXT_APP_CONTEXT:
{
- ret = mi_lttng_app_context(writer,
- context->u.app_ctx.provider_name,
- context->u.app_ctx.ctx_name);
+ ret = mi_lttng_app_context(
+ writer, context->u.app_ctx.provider_name, context->u.app_ctx.ctx_name);
if (ret) {
goto end;
}
}
default:
{
- const char *type_string = mi_lttng_event_contexttype_string(
- context->ctx);
+ const char *type_string = mi_lttng_event_contexttype_string(context->ctx);
if (!type_string) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
/* Print context type */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_type, type_string);
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_type, type_string);
break;
}
}
return ret;
}
-int mi_lttng_snapshot_output_session_name(struct mi_writer *writer,
- const char *session_name)
+int mi_lttng_snapshot_output_session_name(struct mi_writer *writer, const char *session_name)
{
int ret;
}
/* Snapshot output list for current session name */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, session_name);
if (ret) {
goto end;
}
}
int mi_lttng_snapshot_list_output(struct mi_writer *writer,
- const struct lttng_snapshot_output *output)
+ const struct lttng_snapshot_output *output)
{
int ret;
/* Open element snapshot output */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_snapshot);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_snapshot);
if (ret) {
goto end;
}
/* ID of the snapshot output */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_id, output->id);
+ ret = mi_lttng_writer_write_element_unsigned_int(writer, mi_lttng_element_id, output->id);
if (ret) {
goto end;
}
/* Name of the output */
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- output->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, output->name);
if (ret) {
goto end;
}
/* Destination of the output (ctrl_url)*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
if (ret) {
goto end;
}
/* Destination of the output (data_url) */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_data_url, output->data_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_data_url, output->data_url);
if (ret) {
goto end;
}
/* total size of all stream combined */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_snapshot_max_size, output->max_size);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_snapshot_max_size, output->max_size);
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_snapshot_del_output(struct mi_writer *writer, int id,
- const char *name, const char *current_session_name)
+int mi_lttng_snapshot_del_output(struct mi_writer *writer,
+ int id,
+ const char *name,
+ const char *current_session_name)
{
int ret;
/* Open element del_snapshot */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_snapshot);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_snapshot);
if (ret) {
goto end;
}
-
if (id != UINT32_MAX) {
/* "Snapshot output "id" successfully deleted
* for "current_session_name"
* ID of the snapshot output
*/
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_id, id);
+ ret = mi_lttng_writer_write_element_unsigned_int(writer, mi_lttng_element_id, id);
if (ret) {
goto end;
}
* for session "current_session_name"
* Name of the output
*/
- ret = mi_lttng_writer_write_element_string(writer, config_element_name,
- name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, name);
if (ret) {
goto end;
}
}
/* Snapshot was deleted for session "current_session_name"*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_session_name,
- current_session_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_session_name, current_session_name);
if (ret) {
goto end;
}
}
int mi_lttng_snapshot_add_output(struct mi_writer *writer,
- const char *current_session_name, const char *n_ptr,
- struct lttng_snapshot_output *output)
+ const char *current_session_name,
+ const char *n_ptr,
+ struct lttng_snapshot_output *output)
{
int ret;
/* Open element snapshot */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_snapshot);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_snapshot);
if (ret) {
goto end;
}
/* Snapshot output id */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_id, output->id);
+ ret = mi_lttng_writer_write_element_unsigned_int(writer, mi_lttng_element_id, output->id);
if (ret) {
goto end;
}
/* Snapshot output names */
- ret = mi_lttng_writer_write_element_string(writer,
- config_element_name, n_ptr);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, n_ptr);
if (ret) {
goto end;
}
/* Destination of the output (ctrl_url)*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
if (ret) {
goto end;
}
/* Snapshot added for session "current_session_name"*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_session_name, current_session_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_session_name, current_session_name);
if (ret) {
goto end;
}
/* total size of all stream combined */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_snapshot_max_size, output->max_size);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_snapshot_max_size, output->max_size);
if (ret) {
goto end;
}
return ret;
}
-int mi_lttng_snapshot_record(struct mi_writer *writer, const char *url,
- const char *cmdline_ctrl_url, const char *cmdline_data_url)
+int mi_lttng_snapshot_record(struct mi_writer *writer,
+ const char *url,
+ const char *cmdline_ctrl_url,
+ const char *cmdline_data_url)
{
int ret;
/* Open element snapshot */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_command_snapshot);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command_snapshot);
if (ret) {
goto end;
}
* else take the command line data and ctrl urls*/
if (url) {
/* Destination of the output (ctrl_url)*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_ctrl_url, url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_ctrl_url, url);
if (ret) {
goto end;
}
} else if (cmdline_ctrl_url) {
/* Destination of the output (ctrl_url)*/
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_ctrl_url, cmdline_ctrl_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_ctrl_url, cmdline_ctrl_url);
if (ret) {
goto end;
}
/* Destination of the output (data_url) */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_data_url, cmdline_data_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_data_url, cmdline_data_url);
if (ret) {
goto end;
}
}
int mi_lttng_rotation_schedule(struct mi_writer *writer,
- const struct lttng_rotation_schedule *schedule)
+ const struct lttng_rotation_schedule *schedule)
{
int ret = 0;
enum lttng_rotation_status status;
switch (lttng_rotation_schedule_get_type(schedule)) {
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
- status = lttng_rotation_schedule_periodic_get_period(schedule,
- &value);
+ status = lttng_rotation_schedule_periodic_get_period(schedule, &value);
element_name = mi_lttng_element_rotation_schedule_periodic;
value_name = mi_lttng_element_rotation_schedule_periodic_time_us;
break;
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
- status = lttng_rotation_schedule_size_threshold_get_threshold(
- schedule, &value);
+ status = lttng_rotation_schedule_size_threshold_get_threshold(schedule, &value);
element_name = mi_lttng_element_rotation_schedule_size_threshold;
value_name = mi_lttng_element_rotation_schedule_size_threshold_bytes;
break;
}
if (!empty_schedule) {
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- value_name, value);
+ ret = mi_lttng_writer_write_element_unsigned_int(writer, value_name, value);
if (ret) {
goto end;
}
}
int mi_lttng_rotation_schedule_result(struct mi_writer *writer,
- const struct lttng_rotation_schedule *schedule,
- bool success)
+ const struct lttng_rotation_schedule *schedule,
+ bool success)
{
int ret = 0;
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_schedule_result);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rotation_schedule_result);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_schedule);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rotation_schedule);
if (ret) {
goto end;
}
goto end;
}
- ret = mi_lttng_writer_write_element_bool(writer,
- mi_lttng_element_command_success, success);
+ ret = mi_lttng_writer_write_element_bool(writer, mi_lttng_element_command_success, success);
if (ret) {
goto end;
}
return ret;
}
-static
-int mi_lttng_location(struct mi_writer *writer,
- const struct lttng_trace_archive_location *location)
+static int mi_lttng_location(struct mi_writer *writer,
+ const struct lttng_trace_archive_location *location)
{
int ret = 0;
enum lttng_trace_archive_location_type location_type;
{
const char *absolute_path;
- status = lttng_trace_archive_location_local_get_absolute_path(
- location, &absolute_path);
+ status = lttng_trace_archive_location_local_get_absolute_path(location,
+ &absolute_path);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_location_local);
+ mi_lttng_element_rotation_location_local);
if (ret) {
goto end;
}
-
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_rotation_location_local_absolute_path,
- absolute_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_rotation_location_local_absolute_path,
+ absolute_path);
if (ret) {
goto end;
}
enum lttng_trace_archive_location_relay_protocol_type protocol;
/* Fetch all relay location parameters. */
- status = lttng_trace_archive_location_relay_get_protocol_type(
- location, &protocol);
+ status = lttng_trace_archive_location_relay_get_protocol_type(location, &protocol);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_host(
- location, &host);
+ status = lttng_trace_archive_location_relay_get_host(location, &host);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_control_port(
- location, &control_port);
+ status = lttng_trace_archive_location_relay_get_control_port(location,
+ &control_port);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_data_port(
- location, &data_port);
+ status = lttng_trace_archive_location_relay_get_data_port(location, &data_port);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_archive_location_relay_get_relative_path(
- location, &relative_path);
+ status = lttng_trace_archive_location_relay_get_relative_path(location,
+ &relative_path);
if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) {
ret = -1;
goto end;
}
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_location_relay);
+ mi_lttng_element_rotation_location_relay);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_rotation_location_relay_host,
- host);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_rotation_location_relay_host, host);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_rotation_location_relay_control_port,
- control_port);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer,
+ mi_lttng_element_rotation_location_relay_control_port,
+ control_port);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_rotation_location_relay_data_port,
- data_port);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_rotation_location_relay_data_port, data_port);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_rotation_location_relay_protocol,
- mi_lttng_trace_archive_location_relay_protocol_type_string(protocol));
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_rotation_location_relay_protocol,
+ mi_lttng_trace_archive_location_relay_protocol_type_string(protocol));
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_rotation_location_relay_relative_path,
- relative_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_rotation_location_relay_relative_path,
+ relative_path);
if (ret) {
goto end;
}
}
int mi_lttng_rotate(struct mi_writer *writer,
- const char *session_name,
- enum lttng_rotation_state rotation_state,
- const struct lttng_trace_archive_location *location)
+ const char *session_name,
+ enum lttng_rotation_state rotation_state,
+ const struct lttng_trace_archive_location *location)
{
int ret;
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rotation);
if (ret) {
goto end;
}
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_session_name,
- session_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
if (ret) {
goto end;
}
ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_rotation_state,
- mi_lttng_rotation_state_string(rotation_state));
+ mi_lttng_element_rotation_state,
+ mi_lttng_rotation_state_string(rotation_state));
if (ret) {
goto end;
}
goto close_rotation;
}
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_rotation_location);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_rotation_location);
if (ret) {
goto end;
}
*
*/
-#include <lttng/notification/notification-internal.hpp>
+#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+
#include <lttng/condition/condition-internal.hpp>
-#include <lttng/condition/evaluation-internal.hpp>
#include <lttng/condition/condition.h>
+#include <lttng/condition/evaluation-internal.hpp>
#include <lttng/condition/evaluation.h>
+#include <lttng/notification/notification-internal.hpp>
#include <lttng/trigger/trigger-internal.hpp>
-#include <common/payload.hpp>
-#include <common/payload-view.hpp>
-struct lttng_notification *lttng_notification_create(
- struct lttng_trigger *trigger,
- struct lttng_evaluation *evaluation)
+struct lttng_notification *lttng_notification_create(struct lttng_trigger *trigger,
+ struct lttng_evaluation *evaluation)
{
struct lttng_notification *notification = NULL;
}
int lttng_notification_serialize(const struct lttng_notification *notification,
- struct lttng_payload *payload)
+ struct lttng_payload *payload)
{
int ret;
size_t header_offset, size_before_payload;
notification_comm.length = 0;
header_offset = payload->buffer.size;
- ret = lttng_dynamic_buffer_append(&payload->buffer, ¬ification_comm,
- sizeof(notification_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, ¬ification_comm, sizeof(notification_comm));
if (ret) {
goto end;
}
size_before_payload = payload->buffer.size;
- ret = lttng_trigger_serialize(notification->trigger,
- payload);
+ ret = lttng_trigger_serialize(notification->trigger, payload);
if (ret) {
goto end;
}
header->length = (uint32_t) (payload->buffer.size - size_before_payload);
end:
return ret;
-
}
-ssize_t lttng_notification_create_from_payload(
- struct lttng_payload_view *src_view,
- struct lttng_notification **notification)
+ssize_t lttng_notification_create_from_payload(struct lttng_payload_view *src_view,
+ struct lttng_notification **notification)
{
ssize_t ret, notification_size = 0, trigger_size, evaluation_size;
struct lttng_trigger *trigger = NULL;
struct lttng_evaluation *evaluation = NULL;
const struct lttng_notification_comm *notification_comm;
const struct lttng_payload_view notification_comm_view =
- lttng_payload_view_from_view(
- src_view, 0, sizeof(*notification_comm));
+ lttng_payload_view_from_view(src_view, 0, sizeof(*notification_comm));
if (!src_view || !notification) {
ret = -1;
{
/* struct lttng_condition */
struct lttng_payload_view condition_view =
- lttng_payload_view_from_view(src_view,
- notification_size, -1);
+ lttng_payload_view_from_view(src_view, notification_size, -1);
- trigger_size = lttng_trigger_create_from_payload(
- &condition_view, &trigger);
+ trigger_size = lttng_trigger_create_from_payload(&condition_view, &trigger);
}
if (trigger_size < 0) {
{
/* struct lttng_evaluation */
struct lttng_payload_view evaluation_view =
- lttng_payload_view_from_view(src_view,
- notification_size, -1);
+ lttng_payload_view_from_view(src_view, notification_size, -1);
evaluation_size = lttng_evaluation_create_from_payload(
- lttng_trigger_get_const_condition(trigger),
- &evaluation_view, &evaluation);
+ lttng_trigger_get_const_condition(trigger), &evaluation_view, &evaluation);
}
if (evaluation_size < 0) {
notification_size += evaluation_size;
/* Unexpected size of inner-elements; the buffer is corrupted. */
- if ((ssize_t) notification_comm->length !=
- trigger_size + evaluation_size) {
+ if ((ssize_t) notification_comm->length != trigger_size + evaluation_size) {
ret = -1;
goto error;
}
free(notification);
}
-const struct lttng_condition *lttng_notification_get_condition(
- struct lttng_notification *notification)
+const struct lttng_condition *
+lttng_notification_get_condition(struct lttng_notification *notification)
{
return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL;
}
-const struct lttng_evaluation *lttng_notification_get_evaluation(
- struct lttng_notification *notification)
+const struct lttng_evaluation *
+lttng_notification_get_evaluation(struct lttng_notification *notification)
{
return notification ? notification->evaluation : NULL;
}
-const struct lttng_condition *lttng_notification_get_const_condition(
- const struct lttng_notification *notification)
+const struct lttng_condition *
+lttng_notification_get_const_condition(const struct lttng_notification *notification)
{
return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL;
}
-const struct lttng_evaluation *lttng_notification_get_const_evaluation(
- const struct lttng_notification *notification)
+const struct lttng_evaluation *
+lttng_notification_get_const_evaluation(const struct lttng_notification *notification)
{
return notification ? notification->evaluation : NULL;
}
-const struct lttng_trigger *lttng_notification_get_const_trigger(
- const struct lttng_notification *notification)
+const struct lttng_trigger *
+lttng_notification_get_const_trigger(const struct lttng_notification *notification)
{
return notification ? notification->trigger : NULL;
}
-const struct lttng_trigger *lttng_notification_get_trigger(
- struct lttng_notification *notification)
+const struct lttng_trigger *lttng_notification_get_trigger(struct lttng_notification *notification)
{
return notification ? notification->trigger : NULL;
}
*/
#define _LGPL_SOURCE
-#include <common/macros.hpp>
#include <common/common.hpp>
+#include <common/macros.hpp>
#include <common/path.hpp>
/*
*
* Return a newly-allocated string.
*/
-static
-char *utils_partial_realpath(const char *path)
+static char *utils_partial_realpath(const char *path)
{
char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL;
const char *next, *prev, *end;
* the path given as argument
*/
end = path + strlen(path);
- if (*(end-1) == '/') {
+ if (*(end - 1) == '/') {
end--;
}
next = path;
prev = next;
/* Only to ensure try_path is not NULL to enter the while */
- try_path = (char *)next;
+ try_path = (char *) next;
/* Resolve the canonical path of the first part of the path */
while (try_path != NULL && next != end) {
}
/* Concatenate the strings */
- snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s",
- try_path_prev, cut_path);
+ snprintf(resolved_path, LTTNG_PATH_MAX, "%s%s", try_path_prev, cut_path);
/* Free the allocated memory */
free(cut_path);
free(try_path_prev);
cut_path = NULL;
try_path_prev = NULL;
- /*
- * Else, we just copy the path in our resolved_path to
- * return it as is
- */
+ /*
+ * Else, we just copy the path in our resolved_path to
+ * return it as is
+ */
} else {
strncpy(resolved_path, path, LTTNG_PATH_MAX);
}
return NULL;
}
-static
-int expand_double_slashes_dot_and_dotdot(char *path)
+static int expand_double_slashes_dot_and_dotdot(char *path)
{
size_t expanded_path_len, path_len;
const char *curr_char, *path_last_char, *next_slash, *prev_slash;
/* Compute how long is the previous token. */
curr_token_len = next_slash - curr_char;
- switch(curr_token_len) {
+ switch (curr_token_len) {
case 0:
/*
* The pointer has not move meaning that curr_char is
* previous forward slash and substract that
* len to the resulting path.
*/
- prev_slash = (const char *) lttng_memrchr(path, '/', expanded_path_len);
+ prev_slash =
+ (const char *) lttng_memrchr(path, '/', expanded_path_len);
/*
* If prev_slash is NULL, we reached the
* beginning of the path. We can't go back any
* The returned string was allocated in the function, it is thus of
* the responsibility of the caller to free this memory.
*/
-static
-char *_utils_expand_path(const char *path, bool keep_symlink)
+static char *_utils_expand_path(const char *path, bool keep_symlink)
{
int ret;
char *absolute_path = NULL;
* Get the number of character in the CWD and allocate an array
* to can hold it and the path provided by the caller.
*/
- ret = snprintf(absolute_path, LTTNG_PATH_MAX, "%s/%s",
- current_working_dir, path);
+ ret = snprintf(absolute_path, LTTNG_PATH_MAX, "%s/%s", current_working_dir, path);
if (ret >= LTTNG_PATH_MAX) {
ERR("Concatenating current working directory %s and path %s exceeds maximal size of %i bytes",
- current_working_dir, path, LTTNG_PATH_MAX);
+ current_working_dir,
+ path,
+ LTTNG_PATH_MAX);
goto error;
}
}
*
*/
-#include <common/dynamic-array.hpp>
-#include <common/buffer-view.hpp>
#include "payload-view.hpp"
#include "payload.hpp"
+
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+
#include <stddef.h>
bool lttng_payload_view_is_valid(const struct lttng_payload_view *view)
return view && lttng_buffer_view_is_valid(&view->buffer);
}
-struct lttng_payload_view lttng_payload_view_from_payload(
- const struct lttng_payload *payload, size_t offset,
- ptrdiff_t len)
+struct lttng_payload_view
+lttng_payload_view_from_payload(const struct lttng_payload *payload, size_t offset, ptrdiff_t len)
{
- return payload ? (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_dynamic_buffer(
- &payload->buffer, offset, len),
- ._fd_handles = payload->_fd_handles,
- ._iterator = {},
- } : (struct lttng_payload_view) {
- .buffer = {},
- ._fd_handles = {},
- ._iterator = {},
- };
+ return payload ?
+ (struct lttng_payload_view){
+ .buffer = lttng_buffer_view_from_dynamic_buffer(
+ &payload->buffer, offset, len),
+ ._fd_handles = payload->_fd_handles,
+ ._iterator = {},
+ } :
+ (struct lttng_payload_view){
+ .buffer = {},
+ ._fd_handles = {},
+ ._iterator = {},
+ };
}
-struct lttng_payload_view lttng_payload_view_from_view(
- struct lttng_payload_view *view, size_t offset,
- ptrdiff_t len)
+struct lttng_payload_view
+lttng_payload_view_from_view(struct lttng_payload_view *view, size_t offset, ptrdiff_t len)
{
return view ? (struct lttng_payload_view) {
.buffer = lttng_buffer_view_from_view(
}
struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *buffer, size_t offset,
- ptrdiff_t len)
+ const struct lttng_dynamic_buffer *buffer, size_t offset, ptrdiff_t len)
{
- return buffer ? (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_dynamic_buffer(
- buffer, offset, len),
- ._fd_handles = {},
- ._iterator = {},
- } : (struct lttng_payload_view) {
- .buffer = {},
- ._fd_handles = {},
- ._iterator = {},
- };
+ return buffer ?
+ (struct lttng_payload_view){
+ .buffer = lttng_buffer_view_from_dynamic_buffer(buffer, offset, len),
+ ._fd_handles = {},
+ ._iterator = {},
+ } :
+ (struct lttng_payload_view){
+ .buffer = {},
+ ._fd_handles = {},
+ ._iterator = {},
+ };
}
-struct lttng_payload_view lttng_payload_view_from_buffer_view(
- const struct lttng_buffer_view *view, size_t offset,
- ptrdiff_t len)
+struct lttng_payload_view lttng_payload_view_from_buffer_view(const struct lttng_buffer_view *view,
+ size_t offset,
+ ptrdiff_t len)
{
- return view ? (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_view(
- view, offset, len),
- ._fd_handles = {},
- ._iterator = {},
- } : (struct lttng_payload_view) {
- .buffer = {},
- ._fd_handles = {},
- ._iterator = {},
- };
+ return view ?
+ (struct lttng_payload_view){
+ .buffer = lttng_buffer_view_from_view(view, offset, len),
+ ._fd_handles = {},
+ ._iterator = {},
+ } :
+ (struct lttng_payload_view){
+ .buffer = {},
+ ._fd_handles = {},
+ ._iterator = {},
+ };
}
-struct lttng_payload_view lttng_payload_view_init_from_buffer(
- const char *src, size_t offset, ptrdiff_t len)
+struct lttng_payload_view
+lttng_payload_view_init_from_buffer(const char *src, size_t offset, ptrdiff_t len)
{
- return (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_init(
- src, offset, len),
+ return (struct lttng_payload_view){
+ .buffer = lttng_buffer_view_init(src, offset, len),
._fd_handles = {},
._iterator = {},
};
}
-int lttng_payload_view_get_fd_handle_count(
- const struct lttng_payload_view *payload_view)
+int lttng_payload_view_get_fd_handle_count(const struct lttng_payload_view *payload_view)
{
int ret;
size_t position;
}
position = payload_view->_iterator.p_fd_handles_position ?
- *payload_view->_iterator.p_fd_handles_position :
- payload_view->_iterator.fd_handles_position;
+ *payload_view->_iterator.p_fd_handles_position :
+ payload_view->_iterator.fd_handles_position;
ret = ret - (int) position;
end:
return ret;
}
-struct fd_handle *lttng_payload_view_pop_fd_handle(
- struct lttng_payload_view *view)
+struct fd_handle *lttng_payload_view_pop_fd_handle(struct lttng_payload_view *view)
{
struct fd_handle *handle = NULL;
size_t fd_handle_count;
goto end;
}
- pos = view->_iterator.p_fd_handles_position ?
- view->_iterator.p_fd_handles_position :
- &view->_iterator.fd_handles_position;
- handle = (fd_handle *) lttng_dynamic_pointer_array_get_pointer(&view->_fd_handles,
- *pos);
+ pos = view->_iterator.p_fd_handles_position ? view->_iterator.p_fd_handles_position :
+ &view->_iterator.fd_handles_position;
+ handle = (fd_handle *) lttng_dynamic_pointer_array_get_pointer(&view->_fd_handles, *pos);
(*pos)++;
fd_handle_get(handle);
end:
*/
#include "payload.hpp"
+
#include <common/dynamic-array.hpp>
#include <common/dynamic-buffer.hpp>
#include <common/error.hpp>
-static
-void release_fd_handle_ref(void *ptr)
+static void release_fd_handle_ref(void *ptr)
{
struct fd_handle *fd_handle = (struct fd_handle *) ptr;
{
LTTNG_ASSERT(payload);
lttng_dynamic_buffer_init(&payload->buffer);
- lttng_dynamic_pointer_array_init(&payload->_fd_handles,
- release_fd_handle_ref);
+ lttng_dynamic_pointer_array_init(&payload->_fd_handles, release_fd_handle_ref);
}
-int lttng_payload_copy(const struct lttng_payload *src_payload,
- struct lttng_payload *dst_payload)
+int lttng_payload_copy(const struct lttng_payload *src_payload, struct lttng_payload *dst_payload)
{
int ret;
size_t i;
- ret = lttng_dynamic_buffer_append_buffer(
- &dst_payload->buffer, &src_payload->buffer);
+ ret = lttng_dynamic_buffer_append_buffer(&dst_payload->buffer, &src_payload->buffer);
if (ret) {
goto end;
}
- for (i = 0; i < lttng_dynamic_pointer_array_get_count(
- &src_payload->_fd_handles);
- i++) {
+ for (i = 0; i < lttng_dynamic_pointer_array_get_count(&src_payload->_fd_handles); i++) {
struct fd_handle *new_fd_handle;
const struct fd_handle *src_fd_handle =
- (fd_handle *) lttng_dynamic_pointer_array_get_pointer(
- &src_payload->_fd_handles, i);
+ (fd_handle *) lttng_dynamic_pointer_array_get_pointer(
+ &src_payload->_fd_handles, i);
new_fd_handle = fd_handle_copy(src_fd_handle);
if (!new_fd_handle) {
lttng_dynamic_pointer_array_clear(&payload->_fd_handles);
}
-int lttng_payload_push_fd_handle(struct lttng_payload *payload,
- struct fd_handle *fd_handle)
+int lttng_payload_push_fd_handle(struct lttng_payload *payload, struct fd_handle *fd_handle)
{
int ret;
goto end;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &payload->_fd_handles, fd_handle);
+ ret = lttng_dynamic_pointer_array_add_pointer(&payload->_fd_handles, fd_handle);
if (ret) {
goto end;
}
*/
#define _LGPL_SOURCE
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include "pipe.hpp"
#include <common/common.hpp>
-#include "pipe.hpp"
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
/*
* Lock read side of a pipe.
*
* Return a newly allocated lttng pipe on success or else NULL.
*/
-struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
- int flags)
+struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode, int flags)
{
int ret, fd_r, fd_w;
struct lttng_pipe *pipe;
* Return "count" on success. Return < count on error. errno can be used
* to check the actual error.
*/
-ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
- size_t count)
+ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf, size_t count)
{
ssize_t ret;
*
*/
-#include <lttng/constant.h>
-
#include <common/file-descriptor.hpp>
#include <common/format.hpp>
#include <common/hashtable/utils.hpp>
#include <common/readwrite.hpp>
#include <common/time.hpp>
+#include <lttng/constant.h>
+
#include <fcntl.h>
#ifdef HAVE_SYS_SYSCALL_H
if (ret < 0) {
LTTNG_THROW_POSIX(
- fmt::format("Failed to get true random data using getrandom(): size={}",
- size),
- errno);
+ fmt::format("Failed to get true random data using getrandom(): size={}",
+ size),
+ errno);
}
}
#else /* defined(__linux__) && defined(SYS_getrandom) && defined(HAVE_SYS_RANDOM_H) */
void getrandom_nonblock(char *out_data, std::size_t size)
{
- LTTNG_THROW_RANDOM_PRODUCTION_ERROR(
- "getrandom() is not supported by this platform");
+ LTTNG_THROW_RANDOM_PRODUCTION_ERROR("getrandom() is not supported by this platform");
}
#endif /* defined(__linux__) && defined(SYS_getrandom) && defined(HAVE_SYS_RANDOM_H) */
ret = clock_gettime(CLOCK_REALTIME, &real_time);
if (ret) {
LTTNG_THROW_POSIX("Failed to read real time while generating pseudo-random seed",
- errno);
+ errno);
}
ret = clock_gettime(CLOCK_MONOTONIC, &monotonic_time);
if (ret) {
LTTNG_THROW_POSIX(
- "Failed to read monotonic time while generating pseudo-random seed",
- errno);
+ "Failed to read monotonic time while generating pseudo-random seed", errno);
}
ret = gethostname(hostname, sizeof(hostname));
if (ret) {
LTTNG_THROW_POSIX("Failed to get host name while generating pseudo-random seed",
- errno);
+ errno);
}
hash_seed = (unsigned long) real_time.tv_nsec ^ (unsigned long) real_time.tv_sec ^
- (unsigned long) monotonic_time.tv_nsec ^
- (unsigned long) monotonic_time.tv_sec;
+ (unsigned long) monotonic_time.tv_nsec ^ (unsigned long) monotonic_time.tv_sec;
seed = hash_key_ulong((void *) real_time.tv_sec, hash_seed);
seed ^= hash_key_ulong((void *) real_time.tv_nsec, hash_seed);
seed ^= hash_key_ulong((void *) monotonic_time.tv_sec, hash_seed);
* Open /dev/urandom as a file_descriptor, or throw on error. The
* lambda is used to reduce the scope of the raw fd as much as possible.
*/
- lttng::file_descriptor urandom{[]() {
+ lttng::file_descriptor urandom{ []() {
const auto urandom_raw_fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
if (urandom_raw_fd < 0) {
}
return urandom_raw_fd;
- }()};
+ }() };
lttng::random::seed_t seed;
const auto read_ret = lttng_read(urandom.fd(), &seed, sizeof(seed));
if (read_ret != sizeof(seed)) {
LTTNG_THROW_POSIX(fmt::format("Failed to read from `/dev/urandom`: size={}",
- sizeof(seed)),
- errno);
+ sizeof(seed)),
+ errno);
}
return seed;
} /* namespace */
lttng::random::production_error::production_error(const std::string& msg,
- const char *file_name,
- const char *function_name,
- unsigned int line_number) :
+ const char *file_name,
+ const char *function_name,
+ unsigned int line_number) :
lttng::runtime_error(msg, file_name, function_name, line_number)
{
}
return lttng::random::produce_true_random_seed();
} catch (std::exception& e) {
WARN("%s",
- fmt::format("Failed to produce a random seed using getrandom(), falling back to pseudo-random device seed generation which will block until its pool is initialized: {}",
- e.what())
- .c_str());
+ fmt::format(
+ "Failed to produce a random seed using getrandom(), falling back to pseudo-random device seed generation which will block until its pool is initialized: {}",
+ e.what())
+ .c_str());
}
try {
produce_random_seed_from_urandom();
} catch (std::exception& e) {
WARN("%s",
- fmt::format("Failed to produce a random seed from the urandom device: {}",
- e.what())
- .c_str());
+ fmt::format("Failed to produce a random seed from the urandom device: {}",
+ e.what())
+ .c_str());
}
/* Fallback to time-based seed generation. */
*/
#define _LGPL_SOURCE
-#include <limits.h>
-#include <unistd.h>
+#include "readwrite.hpp"
#include <common/compat/errno.hpp>
-#include "readwrite.hpp"
+#include <limits.h>
+#include <unistd.h>
/*
* lttng_read and lttng_write take care of EINTR and partial read/write.
ret = read(fd, (char *) buf + i, count - i);
if (ret < 0) {
if (errno == EINTR) {
- continue; /* retry operation */
+ continue; /* retry operation */
} else {
goto error;
}
ret = write(fd, (char *) buf + i, count - i);
if (ret < 0) {
if (errno == EINTR) {
- continue; /* retry operation */
+ continue; /* retry operation */
} else {
goto error;
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <inttypes.h>
+#include "relayd.hpp"
#include <common/common.hpp>
-#include <common/defaults.hpp>
#include <common/compat/endian.hpp>
#include <common/compat/string.hpp>
-#include <common/sessiond-comm/relayd.hpp>
+#include <common/defaults.hpp>
#include <common/index/ctf-index.hpp>
-#include <common/trace-chunk.hpp>
+#include <common/sessiond-comm/relayd.hpp>
#include <common/string-utils/format.hpp>
+#include <common/trace-chunk.hpp>
-#include "relayd.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
-static
-bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
+static bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
{
if (sock->major > 2) {
return true;
return false;
}
-static
-bool relayd_supports_get_configuration(const struct lttcomm_relayd_sock *sock)
+static bool relayd_supports_get_configuration(const struct lttcomm_relayd_sock *sock)
{
if (sock->major > 2) {
return true;
* Send command. Fill up the header and append the data.
*/
static int send_command(struct lttcomm_relayd_sock *rsock,
- enum lttcomm_relayd_command cmd, const void *data, size_t size,
- int flags)
+ enum lttcomm_relayd_command cmd,
+ const void *data,
+ size_t size,
+ int flags)
{
int ret;
struct lttcomm_relayd_hdr header;
}
DBG3("Relayd sending command %s of size %" PRIu64,
- lttcomm_relayd_command_str(cmd), buf_size);
+ lttcomm_relayd_command_str(cmd),
+ buf_size);
ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
if (ret < 0) {
PERROR("Failed to send command %s of size %" PRIu64,
- lttcomm_relayd_command_str(cmd), buf_size);
- ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
+ lttcomm_relayd_command_str(cmd),
+ buf_size);
+ ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
ret = -errno;
goto error;
}
DBG("Socket %d has performed an orderly shutdown", rsock->sock.fd);
} else {
DBG("Receiving reply failed on sock %d for size %zu with ret %d",
- rsock->sock.fd, size, ret);
+ rsock->sock.fd,
+ size,
+ ret);
}
/* Always return -1 here and the caller can use errno. */
ret = -1;
* payload size is introduced.
*/
static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- unsigned int snapshot, uint64_t sessiond_session_id,
- const lttng_uuid& sessiond_uuid, const uint64_t *current_chunk_id,
- time_t creation_time, bool session_name_contains_creation_time,
- struct lttcomm_relayd_create_session_reply_2_11 *reply,
- char *output_path)
+ const char *session_name,
+ const char *hostname,
+ const char *base_path,
+ int session_live_timer,
+ unsigned int snapshot,
+ uint64_t sessiond_session_id,
+ const lttng_uuid& sessiond_uuid,
+ const uint64_t *current_chunk_id,
+ time_t creation_time,
+ bool session_name_contains_creation_time,
+ struct lttcomm_relayd_create_session_reply_2_11 *reply,
+ char *output_path)
{
int ret;
struct lttcomm_relayd_create_session_2_11 *msg = NULL;
msg->session_id = htobe64(sessiond_session_id);
msg->session_name_contains_creation_time = session_name_contains_creation_time;
if (current_chunk_id) {
- LTTNG_OPTIONAL_SET(&msg->current_chunk_id,
- htobe64(*current_chunk_id));
+ LTTNG_OPTIONAL_SET(&msg->current_chunk_id, htobe64(*current_chunk_id));
}
msg->creation_time = htobe64((uint64_t) creation_time);
reply->generic.ret_code = be32toh(reply->generic.ret_code);
reply->output_path_length = be32toh(reply->output_path_length);
if (reply->output_path_length >= LTTNG_PATH_MAX) {
- ERR("Invalid session output path length in reply (%" PRIu32 " bytes) exceeds maximal allowed length (%d bytes)",
- reply->output_path_length, LTTNG_PATH_MAX);
+ ERR("Invalid session output path length in reply (%" PRIu32
+ " bytes) exceeds maximal allowed length (%d bytes)",
+ reply->output_path_length,
+ LTTNG_PATH_MAX);
ret = -1;
goto error;
}
* support the live reading capability.
*/
static int relayd_create_session_2_4(struct lttcomm_relayd_sock *rsock,
- const char *session_name, const char *hostname,
- int session_live_timer, unsigned int snapshot,
- struct lttcomm_relayd_status_session *reply)
+ const char *session_name,
+ const char *hostname,
+ int session_live_timer,
+ unsigned int snapshot,
+ struct lttcomm_relayd_status_session *reply)
{
int ret;
struct lttcomm_relayd_create_session_2_4 msg;
- if (lttng_strncpy(msg.session_name, session_name,
- sizeof(msg.session_name))) {
+ if (lttng_strncpy(msg.session_name, session_name, sizeof(msg.session_name))) {
ret = -1;
goto error;
}
* RELAYD_CREATE_SESSION from 2.1 to 2.3.
*/
static int relayd_create_session_2_1(struct lttcomm_relayd_sock *rsock,
- struct lttcomm_relayd_status_session *reply)
+ struct lttcomm_relayd_status_session *reply)
{
int ret;
* a lttng error code from the relayd.
*/
int relayd_create_session(struct lttcomm_relayd_sock *rsock,
- uint64_t *relayd_session_id,
- const char *session_name, const char *hostname,
- const char *base_path, int session_live_timer,
- unsigned int snapshot, uint64_t sessiond_session_id,
- const lttng_uuid& sessiond_uuid,
- const uint64_t *current_chunk_id,
- time_t creation_time, bool session_name_contains_creation_time,
- char *output_path)
+ uint64_t *relayd_session_id,
+ const char *session_name,
+ const char *hostname,
+ const char *base_path,
+ int session_live_timer,
+ unsigned int snapshot,
+ uint64_t sessiond_session_id,
+ const lttng_uuid& sessiond_uuid,
+ const uint64_t *current_chunk_id,
+ time_t creation_time,
+ bool session_name_contains_creation_time,
+ char *output_path)
{
int ret;
struct lttcomm_relayd_create_session_reply_2_11 reply = {};
ret = relayd_create_session_2_1(rsock, &reply.generic);
} else if (rsock->minor >= 4 && rsock->minor < 11) {
/* From 2.4 to 2.10 */
- ret = relayd_create_session_2_4(rsock, session_name,
- hostname, session_live_timer, snapshot,
- &reply.generic);
+ ret = relayd_create_session_2_4(
+ rsock, session_name, hostname, session_live_timer, snapshot, &reply.generic);
} else {
/* From 2.11 to ... */
- ret = relayd_create_session_2_11(rsock, session_name,
- hostname, base_path, session_live_timer, snapshot,
- sessiond_session_id, sessiond_uuid,
- current_chunk_id, creation_time,
- session_name_contains_creation_time,
- &reply, output_path);
+ ret = relayd_create_session_2_11(rsock,
+ session_name,
+ hostname,
+ base_path,
+ session_live_timer,
+ snapshot,
+ sessiond_session_id,
+ sessiond_uuid,
+ current_chunk_id,
+ creation_time,
+ session_name_contains_creation_time,
+ &reply,
+ output_path);
}
if (ret < 0) {
/* Return session id or negative ret code. */
if (reply.generic.ret_code != LTTNG_OK) {
ret = -1;
- ERR("Relayd create session replied error %d",
- reply.generic.ret_code);
+ ERR("Relayd create session replied error %d", reply.generic.ret_code);
goto error;
} else {
ret = 0;
}
static int relayd_add_stream_2_1(struct lttcomm_relayd_sock *rsock,
- const char *channel_name, const char *pathname)
+ const char *channel_name,
+ const char *pathname)
{
int ret;
struct lttcomm_relayd_add_stream msg;
memset(&msg, 0, sizeof(msg));
- if (lttng_strncpy(msg.channel_name, channel_name,
- sizeof(msg.channel_name))) {
+ if (lttng_strncpy(msg.channel_name, channel_name, sizeof(msg.channel_name))) {
ret = -1;
goto error;
}
- if (lttng_strncpy(msg.pathname, pathname,
- sizeof(msg.pathname))) {
+ if (lttng_strncpy(msg.pathname, pathname, sizeof(msg.pathname))) {
ret = -1;
goto error;
}
}
static int relayd_add_stream_2_2(struct lttcomm_relayd_sock *rsock,
- const char *channel_name, const char *pathname,
- uint64_t tracefile_size, uint64_t tracefile_count)
+ const char *channel_name,
+ const char *pathname,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count)
{
int ret;
struct lttcomm_relayd_add_stream_2_2 msg;
memset(&msg, 0, sizeof(msg));
/* Compat with relayd 2.2 to 2.10 */
- if (lttng_strncpy(msg.channel_name, channel_name,
- sizeof(msg.channel_name))) {
+ if (lttng_strncpy(msg.channel_name, channel_name, sizeof(msg.channel_name))) {
ret = -1;
goto error;
}
- if (lttng_strncpy(msg.pathname, pathname,
- sizeof(msg.pathname))) {
+ if (lttng_strncpy(msg.pathname, pathname, sizeof(msg.pathname))) {
ret = -1;
goto error;
}
}
static int relayd_add_stream_2_11(struct lttcomm_relayd_sock *rsock,
- const char *channel_name, const char *pathname,
- uint64_t tracefile_size, uint64_t tracefile_count,
- uint64_t trace_archive_id)
+ const char *channel_name,
+ const char *pathname,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ uint64_t trace_archive_id)
{
int ret;
struct lttcomm_relayd_add_stream_2_11 *msg = NULL;
*
* On success return 0 else return ret_code negative value.
*/
-int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_name,
- const char *domain_name, const char *_pathname, uint64_t *stream_id,
- uint64_t tracefile_size, uint64_t tracefile_count,
- struct lttng_trace_chunk *trace_chunk)
+int relayd_add_stream(struct lttcomm_relayd_sock *rsock,
+ const char *channel_name,
+ const char *domain_name,
+ const char *_pathname,
+ uint64_t *stream_id,
+ uint64_t tracefile_size,
+ uint64_t tracefile_count,
+ struct lttng_trace_chunk *trace_chunk)
{
int ret;
struct lttcomm_relayd_status_stream reply;
} else if (rsock->minor > 1 && rsock->minor < 11) {
/* From 2.2 to 2.10 */
- ret = relayd_add_stream_2_2(rsock, channel_name, _pathname,
- tracefile_size, tracefile_count);
+ ret = relayd_add_stream_2_2(
+ rsock, channel_name, _pathname, tracefile_size, tracefile_count);
} else {
const char *separator;
enum lttng_trace_chunk_status chunk_status;
separator = "/";
}
- ret = snprintf(pathname, RELAYD_COMM_LTTNG_PATH_MAX, "%s%s%s",
- domain_name, separator, _pathname);
+ ret = snprintf(pathname,
+ RELAYD_COMM_LTTNG_PATH_MAX,
+ "%s%s%s",
+ domain_name,
+ separator,
+ _pathname);
if (ret <= 0 || ret >= RELAYD_COMM_LTTNG_PATH_MAX) {
ERR("Failed to format stream path: %s",
- ret <= 0 ? "formatting error" :
- "path exceeds maximal allowed length");
+ ret <= 0 ? "formatting error" : "path exceeds maximal allowed length");
ret = -1;
goto error;
}
- chunk_status = lttng_trace_chunk_get_id(trace_chunk,
- &chunk_id);
+ chunk_status = lttng_trace_chunk_get_id(trace_chunk, &chunk_id);
LTTNG_ASSERT(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
/* From 2.11 to ...*/
- ret = relayd_add_stream_2_11(rsock, channel_name, pathname,
- tracefile_size, tracefile_count,
- chunk_id);
+ ret = relayd_add_stream_2_11(
+ rsock, channel_name, pathname, tracefile_size, tracefile_count, chunk_id);
}
if (ret) {
*stream_id = reply.handle;
}
- DBG("Relayd stream added successfully with handle %" PRIu64,
- reply.handle);
+ DBG("Relayd stream added successfully with handle %" PRIu64, reply.handle);
error:
return ret;
/* Code flow error. Safety net. */
LTTNG_ASSERT(rsock);
- DBG("Relayd version check for major.minor %u.%u", rsock->major,
- rsock->minor);
+ DBG("Relayd version check for major.minor %u.%u", rsock->major, rsock->minor);
memset(&msg, 0, sizeof(msg));
/* Prepare network byte order before transmission. */
/* Not compatible */
ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
DBG2("Relayd version is NOT compatible. Relayd version %u != %u (us)",
- msg.major, rsock->major);
+ msg.major,
+ rsock->major);
goto error;
}
/* Version number compatible */
DBG2("Relayd version is compatible, using protocol version %u.%u",
- rsock->major, rsock->minor);
+ rsock->major,
+ rsock->minor);
ret = 0;
error:
* Send data header structure to the relayd.
*/
int relayd_send_data_hdr(struct lttcomm_relayd_sock *rsock,
- struct lttcomm_relayd_data_hdr *hdr, size_t size)
+ struct lttcomm_relayd_data_hdr *hdr,
+ size_t size)
{
int ret;
/*
* Send close stream command to the relayd.
*/
-int relayd_send_close_stream(struct lttcomm_relayd_sock *rsock, uint64_t stream_id,
- uint64_t last_net_seq_num)
+int relayd_send_close_stream(struct lttcomm_relayd_sock *rsock,
+ uint64_t stream_id,
+ uint64_t last_net_seq_num)
{
int ret;
struct lttcomm_relayd_close_stream msg;
*
* Return 0 if NOT pending, 1 if so and a negative value on error.
*/
-int relayd_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t stream_id,
- uint64_t last_net_seq_num)
+int relayd_data_pending(struct lttcomm_relayd_sock *rsock,
+ uint64_t stream_id,
+ uint64_t last_net_seq_num)
{
int ret;
struct lttcomm_relayd_data_pending msg;
msg.last_net_seq_num = htobe64(last_net_seq_num);
/* Send command */
- ret = send_command(rsock, RELAYD_DATA_PENDING, (void *) &msg,
- sizeof(msg), 0);
+ ret = send_command(rsock, RELAYD_DATA_PENDING, (void *) &msg, sizeof(msg), 0);
if (ret < 0) {
goto error;
}
/* At this point, the ret code is either 1 or 0 */
ret = reply.ret_code;
- DBG("Relayd data is %s pending for stream id %" PRIu64,
- ret == 1 ? "" : "NOT", stream_id);
+ DBG("Relayd data is %s pending for stream id %" PRIu64, ret == 1 ? "" : "NOT", stream_id);
error:
return ret;
/*
* Check on the relayd side for a quiescent state on the control socket.
*/
-int relayd_quiescent_control(struct lttcomm_relayd_sock *rsock,
- uint64_t metadata_stream_id)
+int relayd_quiescent_control(struct lttcomm_relayd_sock *rsock, uint64_t metadata_stream_id)
{
int ret;
struct lttcomm_relayd_quiescent_control msg;
* Return 0 on success and set is_data_inflight to 0 if no data is being
* streamed or 1 if it is the case.
*/
-int relayd_end_data_pending(struct lttcomm_relayd_sock *rsock, uint64_t id,
- unsigned int *is_data_inflight)
+int relayd_end_data_pending(struct lttcomm_relayd_sock *rsock,
+ uint64_t id,
+ unsigned int *is_data_inflight)
{
int ret, recv_ret;
struct lttcomm_relayd_end_data_pending msg;
* Send index to the relayd.
*/
int relayd_send_index(struct lttcomm_relayd_sock *rsock,
- struct ctf_packet_index *index, uint64_t relay_stream_id,
- uint64_t net_seq_num)
+ struct ctf_packet_index *index,
+ uint64_t relay_stream_id,
+ uint64_t net_seq_num)
{
int ret;
struct lttcomm_relayd_index msg;
}
/* Send command */
- ret = send_command(rsock, RELAYD_SEND_INDEX, &msg,
- lttcomm_relayd_index_len(lttng_to_index_major(rsock->major,
- rsock->minor),
- lttng_to_index_minor(rsock->major, rsock->minor)),
- 0);
+ ret = send_command(
+ rsock,
+ RELAYD_SEND_INDEX,
+ &msg,
+ lttcomm_relayd_index_len(lttng_to_index_major(rsock->major, rsock->minor),
+ lttng_to_index_minor(rsock->major, rsock->minor)),
+ 0);
if (ret < 0) {
goto error;
}
/*
* Ask the relay to reset the metadata trace file (regeneration).
*/
-int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock,
- uint64_t stream_id, uint64_t version)
+int relayd_reset_metadata(struct lttcomm_relayd_sock *rsock, uint64_t stream_id, uint64_t version)
{
int ret;
struct lttcomm_relayd_reset_metadata msg;
}
int relayd_rotate_streams(struct lttcomm_relayd_sock *sock,
- unsigned int stream_count, const uint64_t *new_chunk_id,
- const struct relayd_stream_rotation_position *positions)
+ unsigned int stream_count,
+ const uint64_t *new_chunk_id,
+ const struct relayd_stream_rotation_position *positions)
{
int ret;
unsigned int i;
LTTNG_ASSERT(sock);
if (new_chunk_id) {
- ret = snprintf(new_chunk_id_buf, sizeof(new_chunk_id_buf),
- "%" PRIu64, *new_chunk_id);
+ ret = snprintf(
+ new_chunk_id_buf, sizeof(new_chunk_id_buf), "%" PRIu64, *new_chunk_id);
if (ret == -1 || ret >= sizeof(new_chunk_id_buf)) {
new_chunk_id_str = "formatting error";
} else {
}
DBG("Preparing \"rotate streams\" command payload: new_chunk_id = %s, stream_count = %u",
- new_chunk_id_str, stream_count);
+ new_chunk_id_str,
+ stream_count);
ret = lttng_dynamic_buffer_append(&payload, &msg, sizeof(msg));
if (ret) {
}
for (i = 0; i < stream_count; i++) {
- const struct relayd_stream_rotation_position *position =
- &positions[i];
+ const struct relayd_stream_rotation_position *position = &positions[i];
const struct lttcomm_relayd_stream_rotation_position comm_position = {
.stream_id = htobe64(position->stream_id),
- .rotate_at_seq_num = htobe64(
- position->rotate_at_seq_num),
+ .rotate_at_seq_num = htobe64(position->rotate_at_seq_num),
};
DBG("Rotate stream %" PRIu64 " at sequence number %" PRIu64,
- position->stream_id,
- position->rotate_at_seq_num);
- ret = lttng_dynamic_buffer_append(&payload, &comm_position,
- sizeof(comm_position));
+ position->stream_id,
+ position->rotate_at_seq_num);
+ ret = lttng_dynamic_buffer_append(&payload, &comm_position, sizeof(comm_position));
if (ret) {
ERR("Failed to allocate \"rotate streams\" command payload");
goto error;
}
/* Send command. */
- ret = send_command(sock, RELAYD_ROTATE_STREAMS, payload.data,
- payload.size, 0);
+ ret = send_command(sock, RELAYD_ROTATE_STREAMS, payload.data, payload.size, 0);
if (ret < 0) {
ERR("Failed to send \"rotate stream\" command");
goto error;
return ret;
}
-int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock,
- struct lttng_trace_chunk *chunk)
+int relayd_create_trace_chunk(struct lttcomm_relayd_sock *sock, struct lttng_trace_chunk *chunk)
{
int ret = 0;
enum lttng_trace_chunk_status status;
goto end;
}
- status = lttng_trace_chunk_get_creation_timestamp(
- chunk, &creation_timestamp);
+ status = lttng_trace_chunk_get_creation_timestamp(chunk, &creation_timestamp);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ret = -1;
goto end;
}
- status = lttng_trace_chunk_get_name(
- chunk, &chunk_name, &overridden_name);
- if (status != LTTNG_TRACE_CHUNK_STATUS_OK &&
- status != LTTNG_TRACE_CHUNK_STATUS_NONE) {
+ status = lttng_trace_chunk_get_name(chunk, &chunk_name, &overridden_name);
+ if (status != LTTNG_TRACE_CHUNK_STATUS_OK && status != LTTNG_TRACE_CHUNK_STATUS_NONE) {
ret = -1;
goto end;
}
goto end;
}
if (chunk_name_length) {
- ret = lttng_dynamic_buffer_append(
- &payload, chunk_name, chunk_name_length);
+ ret = lttng_dynamic_buffer_append(&payload, chunk_name, chunk_name_length);
if (ret) {
goto end;
}
}
- ret = send_command(sock, RELAYD_CREATE_TRACE_CHUNK, payload.data,
- payload.size, 0);
+ ret = send_command(sock, RELAYD_CREATE_TRACE_CHUNK, payload.data, payload.size, 0);
if (ret < 0) {
ERR("Failed to send trace chunk creation command to relay daemon");
goto end;
reply.ret_code = be32toh(reply.ret_code);
if (reply.ret_code != LTTNG_OK) {
ret = -1;
- ERR("Relayd trace chunk create replied error %d",
- reply.ret_code);
+ ERR("Relayd trace chunk create replied error %d", reply.ret_code);
} else {
ret = 0;
- DBG("Relayd successfully created trace chunk: chunk_id = %" PRIu64,
- chunk_id);
+ DBG("Relayd successfully created trace chunk: chunk_id = %" PRIu64, chunk_id);
}
end:
}
int relayd_close_trace_chunk(struct lttcomm_relayd_sock *sock,
- struct lttng_trace_chunk *chunk,
- char *path)
+ struct lttng_trace_chunk *chunk,
+ char *path)
{
int ret = 0;
enum lttng_trace_chunk_status status;
goto end;
}
- status = lttng_trace_chunk_get_close_command(chunk,
- &close_command.value);
+ status = lttng_trace_chunk_get_close_command(chunk, &close_command.value);
switch (status) {
case LTTNG_TRACE_CHUNK_STATUS_OK:
close_command.is_set = 1;
},
};
- ret = send_command(sock, RELAYD_CLOSE_TRACE_CHUNK, &msg, sizeof(msg),
- 0);
+ ret = send_command(sock, RELAYD_CLOSE_TRACE_CHUNK, &msg, sizeof(msg), 0);
if (ret < 0) {
ERR("Failed to send trace chunk close command to relay daemon");
goto end;
reply.generic.ret_code = be32toh(reply.generic.ret_code);
if (reply.generic.ret_code != LTTNG_OK) {
ret = -1;
- ERR("Relayd trace chunk close replied error %d",
- reply.generic.ret_code);
+ ERR("Relayd trace chunk close replied error %d", reply.generic.ret_code);
} else {
ret = 0;
- DBG("Relayd successfully closed trace chunk: chunk_id = %" PRIu64,
- chunk_id);
+ DBG("Relayd successfully closed trace chunk: chunk_id = %" PRIu64, chunk_id);
}
end:
return ret;
}
int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
- uint64_t chunk_id, bool *chunk_exists)
+ uint64_t chunk_id,
+ bool *chunk_exists)
{
int ret = 0;
struct lttcomm_relayd_trace_chunk_exists msg = {};
}
msg = (typeof(msg)){
- .chunk_id = htobe64(chunk_id),
+ .chunk_id = htobe64(chunk_id),
};
- ret = send_command(sock, RELAYD_TRACE_CHUNK_EXISTS, &msg, sizeof(msg),
- 0);
+ ret = send_command(sock, RELAYD_TRACE_CHUNK_EXISTS, &msg, sizeof(msg), 0);
if (ret < 0) {
ERR("Failed to send trace chunk exists command to relay daemon");
goto end;
reply.generic.ret_code = be32toh(reply.generic.ret_code);
if (reply.generic.ret_code != LTTNG_OK) {
ret = -1;
- ERR("Relayd trace chunk close replied error %d",
- reply.generic.ret_code);
+ ERR("Relayd trace chunk close replied error %d", reply.generic.ret_code);
} else {
ret = 0;
DBG("Relayd successfully checked trace chunk existence: chunk_id = %" PRIu64
- ", exists = %s", chunk_id,
- reply.trace_chunk_exists ? "true" : "false");
+ ", exists = %s",
+ chunk_id,
+ reply.trace_chunk_exists ? "true" : "false");
*chunk_exists = !!reply.trace_chunk_exists;
}
end:
}
int relayd_get_configuration(struct lttcomm_relayd_sock *sock,
- uint64_t query_flags,
- uint64_t *result_flags)
+ uint64_t query_flags,
+ uint64_t *result_flags)
{
int ret = 0;
- struct lttcomm_relayd_get_configuration msg = (typeof(msg)) {
+ struct lttcomm_relayd_get_configuration msg = (typeof(msg)){
.query_flags = htobe64(query_flags),
};
struct lttcomm_relayd_get_configuration_reply reply = {};
goto end;
}
- ret = send_command(sock, RELAYD_GET_CONFIGURATION, &msg, sizeof(msg),
- 0);
+ ret = send_command(sock, RELAYD_GET_CONFIGURATION, &msg, sizeof(msg), 0);
if (ret < 0) {
ERR("Failed to send get configuration command to relay daemon");
goto end;
reply.generic.ret_code = be32toh(reply.generic.ret_code);
if (reply.generic.ret_code != LTTNG_OK) {
ret = -1;
- ERR("Relayd get configuration replied error %d",
- reply.generic.ret_code);
+ ERR("Relayd get configuration replied error %d", reply.generic.ret_code);
} else {
- reply.relayd_configuration_flags =
- be64toh(reply.relayd_configuration_flags);
+ reply.relayd_configuration_flags = be64toh(reply.relayd_configuration_flags);
ret = 0;
DBG("Relayd successfully got configuration: query_flags = %" PRIu64
- ", results_flags = %" PRIu64, query_flags,
- reply.relayd_configuration_flags);
+ ", results_flags = %" PRIu64,
+ query_flags,
+ reply.relayd_configuration_flags);
*result_flags = reply.relayd_configuration_flags;
}
end:
*/
#define _LGPL_SOURCE
+#include "runas.hpp"
+
+#include <common/bytecode/bytecode.hpp>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/getenv.hpp>
+#include <common/compat/string.hpp>
+#include <common/defaults.hpp>
+#include <common/filter/filter-ast.hpp>
+#include <common/lttng-elf.hpp>
+#include <common/lttng-kernel.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/thread.hpp>
+#include <common/unix.hpp>
+#include <common/utils.hpp>
+
+#include <lttng/constant.h>
+
#include <fcntl.h>
#include <grp.h>
#include <limits.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <common/bytecode/bytecode.hpp>
-#include <common/lttng-kernel.hpp>
-#include <common/common.hpp>
-#include <common/utils.hpp>
-#include <common/compat/errno.hpp>
-#include <common/compat/getenv.hpp>
-#include <common/compat/string.hpp>
-#include <common/unix.hpp>
-#include <common/defaults.hpp>
-#include <common/lttng-elf.hpp>
-#include <common/thread.hpp>
-
-#include <lttng/constant.h>
-
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/filter/filter-ast.hpp>
-
-#include "runas.hpp"
-
#define GETPW_BUFFER_FALLBACK_SIZE 4096
enum run_as_cmd {
bool _error;
} LTTNG_PACKED;
-#define COMMAND_IN_FDS(data_ptr) ({ \
- int *fds = NULL; \
- if (command_properties[data_ptr->cmd].in_fds_offset != -1) { \
- fds = (int *) ((char *) data_ptr + command_properties[data_ptr->cmd].in_fds_offset); \
- } \
- fds; \
-})
-
-#define COMMAND_OUT_FDS(cmd, ret_ptr) ({ \
- int *fds = NULL; \
- if (command_properties[cmd].out_fds_offset != -1) { \
- fds = (int *) ((char *) ret_ptr + command_properties[cmd].out_fds_offset); \
- } \
- fds; \
-})
-
-#define COMMAND_IN_FD_COUNT(data_ptr) ({ \
- command_properties[data_ptr->cmd].in_fd_count; \
-})
-
-#define COMMAND_OUT_FD_COUNT(cmd) ({ \
- command_properties[cmd].out_fd_count; \
-})
+#define COMMAND_IN_FDS(data_ptr) \
+ ({ \
+ int *fds = NULL; \
+ if (command_properties[data_ptr->cmd].in_fds_offset != -1) { \
+ fds = (int *) ((char *) data_ptr + \
+ command_properties[data_ptr->cmd].in_fds_offset); \
+ } \
+ fds; \
+ })
+
+#define COMMAND_OUT_FDS(cmd, ret_ptr) \
+ ({ \
+ int *fds = NULL; \
+ if (command_properties[cmd].out_fds_offset != -1) { \
+ fds = (int *) ((char *) ret_ptr + command_properties[cmd].out_fds_offset); \
+ } \
+ fds; \
+ })
+
+#define COMMAND_IN_FD_COUNT(data_ptr) ({ command_properties[data_ptr->cmd].in_fd_count; })
+
+#define COMMAND_OUT_FD_COUNT(cmd) ({ command_properties[cmd].out_fd_count; })
#define COMMAND_USE_CWD_FD(data_ptr) command_properties[data_ptr->cmd].use_cwd_fd
.use_cwd_fd = false,
},
{
- .in_fds_offset = offsetof(struct run_as_data,
- u.extract_elf_symbol_offset.fd),
+ .in_fds_offset = offsetof(struct run_as_data, u.extract_elf_symbol_offset.fd),
.out_fds_offset = -1,
.in_fd_count = 1,
.out_fd_count = 0,
.use_cwd_fd = false,
},
{
- .in_fds_offset = offsetof(struct run_as_data,
- u.extract_sdt_probe_offsets.fd),
+ .in_fds_offset = offsetof(struct run_as_data, u.extract_sdt_probe_offsets.fd),
.out_fds_offset = -1,
.in_fd_count = 1,
.out_fd_count = 0,
};
struct run_as_worker_data {
- pid_t pid; /* Worker PID. */
+ pid_t pid; /* Worker PID. */
int sockpair[2];
char *procname;
};
} /* namespace */
#ifdef VALGRIND
-static
-int use_clone(void)
+static int use_clone(void)
{
return 0;
}
#else
-static
-int use_clone(void)
+static int use_clone(void)
{
return !lttng_secure_getenv("LTTNG_DEBUG_NOCLONE");
}
/*
* Create recursively directory using the FULL path.
*/
-static
-int _mkdirat_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _mkdirat_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
{
const char *path;
mode_t mode;
/* Ownership of dirfd is transferred to the handle. */
data->u.mkdir.dirfd = -1;
/* Safe to call as we have transitioned to the requested uid/gid. */
- ret_value->u.ret = lttng_directory_handle_create_subdirectory_recursive(
- handle, path, mode);
+ ret_value->u.ret = lttng_directory_handle_create_subdirectory_recursive(handle, path, mode);
ret_value->_errno = errno;
ret_value->_error = (ret_value->u.ret) ? true : false;
lttng_directory_handle_put(handle);
return ret_value->u.ret;
}
-static
-int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value)
{
const char *path;
mode_t mode;
/* Ownership of dirfd is transferred to the handle. */
data->u.mkdir.dirfd = -1;
/* Safe to call as we have transitioned to the requested uid/gid. */
- ret_value->u.ret = lttng_directory_handle_create_subdirectory(
- handle, path, mode);
+ ret_value->u.ret = lttng_directory_handle_create_subdirectory(handle, path, mode);
ret_value->_errno = errno;
ret_value->_error = (ret_value->u.ret) ? true : false;
lttng_directory_handle_put(handle);
return ret_value->u.ret;
}
-static
-int _open(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _open(struct run_as_data *data, struct run_as_ret *ret_value)
{
int fd;
struct lttng_directory_handle *handle;
/* Ownership of dirfd is transferred to the handle. */
data->u.open.dirfd = -1;
- fd = lttng_directory_handle_open_file(handle,
- data->u.open.path, data->u.open.flags,
- data->u.open.mode);
+ fd = lttng_directory_handle_open_file(
+ handle, data->u.open.path, data->u.open.flags, data->u.open.mode);
if (fd < 0) {
ret_value->u.ret = -1;
ret_value->u.open.fd = -1;
return ret_value->u.ret;
}
-static
-int _unlink(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _unlink(struct run_as_data *data, struct run_as_ret *ret_value)
{
struct lttng_directory_handle *handle;
/* Ownership of dirfd is transferred to the handle. */
data->u.unlink.dirfd = -1;
- ret_value->u.ret = lttng_directory_handle_unlink_file(handle,
- data->u.unlink.path);
+ ret_value->u.ret = lttng_directory_handle_unlink_file(handle, data->u.unlink.path);
ret_value->_errno = errno;
ret_value->_error = (ret_value->u.ret) ? true : false;
lttng_directory_handle_put(handle);
return ret_value->u.ret;
}
-static
-int _rmdir(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _rmdir(struct run_as_data *data, struct run_as_ret *ret_value)
{
struct lttng_directory_handle *handle;
/* Ownership of dirfd is transferred to the handle. */
data->u.rmdir.dirfd = -1;
- ret_value->u.ret = lttng_directory_handle_remove_subdirectory(
- handle, data->u.rmdir.path);
+ ret_value->u.ret = lttng_directory_handle_remove_subdirectory(handle, data->u.rmdir.path);
ret_value->_errno = errno;
ret_value->_error = (ret_value->u.ret) ? true : false;
lttng_directory_handle_put(handle);
return ret_value->u.ret;
}
-static
-int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_value)
{
struct lttng_directory_handle *handle;
data->u.rmdir.dirfd = -1;
ret_value->u.ret = lttng_directory_handle_remove_subdirectory_recursive(
- handle, data->u.rmdir.path, data->u.rmdir.flags);
+ handle, data->u.rmdir.path, data->u.rmdir.flags);
ret_value->_errno = errno;
ret_value->_error = (ret_value->u.ret) ? true : false;
lttng_directory_handle_put(handle);
return ret_value->u.ret;
}
-static
-int _rename(struct run_as_data *data, struct run_as_ret *ret_value)
+static int _rename(struct run_as_data *data, struct run_as_ret *ret_value)
{
const char *old_path, *new_path;
struct lttng_directory_handle *old_handle = NULL, *new_handle = NULL;
old_path = data->u.rename.old_path;
new_path = data->u.rename.new_path;
- old_handle = lttng_directory_handle_create_from_dirfd(
- data->u.rename.dirfds[0]);
+ old_handle = lttng_directory_handle_create_from_dirfd(data->u.rename.dirfds[0]);
if (!old_handle) {
ret_value->u.ret = -1;
goto end;
}
- new_handle = lttng_directory_handle_create_from_dirfd(
- data->u.rename.dirfds[1]);
+ new_handle = lttng_directory_handle_create_from_dirfd(data->u.rename.dirfds[1]);
if (!new_handle) {
ret_value->u.ret = -1;
goto end;
data->u.rename.dirfds[0] = data->u.rename.dirfds[1] = -1;
/* Safe to call as we have transitioned to the requested uid/gid. */
- ret_value->u.ret = lttng_directory_handle_rename(
- old_handle, old_path, new_handle, new_path);
+ ret_value->u.ret =
+ lttng_directory_handle_rename(old_handle, old_path, new_handle, new_path);
end:
lttng_directory_handle_put(old_handle);
lttng_directory_handle_put(new_handle);
}
#ifdef HAVE_ELF_H
-static
-int _extract_elf_symbol_offset(struct run_as_data *data,
- struct run_as_ret *ret_value)
+static int _extract_elf_symbol_offset(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
uint64_t offset;
ret_value->_error = false;
ret = lttng_elf_get_symbol_offset(data->u.extract_elf_symbol_offset.fd,
- data->u.extract_elf_symbol_offset.function,
- &offset);
+ data->u.extract_elf_symbol_offset.function,
+ &offset);
if (ret) {
DBG("Failed to extract ELF function offset");
ret_value->_error = true;
return ret;
}
-static
-int _extract_sdt_probe_offsets(struct run_as_data *data,
- struct run_as_ret *ret_value)
+static int _extract_sdt_probe_offsets(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
uint64_t *offsets = NULL;
ret_value->_error = false;
/* On success, this call allocates the offsets paramater. */
- ret = lttng_elf_get_sdt_probe_offsets(
- data->u.extract_sdt_probe_offsets.fd,
- data->u.extract_sdt_probe_offsets.provider_name,
- data->u.extract_sdt_probe_offsets.probe_name,
- &offsets, &num_offset);
+ ret = lttng_elf_get_sdt_probe_offsets(data->u.extract_sdt_probe_offsets.fd,
+ data->u.extract_sdt_probe_offsets.provider_name,
+ data->u.extract_sdt_probe_offsets.probe_name,
+ &offsets,
+ &num_offset);
if (ret) {
DBG("Failed to extract SDT probe offsets");
/* Copy the content of the offsets array to the ret struct. */
memcpy(ret_value->u.extract_sdt_probe_offsets.offsets,
- offsets, num_offset * sizeof(uint64_t));
+ offsets,
+ num_offset * sizeof(uint64_t));
ret_value->u.extract_sdt_probe_offsets.num_offset = num_offset;
return ret;
}
#else
-static
-int _extract_elf_symbol_offset(
- struct run_as_data *data __attribute__((unused)),
- struct run_as_ret *ret_value __attribute__((unused)))
+static int _extract_elf_symbol_offset(struct run_as_data *data __attribute__((unused)),
+ struct run_as_ret *ret_value __attribute__((unused)))
{
ERR("Unimplemented runas command RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET");
return -1;
}
-static
-int _extract_sdt_probe_offsets(
- struct run_as_data *data __attribute__((unused)),
- struct run_as_ret *ret_value __attribute__((unused)))
+static int _extract_sdt_probe_offsets(struct run_as_data *data __attribute__((unused)),
+ struct run_as_ret *ret_value __attribute__((unused)))
{
ERR("Unimplemented runas command RUN_AS_EXTRACT_SDT_PROBE_OFFSETS");
return -1;
}
#endif
-static
-int _generate_filter_bytecode(struct run_as_data *data,
- struct run_as_ret *ret_value) {
+static int _generate_filter_bytecode(struct run_as_data *data, struct run_as_ret *ret_value)
+{
int ret = 0;
const char *filter_expression = NULL;
struct filter_parser_ctx *ctx = NULL;
filter_expression = data->u.generate_filter_bytecode.filter_expression;
- if (lttng_strnlen(filter_expression, LTTNG_FILTER_MAX_LEN - 1) == LTTNG_FILTER_MAX_LEN - 1) {
+ if (lttng_strnlen(filter_expression, LTTNG_FILTER_MAX_LEN - 1) ==
+ LTTNG_FILTER_MAX_LEN - 1) {
ret_value->_error = true;
ret = -1;
goto end;
goto end;
}
- DBG("Size of bytecode generated: %u bytes.",
- bytecode_get_len(&ctx->bytecode->b));
+ DBG("Size of bytecode generated: %u bytes.", bytecode_get_len(&ctx->bytecode->b));
/* Copy the lttng_bytecode_filter object to the return structure. */
memcpy(ret_value->u.generate_filter_bytecode.bytecode,
- &ctx->bytecode->b,
- sizeof(ctx->bytecode->b) +
- bytecode_get_len(&ctx->bytecode->b));
+ &ctx->bytecode->b,
+ sizeof(ctx->bytecode->b) + bytecode_get_len(&ctx->bytecode->b));
end:
if (ctx) {
return ret;
}
-static
-run_as_fct run_as_enum_to_fct(enum run_as_cmd cmd)
+static run_as_fct run_as_enum_to_fct(enum run_as_cmd cmd)
{
switch (cmd) {
case RUN_AS_MKDIR:
}
}
-static
-int do_send_fds(int sock, const int *fds, unsigned int fd_count)
+static int do_send_fds(int sock, const int *fds, unsigned int fd_count)
{
ssize_t len;
unsigned int i;
for (i = 0; i < fd_count; i++) {
if (fds[i] < 0) {
- DBG("Attempt to send invalid file descriptor (fd = %i)",
- fds[i]);
+ DBG("Attempt to send invalid file descriptor (fd = %i)", fds[i]);
/* Return 0 as this is not a fatal error. */
return 0;
}
return len < 0 ? -1 : 0;
}
-static
-int do_recv_fds(int sock, int *fds, unsigned int fd_count)
+static int do_recv_fds(int sock, int *fds, unsigned int fd_count)
{
int ret = 0;
unsigned int i;
return ret;
}
-static
-int send_fds_to_worker(const run_as_worker_data *worker,
- const struct run_as_data *data)
+static int send_fds_to_worker(const run_as_worker_data *worker, const struct run_as_data *data)
{
int ret = 0;
unsigned int i;
for (i = 0; i < COMMAND_IN_FD_COUNT(data); i++) {
if (COMMAND_IN_FDS(data)[i] < 0) {
ERR("Refusing to send invalid fd to worker (fd = %i)",
- COMMAND_IN_FDS(data)[i]);
+ COMMAND_IN_FDS(data)[i]);
ret = -1;
goto end;
}
}
- ret = do_send_fds(worker->sockpair[0], COMMAND_IN_FDS(data),
- COMMAND_IN_FD_COUNT(data));
+ ret = do_send_fds(worker->sockpair[0], COMMAND_IN_FDS(data), COMMAND_IN_FD_COUNT(data));
if (ret < 0) {
PERROR("Failed to send file descriptor to run-as worker");
ret = -1;
return ret;
}
-static
-int send_fds_to_master(run_as_worker_data *worker, enum run_as_cmd cmd,
- struct run_as_ret *run_as_ret)
+static int
+send_fds_to_master(run_as_worker_data *worker, enum run_as_cmd cmd, struct run_as_ret *run_as_ret)
{
int ret = 0;
unsigned int i;
goto end;
}
- ret = do_send_fds(worker->sockpair[1], COMMAND_OUT_FDS(cmd, run_as_ret),
- COMMAND_OUT_FD_COUNT(cmd));
+ ret = do_send_fds(
+ worker->sockpair[1], COMMAND_OUT_FDS(cmd, run_as_ret), COMMAND_OUT_FD_COUNT(cmd));
if (ret < 0) {
PERROR("Failed to send file descriptor to master process");
goto end;
int ret_close = close(fd);
if (ret_close < 0) {
- PERROR("Failed to close result file descriptor (fd = %i)",
- fd);
+ PERROR("Failed to close result file descriptor (fd = %i)", fd);
}
}
}
return ret;
}
-static
-int recv_fds_from_worker(const run_as_worker_data *worker, enum run_as_cmd cmd,
- struct run_as_ret *run_as_ret)
+static int recv_fds_from_worker(const run_as_worker_data *worker,
+ enum run_as_cmd cmd,
+ struct run_as_ret *run_as_ret)
{
int ret = 0;
goto end;
}
- ret = do_recv_fds(worker->sockpair[0], COMMAND_OUT_FDS(cmd, run_as_ret),
- COMMAND_OUT_FD_COUNT(cmd));
+ ret = do_recv_fds(
+ worker->sockpair[0], COMMAND_OUT_FDS(cmd, run_as_ret), COMMAND_OUT_FD_COUNT(cmd));
if (ret < 0) {
PERROR("Failed to receive file descriptor from run-as worker");
ret = -1;
return ret;
}
-static
-int recv_fds_from_master(run_as_worker_data *worker, struct run_as_data *data)
+static int recv_fds_from_master(run_as_worker_data *worker, struct run_as_data *data)
{
int ret = 0;
goto end;
}
- ret = do_recv_fds(worker->sockpair[1], COMMAND_IN_FDS(data),
- COMMAND_IN_FD_COUNT(data));
+ ret = do_recv_fds(worker->sockpair[1], COMMAND_IN_FDS(data), COMMAND_IN_FD_COUNT(data));
if (ret < 0) {
PERROR("Failed to receive file descriptors from master process");
ret = -1;
return ret;
}
-static
-int cleanup_received_fds(struct run_as_data *data)
+static int cleanup_received_fds(struct run_as_data *data)
{
int ret = 0, i;
return ret;
}
-static int get_user_infos_from_uid(
- uid_t uid, char **username, gid_t *primary_gid)
+static int get_user_infos_from_uid(uid_t uid, char **username, gid_t *primary_gid)
{
int ret;
char *buf = NULL;
/* Limit is indeterminate. */
WARN("Failed to query _SC_GETPW_R_SIZE_MAX as it is "
- "indeterminate; falling back to default buffer size");
+ "indeterminate; falling back to default buffer size");
raw_get_pw_buf_size = GETPW_BUFFER_FALLBACK_SIZE;
}
ret = getpwuid_r(uid, &pwd, buf, get_pw_buf_size, &result);
if (ret < 0) {
- PERROR("Failed to get user information for user: uid = %d",
- (int) uid);
+ PERROR("Failed to get user information for user: uid = %d", (int) uid);
goto error;
}
if (result == NULL) {
- ERR("Failed to find user information in password entries: uid = %d",
- (int) uid);
+ ERR("Failed to find user information in password entries: uid = %d", (int) uid);
ret = -1;
goto error;
}
goto end;
}
-static int demote_creds(
- uid_t prev_uid, gid_t prev_gid, uid_t new_uid, gid_t new_gid)
+static int demote_creds(uid_t prev_uid, gid_t prev_gid, uid_t new_uid, gid_t new_gid)
{
int ret = 0;
gid_t primary_gid;
if (prev_gid != new_gid) {
ret = setegid(new_gid);
if (ret < 0) {
- PERROR("Failed to set effective group id: new_gid = %d",
- (int) new_gid);
+ PERROR("Failed to set effective group id: new_gid = %d", (int) new_gid);
goto end;
}
}
ret = initgroups(username, primary_gid);
if (ret < 0) {
PERROR("Failed to init the supplementary group access list: "
- "username = `%s`, primary gid = %d", username,
- (int) primary_gid);
+ "username = `%s`, primary gid = %d",
+ username,
+ (int) primary_gid);
goto end;
}
ret = seteuid(new_uid);
if (ret < 0) {
- PERROR("Failed to set effective user id: new_uid = %d",
- (int) new_uid);
+ PERROR("Failed to set effective user id: new_uid = %d", (int) new_uid);
goto end;
}
}
return ret;
}
-static int promote_creds(
- uid_t prev_uid, gid_t prev_gid, uid_t new_uid, gid_t new_gid)
+static int promote_creds(uid_t prev_uid, gid_t prev_gid, uid_t new_uid, gid_t new_gid)
{
int ret = 0;
gid_t primary_gid;
if (prev_gid != new_gid) {
ret = setegid(new_gid);
if (ret < 0) {
- PERROR("Failed to set effective group id: new_gid = %d",
- (int) new_gid);
+ PERROR("Failed to set effective group id: new_gid = %d", (int) new_gid);
goto end;
}
}
*/
ret = seteuid(new_uid);
if (ret < 0) {
- PERROR("Failed to set effective user id: new_uid = %d",
- (int) new_uid);
+ PERROR("Failed to set effective user id: new_uid = %d", (int) new_uid);
goto end;
}
ret = initgroups(username, primary_gid);
if (ret < 0) {
PERROR("Failed to init the supplementary group access "
- "list: username = `%s`, primary gid = %d",
- username, (int) primary_gid)
+ "list: username = `%s`, primary gid = %d",
+ username,
+ (int) primary_gid)
goto end;
}
}
/*
* Return < 0 on error, 0 if OK, 1 on hangup.
*/
-static
-int handle_one_cmd(run_as_worker_data *worker)
+static int handle_one_cmd(run_as_worker_data *worker)
{
int ret = 0, promote_ret;
struct run_as_data data = {};
* The structure contains the command type and all the parameters needed for
* its execution
*/
- readlen = lttcomm_recv_unix_sock(worker->sockpair[1], &data,
- sizeof(data));
+ readlen = lttcomm_recv_unix_sock(worker->sockpair[1], &data, sizeof(data));
if (readlen == 0) {
/* hang up */
ret = 1;
* Stage 4: Send run_as_ret structure to the master.
* This structure contain the return value of the command and the errno.
*/
- writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret,
- sizeof(sendret));
+ writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret, sizeof(sendret));
if (writelen < sizeof(sendret)) {
PERROR("lttcomm_send_unix_sock error");
ret = -1;
return ret;
}
-static
-int run_as_worker(run_as_worker_data *worker)
+static int run_as_worker(run_as_worker_data *worker)
{
int ret;
ssize_t writelen;
memset(&sendret, 0, sizeof(sendret));
- writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret,
- sizeof(sendret));
+ writelen = lttcomm_send_unix_sock(worker->sockpair[1], &sendret, sizeof(sendret));
if (writelen < sizeof(sendret)) {
PERROR("lttcomm_send_unix_sock error");
ret = EXIT_FAILURE;
} else if (ret > 0) {
break;
} else {
- continue; /* Next command. */
+ continue; /* Next command. */
}
}
ret = EXIT_SUCCESS;
return ret;
}
-static
-int run_as_cmd(run_as_worker_data *worker,
- enum run_as_cmd cmd,
- struct run_as_data *data,
- struct run_as_ret *ret_value,
- uid_t uid, gid_t gid)
+static int run_as_cmd(run_as_worker_data *worker,
+ enum run_as_cmd cmd,
+ struct run_as_data *data,
+ struct run_as_ret *ret_value,
+ uid_t uid,
+ gid_t gid)
{
int ret = 0;
ssize_t readlen, writelen;
ret = -1;
ret_value->_errno = EPERM;
ERR("Client (%d)/Server (%d) UID mismatch (and sessiond is not root)",
- (int) uid, (int) geteuid());
+ (int) uid,
+ (int) geteuid());
goto end;
}
}
/*
* Stage 1: Send the run_as_data struct to the worker process
*/
- writelen = lttcomm_send_unix_sock(worker->sockpair[0], data,
- sizeof(*data));
+ writelen = lttcomm_send_unix_sock(worker->sockpair[0], data, sizeof(*data));
if (writelen < sizeof(*data)) {
PERROR("Error writing message to run_as");
ret = -1;
* Stage 4: Receive the run_as_ret struct containing the return value and
* errno
*/
- readlen = lttcomm_recv_unix_sock(worker->sockpair[0], ret_value,
- sizeof(*ret_value));
+ readlen = lttcomm_recv_unix_sock(worker->sockpair[0], ret_value, sizeof(*ret_value));
if (!readlen) {
ERR("Run-as worker has hung-up during run_as_cmd");
ret = -1;
/*
* This is for debugging ONLY and should not be considered secure.
*/
-static
-int run_as_noworker(enum run_as_cmd cmd,
- struct run_as_data *data, struct run_as_ret *ret_value,
- uid_t uid __attribute__((unused)), gid_t gid __attribute__((unused)))
+static int run_as_noworker(enum run_as_cmd cmd,
+ struct run_as_data *data,
+ struct run_as_ret *ret_value,
+ uid_t uid __attribute__((unused)),
+ gid_t gid __attribute__((unused)))
{
int ret, saved_errno;
mode_t old_mask;
return ret;
}
-static
-int reset_sighandler(void)
+static int reset_sighandler(void)
{
int sig;
return 0;
}
-static
-void worker_sighandler(int sig)
+static void worker_sighandler(int sig)
{
const char *signame;
}
}
-static
-int set_worker_sighandlers(void)
+static int set_worker_sighandlers(void)
{
int ret = 0;
sigset_t sigset;
return ret;
}
-static
-int run_as_create_worker_no_lock(const char *procname,
- post_fork_cleanup_cb clean_up_func,
- void *clean_up_user_data)
+static int run_as_create_worker_no_lock(const char *procname,
+ post_fork_cleanup_cb clean_up_func,
+ void *clean_up_user_data)
{
pid_t pid;
int i, ret = 0;
worker->sockpair[1] = -1;
worker->pid = pid;
/* Wait for worker to become ready. */
- readlen = lttcomm_recv_unix_sock(worker->sockpair[0],
- &recvret, sizeof(recvret));
+ readlen = lttcomm_recv_unix_sock(worker->sockpair[0], &recvret, sizeof(recvret));
if (readlen < sizeof(recvret)) {
ERR("readlen: %zd", readlen);
PERROR("Error reading response from run_as at creation");
return ret;
}
-static
-void run_as_destroy_worker_no_lock(void)
+static void run_as_destroy_worker_no_lock(void)
{
run_as_worker_data *worker = global_worker;
if (WIFEXITED(status)) {
LOG(WEXITSTATUS(status) == 0 ? PRINT_DBG : PRINT_ERR,
- DEFAULT_RUN_AS_WORKER_NAME " terminated with status code %d",
- WEXITSTATUS(status));
+ DEFAULT_RUN_AS_WORKER_NAME " terminated with status code %d",
+ WEXITSTATUS(status));
break;
} else if (WIFSIGNALED(status)) {
ERR(DEFAULT_RUN_AS_WORKER_NAME " was killed by signal %d",
- WTERMSIG(status));
+ WTERMSIG(status));
break;
}
}
global_worker = NULL;
}
-static
-int run_as_restart_worker(run_as_worker_data *worker)
+static int run_as_restart_worker(run_as_worker_data *worker)
{
int ret = 0;
char *procname = NULL;
/* Create a new run_as worker process*/
ret = run_as_create_worker_no_lock(procname, NULL, NULL);
- if (ret < 0 ) {
+ if (ret < 0) {
ERR("Restarting the worker process failed");
ret = -1;
goto err;
return ret;
}
-static
-int run_as(enum run_as_cmd cmd, struct run_as_data *data,
- struct run_as_ret *ret_value, uid_t uid, gid_t gid)
+static int run_as(enum run_as_cmd cmd,
+ struct run_as_data *data,
+ struct run_as_ret *ret_value,
+ uid_t uid,
+ gid_t gid)
{
int ret, saved_errno;
*/
if (ret == -1 && saved_errno == EIO) {
DBG("Socket closed unexpectedly... "
- "Restarting the worker process");
+ "Restarting the worker process");
ret = run_as_restart_worker(global_worker);
if (ret == -1) {
ERR("Failed to restart worker process.");
return run_as_mkdirat_recursive(AT_FDCWD, path, mode, uid, gid);
}
-int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
- uid_t uid, gid_t gid)
+int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode, uid_t uid, gid_t gid)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("mkdirat() recursive fd = %d%s, path = %s, mode = %d, uid = %d, gid = %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, (int) mode, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.mkdir.path, path,
- sizeof(data.u.mkdir.path));
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ (int) mode,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.mkdir.path, path, sizeof(data.u.mkdir.path));
if (ret) {
ERR("Failed to copy path argument of mkdirat recursive command");
goto error;
data.u.mkdir.mode = mode;
data.u.mkdir.dirfd = dirfd;
run_as(dirfd == AT_FDCWD ? RUN_AS_MKDIR_RECURSIVE : RUN_AS_MKDIRAT_RECURSIVE,
- &data, &run_as_ret, uid, gid);
+ &data,
+ &run_as_ret,
+ uid,
+ gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
return run_as_mkdirat(AT_FDCWD, path, mode, uid, gid);
}
-int run_as_mkdirat(int dirfd, const char *path, mode_t mode,
- uid_t uid, gid_t gid)
+int run_as_mkdirat(int dirfd, const char *path, mode_t mode, uid_t uid, gid_t gid)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("mkdirat() recursive fd = %d%s, path = %s, mode = %d, uid = %d, gid = %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, (int) mode, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.mkdir.path, path,
- sizeof(data.u.mkdir.path));
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ (int) mode,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.mkdir.path, path, sizeof(data.u.mkdir.path));
if (ret) {
ERR("Failed to copy path argument of mkdirat command");
goto error;
data.u.mkdir.path[sizeof(data.u.mkdir.path) - 1] = '\0';
data.u.mkdir.mode = mode;
data.u.mkdir.dirfd = dirfd;
- run_as(dirfd == AT_FDCWD ? RUN_AS_MKDIR : RUN_AS_MKDIRAT,
- &data, &run_as_ret, uid, gid);
+ run_as(dirfd == AT_FDCWD ? RUN_AS_MKDIR : RUN_AS_MKDIRAT, &data, &run_as_ret, uid, gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
return ret;
}
-int run_as_open(const char *path, int flags, mode_t mode, uid_t uid,
- gid_t gid)
+int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
{
return run_as_openat(AT_FDCWD, path, flags, mode, uid, gid);
}
-int run_as_openat(int dirfd, const char *path, int flags, mode_t mode,
- uid_t uid, gid_t gid)
+int run_as_openat(int dirfd, const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("openat() fd = %d%s, path = %s, flags = %X, mode = %d, uid %d, gid %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, flags, (int) mode, (int) uid, (int) gid);
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ flags,
+ (int) mode,
+ (int) uid,
+ (int) gid);
ret = lttng_strncpy(data.u.open.path, path, sizeof(data.u.open.path));
if (ret) {
ERR("Failed to copy path argument of open command");
data.u.open.flags = flags;
data.u.open.mode = mode;
data.u.open.dirfd = dirfd;
- run_as(dirfd == AT_FDCWD ? RUN_AS_OPEN : RUN_AS_OPENAT,
- &data, &run_as_ret, uid, gid);
+ run_as(dirfd == AT_FDCWD ? RUN_AS_OPEN : RUN_AS_OPENAT, &data, &run_as_ret, uid, gid);
errno = run_as_ret._errno;
- ret = run_as_ret.u.ret < 0 ? run_as_ret.u.ret :
- run_as_ret.u.open.fd;
+ ret = run_as_ret.u.ret < 0 ? run_as_ret.u.ret : run_as_ret.u.open.fd;
error:
return ret;
}
struct run_as_ret run_as_ret = {};
DBG3("unlinkat() fd = %d%s, path = %s, uid = %d, gid = %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.unlink.path, path,
- sizeof(data.u.unlink.path));
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.unlink.path, path, sizeof(data.u.unlink.path));
if (ret) {
goto error;
}
data.u.unlink.dirfd = dirfd;
- run_as(dirfd == AT_FDCWD ? RUN_AS_UNLINK : RUN_AS_UNLINKAT, &data,
- &run_as_ret, uid, gid);
+ run_as(dirfd == AT_FDCWD ? RUN_AS_UNLINK : RUN_AS_UNLINKAT, &data, &run_as_ret, uid, gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
struct run_as_ret run_as_ret = {};
DBG3("rmdirat() fd = %d%s, path = %s, uid = %d, gid = %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.rmdir.path, path,
- sizeof(data.u.rmdir.path));
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.rmdir.path, path, sizeof(data.u.rmdir.path));
if (ret) {
goto error;
}
data.u.rmdir.dirfd = dirfd;
- run_as(dirfd == AT_FDCWD ? RUN_AS_RMDIR : RUN_AS_RMDIRAT, &data,
- &run_as_ret, uid, gid);
+ run_as(dirfd == AT_FDCWD ? RUN_AS_RMDIR : RUN_AS_RMDIRAT, &data, &run_as_ret, uid, gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
struct run_as_ret run_as_ret = {};
DBG3("rmdirat() recursive fd = %d%s, path = %s, uid = %d, gid = %d",
- dirfd, dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- path, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.rmdir.path, path,
- sizeof(data.u.rmdir.path));
+ dirfd,
+ dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ path,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.rmdir.path, path, sizeof(data.u.rmdir.path));
if (ret) {
goto error;
}
data.u.rmdir.dirfd = dirfd;
data.u.rmdir.flags = flags;
run_as(dirfd == AT_FDCWD ? RUN_AS_RMDIR_RECURSIVE : RUN_AS_RMDIRAT_RECURSIVE,
- &data, &run_as_ret, uid, gid);
+ &data,
+ &run_as_ret,
+ uid,
+ gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
return run_as_renameat(AT_FDCWD, old_name, AT_FDCWD, new_name, uid, gid);
}
-int run_as_renameat(int old_dirfd, const char *old_name,
- int new_dirfd, const char *new_name, uid_t uid, gid_t gid)
+int run_as_renameat(int old_dirfd,
+ const char *old_name,
+ int new_dirfd,
+ const char *new_name,
+ uid_t uid,
+ gid_t gid)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("renameat() old_dirfd = %d%s, old_name = %s, new_dirfd = %d%s, new_name = %s, uid = %d, gid = %d",
- old_dirfd, old_dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- old_name,
- new_dirfd, new_dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
- new_name, (int) uid, (int) gid);
- ret = lttng_strncpy(data.u.rename.old_path, old_name,
- sizeof(data.u.rename.old_path));
+ old_dirfd,
+ old_dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ old_name,
+ new_dirfd,
+ new_dirfd == AT_FDCWD ? " (AT_FDCWD)" : "",
+ new_name,
+ (int) uid,
+ (int) gid);
+ ret = lttng_strncpy(data.u.rename.old_path, old_name, sizeof(data.u.rename.old_path));
if (ret) {
goto error;
}
- ret = lttng_strncpy(data.u.rename.new_path, new_name,
- sizeof(data.u.rename.new_path));
+ ret = lttng_strncpy(data.u.rename.new_path, new_name, sizeof(data.u.rename.new_path));
if (ret) {
goto error;
}
data.u.rename.dirfds[0] = old_dirfd;
data.u.rename.dirfds[1] = new_dirfd;
- run_as(old_dirfd == AT_FDCWD && new_dirfd == AT_FDCWD ?
- RUN_AS_RENAME : RUN_AS_RENAMEAT,
- &data, &run_as_ret, uid, gid);
+ run_as(old_dirfd == AT_FDCWD && new_dirfd == AT_FDCWD ? RUN_AS_RENAME : RUN_AS_RENAMEAT,
+ &data,
+ &run_as_ret,
+ uid,
+ gid);
errno = run_as_ret._errno;
ret = run_as_ret.u.ret;
error:
return ret;
}
-int run_as_extract_elf_symbol_offset(int fd, const char* function,
- uid_t uid, gid_t gid, uint64_t *offset)
+int run_as_extract_elf_symbol_offset(
+ int fd, const char *function, uid_t uid, gid_t gid, uint64_t *offset)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
- "with for uid %d and gid %d", fd, function,
- (int) uid, (int) gid);
+ "with for uid %d and gid %d",
+ fd,
+ function,
+ (int) uid,
+ (int) gid);
data.u.extract_elf_symbol_offset.fd = fd;
strncpy(data.u.extract_elf_symbol_offset.function, function, LTTNG_SYMBOL_NAME_LEN - 1);
data.u.extract_elf_symbol_offset.function[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
ret = lttng_strncpy(data.u.extract_elf_symbol_offset.function,
- function,
- sizeof(data.u.extract_elf_symbol_offset.function));
+ function,
+ sizeof(data.u.extract_elf_symbol_offset.function));
if (ret) {
goto error;
}
return ret;
}
-int run_as_extract_sdt_probe_offsets(int fd, const char* provider_name,
- const char* probe_name, uid_t uid, gid_t gid,
- uint64_t **offsets, uint32_t *num_offset)
+int run_as_extract_sdt_probe_offsets(int fd,
+ const char *provider_name,
+ const char *probe_name,
+ uid_t uid,
+ gid_t gid,
+ uint64_t **offsets,
+ uint32_t *num_offset)
{
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
DBG3("extract_sdt_probe_offsets() on fd=%d, probe_name=%s and "
- "provider_name=%s with for uid %d and gid %d", fd,
- probe_name, provider_name, (int) uid, (int) gid);
+ "provider_name=%s with for uid %d and gid %d",
+ fd,
+ probe_name,
+ provider_name,
+ (int) uid,
+ (int) gid);
data.u.extract_sdt_probe_offsets.fd = fd;
- ret = lttng_strncpy(data.u.extract_sdt_probe_offsets.probe_name, probe_name,
- sizeof(data.u.extract_sdt_probe_offsets.probe_name));
+ ret = lttng_strncpy(data.u.extract_sdt_probe_offsets.probe_name,
+ probe_name,
+ sizeof(data.u.extract_sdt_probe_offsets.probe_name));
if (ret) {
goto error;
}
ret = lttng_strncpy(data.u.extract_sdt_probe_offsets.provider_name,
- provider_name,
- sizeof(data.u.extract_sdt_probe_offsets.provider_name));
+ provider_name,
+ sizeof(data.u.extract_sdt_probe_offsets.provider_name));
if (ret) {
goto error;
}
goto error;
}
- memcpy(*offsets, run_as_ret.u.extract_sdt_probe_offsets.offsets,
- *num_offset * sizeof(uint64_t));
+ memcpy(*offsets,
+ run_as_ret.u.extract_sdt_probe_offsets.offsets,
+ *num_offset * sizeof(uint64_t));
error:
return ret;
}
int run_as_generate_filter_bytecode(const char *filter_expression,
- const struct lttng_credentials *creds,
- struct lttng_bytecode **bytecode)
+ const struct lttng_credentials *creds,
+ struct lttng_bytecode **bytecode)
{
int ret;
struct run_as_data data = {};
const gid_t gid = lttng_credentials_get_gid(creds);
DBG3("generate_filter_bytecode() from expression=\"%s\" for uid %d and gid %d",
- filter_expression, (int) uid, (int) gid);
+ filter_expression,
+ (int) uid,
+ (int) gid);
- ret = lttng_strncpy(data.u.generate_filter_bytecode.filter_expression, filter_expression,
- sizeof(data.u.generate_filter_bytecode.filter_expression));
+ ret = lttng_strncpy(data.u.generate_filter_bytecode.filter_expression,
+ filter_expression,
+ sizeof(data.u.generate_filter_bytecode.filter_expression));
if (ret) {
goto error;
}
goto error;
}
- view_bytecode = (const struct lttng_bytecode *) run_as_ret.u.generate_filter_bytecode.bytecode;
+ view_bytecode =
+ (const struct lttng_bytecode *) run_as_ret.u.generate_filter_bytecode.bytecode;
local_bytecode = calloc<lttng_bytecode>(view_bytecode->len);
if (!local_bytecode) {
goto error;
}
- memcpy(local_bytecode, run_as_ret.u.generate_filter_bytecode.bytecode,
- sizeof(*local_bytecode) + view_bytecode->len);
+ memcpy(local_bytecode,
+ run_as_ret.u.generate_filter_bytecode.bytecode,
+ sizeof(*local_bytecode) + view_bytecode->len);
*bytecode = local_bytecode;
error:
return ret;
}
int run_as_create_worker(const char *procname,
- post_fork_cleanup_cb clean_up_func,
- void *clean_up_user_data)
+ post_fork_cleanup_cb clean_up_func,
+ void *clean_up_user_data)
{
int ret;
pthread_mutex_lock(&worker_lock);
- ret = run_as_create_worker_no_lock(procname, clean_up_func,
- clean_up_user_data);
+ ret = run_as_create_worker_no_lock(procname, clean_up_func, clean_up_user_data);
pthread_mutex_unlock(&worker_lock);
return ret;
}
* SPDX-License-Identifier: LGPL-2.1-only
*/
-#include <lttng/session-descriptor-internal.hpp>
-#include <common/macros.hpp>
-#include <common/uri.hpp>
#include <common/defaults.hpp>
#include <common/error.hpp>
-#include <time.h>
+#include <common/macros.hpp>
+#include <common/uri.hpp>
+
+#include <lttng/session-descriptor-internal.hpp>
+
#include <stdio.h>
+#include <time.h>
namespace {
struct lttng_session_descriptor_network_location {
} LTTNG_PACKED;
} /* namespace */
-static
-struct lttng_uri *uri_copy(const struct lttng_uri *uri)
+static struct lttng_uri *uri_copy(const struct lttng_uri *uri)
{
struct lttng_uri *new_uri = NULL;
return new_uri;
}
-static
-struct lttng_uri *uri_from_path(const char *path)
+static struct lttng_uri *uri_from_path(const char *path)
{
struct lttng_uri *uris = NULL;
ssize_t uri_count;
- char local_protocol_string[LTTNG_PATH_MAX + sizeof("file://")] =
- "file://";
+ char local_protocol_string[LTTNG_PATH_MAX + sizeof("file://")] = "file://";
if (strlen(path) >= LTTNG_PATH_MAX) {
goto end;
return NULL;
}
-static
-void network_location_fini(
- struct lttng_session_descriptor_network_location *location)
+static void network_location_fini(struct lttng_session_descriptor_network_location *location)
{
free(location->control);
free(location->data);
}
/* Assumes ownership of control and data. */
-static
-int network_location_set_from_lttng_uris(
- struct lttng_session_descriptor_network_location *location,
- struct lttng_uri *control, struct lttng_uri *data)
+static int
+network_location_set_from_lttng_uris(struct lttng_session_descriptor_network_location *location,
+ struct lttng_uri *control,
+ struct lttng_uri *data)
{
int ret = 0;
goto end;
}
- if (control->stype != LTTNG_STREAM_CONTROL ||
- data->stype != LTTNG_STREAM_DATA) {
+ if (control->stype != LTTNG_STREAM_CONTROL || data->stype != LTTNG_STREAM_DATA) {
ret = -1;
goto end;
}
return ret;
}
-static
-int network_location_set_from_uri_strings(
- struct lttng_session_descriptor_network_location *location,
- const char *control, const char *data)
+static int
+network_location_set_from_uri_strings(struct lttng_session_descriptor_network_location *location,
+ const char *control,
+ const char *data)
{
int ret = 0;
ssize_t uri_count;
}
/* Ownership of control and data uris is transferred. */
- ret = network_location_set_from_lttng_uris(
- location,
- control_uri,
- data_uri);
+ ret = network_location_set_from_lttng_uris(location, control_uri, data_uri);
control_uri = NULL;
data_uri = NULL;
end:
return ret;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_create(const char *name)
+struct lttng_session_descriptor *lttng_session_descriptor_create(const char *name)
{
struct lttng_session_descriptor *descriptor;
}
descriptor->type = LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR;
- descriptor->output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
+ descriptor->output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
if (lttng_session_descriptor_set_session_name(descriptor, name)) {
goto error;
}
}
/* Ownership of uri is transferred. */
-static
-struct lttng_session_descriptor *
-_lttng_session_descriptor_local_create(const char *name,
- struct lttng_uri *uri)
+static struct lttng_session_descriptor *
+_lttng_session_descriptor_local_create(const char *name, struct lttng_uri *uri)
{
struct lttng_session_descriptor *descriptor;
goto error;
}
descriptor->type = LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR;
- descriptor->output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL;
+ descriptor->output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL;
if (uri) {
if (uri->dtype != LTTNG_DST_PATH) {
goto error;
return NULL;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_local_create(const char *name, const char *path)
+struct lttng_session_descriptor *lttng_session_descriptor_local_create(const char *name,
+ const char *path)
{
struct lttng_uri *uri = NULL;
struct lttng_session_descriptor *descriptor;
}
/* Assumes the ownership of both uris. */
-static
-struct lttng_session_descriptor *
-_lttng_session_descriptor_network_create(const char *name,
- struct lttng_uri *control, struct lttng_uri *data)
+static struct lttng_session_descriptor *_lttng_session_descriptor_network_create(
+ const char *name, struct lttng_uri *control, struct lttng_uri *data)
{
int ret;
struct lttng_session_descriptor *descriptor;
descriptor->type = LTTNG_SESSION_DESCRIPTOR_TYPE_REGULAR;
descriptor->output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
/* Assumes the ownership of both uris. */
- ret = network_location_set_from_lttng_uris(&descriptor->output.network,
- control, data);
+ ret = network_location_set_from_lttng_uris(&descriptor->output.network, control, data);
control = NULL;
data = NULL;
if (ret) {
return NULL;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_network_create(const char *name,
- const char *control_url, const char *data_url)
+struct lttng_session_descriptor *lttng_session_descriptor_network_create(const char *name,
+ const char *control_url,
+ const char *data_url)
{
int ret;
struct lttng_session_descriptor *descriptor;
- descriptor = _lttng_session_descriptor_network_create(name,
- NULL, NULL);
+ descriptor = _lttng_session_descriptor_network_create(name, NULL, NULL);
if (!descriptor) {
goto error;
}
- ret = network_location_set_from_uri_strings(&descriptor->output.network,
- control_url, data_url);
+ ret = network_location_set_from_uri_strings(
+ &descriptor->output.network, control_url, data_url);
if (ret) {
goto error;
}
return NULL;
}
-static
-struct lttng_session_descriptor_snapshot *
+static struct lttng_session_descriptor_snapshot *
_lttng_session_descriptor_snapshot_create(const char *name)
{
struct lttng_session_descriptor_snapshot *descriptor;
}
descriptor->base.type = LTTNG_SESSION_DESCRIPTOR_TYPE_SNAPSHOT;
- descriptor->base.output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
- if (lttng_session_descriptor_set_session_name(&descriptor->base,
- name)) {
+ descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
+ if (lttng_session_descriptor_set_session_name(&descriptor->base, name)) {
goto error;
}
return descriptor;
}
/* Ownership of control and data is transferred. */
-static
-struct lttng_session_descriptor_snapshot *
-_lttng_session_descriptor_snapshot_network_create(const char *name,
- struct lttng_uri *control, struct lttng_uri *data)
+static struct lttng_session_descriptor_snapshot *_lttng_session_descriptor_snapshot_network_create(
+ const char *name, struct lttng_uri *control, struct lttng_uri *data)
{
int ret;
struct lttng_session_descriptor_snapshot *descriptor;
goto error;
}
- descriptor->base.output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
+ descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
/* Ownership of control and data is transferred. */
- ret = network_location_set_from_lttng_uris(
- &descriptor->base.output.network,
- control, data);
+ ret = network_location_set_from_lttng_uris(&descriptor->base.output.network, control, data);
control = NULL;
data = NULL;
if (ret) {
return NULL;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_snapshot_create(const char *name)
+struct lttng_session_descriptor *lttng_session_descriptor_snapshot_create(const char *name)
{
struct lttng_session_descriptor_snapshot *descriptor;
return descriptor ? &descriptor->base : NULL;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_snapshot_network_create(const char *name,
- const char *control_url, const char *data_url)
+struct lttng_session_descriptor *lttng_session_descriptor_snapshot_network_create(
+ const char *name, const char *control_url, const char *data_url)
{
int ret;
struct lttng_session_descriptor_snapshot *descriptor;
- descriptor = _lttng_session_descriptor_snapshot_network_create(name,
- NULL, NULL);
+ descriptor = _lttng_session_descriptor_snapshot_network_create(name, NULL, NULL);
if (!descriptor) {
goto error;
}
ret = network_location_set_from_uri_strings(
- &descriptor->base.output.network,
- control_url, data_url);
+ &descriptor->base.output.network, control_url, data_url);
if (ret) {
goto error;
}
}
/* Ownership of uri is transferred. */
-static
-struct lttng_session_descriptor_snapshot *
-_lttng_session_descriptor_snapshot_local_create(const char *name,
- struct lttng_uri *uri)
+static struct lttng_session_descriptor_snapshot *
+_lttng_session_descriptor_snapshot_local_create(const char *name, struct lttng_uri *uri)
{
struct lttng_session_descriptor_snapshot *descriptor;
if (!descriptor) {
goto error;
}
- descriptor->base.output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL;
+ descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL;
if (uri) {
if (uri->dtype != LTTNG_DST_PATH) {
goto error;
return NULL;
}
-struct lttng_session_descriptor *
-lttng_session_descriptor_snapshot_local_create(const char *name,
- const char *path)
+struct lttng_session_descriptor *lttng_session_descriptor_snapshot_local_create(const char *name,
+ const char *path)
{
struct lttng_uri *path_uri = NULL;
struct lttng_session_descriptor_snapshot *descriptor;
goto error;
}
}
- descriptor = _lttng_session_descriptor_snapshot_local_create(name,
- path_uri);
+ descriptor = _lttng_session_descriptor_snapshot_local_create(name, path_uri);
return descriptor ? &descriptor->base : NULL;
error:
return NULL;
}
-static
-struct lttng_session_descriptor_live *
-_lttng_session_descriptor_live_create(const char *name,
- unsigned long long live_timer_interval_us)
+static struct lttng_session_descriptor_live *
+_lttng_session_descriptor_live_create(const char *name, unsigned long long live_timer_interval_us)
{
struct lttng_session_descriptor_live *descriptor = NULL;
}
descriptor->base.type = LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE;
- descriptor->base.output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
+ descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE;
descriptor->live_timer_us = live_timer_interval_us;
- if (lttng_session_descriptor_set_session_name(&descriptor->base,
- name)) {
+ if (lttng_session_descriptor_set_session_name(&descriptor->base, name)) {
goto error;
}
}
/* Ownership of control and data is transferred. */
-static
-struct lttng_session_descriptor_live *
-_lttng_session_descriptor_live_network_create(
- const char *name,
- struct lttng_uri *control, struct lttng_uri *data,
- unsigned long long live_timer_interval_us)
+static struct lttng_session_descriptor_live *
+_lttng_session_descriptor_live_network_create(const char *name,
+ struct lttng_uri *control,
+ struct lttng_uri *data,
+ unsigned long long live_timer_interval_us)
{
int ret;
struct lttng_session_descriptor_live *descriptor;
- descriptor = _lttng_session_descriptor_live_create(name,
- live_timer_interval_us);
+ descriptor = _lttng_session_descriptor_live_create(name, live_timer_interval_us);
if (!descriptor) {
goto error;
}
- descriptor->base.output_type =
- LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
+ descriptor->base.output_type = LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK;
/* Ownerwhip of control and data is transferred. */
- ret = network_location_set_from_lttng_uris(
- &descriptor->base.output.network,
- control, data);
+ ret = network_location_set_from_lttng_uris(&descriptor->base.output.network, control, data);
control = NULL;
data = NULL;
if (ret) {
}
struct lttng_session_descriptor *
-lttng_session_descriptor_live_create(
- const char *name,
- unsigned long long live_timer_us)
+lttng_session_descriptor_live_create(const char *name, unsigned long long live_timer_us)
{
struct lttng_session_descriptor_live *descriptor;
}
struct lttng_session_descriptor *
-lttng_session_descriptor_live_network_create(
- const char *name,
- const char *control_url, const char *data_url,
- unsigned long long live_timer_us)
+lttng_session_descriptor_live_network_create(const char *name,
+ const char *control_url,
+ const char *data_url,
+ unsigned long long live_timer_us)
{
int ret;
struct lttng_session_descriptor_live *descriptor;
- descriptor = _lttng_session_descriptor_live_network_create(name,
- NULL, NULL, live_timer_us);
+ descriptor = _lttng_session_descriptor_live_network_create(name, NULL, NULL, live_timer_us);
if (!descriptor) {
goto error;
}
ret = network_location_set_from_uri_strings(
- &descriptor->base.output.network,
- control_url, data_url);
+ &descriptor->base.output.network, control_url, data_url);
if (ret) {
goto error;
}
return NULL;
}
-void lttng_session_descriptor_destroy(
- struct lttng_session_descriptor *descriptor)
+void lttng_session_descriptor_destroy(struct lttng_session_descriptor *descriptor)
{
if (!descriptor) {
return;
free(descriptor);
}
-ssize_t lttng_session_descriptor_create_from_buffer(
- const struct lttng_buffer_view *payload,
- struct lttng_session_descriptor **descriptor)
+ssize_t lttng_session_descriptor_create_from_buffer(const struct lttng_buffer_view *payload,
+ struct lttng_session_descriptor **descriptor)
{
int i;
ssize_t offset = 0, ret;
enum lttng_session_descriptor_type type;
enum lttng_session_descriptor_output_type output_type;
- current_view = lttng_buffer_view_from_view(payload, offset,
- sizeof(*base_header));
+ current_view = lttng_buffer_view_from_view(payload, offset, sizeof(*base_header));
if (!lttng_buffer_view_is_valid(¤t_view)) {
ret = -1;
goto end;
{
const struct lttng_session_descriptor_live_comm *live_header;
- current_view = lttng_buffer_view_from_view(payload, offset,
- sizeof(*live_header));
+ current_view = lttng_buffer_view_from_view(payload, offset, sizeof(*live_header));
if (!lttng_buffer_view_is_valid(¤t_view)) {
ret = -1;
goto end;
}
/* Map the name. */
- current_view = lttng_buffer_view_from_view(payload, offset,
- base_header->name_len);
+ current_view = lttng_buffer_view_from_view(payload, offset, base_header->name_len);
if (!lttng_buffer_view_is_valid(¤t_view)) {
ret = -1;
goto end;
}
name = current_view.data;
- if (base_header->name_len == 1 ||
- name[base_header->name_len - 1] ||
- strlen(name) != base_header->name_len - 1) {
+ if (base_header->name_len == 1 || name[base_header->name_len - 1] ||
+ strlen(name) != base_header->name_len - 1) {
/*
* Check that the name is not NULL, is NULL-terminated, and
* does not contain a NULL before the last byte.
struct lttng_uri *uri;
/* Map a URI. */
- current_view = lttng_buffer_view_from_view(payload,
- offset, sizeof(*uri));
+ current_view = lttng_buffer_view_from_view(payload, offset, sizeof(*uri));
if (!lttng_buffer_view_is_valid(¤t_view)) {
ret = -1;
goto end;
*descriptor = lttng_session_descriptor_create(name);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL:
- *descriptor = _lttng_session_descriptor_local_create(
- name, uris[0]);
+ *descriptor = _lttng_session_descriptor_local_create(name, uris[0]);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
- *descriptor = _lttng_session_descriptor_network_create(
- name, uris[0], uris[1]);
+ *descriptor =
+ _lttng_session_descriptor_network_create(name, uris[0], uris[1]);
break;
default:
/* Already checked. */
struct lttng_session_descriptor_snapshot *snapshot;
switch (output_type) {
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
- snapshot = _lttng_session_descriptor_snapshot_create(
- name);
+ snapshot = _lttng_session_descriptor_snapshot_create(name);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL:
- snapshot = _lttng_session_descriptor_snapshot_local_create(
- name, uris[0]);
+ snapshot = _lttng_session_descriptor_snapshot_local_create(name, uris[0]);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
snapshot = _lttng_session_descriptor_snapshot_network_create(
- name, uris[0], uris[1]);
+ name, uris[0], uris[1]);
break;
default:
/* Already checked. */
switch (output_type) {
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
- live = _lttng_session_descriptor_live_create(
- name, live_timer_us);
+ live = _lttng_session_descriptor_live_create(name, live_timer_us);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NETWORK:
live = _lttng_session_descriptor_live_network_create(
- name, uris[0], uris[1],
- live_timer_us);
+ name, uris[0], uris[1], live_timer_us);
break;
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_LOCAL:
ret = -1;
return ret;
}
-int lttng_session_descriptor_serialize(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_dynamic_buffer *buffer)
+int lttng_session_descriptor_serialize(const struct lttng_session_descriptor *descriptor,
+ struct lttng_dynamic_buffer *buffer)
{
int ret, i;
/* There are, at most, two URIs to serialize. */
header.base.uri_count = uri_count;
if (descriptor->type == LTTNG_SESSION_DESCRIPTOR_TYPE_LIVE) {
const struct lttng_session_descriptor_live *live = lttng::utils::container_of(
- descriptor, <tng_session_descriptor_live::base);
+ descriptor, <tng_session_descriptor_live::base);
header.live_timer_us = live->live_timer_us;
header_ptr = &header;
goto end;
}
if (header.base.name_len) {
- ret = lttng_dynamic_buffer_append(buffer, descriptor->name,
- header.base.name_len);
+ ret = lttng_dynamic_buffer_append(buffer, descriptor->name, header.base.name_len);
if (ret) {
goto end;
}
}
for (i = 0; i < uri_count; i++) {
- ret = lttng_dynamic_buffer_append(buffer, uris[i],
- sizeof(struct lttng_uri));
+ ret = lttng_dynamic_buffer_append(buffer, uris[i], sizeof(struct lttng_uri));
if (ret) {
goto end;
}
}
enum lttng_session_descriptor_type
-lttng_session_descriptor_get_type(
- const struct lttng_session_descriptor *descriptor)
+lttng_session_descriptor_get_type(const struct lttng_session_descriptor *descriptor)
{
return descriptor->type;
}
enum lttng_session_descriptor_output_type
-lttng_session_descriptor_get_output_type(
- const struct lttng_session_descriptor *descriptor)
+lttng_session_descriptor_get_output_type(const struct lttng_session_descriptor *descriptor)
{
return descriptor->output_type;
}
void lttng_session_descriptor_get_local_output_uri(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_uri *local_uri)
+ const struct lttng_session_descriptor *descriptor, struct lttng_uri *local_uri)
{
memcpy(local_uri, descriptor->output.local, sizeof(*local_uri));
}
void lttng_session_descriptor_get_network_output_uris(
- const struct lttng_session_descriptor *descriptor,
- struct lttng_uri *control,
- struct lttng_uri *data)
+ const struct lttng_session_descriptor *descriptor,
+ struct lttng_uri *control,
+ struct lttng_uri *data)
{
memcpy(control, descriptor->output.network.control, sizeof(*control));
memcpy(data, descriptor->output.network.data, sizeof(*data));
}
unsigned long long
-lttng_session_descriptor_live_get_timer_interval(
- const struct lttng_session_descriptor *descriptor)
+lttng_session_descriptor_live_get_timer_interval(const struct lttng_session_descriptor *descriptor)
{
struct lttng_session_descriptor_live *live;
}
enum lttng_session_descriptor_status
-lttng_session_descriptor_get_session_name(
- const struct lttng_session_descriptor *descriptor,
- const char **session_name)
+lttng_session_descriptor_get_session_name(const struct lttng_session_descriptor *descriptor,
+ const char **session_name)
{
enum lttng_session_descriptor_status status;
}
*session_name = descriptor->name;
- status = descriptor->name ?
- LTTNG_SESSION_DESCRIPTOR_STATUS_OK :
- LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET;
+ status = descriptor->name ? LTTNG_SESSION_DESCRIPTOR_STATUS_OK :
+ LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET;
end:
return status;
}
-int lttng_session_descriptor_set_session_name(
- struct lttng_session_descriptor *descriptor,
- const char *name)
+int lttng_session_descriptor_set_session_name(struct lttng_session_descriptor *descriptor,
+ const char *name)
{
int ret = 0;
char *new_name;
}
bool lttng_session_descriptor_is_output_destination_initialized(
- const struct lttng_session_descriptor *descriptor)
+ const struct lttng_session_descriptor *descriptor)
{
switch (descriptor->output_type) {
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
}
}
-bool lttng_session_descriptor_has_output_directory(
- const struct lttng_session_descriptor *descriptor)
+bool lttng_session_descriptor_has_output_directory(const struct lttng_session_descriptor *descriptor)
{
switch (descriptor->output_type) {
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
return false;
}
-enum lttng_error_code lttng_session_descriptor_set_default_output(
- struct lttng_session_descriptor *descriptor,
- time_t *session_creation_time,
- const char *absolute_home_path)
+enum lttng_error_code
+lttng_session_descriptor_set_default_output(struct lttng_session_descriptor *descriptor,
+ time_t *session_creation_time,
+ const char *absolute_home_path)
{
enum lttng_error_code ret_code = LTTNG_OK;
struct lttng_uri *uris = NULL;
goto end;
}
strftime_ret = strftime(creation_datetime_suffix,
- sizeof(creation_datetime_suffix),
- "-%Y%m%d-%H%M%S", timeinfo);
+ sizeof(creation_datetime_suffix),
+ "-%Y%m%d-%H%M%S",
+ timeinfo);
if (strftime_ret == 0) {
ERR("Failed to format session creation timestamp while setting default local output destination");
ret_code = LTTNG_ERR_FATAL;
}
}
LTTNG_ASSERT(descriptor->name);
- ret = snprintf(local_uri, sizeof(local_uri),
- "file://%s/%s/%s%s",
- absolute_home_path,
- DEFAULT_TRACE_DIR_NAME, descriptor->name,
- creation_datetime_suffix);
+ ret = snprintf(local_uri,
+ sizeof(local_uri),
+ "file://%s/%s/%s%s",
+ absolute_home_path,
+ DEFAULT_TRACE_DIR_NAME,
+ descriptor->name,
+ creation_datetime_suffix);
if (ret >= sizeof(local_uri)) {
ERR("Truncation occurred while setting default local output destination");
ret_code = LTTNG_ERR_SET_URL;
/* Ownership of uris is transferred. */
ret = network_location_set_from_lttng_uris(
- &descriptor->output.network,
- control, data);
+ &descriptor->output.network, control, data);
if (ret) {
abort();
ret_code = LTTNG_ERR_SET_URL;
* Note that only properties that can be populated by the session daemon
* (output destination and name) are assigned.
*/
-int lttng_session_descriptor_assign(
- struct lttng_session_descriptor *dst,
- const struct lttng_session_descriptor *src)
+int lttng_session_descriptor_assign(struct lttng_session_descriptor *dst,
+ const struct lttng_session_descriptor *src)
{
int ret = 0;
ret = -1;
goto end;
}
- ret = network_location_set_from_lttng_uris(&dst->output.network,
- control_copy, data_copy);
+ ret = network_location_set_from_lttng_uris(
+ &dst->output.network, control_copy, data_copy);
break;
}
case LTTNG_SESSION_DESCRIPTOR_OUTPUT_TYPE_NONE:
*/
#define _LGPL_SOURCE
+#include "inet.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/time.hpp>
+#include <common/time.hpp>
+
#include <algorithm>
+#include <fcntl.h>
#include <limits.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <common/compat/time.hpp>
-#include <poll.h>
-
-#include <common/common.hpp>
-#include <common/time.hpp>
-#include <common/compat/errno.hpp>
-
-#include "inet.hpp"
-#define RECONNECT_DELAY 200 /* ms */
+#define RECONNECT_DELAY 200 /* ms */
/*
* INET protocol operations.
return bind(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_no_timeout(struct lttcomm_sock *sock)
+static int connect_no_timeout(struct lttcomm_sock *sock)
{
struct sockaddr_in sockaddr = sock->sockaddr.addr.sin;
return connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_with_timeout(struct lttcomm_sock *sock)
+static int connect_with_timeout(struct lttcomm_sock *sock)
{
unsigned long timeout = lttcomm_get_network_timeout();
int ret, flags, connect_ret;
sockaddr = sock->sockaddr.addr.sin;
connect_ret = connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
- if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK &&
- errno != EINPROGRESS) {
+ if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINPROGRESS) {
goto error;
} else if (!connect_ret) {
/* Connect succeeded */
}
DBG("Asynchronous connect for sock %d, performing polling with"
- " timeout: %lums", sock->fd, timeout);
+ " timeout: %lums",
+ sock->fd,
+ timeout);
/*
* Perform poll loop following EINPROGRESS recommendation from
* connect(2) man page.
goto error;
}
/* got something */
- ret = getsockopt(sock->fd, SOL_SOCKET,
- SO_ERROR, &optval, &optval_len);
+ ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &optval, &optval_len);
if (ret) {
PERROR("getsockopt");
goto error;
*
* Return the size of received data.
*/
-ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
- size_t len, int flags)
+ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
*
* Return the size of sent data.
*/
-ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, const void *buf,
- size_t len, int flags)
+ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
* Get the maximum between the two possible timeout value and use that to
* get the maximum with the default timeout.
*/
- lttcomm_inet_tcp_timeout = std::max(std::max(syn_timeout, fin_timeout),
- lttcomm_inet_tcp_timeout);
+ lttcomm_inet_tcp_timeout =
+ std::max(std::max(syn_timeout, fin_timeout), lttcomm_inet_tcp_timeout);
end:
DBG("TCP inet operation timeout set to %lu sec", lttcomm_inet_tcp_timeout);
*/
#define _LGPL_SOURCE
+#include "inet6.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/compat/time.hpp>
+#include <common/time.hpp>
+
+#include <fcntl.h>
#include <limits.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <common/compat/time.hpp>
-#include <poll.h>
-
-#include <common/common.hpp>
-#include <common/time.hpp>
-#include <common/compat/errno.hpp>
-
-#include "inet6.hpp"
-#define RECONNECT_DELAY 200 /* ms */
+#define RECONNECT_DELAY 200 /* ms */
/*
* INET protocol operations.
return bind(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_no_timeout(struct lttcomm_sock *sock)
+static int connect_no_timeout(struct lttcomm_sock *sock)
{
struct sockaddr_in6 sockaddr = sock->sockaddr.addr.sin6;
return connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
}
-static
-int connect_with_timeout(struct lttcomm_sock *sock)
+static int connect_with_timeout(struct lttcomm_sock *sock)
{
unsigned long timeout = lttcomm_get_network_timeout();
int ret, flags, connect_ret;
sockaddr = sock->sockaddr.addr.sin6;
connect_ret = connect(sock->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr));
- if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK &&
- errno != EINPROGRESS) {
+ if (connect_ret == -1 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINPROGRESS) {
goto error;
} else if (!connect_ret) {
/* Connect succeeded */
}
DBG("Asynchronous connect for sock %d, performing polling with"
- " timeout: %lums", sock->fd, timeout);
+ " timeout: %lums",
+ sock->fd,
+ timeout);
/*
* Perform poll loop following EINPROGRESS recommendation from
goto error;
}
/* got something */
- ret = getsockopt(sock->fd, SOL_SOCKET,
- SO_ERROR, &optval, &optval_len);
+ ret = getsockopt(sock->fd, SOL_SOCKET, SO_ERROR, &optval, &optval_len);
if (ret) {
PERROR("getsockopt");
goto error;
*
* Return the size of received data.
*/
-ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
- size_t len, int flags)
+ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
*
* Return the size of sent data.
*/
-ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf,
- size_t len, int flags)
+ssize_t
+lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, const void *buf, size_t len, int flags)
{
struct msghdr msg;
struct iovec iov[1];
#include <sys/socket.h>
#define _LGPL_SOURCE
+#include "sessiond-comm.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+
+#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-
-#include <common/common.hpp>
-#include <common/compat/errno.hpp>
-
-#include "sessiond-comm.hpp"
/* For Unix socket */
#include <common/unix.hpp>
/* For Inet6 socket */
#include "inet6.hpp"
-#define NETWORK_TIMEOUT_ENV "LTTNG_NETWORK_SOCKET_TIMEOUT"
+#define NETWORK_TIMEOUT_ENV "LTTNG_NETWORK_SOCKET_TIMEOUT"
static struct lttcomm_net_family net_families[] = {
{ LTTCOMM_INET, lttcomm_create_inet_sock },
/*
* Human readable error message.
*/
-static
-const char *lttcomm_return_code_str(lttcomm_return_code code) {
+static const char *lttcomm_return_code_str(lttcomm_return_code code)
+{
switch (code) {
case LTTCOMM_CONSUMERD_SUCCESS:
return "consumerd success";
code = (lttcomm_return_code) -code;
if (code != LTTCOMM_CONSUMERD_SUCCESS &&
- !(code >= LTTCOMM_CONSUMERD_COMMAND_SOCK_READY && code < LTTCOMM_NR)) {
+ !(code >= LTTCOMM_CONSUMERD_COMMAND_SOCK_READY && code < LTTCOMM_NR)) {
code = LTTCOMM_CONSUMERD_UNKNOWN_ERROR;
}
/*
* Init IPv4 sockaddr structure.
*/
-int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
- const char *ip, unsigned int port)
+int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr, const char *ip, unsigned int port)
{
int ret;
sockaddr->type = LTTCOMM_INET;
sockaddr->addr.sin.sin_family = AF_INET;
sockaddr->addr.sin.sin_port = htons(port);
- ret = inet_pton(sockaddr->addr.sin.sin_family, ip,
- &sockaddr->addr.sin.sin_addr);
+ ret = inet_pton(sockaddr->addr.sin.sin_family, ip, &sockaddr->addr.sin.sin_addr);
if (ret < 1) {
ret = -1;
ERR("%s with port %d: unrecognized IPv4 address", ip, port);
* Init IPv6 sockaddr structure.
*/
int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
- const char *ip, unsigned int port)
+ const char *ip,
+ unsigned int port)
{
int ret;
sockaddr->type = LTTCOMM_INET6;
sockaddr->addr.sin6.sin6_family = AF_INET6;
sockaddr->addr.sin6.sin6_port = htons(port);
- ret = inet_pton(sockaddr->addr.sin6.sin6_family, ip,
- &sockaddr->addr.sin6.sin6_addr);
+ ret = inet_pton(sockaddr->addr.sin6.sin6_family, ip, &sockaddr->addr.sin6.sin6_addr);
if (ret < 1) {
ret = -1;
goto error;
/* Check destination type */
if (uri->dtype == LTTNG_DST_IPV4) {
- ret = lttcomm_init_inet_sockaddr(&sock->sockaddr, uri->dst.ipv4,
- uri->port);
+ ret = lttcomm_init_inet_sockaddr(&sock->sockaddr, uri->dst.ipv4, uri->port);
if (ret < 0) {
goto error;
}
} else if (uri->dtype == LTTNG_DST_IPV6) {
- ret = lttcomm_init_inet6_sockaddr(&sock->sockaddr, uri->dst.ipv6,
- uri->port);
+ ret = lttcomm_init_inet6_sockaddr(&sock->sockaddr, uri->dst.ipv6, uri->port);
if (ret < 0) {
goto error;
}
*
* On error, NULL is returned.
*/
-struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(struct lttng_uri *uri,
- uint32_t major, uint32_t minor)
+struct lttcomm_relayd_sock *
+lttcomm_alloc_relayd_sock(struct lttng_uri *uri, uint32_t major, uint32_t minor)
{
int ret;
struct lttcomm_sock *tmp_sock = NULL;
{
LTTNG_ASSERT(sock);
LTTNG_ASSERT(port);
- LTTNG_ASSERT(sock->sockaddr.type == LTTCOMM_INET ||
- sock->sockaddr.type == LTTCOMM_INET6);
- LTTNG_ASSERT(sock->proto == LTTCOMM_SOCK_TCP ||
- sock->proto == LTTCOMM_SOCK_UDP);
+ LTTNG_ASSERT(sock->sockaddr.type == LTTCOMM_INET || sock->sockaddr.type == LTTCOMM_INET6);
+ LTTNG_ASSERT(sock->proto == LTTCOMM_SOCK_TCP || sock->proto == LTTCOMM_SOCK_UDP);
switch (sock->sockaddr.type) {
case LTTCOMM_INET:
int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port)
{
LTTNG_ASSERT(sock);
- LTTNG_ASSERT(sock->sockaddr.type == LTTCOMM_INET ||
- sock->sockaddr.type == LTTCOMM_INET6);
- LTTNG_ASSERT(sock->proto == LTTCOMM_SOCK_TCP ||
- sock->proto == LTTCOMM_SOCK_UDP);
+ LTTNG_ASSERT(sock->sockaddr.type == LTTCOMM_INET || sock->sockaddr.type == LTTCOMM_INET6);
+ LTTNG_ASSERT(sock->proto == LTTCOMM_SOCK_TCP || sock->proto == LTTCOMM_SOCK_UDP);
switch (sock->sockaddr.type) {
case LTTCOMM_INET:
* Only valid for an ipv4 and ipv6 bound socket that is already connected to its
* peer.
*/
-int lttcomm_populate_sock_from_open_socket(
- struct lttcomm_sock *sock,
- int fd,
- enum lttcomm_sock_proto protocol)
+int lttcomm_populate_sock_from_open_socket(struct lttcomm_sock *sock,
+ int fd,
+ enum lttcomm_sock_proto protocol)
{
int ret = 0;
socklen_t storage_len;
sock->proto = protocol;
storage_len = sizeof(storage);
- ret = getpeername(fd, (struct sockaddr *) &storage,
- &storage_len);
+ ret = getpeername(fd, (struct sockaddr *) &storage, &storage_len);
if (ret) {
- ERR("Failed to get peer info for socket %d (errno: %d)", fd,
- errno);
+ ERR("Failed to get peer info for socket %d (errno: %d)", fd, errno);
ret = -1;
goto end;
}
switch (storage.ss_family) {
case AF_INET:
sock->sockaddr.type = LTTCOMM_INET;
- memcpy(&sock->sockaddr.addr, &storage,
- sizeof(struct sockaddr_in));
+ memcpy(&sock->sockaddr.addr, &storage, sizeof(struct sockaddr_in));
break;
case AF_INET6:
sock->sockaddr.type = LTTCOMM_INET6;
- memcpy(&sock->sockaddr.addr, &storage,
- sizeof(struct sockaddr_in6));
+ memcpy(&sock->sockaddr.addr, &storage, sizeof(struct sockaddr_in6));
break;
default:
abort();
*/
#define _LGPL_SOURCE
+#include "shm.hpp"
+
+#include <common/error.hpp>
+
#include <fcntl.h>
#include <limits.h>
#include <sys/mman.h>
#include <unistd.h>
#include <urcu.h>
-#include <common/error.hpp>
-
-#include "shm.hpp"
-
/*
* We deal with the shm_open vs ftruncate race (happening when the sessiond owns
* the shm and does not let everybody modify it, to ensure safety against
if (errno == EACCES) {
/* Work around sysctl fs.protected_regular. */
DBG("shm_open of %s returned EACCES, this may be caused "
- "by the fs.protected_regular sysctl. "
- "Attempting to open the shm without "
- "creating it.", shm_path);
+ "by the fs.protected_regular sysctl. "
+ "Attempting to open the shm without "
+ "creating it.",
+ shm_path);
wait_shm_fd = shm_open(shm_path, O_RDWR, mode);
}
if (wait_shm_fd < 0) {
- PERROR("Failed to open \"wait\" shared memory object: path = '%s'", shm_path);
+ PERROR("Failed to open \"wait\" shared memory object: path = '%s'",
+ shm_path);
goto error;
}
}
ret = ftruncate(wait_shm_fd, mmap_size);
if (ret < 0) {
PERROR("Failed to truncate \"wait\" shared memory object: fd = %d, size = %zu",
- wait_shm_fd, mmap_size);
+ wait_shm_fd,
+ mmap_size);
goto error;
}
ret = fchown(wait_shm_fd, 0, 0);
if (ret < 0) {
PERROR("Failed to set ownership of \"wait\" shared memory object: fd = %d, owner = 0, group = 0",
- wait_shm_fd);
+ wait_shm_fd);
goto error;
}
/*
ret = fchmod(wait_shm_fd, mode);
if (ret < 0) {
PERROR("Failed to set the mode of the \"wait\" shared memory object: fd = %d, mode = %d",
- wait_shm_fd, mode);
+ wait_shm_fd,
+ mode);
goto error;
}
} else {
ret = fchown(wait_shm_fd, getuid(), getgid());
if (ret < 0) {
PERROR("Failed to set ownership of \"wait\" shared memory object: fd = %d, owner = %d, group = %d",
- wait_shm_fd, getuid(), getgid());
+ wait_shm_fd,
+ getuid(),
+ getgid());
goto error;
}
}
DBG("Wait shared memory file descriptor created successfully: path = '%s', mmap_size = %zu, global = %s, fd = %d",
- shm_path, mmap_size, global ? "true" : "false",
- wait_shm_fd);
+ shm_path,
+ mmap_size,
+ global ? "true" : "false",
+ wait_shm_fd);
end:
(void) umask(old_mode);
goto error;
}
- wait_shm_mmap = (char *) mmap(NULL, mmap_size, PROT_WRITE | PROT_READ,
- MAP_SHARED, wait_shm_fd, 0);
+ wait_shm_mmap =
+ (char *) mmap(NULL, mmap_size, PROT_WRITE | PROT_READ, MAP_SHARED, wait_shm_fd, 0);
/* close shm fd immediately after taking the mmap reference */
ret = close(wait_shm_fd);
if (ret) {
PERROR("Failed to close \"wait\" shared memory object file descriptor: fd = %d",
- wait_shm_fd);
+ wait_shm_fd);
}
if (wait_shm_mmap == MAP_FAILED) {
DBG("Failed to mmap the \"wait\" shareed memory object (can be caused by race with ust): path = '%s', global = %s",
- shm_path, global ? "true" : "false");
+ shm_path,
+ global ? "true" : "false");
goto error;
}
ret = snprintf(tmp_name, NAME_MAX, "/shm-%s-%d", owner_name, getpid());
if (ret < 0) {
PERROR("Failed to format shm path: owner_name = '%s', pid = %d",
- owner_name, getpid());
+ owner_name,
+ getpid());
return -1;
}
ret = shm_unlink(tmp_name);
if (ret < 0 && errno != ENOENT) {
- PERROR("Failed to unlink shared memory object: path = '%s'",
- tmp_name);
+ PERROR("Failed to unlink shared memory object: path = '%s'", tmp_name);
goto error_shm_release;
}
ret = close(shmfd);
if (ret) {
PERROR("Failed to close shared memory object file descriptor: fd = %d, path = '%s'",
- shmfd, tmp_name);
+ shmfd,
+ tmp_name);
}
error_shm_open:
return -1;
#include <common/payload-view.hpp>
#include <common/payload.hpp>
#include <common/snapshot.hpp>
+
#include <lttng/snapshot-internal.hpp>
#include <lttng/snapshot.h>
return valid;
}
-bool lttng_snapshot_output_is_equal(
- const struct lttng_snapshot_output *a,
- const struct lttng_snapshot_output *b)
+bool lttng_snapshot_output_is_equal(const struct lttng_snapshot_output *a,
+ const struct lttng_snapshot_output *b)
{
bool equal = false;
} LTTNG_PACKED;
} /* namespace */
-int lttng_snapshot_output_serialize(
- const struct lttng_snapshot_output *output,
- struct lttng_payload *payload)
+int lttng_snapshot_output_serialize(const struct lttng_snapshot_output *output,
+ struct lttng_payload *payload)
{
struct lttng_snapshot_output_comm comm;
int ret;
goto end;
}
- ret = lttng_strncpy(
- comm.ctrl_url, output->ctrl_url, sizeof(comm.ctrl_url));
+ ret = lttng_strncpy(comm.ctrl_url, output->ctrl_url, sizeof(comm.ctrl_url));
if (ret) {
goto end;
}
- ret = lttng_strncpy(
- comm.data_url, output->data_url, sizeof(comm.data_url));
+ ret = lttng_strncpy(comm.data_url, output->data_url, sizeof(comm.data_url));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &comm, sizeof(comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &comm, sizeof(comm));
if (ret) {
goto end;
}
return ret;
}
-ssize_t lttng_snapshot_output_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_snapshot_output **output_p)
+ssize_t lttng_snapshot_output_create_from_payload(struct lttng_payload_view *view,
+ struct lttng_snapshot_output **output_p)
{
const struct lttng_snapshot_output_comm *comm;
struct lttng_snapshot_output *output = NULL;
goto end;
}
- ret = lttng_strncpy(output->ctrl_url, comm->ctrl_url,
- sizeof(output->ctrl_url));
+ ret = lttng_strncpy(output->ctrl_url, comm->ctrl_url, sizeof(output->ctrl_url));
if (ret) {
goto end;
}
- ret = lttng_strncpy(output->data_url, comm->data_url,
- sizeof(output->data_url));
+ ret = lttng_strncpy(output->data_url, comm->data_url, sizeof(output->data_url));
if (ret) {
goto end;
}
return ret;
}
-enum lttng_error_code lttng_snapshot_output_mi_serialize(
- const struct lttng_snapshot_output *output,
- struct mi_writer *writer)
+enum lttng_error_code lttng_snapshot_output_mi_serialize(const struct lttng_snapshot_output *output,
+ struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(writer);
/* Open output element. */
- ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_action_snapshot_session_output);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_snapshot_session_output);
if (ret) {
goto mi_error;
}
/* Name. */
if (strnlen(output->name, LTTNG_NAME_MAX) != 0) {
ret = mi_lttng_writer_write_element_string(
- writer, config_element_name, output->name);
+ writer, config_element_name, output->name);
if (ret) {
goto mi_error;
}
}
/* Control url (always present). */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
if (ret) {
goto mi_error;
}
/* Data url (optional). */
if (strnlen(output->data_url, PATH_MAX) != 0) {
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_snapshot_data_url,
- output->data_url);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_snapshot_data_url, output->data_url);
if (ret) {
goto mi_error;
}
*/
if (output->max_size > 0 && output->max_size != UINT64_MAX) {
/* Total size of all stream combined. */
- ret = mi_lttng_writer_write_element_unsigned_int(writer,
- mi_lttng_element_snapshot_max_size,
- output->max_size);
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_snapshot_max_size, output->max_size);
if (ret) {
goto mi_error;
}
*
*/
+#include "error.hpp"
+#include "macros.hpp"
+#include "spawn-viewer.hpp"
+
+#include <common/compat/errno.hpp>
+
+#include <lttng/constant.h>
+
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <lttng/constant.h>
-
-#include <common/compat/errno.hpp>
-#include "error.hpp"
-#include "macros.hpp"
-#include "spawn-viewer.hpp"
-
/*
* Type is also use as the index in the viewers array. So please, make sure
* your enum value is in the right order in the array below.
*/
enum viewer_type {
- VIEWER_BABELTRACE = 0,
- VIEWER_BABELTRACE2 = 1,
- VIEWER_USER_DEFINED = 2,
+ VIEWER_BABELTRACE = 0,
+ VIEWER_BABELTRACE2 = 1,
+ VIEWER_USER_DEFINED = 2,
};
namespace {
*
* The returning pointer is ready to be passed to execvp().
*/
-static char **alloc_argv_from_local_opts(const char **opts, size_t opts_len,
- const char *trace_path, bool opt_live_mode)
+static char **alloc_argv_from_local_opts(const char **opts,
+ size_t opts_len,
+ const char *trace_path,
+ bool opt_live_mode)
{
char **argv;
size_t mem_len;
return argv;
}
-
/*
* Spawn viewer with the trace directory path.
*/
} else {
viewer_bin = viewer->exec_name;
}
- argv = alloc_argv_from_local_opts(babeltrace2_opts,
- ARRAY_SIZE(babeltrace2_opts), trace_path,
- opt_live_mode);
+ argv = alloc_argv_from_local_opts(
+ babeltrace2_opts, ARRAY_SIZE(babeltrace2_opts), trace_path, opt_live_mode);
break;
case VIEWER_BABELTRACE:
if (stat(babeltrace_bin, &status) == 0) {
} else {
viewer_bin = viewer->exec_name;
}
- argv = alloc_argv_from_local_opts(babeltrace_opts,
- ARRAY_SIZE(babeltrace_opts), trace_path,
- opt_live_mode);
+ argv = alloc_argv_from_local_opts(
+ babeltrace_opts, ARRAY_SIZE(babeltrace_opts), trace_path, opt_live_mode);
break;
case VIEWER_USER_DEFINED:
argv = alloc_argv_from_user_opts(opt_viewer, trace_path);
if (viewer->type == VIEWER_BABELTRACE2) {
/* Fallback to legacy babeltrace. */
DBG("Default viewer \"%s\" not installed on the system, falling back to \"%s\"",
- viewers[VIEWER_BABELTRACE2].exec_name,
- viewers[VIEWER_BABELTRACE].exec_name);
+ viewers[VIEWER_BABELTRACE2].exec_name,
+ viewers[VIEWER_BABELTRACE].exec_name);
viewer = &viewers[VIEWER_BABELTRACE];
free(argv);
argv = NULL;
goto retry_viewer;
} else {
ERR("Default viewer \"%s\" (and fallback \"%s\") not found on the system",
- viewers[VIEWER_BABELTRACE2].exec_name,
- viewers[VIEWER_BABELTRACE].exec_name);
+ viewers[VIEWER_BABELTRACE2].exec_name,
+ viewers[VIEWER_BABELTRACE].exec_name);
}
} else {
PERROR("Failed to launch \"%s\" viewer", viewer_bin);
*/
#define _LGPL_SOURCE
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdbool.h>
-#include <type_traits>
+#include "../macros.hpp"
+#include "string-utils.hpp"
+
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
-
-#include "string-utils.hpp"
-#include "../macros.hpp"
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <type_traits>
enum star_glob_pattern_type_flags {
STAR_GLOB_PATTERN_TYPE_FLAG_NONE = 0,
STAR_GLOB_PATTERN_TYPE_FLAG_END_ONLY = 2,
};
-static
-star_glob_pattern_type_flags &operator|=(star_glob_pattern_type_flags &l,
- star_glob_pattern_type_flags r)
+static star_glob_pattern_type_flags& operator|=(star_glob_pattern_type_flags& l,
+ star_glob_pattern_type_flags r)
{
using T = std::underlying_type<star_glob_pattern_type_flags>::type;
- l = static_cast<star_glob_pattern_type_flags> (
- static_cast<T> (l) | static_cast<T> (r));
+ l = static_cast<star_glob_pattern_type_flags>(static_cast<T>(l) | static_cast<T>(r));
return l;
}
*np = '\0';
}
-static
-enum star_glob_pattern_type_flags strutils_test_glob_pattern(const char *pattern)
+static enum star_glob_pattern_type_flags strutils_test_glob_pattern(const char *pattern)
{
- enum star_glob_pattern_type_flags ret =
- STAR_GLOB_PATTERN_TYPE_FLAG_NONE;
+ enum star_glob_pattern_type_flags ret = STAR_GLOB_PATTERN_TYPE_FLAG_NONE;
const char *p;
LTTNG_ASSERT(pattern);
*/
bool strutils_is_star_glob_pattern(const char *pattern)
{
- return strutils_test_glob_pattern(pattern) &
- STAR_GLOB_PATTERN_TYPE_FLAG_PATTERN;
+ return strutils_test_glob_pattern(pattern) & STAR_GLOB_PATTERN_TYPE_FLAG_PATTERN;
}
/*
*/
bool strutils_is_star_at_the_end_only_glob_pattern(const char *pattern)
{
- return strutils_test_glob_pattern(pattern) &
- STAR_GLOB_PATTERN_TYPE_FLAG_END_ONLY;
+ return strutils_test_glob_pattern(pattern) & STAR_GLOB_PATTERN_TYPE_FLAG_END_ONLY;
}
/*
* Returns -1 if there's an error.
*/
int strutils_split(const char *input,
- char delim,
- bool escape_delim,
- struct lttng_dynamic_pointer_array *out_strings)
+ char delim,
+ bool escape_delim,
+ struct lttng_dynamic_pointer_array *out_strings)
{
int ret;
size_t at;
goto error;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- out_strings, substring);
+ ret = lttng_dynamic_pointer_array_add_pointer(out_strings, substring);
if (ret) {
free(substring);
goto error;
return ret;
}
-size_t strutils_array_of_strings_len(char * const *array)
+size_t strutils_array_of_strings_len(char *const *array)
{
- char * const *item;
+ char *const *item;
size_t count = 0;
LTTNG_ASSERT(array);
/* Format new string in-place. */
va_start(args, fmt);
- ret = vsprintf(&new_str[oldlen], fmt, args);
+ ret = vsprintf(&new_str[oldlen], fmt, args);
va_end(args);
if (ret == -1) {
#ifndef NTESTPOINT
#define _LGPL_SOURCE
-#include <dlfcn.h> /* for dlsym */
+#include "testpoint.hpp"
+
+#include <dlfcn.h> /* for dlsym */
#include <stdlib.h> /* for getenv */
#include <string.h> /* for strncmp */
-#include "testpoint.hpp"
-
/* Environment variable used to enable the testpoints facilities. */
static const char *lttng_testpoint_env_var = "LTTNG_TESTPOINT_ENABLE";
char *testpoint_env_val = NULL;
testpoint_env_val = getenv(lttng_testpoint_env_var);
- if (testpoint_env_val != NULL
- && (strncmp(testpoint_env_val, "1", 1) == 0)) {
+ if (testpoint_env_val != NULL && (strncmp(testpoint_env_val, "1", 1) == 0)) {
lttng_testpoint_activated = 1;
}
}
*
*/
-#include <string.h>
+#include "thread.hpp"
#include <common/compat/pthread.hpp>
-#include "thread.hpp"
+#include <string.h>
int lttng_thread_setname(const char *name)
{
return ret;
}
-
if (ts.tv_sec > ULONG_MAX / MSEC_PER_SEC) {
errno = EOVERFLOW;
- return -1; /* multiplication overflow */
+ return -1; /* multiplication overflow */
}
res = ts.tv_sec * MSEC_PER_SEC;
remain_ms = ULONG_MAX - res;
if (ts.tv_nsec / NSEC_PER_MSEC > remain_ms) {
errno = EOVERFLOW;
- return -1; /* addition overflow */
+ return -1; /* addition overflow */
}
res += ts.tv_nsec / NSEC_PER_MSEC;
*ms = res;
struct timespec timespec_abs_diff(struct timespec t1, struct timespec t2)
{
- uint64_t ts1 = (uint64_t) t1.tv_sec * (uint64_t) NSEC_PER_SEC +
- (uint64_t) t1.tv_nsec;
- uint64_t ts2 = (uint64_t) t2.tv_sec * (uint64_t) NSEC_PER_SEC +
- (uint64_t) t2.tv_nsec;
+ uint64_t ts1 = (uint64_t) t1.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t1.tv_nsec;
+ uint64_t ts2 = (uint64_t) t2.tv_sec * (uint64_t) NSEC_PER_SEC + (uint64_t) t2.tv_nsec;
uint64_t diff = std::max(ts1, ts2) - std::min(ts1, ts2);
struct timespec res;
return res;
}
-static
-void __attribute__((constructor)) init_locale_utf8_support(void)
+static void __attribute__((constructor)) init_locale_utf8_support(void)
{
const char *program_locale = setlocale(LC_ALL, NULL);
const char *lang = getenv("LANG");
if (len < ISO8601_STR_LEN) {
ERR("Buffer too short to format ISO 8601 timestamp: %zu bytes provided when at least %zu are needed",
- len, ISO8601_STR_LEN);
+ len,
+ ISO8601_STR_LEN);
ret = -1;
goto end;
}
if (len < DATETIME_STR_LEN) {
ERR("Buffer too short to format to datetime: %zu bytes provided when at least %zu are needed",
- len, DATETIME_STR_LEN);
+ len,
+ DATETIME_STR_LEN);
ret = -1;
goto end;
}
#include <common/error.hpp>
#include <common/fd-tracker/fd-tracker.hpp>
#include <common/fd-tracker/utils.hpp>
-#include <common/fs-handle.hpp>
#include <common/fs-handle-internal.hpp>
+#include <common/fs-handle.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/hashtable/utils.hpp>
#include <common/optional.hpp>
#include <common/trace-chunk-registry.hpp>
#include <common/trace-chunk.hpp>
#include <common/utils.hpp>
+
#include <lttng/constant.h>
#include <inttypes.h>
* index, i.e. <start-iso-8601>-<end-iso-8601>-<id-uint64_t>.
*/
#define GENERATED_CHUNK_NAME_LEN (2 * sizeof("YYYYmmddTHHMMSS+HHMM") + MAX_INT_DEC_LEN(uint64_t))
-#define DIR_CREATION_MODE (S_IRWXU | S_IRWXG)
+#define DIR_CREATION_MODE (S_IRWXU | S_IRWXG)
enum trace_chunk_mode {
TRACE_CHUNK_MODE_USER,
typedef int (*chunk_command)(struct lttng_trace_chunk *trace_chunk);
/* Move a completed trace chunk to the 'completed' trace archive folder. */
-static
-int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_chunk *trace_chunk);
+static int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_chunk *trace_chunk);
/* Empty callback. */
-static
-int lttng_trace_chunk_no_operation(struct lttng_trace_chunk *trace_chunk);
+static int lttng_trace_chunk_no_operation(struct lttng_trace_chunk *trace_chunk);
/* Unlink old chunk files. */
-static
-int lttng_trace_chunk_delete_post_release(struct lttng_trace_chunk *trace_chunk);
-static
-enum lttng_trace_chunk_status lttng_trace_chunk_rename_path_no_lock(
- struct lttng_trace_chunk *chunk, const char *path);
+static int lttng_trace_chunk_delete_post_release(struct lttng_trace_chunk *trace_chunk);
+static enum lttng_trace_chunk_status
+lttng_trace_chunk_rename_path_no_lock(struct lttng_trace_chunk *chunk, const char *path);
namespace {
struct chunk_credentials {
};
} /* namespace */
-static
-int fs_handle_untracked_get_fd(struct fs_handle *handle);
-static
-void fs_handle_untracked_put_fd(struct fs_handle *handle);
-static
-int fs_handle_untracked_unlink(struct fs_handle *handle);
-static
-int fs_handle_untracked_close(struct fs_handle *handle);
-
-static
-const char *lttng_trace_chunk_command_type_str(
- lttng_trace_chunk_command_type type) {
+static int fs_handle_untracked_get_fd(struct fs_handle *handle);
+static void fs_handle_untracked_put_fd(struct fs_handle *handle);
+static int fs_handle_untracked_unlink(struct fs_handle *handle);
+static int fs_handle_untracked_close(struct fs_handle *handle);
+
+static const char *lttng_trace_chunk_command_type_str(lttng_trace_chunk_command_type type)
+{
switch (type) {
case LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED:
return "move to completed chunk folder";
abort();
};
-static
-chunk_command close_command_get_post_release_func(
- lttng_trace_chunk_command_type type) {
+static chunk_command close_command_get_post_release_func(lttng_trace_chunk_command_type type)
+{
switch (type) {
case LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED:
return lttng_trace_chunk_move_to_completed_post_release;
abort();
};
-static
-struct fs_handle *fs_handle_untracked_create(
- struct lttng_directory_handle *directory_handle,
- const char *path,
- int fd)
+static struct fs_handle *fs_handle_untracked_create(struct lttng_directory_handle *directory_handle,
+ const char *path,
+ int fd)
{
struct fs_handle_untracked *handle = NULL;
bool reference_acquired;
goto end;
}
- handle->parent = (typeof(handle->parent)) {
+ handle->parent = (typeof(handle->parent)){
.get_fd = fs_handle_untracked_get_fd,
.put_fd = fs_handle_untracked_put_fd,
.unlink = fs_handle_untracked_unlink,
return handle ? &handle->parent : NULL;
}
-static
-int fs_handle_untracked_get_fd(struct fs_handle *_handle)
+static int fs_handle_untracked_get_fd(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = lttng::utils::container_of(
- _handle, &fs_handle_untracked::parent);
+ struct fs_handle_untracked *handle =
+ lttng::utils::container_of(_handle, &fs_handle_untracked::parent);
return handle->fd;
}
-static
-void fs_handle_untracked_put_fd(struct fs_handle *_handle __attribute__((unused)))
+static void fs_handle_untracked_put_fd(struct fs_handle *_handle __attribute__((unused)))
{
/* no-op. */
}
-static
-int fs_handle_untracked_unlink(struct fs_handle *_handle)
+static int fs_handle_untracked_unlink(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = lttng::utils::container_of(
- _handle, &fs_handle_untracked::parent);
+ struct fs_handle_untracked *handle =
+ lttng::utils::container_of(_handle, &fs_handle_untracked::parent);
- return lttng_directory_handle_unlink_file(
- handle->location.directory_handle,
- handle->location.path);
+ return lttng_directory_handle_unlink_file(handle->location.directory_handle,
+ handle->location.path);
}
-static
-void fs_handle_untracked_destroy(struct fs_handle_untracked *handle)
+static void fs_handle_untracked_destroy(struct fs_handle_untracked *handle)
{
lttng_directory_handle_put(handle->location.directory_handle);
free(handle->location.path);
free(handle);
}
-static
-int fs_handle_untracked_close(struct fs_handle *_handle)
+static int fs_handle_untracked_close(struct fs_handle *_handle)
{
- struct fs_handle_untracked *handle = lttng::utils::container_of(
- _handle, &fs_handle_untracked::parent);
+ struct fs_handle_untracked *handle =
+ lttng::utils::container_of(_handle, &fs_handle_untracked::parent);
int ret = close(handle->fd);
fs_handle_untracked_destroy(handle);
return ret;
}
-static
-bool lttng_trace_chunk_registry_element_equals(
- const struct lttng_trace_chunk_registry_element *a,
- const struct lttng_trace_chunk_registry_element *b)
+static bool
+lttng_trace_chunk_registry_element_equals(const struct lttng_trace_chunk_registry_element *a,
+ const struct lttng_trace_chunk_registry_element *b)
{
if (a->session_id != b->session_id) {
goto not_equal;
return false;
}
-static
-int lttng_trace_chunk_registry_element_match(struct cds_lfht_node *node,
- const void *key)
+static int lttng_trace_chunk_registry_element_match(struct cds_lfht_node *node, const void *key)
{
const struct lttng_trace_chunk_registry_element *element_a, *element_b;
element_a = (const struct lttng_trace_chunk_registry_element *) key;
- element_b = caa_container_of(node, typeof(*element_b),
- trace_chunk_registry_ht_node);
+ element_b = caa_container_of(node, typeof(*element_b), trace_chunk_registry_ht_node);
return lttng_trace_chunk_registry_element_equals(element_a, element_b);
}
-static
-unsigned long lttng_trace_chunk_registry_element_hash(
- const struct lttng_trace_chunk_registry_element *element)
+static unsigned long
+lttng_trace_chunk_registry_element_hash(const struct lttng_trace_chunk_registry_element *element)
{
- unsigned long hash = hash_key_u64(&element->session_id,
- lttng_ht_seed);
+ unsigned long hash = hash_key_u64(&element->session_id, lttng_ht_seed);
if (element->chunk.id.is_set) {
hash ^= hash_key_u64(&element->chunk.id.value, lttng_ht_seed);
return hash;
}
-static
-char *generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp,
- const time_t *close_timestamp)
+static char *
+generate_chunk_name(uint64_t chunk_id, time_t creation_timestamp, const time_t *close_timestamp)
{
int ret = 0;
- char *new_name= NULL;
+ char *new_name = NULL;
char start_datetime[ISO8601_STR_LEN] = {};
/* Add 1 for a '-' prefix. */
char end_datetime_suffix[ISO8601_STR_LEN + 1] = {};
- ret = time_to_iso8601_str(
- creation_timestamp,
- start_datetime, sizeof(start_datetime));
+ ret = time_to_iso8601_str(creation_timestamp, start_datetime, sizeof(start_datetime));
if (ret) {
ERR("Failed to format trace chunk start date time");
goto error;
if (close_timestamp) {
*end_datetime_suffix = '-';
ret = time_to_iso8601_str(
- *close_timestamp,
- end_datetime_suffix + 1,
- sizeof(end_datetime_suffix) - 1);
+ *close_timestamp, end_datetime_suffix + 1, sizeof(end_datetime_suffix) - 1);
if (ret) {
ERR("Failed to format trace chunk end date time");
goto error;
ERR("Failed to allocate buffer for automatically-generated trace chunk name");
goto error;
}
- ret = snprintf(new_name, GENERATED_CHUNK_NAME_LEN, "%s%s-%" PRIu64,
- start_datetime, end_datetime_suffix, chunk_id);
+ ret = snprintf(new_name,
+ GENERATED_CHUNK_NAME_LEN,
+ "%s%s-%" PRIu64,
+ start_datetime,
+ end_datetime_suffix,
+ chunk_id);
if (ret >= GENERATED_CHUNK_NAME_LEN || ret == -1) {
ERR("Failed to format trace chunk name");
goto error;
return NULL;
}
-static
-void lttng_trace_chunk_init(struct lttng_trace_chunk *chunk)
+static void lttng_trace_chunk_init(struct lttng_trace_chunk *chunk)
{
urcu_ref_init(&chunk->ref);
pthread_mutex_init(&chunk->lock, NULL);
lttng_dynamic_pointer_array_init(&chunk->files, free);
}
-static
-void lttng_trace_chunk_fini(struct lttng_trace_chunk *chunk)
+static void lttng_trace_chunk_fini(struct lttng_trace_chunk *chunk)
{
if (chunk->session_output_directory) {
- lttng_directory_handle_put(
- chunk->session_output_directory);
+ lttng_directory_handle_put(chunk->session_output_directory);
chunk->session_output_directory = NULL;
}
if (chunk->chunk_directory) {
pthread_mutex_destroy(&chunk->lock);
}
-static
-struct lttng_trace_chunk *lttng_trace_chunk_allocate(void)
+static struct lttng_trace_chunk *lttng_trace_chunk_allocate(void)
{
struct lttng_trace_chunk *chunk = NULL;
return lttng_trace_chunk_allocate();
}
-struct lttng_trace_chunk *lttng_trace_chunk_create(
- uint64_t chunk_id, time_t chunk_creation_time, const char *path)
+struct lttng_trace_chunk *
+lttng_trace_chunk_create(uint64_t chunk_id, time_t chunk_creation_time, const char *path)
{
struct lttng_trace_chunk *chunk;
char chunk_creation_datetime_buf[16] = {};
/* Don't fail because of this; it is only used for logging. */
strftime_ret = strftime(chunk_creation_datetime_buf,
- sizeof(chunk_creation_datetime_buf),
- "%Y%m%d-%H%M%S", timeinfo);
+ sizeof(chunk_creation_datetime_buf),
+ "%Y%m%d-%H%M%S",
+ timeinfo);
if (strftime_ret) {
- chunk_creation_datetime_str =
- chunk_creation_datetime_buf;
+ chunk_creation_datetime_str = chunk_creation_datetime_buf;
}
}
DBG("Creating trace chunk: chunk_id = %" PRIu64 ", creation time = %s",
- chunk_id, chunk_creation_datetime_str);
+ chunk_id,
+ chunk_creation_datetime_str);
chunk = lttng_trace_chunk_allocate();
if (!chunk) {
goto end;
LTTNG_OPTIONAL_SET(&chunk->id, chunk_id);
LTTNG_OPTIONAL_SET(&chunk->timestamp_creation, chunk_creation_time);
if (chunk_id != 0) {
- chunk->name = generate_chunk_name(chunk_id,
- chunk_creation_time, NULL);
+ chunk->name = generate_chunk_name(chunk_id, chunk_creation_time, NULL);
if (!chunk->name) {
ERR("Failed to allocate trace chunk name storage");
goto error;
}
}
- DBG("Chunk name set to \"%s\"", chunk->name ? : "(none)");
+ DBG("Chunk name set to \"%s\"", chunk->name ?: "(none)");
end:
return chunk;
error:
}
void lttng_trace_chunk_set_fd_tracker(struct lttng_trace_chunk *chunk,
- struct fd_tracker *fd_tracker)
+ struct fd_tracker *fd_tracker)
{
LTTNG_ASSERT(!chunk->session_output_directory);
LTTNG_ASSERT(!chunk->chunk_directory);
chunk->fd_tracker = fd_tracker;
}
-struct lttng_trace_chunk *lttng_trace_chunk_copy(
- struct lttng_trace_chunk *source_chunk)
+struct lttng_trace_chunk *lttng_trace_chunk_copy(struct lttng_trace_chunk *source_chunk)
{
struct lttng_trace_chunk *new_chunk = lttng_trace_chunk_allocate();
* A new chunk is always a user; it shall create no new trace
* subdirectories.
*/
- new_chunk->mode = (typeof(new_chunk->mode)) {
+ new_chunk->mode = (typeof(new_chunk->mode)){
.is_set = true,
.value = TRACE_CHUNK_MODE_USER,
};
if (source_chunk->name) {
new_chunk->name = strdup(source_chunk->name);
if (!new_chunk->name) {
- ERR("Failed to copy source trace chunk name in %s()",
- __FUNCTION__);
+ ERR("Failed to copy source trace chunk name in %s()", __FUNCTION__);
goto error_unlock;
}
}
if (source_chunk->path) {
new_chunk->path = strdup(source_chunk->path);
if (!new_chunk->path) {
- ERR("Failed to copy source trace chunk path in %s()",
- __FUNCTION__);
+ ERR("Failed to copy source trace chunk path in %s()", __FUNCTION__);
}
}
new_chunk->id = source_chunk->id;
new_chunk->timestamp_close = source_chunk->timestamp_close;
new_chunk->credentials = source_chunk->credentials;
if (source_chunk->session_output_directory) {
- const bool reference_acquired = lttng_directory_handle_get(
- source_chunk->session_output_directory);
+ const bool reference_acquired =
+ lttng_directory_handle_get(source_chunk->session_output_directory);
LTTNG_ASSERT(reference_acquired);
- new_chunk->session_output_directory =
- source_chunk->session_output_directory;
+ new_chunk->session_output_directory = source_chunk->session_output_directory;
}
if (source_chunk->chunk_directory) {
- const bool reference_acquired = lttng_directory_handle_get(
- source_chunk->chunk_directory);
+ const bool reference_acquired =
+ lttng_directory_handle_get(source_chunk->chunk_directory);
LTTNG_ASSERT(reference_acquired);
new_chunk->chunk_directory = source_chunk->chunk_directory;
return NULL;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_id(
- struct lttng_trace_chunk *chunk, uint64_t *id)
+enum lttng_trace_chunk_status lttng_trace_chunk_get_id(struct lttng_trace_chunk *chunk,
+ uint64_t *id)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_creation_timestamp(
- struct lttng_trace_chunk *chunk, time_t *creation_ts)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_get_creation_timestamp(struct lttng_trace_chunk *chunk, time_t *creation_ts)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(
- struct lttng_trace_chunk *chunk, time_t *close_ts)
+enum lttng_trace_chunk_status lttng_trace_chunk_get_close_timestamp(struct lttng_trace_chunk *chunk,
+ time_t *close_ts)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(
- struct lttng_trace_chunk *chunk, time_t close_ts)
+enum lttng_trace_chunk_status lttng_trace_chunk_set_close_timestamp(struct lttng_trace_chunk *chunk,
+ time_t close_ts)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
*/
if (chunk->timestamp_creation.value > close_ts) {
WARN("Set trace chunk close timestamp: close timestamp is before creation timestamp, begin : %ld, close : %ld",
- chunk->timestamp_creation.value, close_ts);
+ chunk->timestamp_creation.value,
+ close_ts);
}
LTTNG_OPTIONAL_SET(&chunk->timestamp_close, close_ts);
if (!chunk->name_overridden) {
free(chunk->name);
chunk->name = generate_chunk_name(LTTNG_OPTIONAL_GET(chunk->id),
- LTTNG_OPTIONAL_GET(chunk->timestamp_creation),
- &close_ts);
+ LTTNG_OPTIONAL_GET(chunk->timestamp_creation),
+ &close_ts);
if (!chunk->name) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
}
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_name(
- struct lttng_trace_chunk *chunk, const char **name,
- bool *name_overridden)
+enum lttng_trace_chunk_status lttng_trace_chunk_get_name(struct lttng_trace_chunk *chunk,
+ const char **name,
+ bool *name_overridden)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return name_overridden;
}
-static
-bool is_valid_chunk_name(const char *name)
+static bool is_valid_chunk_name(const char *name)
{
size_t len;
return true;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_override_name(
- struct lttng_trace_chunk *chunk, const char *name)
+enum lttng_trace_chunk_status lttng_trace_chunk_override_name(struct lttng_trace_chunk *chunk,
+ const char *name)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
DBG("Override trace chunk name from %s to %s", chunk->name, name);
if (!is_valid_chunk_name(name)) {
- ERR("Attempted to set an invalid name on a trace chunk: name = %s",
- name ? : "NULL");
+ ERR("Attempted to set an invalid name on a trace chunk: name = %s", name ?: "NULL");
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT;
goto end;
}
pthread_mutex_lock(&chunk->lock);
if (!chunk->id.is_set) {
ERR("Attempted to set an override name on an anonymous trace chunk: name = %s",
- name);
+ name);
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION;
goto end_unlock;
}
return status;
}
-static
-enum lttng_trace_chunk_status lttng_trace_chunk_rename_path_no_lock(
- struct lttng_trace_chunk *chunk, const char *path)
+static enum lttng_trace_chunk_status
+lttng_trace_chunk_rename_path_no_lock(struct lttng_trace_chunk *chunk, const char *path)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
old_path = chunk->path;
DBG("lttng_trace_chunk_rename_path from %s to %s", old_path, path);
- if ((!old_path && !path) ||
- (old_path && path && !strcmp(old_path, path))) {
+ if ((!old_path && !path) || (old_path && path && !strcmp(old_path, path))) {
goto end;
}
/*
* is not set (yet), or the session_output_directory is not set
* (interacting with a relay daemon), there is no rename to perform.
*/
- if (!chunk->chunk_directory ||
- !chunk->session_output_directory) {
+ if (!chunk->chunk_directory || !chunk->session_output_directory) {
goto skip_move;
}
&chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move trace chunk directory \"%s\" to \"%s\"",
- old_path, path);
+ old_path,
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
rename_directory = chunk->fd_tracker ?
- fd_tracker_create_directory_handle_from_handle(
- chunk->fd_tracker,
- chunk->session_output_directory,
- path) :
- lttng_directory_handle_create_from_handle(
- path,
- chunk->session_output_directory);
+ fd_tracker_create_directory_handle_from_handle(
+ chunk->fd_tracker, chunk->session_output_directory, path) :
+ lttng_directory_handle_create_from_handle(path,
+ chunk->session_output_directory);
if (!rename_directory) {
ERR("Failed to get handle to trace chunk rename directory");
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
chunk->chunk_directory = rename_directory;
rename_directory = NULL;
} else if (old_path && old_path[0] == '\0') {
- size_t i, count = lttng_dynamic_pointer_array_get_count(
+ size_t i,
+ count = lttng_dynamic_pointer_array_get_count(
&chunk->top_level_directories);
ret = lttng_directory_handle_create_subdirectory_as_user(
- chunk->session_output_directory,
- path,
- DIR_CREATION_MODE,
- LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
- &chunk->credentials.value.user);
+ chunk->session_output_directory,
+ path,
+ DIR_CREATION_MODE,
+ LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
+ NULL :
+ &chunk->credentials.value.user);
if (ret) {
- PERROR("Failed to create trace chunk rename directory \"%s\"",
- path);
+ PERROR("Failed to create trace chunk rename directory \"%s\"", path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
rename_directory = lttng_directory_handle_create_from_handle(
- path, chunk->session_output_directory);
+ path, chunk->session_output_directory);
if (!rename_directory) {
ERR("Failed to get handle to trace chunk rename directory");
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
&chunk->top_level_directories, i);
ret = lttng_directory_handle_rename_as_user(
- chunk->chunk_directory,
- top_level_name,
- rename_directory,
- top_level_name,
- LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
- &chunk->credentials.value.user);
+ chunk->chunk_directory,
+ top_level_name,
+ rename_directory,
+ top_level_name,
+ LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
+ NULL :
+ &chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move \"%s\" to trace chunk rename directory",
- top_level_name);
+ top_level_name);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
chunk->chunk_directory = rename_directory;
rename_directory = NULL;
} else if (old_path) {
- size_t i, count = lttng_dynamic_pointer_array_get_count(
+ size_t i,
+ count = lttng_dynamic_pointer_array_get_count(
&chunk->top_level_directories);
- const bool reference_acquired = lttng_directory_handle_get(
- chunk->session_output_directory);
+ const bool reference_acquired =
+ lttng_directory_handle_get(chunk->session_output_directory);
LTTNG_ASSERT(reference_acquired);
rename_directory = chunk->session_output_directory;
&chunk->top_level_directories, i);
ret = lttng_directory_handle_rename_as_user(
- chunk->chunk_directory,
- top_level_name,
- rename_directory,
- top_level_name,
- LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
- NULL :
- &chunk->credentials.value.user);
+ chunk->chunk_directory,
+ top_level_name,
+ rename_directory,
+ top_level_name,
+ LTTNG_OPTIONAL_GET(chunk->credentials).use_current_user ?
+ NULL :
+ &chunk->credentials.value.user);
if (ret) {
PERROR("Failed to move \"%s\" to trace chunk rename directory",
- top_level_name);
+ top_level_name);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
/* Remove old directory. */
status = (lttng_trace_chunk_status) lttng_directory_handle_remove_subdirectory(
- chunk->session_output_directory,
- old_path);
+ chunk->session_output_directory, old_path);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
- ERR("Error removing subdirectory '%s' file when deleting chunk",
- old_path);
+ ERR("Error removing subdirectory '%s' file when deleting chunk", old_path);
goto end;
}
} else {
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(
- struct lttng_trace_chunk *chunk, const char *path)
+enum lttng_trace_chunk_status lttng_trace_chunk_rename_path(struct lttng_trace_chunk *chunk,
+ const char *path)
{
enum lttng_trace_chunk_status status;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_credentials(
- struct lttng_trace_chunk *chunk,
- struct lttng_credentials *credentials)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_get_credentials(struct lttng_trace_chunk *chunk,
+ struct lttng_credentials *credentials)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials(
- struct lttng_trace_chunk *chunk,
- const struct lttng_credentials *user_credentials)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_set_credentials(struct lttng_trace_chunk *chunk,
+ const struct lttng_credentials *user_credentials)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
const struct chunk_credentials credentials = {
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_set_credentials_current_user(
- struct lttng_trace_chunk *chunk)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_set_credentials_current_user(struct lttng_trace_chunk *chunk)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
const struct chunk_credentials credentials = {
return status;
}
-
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_owner(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle *session_output_directory)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_set_as_owner(struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle *session_output_directory)
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
}
if (chunk->path && chunk->path[0] != '\0') {
ret = lttng_directory_handle_create_subdirectory_as_user(
- session_output_directory,
- chunk->path,
- DIR_CREATION_MODE,
- !chunk->credentials.value.use_current_user ?
- &chunk->credentials.value.user : NULL);
+ session_output_directory,
+ chunk->path,
+ DIR_CREATION_MODE,
+ !chunk->credentials.value.use_current_user ?
+ &chunk->credentials.value.user :
+ NULL);
if (ret) {
- PERROR("Failed to create chunk output directory \"%s\"",
- chunk->path);
+ PERROR("Failed to create chunk output directory \"%s\"", chunk->path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
- chunk_directory_handle =
- chunk->fd_tracker ?
- fd_tracker_create_directory_handle_from_handle(
- chunk->fd_tracker,
- session_output_directory,
- chunk->path) :
- lttng_directory_handle_create_from_handle(
- chunk->path,
- session_output_directory);
+ chunk_directory_handle = chunk->fd_tracker ?
+ fd_tracker_create_directory_handle_from_handle(
+ chunk->fd_tracker, session_output_directory, chunk->path) :
+ lttng_directory_handle_create_from_handle(chunk->path,
+ session_output_directory);
if (!chunk_directory_handle) {
/* The function already logs on all error paths. */
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
* A nameless chunk does not need its own output directory.
* The session's output directory will be used.
*/
- reference_acquired = lttng_directory_handle_get(
- session_output_directory);
+ reference_acquired = lttng_directory_handle_get(session_output_directory);
LTTNG_ASSERT(reference_acquired);
chunk_directory_handle = session_output_directory;
}
chunk->chunk_directory = chunk_directory_handle;
chunk_directory_handle = NULL;
- reference_acquired = lttng_directory_handle_get(
- session_output_directory);
+ reference_acquired = lttng_directory_handle_get(session_output_directory);
LTTNG_ASSERT(reference_acquired);
chunk->session_output_directory = session_output_directory;
LTTNG_OPTIONAL_SET(&chunk->mode, TRACE_CHUNK_MODE_OWNER);
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_set_as_user(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle *chunk_directory)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_set_as_user(struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle *chunk_directory)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
bool reference_acquired;
}
enum lttng_trace_chunk_status
-lttng_trace_chunk_get_session_output_directory_handle(
- struct lttng_trace_chunk *chunk,
- struct lttng_directory_handle **handle)
+lttng_trace_chunk_get_session_output_directory_handle(struct lttng_trace_chunk *chunk,
+ struct lttng_directory_handle **handle)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
*handle = NULL;
goto end;
} else {
- const bool reference_acquired = lttng_directory_handle_get(
- chunk->session_output_directory);
+ const bool reference_acquired =
+ lttng_directory_handle_get(chunk->session_output_directory);
LTTNG_ASSERT(reference_acquired);
*handle = chunk->session_output_directory;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_borrow_chunk_directory_handle(
- struct lttng_trace_chunk *chunk,
- const struct lttng_directory_handle **handle)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_borrow_chunk_directory_handle(struct lttng_trace_chunk *chunk,
+ const struct lttng_directory_handle **handle)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
}
/* Add a top-level directory to the trace chunk if it was previously unknown. */
-static
-int add_top_level_directory_unique(struct lttng_trace_chunk *chunk,
- const char *new_path)
+static int add_top_level_directory_unique(struct lttng_trace_chunk *chunk, const char *new_path)
{
int ret = 0;
bool found = false;
- size_t i, count = lttng_dynamic_pointer_array_get_count(
- &chunk->top_level_directories);
+ size_t i, count = lttng_dynamic_pointer_array_get_count(&chunk->top_level_directories);
const char *new_path_separator_pos = strchr(new_path, '/');
- const ptrdiff_t new_path_top_level_len = new_path_separator_pos ?
- new_path_separator_pos - new_path : strlen(new_path);
+ const ptrdiff_t new_path_top_level_len =
+ new_path_separator_pos ? new_path_separator_pos - new_path : strlen(new_path);
for (i = 0; i < count; i++) {
const char *path = (const char *) lttng_dynamic_pointer_array_get_pointer(
- &chunk->top_level_directories, i);
+ &chunk->top_level_directories, i);
const ptrdiff_t path_top_level_len = strlen(path);
if (path_top_level_len != new_path_top_level_len) {
char *copy = lttng_strndup(new_path, new_path_top_level_len);
DBG("Adding new top-level directory \"%s\" to trace chunk \"%s\"",
- new_path, chunk->name ? : "(unnamed)");
+ new_path,
+ chunk->name ?: "(unnamed)");
if (!copy) {
PERROR("Failed to copy path");
ret = -1;
goto end;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &chunk->top_level_directories, copy);
+ ret = lttng_dynamic_pointer_array_add_pointer(&chunk->top_level_directories, copy);
if (ret) {
ERR("Allocation failure while adding top-level directory entry to a trace chunk");
free(copy);
return ret;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(
- struct lttng_trace_chunk *chunk,
- const char *path)
+enum lttng_trace_chunk_status lttng_trace_chunk_create_subdirectory(struct lttng_trace_chunk *chunk,
+ const char *path)
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
* directory is created.
*/
ERR("Credentials of trace chunk are unset: refusing to create subdirectory \"%s\"",
- path);
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
- if (!chunk->mode.is_set ||
- chunk->mode.value != TRACE_CHUNK_MODE_OWNER) {
+ if (!chunk->mode.is_set || chunk->mode.value != TRACE_CHUNK_MODE_OWNER) {
ERR("Attempted to create trace chunk subdirectory \"%s\" through a non-owner chunk",
- path);
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_OPERATION;
goto end;
}
if (!chunk->chunk_directory) {
ERR("Attempted to create trace chunk subdirectory \"%s\" before setting the chunk output directory",
- path);
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
if (*path == '/') {
- ERR("Refusing to create absolute trace chunk directory \"%s\"",
- path);
+ ERR("Refusing to create absolute trace chunk directory \"%s\"", path);
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive_as_user(
- chunk->chunk_directory, path,
- DIR_CREATION_MODE,
- chunk->credentials.value.use_current_user ?
- NULL : &chunk->credentials.value.user);
+ chunk->chunk_directory,
+ path,
+ DIR_CREATION_MODE,
+ chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user);
if (ret) {
- PERROR("Failed to create trace chunk subdirectory \"%s\"",
- path);
+ PERROR("Failed to create trace chunk subdirectory \"%s\"", path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
/*
* TODO: Implement O(1) lookup.
*/
-static
-bool lttng_trace_chunk_find_file(struct lttng_trace_chunk *chunk,
- const char *path, size_t *index)
+static bool
+lttng_trace_chunk_find_file(struct lttng_trace_chunk *chunk, const char *path, size_t *index)
{
size_t i, count;
count = lttng_dynamic_pointer_array_get_count(&chunk->files);
for (i = 0; i < count; i++) {
const char *iter_path =
- (const char *) lttng_dynamic_pointer_array_get_pointer(
- &chunk->files, i);
+ (const char *) lttng_dynamic_pointer_array_get_pointer(&chunk->files, i);
if (!strcmp(iter_path, path)) {
if (index) {
*index = i;
return false;
}
-static
-enum lttng_trace_chunk_status lttng_trace_chunk_add_file(
- struct lttng_trace_chunk *chunk,
- const char *path)
+static enum lttng_trace_chunk_status lttng_trace_chunk_add_file(struct lttng_trace_chunk *chunk,
+ const char *path)
{
char *copy;
int ret;
if (lttng_trace_chunk_find_file(chunk, path, NULL)) {
return LTTNG_TRACE_CHUNK_STATUS_OK;
}
- DBG("Adding new file \"%s\" to trace chunk \"%s\"",
- path, chunk->name ? : "(unnamed)");
+ DBG("Adding new file \"%s\" to trace chunk \"%s\"", path, chunk->name ?: "(unnamed)");
copy = strdup(path);
if (!copy) {
PERROR("Failed to copy path");
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &chunk->files, copy);
+ ret = lttng_dynamic_pointer_array_add_pointer(&chunk->files, copy);
if (ret) {
ERR("Allocation failure while adding file to a trace chunk");
free(copy);
return status;
}
-static
-void lttng_trace_chunk_remove_file(
- struct lttng_trace_chunk *chunk,
- const char *path)
+static void lttng_trace_chunk_remove_file(struct lttng_trace_chunk *chunk, const char *path)
{
size_t index;
bool found;
if (!found) {
return;
}
- ret = lttng_dynamic_pointer_array_remove_pointer(
- &chunk->files, index);
+ ret = lttng_dynamic_pointer_array_remove_pointer(&chunk->files, index);
LTTNG_ASSERT(!ret);
}
-static
-enum lttng_trace_chunk_status _lttng_trace_chunk_open_fs_handle_locked(
- struct lttng_trace_chunk *chunk,
- const char *file_path,
- int flags,
- mode_t mode,
- struct fs_handle **out_handle,
- bool expect_no_file)
+static enum lttng_trace_chunk_status
+_lttng_trace_chunk_open_fs_handle_locked(struct lttng_trace_chunk *chunk,
+ const char *file_path,
+ int flags,
+ mode_t mode,
+ struct fs_handle **out_handle,
+ bool expect_no_file)
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
* file is created.
*/
ERR("Credentials of trace chunk are unset: refusing to open file \"%s\"",
- file_path);
+ file_path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
if (!chunk->chunk_directory) {
ERR("Attempted to open trace chunk file \"%s\" before setting the chunk output directory",
- file_path);
+ file_path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
}
if (chunk->fd_tracker) {
LTTNG_ASSERT(chunk->credentials.value.use_current_user);
- *out_handle = fd_tracker_open_fs_handle(chunk->fd_tracker,
- chunk->chunk_directory, file_path, flags, &mode);
+ *out_handle = fd_tracker_open_fs_handle(
+ chunk->fd_tracker, chunk->chunk_directory, file_path, flags, &mode);
ret = *out_handle ? 0 : -1;
} else {
ret = lttng_directory_handle_open_file_as_user(
- chunk->chunk_directory, file_path, flags, mode,
- chunk->credentials.value.use_current_user ?
- NULL :
- &chunk->credentials.value.user);
+ chunk->chunk_directory,
+ file_path,
+ flags,
+ mode,
+ chunk->credentials.value.use_current_user ? NULL :
+ &chunk->credentials.value.user);
if (ret >= 0) {
- *out_handle = fs_handle_untracked_create(
- chunk->chunk_directory, file_path, ret);
+ *out_handle =
+ fs_handle_untracked_create(chunk->chunk_directory, file_path, ret);
if (!*out_handle) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
status = LTTNG_TRACE_CHUNK_STATUS_NO_FILE;
} else {
PERROR("Failed to open file relative to trace chunk file_path = \"%s\", flags = %d, mode = %d",
- file_path, flags, (int) mode);
+ file_path,
+ flags,
+ (int) mode);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
}
lttng_trace_chunk_remove_file(chunk, file_path);
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(
- struct lttng_trace_chunk *chunk,
- const char *file_path,
- int flags,
- mode_t mode,
- struct fs_handle **out_handle,
- bool expect_no_file)
+enum lttng_trace_chunk_status lttng_trace_chunk_open_fs_handle(struct lttng_trace_chunk *chunk,
+ const char *file_path,
+ int flags,
+ mode_t mode,
+ struct fs_handle **out_handle,
+ bool expect_no_file)
{
enum lttng_trace_chunk_status status;
pthread_mutex_lock(&chunk->lock);
- status = _lttng_trace_chunk_open_fs_handle_locked(chunk, file_path,
- flags, mode, out_handle, expect_no_file);
+ status = _lttng_trace_chunk_open_fs_handle_locked(
+ chunk, file_path, flags, mode, out_handle, expect_no_file);
pthread_mutex_unlock(&chunk->lock);
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_open_file(
- struct lttng_trace_chunk *chunk,
- const char *file_path,
- int flags,
- mode_t mode,
- int *out_fd,
- bool expect_no_file)
+enum lttng_trace_chunk_status lttng_trace_chunk_open_file(struct lttng_trace_chunk *chunk,
+ const char *file_path,
+ int flags,
+ mode_t mode,
+ int *out_fd,
+ bool expect_no_file)
{
enum lttng_trace_chunk_status status;
struct fs_handle *fs_handle;
* used since the resulting file descriptor would not be tracked.
*/
LTTNG_ASSERT(!chunk->fd_tracker);
- status = _lttng_trace_chunk_open_fs_handle_locked(chunk, file_path,
- flags, mode, &fs_handle, expect_no_file);
+ status = _lttng_trace_chunk_open_fs_handle_locked(
+ chunk, file_path, flags, mode, &fs_handle, expect_no_file);
pthread_mutex_unlock(&chunk->lock);
if (status == LTTNG_TRACE_CHUNK_STATUS_OK) {
/*
* Does not close the fd; we just "unbox" it from the fs_handle.
*/
- fs_handle_untracked_destroy(lttng::utils::container_of(
- fs_handle, &fs_handle_untracked::parent));
+ fs_handle_untracked_destroy(
+ lttng::utils::container_of(fs_handle, &fs_handle_untracked::parent));
}
return status;
}
-int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk,
- const char *file_path)
+int lttng_trace_chunk_unlink_file(struct lttng_trace_chunk *chunk, const char *file_path)
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
* file is unlinked.
*/
ERR("Credentials of trace chunk are unset: refusing to unlink file \"%s\"",
- file_path);
+ file_path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
if (!chunk->chunk_directory) {
ERR("Attempted to unlink trace chunk file \"%s\" before setting the chunk output directory",
- file_path);
+ file_path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
ret = lttng_directory_handle_unlink_file_as_user(
- chunk->chunk_directory, file_path,
- chunk->credentials.value.use_current_user ?
- NULL : &chunk->credentials.value.user);
+ chunk->chunk_directory,
+ file_path,
+ chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user);
if (ret < 0) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
return status;
}
-static
-int lttng_trace_chunk_remove_subdirectory_recursive(struct lttng_trace_chunk *chunk,
- const char *path)
+static int lttng_trace_chunk_remove_subdirectory_recursive(struct lttng_trace_chunk *chunk,
+ const char *path)
{
int ret;
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
* directory is removed.
*/
ERR("Credentials of trace chunk are unset: refusing to recursively remove directory \"%s\"",
- path);
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
if (!chunk->chunk_directory) {
ERR("Attempted to recursively remove trace chunk directory \"%s\" before setting the chunk output directory",
- path);
+ path);
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
}
ret = lttng_directory_handle_remove_subdirectory_recursive_as_user(
- chunk->chunk_directory, path,
- chunk->credentials.value.use_current_user ?
- NULL : &chunk->credentials.value.user,
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ chunk->chunk_directory,
+ path,
+ chunk->credentials.value.use_current_user ? NULL : &chunk->credentials.value.user,
+ LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
if (ret < 0) {
status = LTTNG_TRACE_CHUNK_STATUS_ERROR;
goto end;
return status;
}
-static
-int lttng_trace_chunk_move_to_completed_post_release(
- struct lttng_trace_chunk *trace_chunk)
+static int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_chunk *trace_chunk)
{
int ret = 0;
char *archived_chunk_name = NULL;
const uint64_t chunk_id = LTTNG_OPTIONAL_GET(trace_chunk->id);
- const time_t creation_timestamp =
- LTTNG_OPTIONAL_GET(trace_chunk->timestamp_creation);
- const time_t close_timestamp =
- LTTNG_OPTIONAL_GET(trace_chunk->timestamp_close);
+ const time_t creation_timestamp = LTTNG_OPTIONAL_GET(trace_chunk->timestamp_creation);
+ const time_t close_timestamp = LTTNG_OPTIONAL_GET(trace_chunk->timestamp_close);
struct lttng_directory_handle *archived_chunks_directory = NULL;
enum lttng_trace_chunk_status status;
- if (!trace_chunk->mode.is_set ||
- trace_chunk->mode.value != TRACE_CHUNK_MODE_OWNER ||
- !trace_chunk->session_output_directory) {
+ if (!trace_chunk->mode.is_set || trace_chunk->mode.value != TRACE_CHUNK_MODE_OWNER ||
+ !trace_chunk->session_output_directory) {
/*
* This command doesn't need to run if the output is remote
* or if the trace chunk is not owned by this process.
LTTNG_ASSERT(!trace_chunk->name_overridden);
LTTNG_ASSERT(trace_chunk->path);
- archived_chunk_name = generate_chunk_name(chunk_id, creation_timestamp,
- &close_timestamp);
+ archived_chunk_name = generate_chunk_name(chunk_id, creation_timestamp, &close_timestamp);
if (!archived_chunk_name) {
ERR("Failed to generate archived trace chunk name while renaming trace chunk");
ret = -1;
}
ret = lttng_directory_handle_create_subdirectory_as_user(
- trace_chunk->session_output_directory,
- DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY,
- DIR_CREATION_MODE,
- !trace_chunk->credentials.value.use_current_user ?
- &trace_chunk->credentials.value.user :
- NULL);
+ trace_chunk->session_output_directory,
+ DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY,
+ DIR_CREATION_MODE,
+ !trace_chunk->credentials.value.use_current_user ?
+ &trace_chunk->credentials.value.user :
+ NULL);
if (ret) {
PERROR("Failed to create \"" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY
- "\" directory for archived trace chunks");
+ "\" directory for archived trace chunks");
goto end;
}
archived_chunks_directory = trace_chunk->fd_tracker ?
- fd_tracker_create_directory_handle_from_handle(
- trace_chunk->fd_tracker,
- trace_chunk->session_output_directory,
- DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY) :
- lttng_directory_handle_create_from_handle(
- DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY,
- trace_chunk->session_output_directory);
+ fd_tracker_create_directory_handle_from_handle(
+ trace_chunk->fd_tracker,
+ trace_chunk->session_output_directory,
+ DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY) :
+ lttng_directory_handle_create_from_handle(DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY,
+ trace_chunk->session_output_directory);
if (!archived_chunks_directory) {
PERROR("Failed to get handle to archived trace chunks directory");
ret = -1;
* the creation of the next chunk. This happens if a rotation is
* performed while tracing is stopped.
*/
- if (!trace_chunk->path || strcmp(trace_chunk->path,
- DEFAULT_CHUNK_TMP_OLD_DIRECTORY)) {
+ if (!trace_chunk->path || strcmp(trace_chunk->path, DEFAULT_CHUNK_TMP_OLD_DIRECTORY)) {
status = lttng_trace_chunk_rename_path_no_lock(trace_chunk,
- DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
+ DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Failed to rename chunk to %s", DEFAULT_CHUNK_TMP_OLD_DIRECTORY);
ret = -1;
}
ret = lttng_directory_handle_rename_as_user(
- trace_chunk->session_output_directory,
- trace_chunk->path,
- archived_chunks_directory,
- archived_chunk_name,
- LTTNG_OPTIONAL_GET(trace_chunk->credentials).use_current_user ?
- NULL :
- &trace_chunk->credentials.value.user);
+ trace_chunk->session_output_directory,
+ trace_chunk->path,
+ archived_chunks_directory,
+ archived_chunk_name,
+ LTTNG_OPTIONAL_GET(trace_chunk->credentials).use_current_user ?
+ NULL :
+ &trace_chunk->credentials.value.user);
if (ret) {
PERROR("Failed to rename folder \"%s\" to \"%s\"",
- trace_chunk->path,
- archived_chunk_name);
+ trace_chunk->path,
+ archived_chunk_name);
}
end:
return ret;
}
-static
-int lttng_trace_chunk_no_operation(struct lttng_trace_chunk *trace_chunk __attribute__((unused)))
+static int lttng_trace_chunk_no_operation(struct lttng_trace_chunk *trace_chunk
+ __attribute__((unused)))
{
return 0;
}
-static
-int lttng_trace_chunk_delete_post_release_user(
- struct lttng_trace_chunk *trace_chunk)
+static int lttng_trace_chunk_delete_post_release_user(struct lttng_trace_chunk *trace_chunk)
{
int ret = 0;
const char *path;
/* Remove first. */
- path = (const char *) lttng_dynamic_pointer_array_get_pointer(
- &trace_chunk->files, 0);
+ path = (const char *) lttng_dynamic_pointer_array_get_pointer(&trace_chunk->files,
+ 0);
DBG("Unlink file: %s", path);
- status = (lttng_trace_chunk_status) lttng_trace_chunk_unlink_file(trace_chunk, path);
+ status =
+ (lttng_trace_chunk_status) lttng_trace_chunk_unlink_file(trace_chunk, path);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Error unlinking file '%s' when deleting chunk", path);
ret = -1;
return ret;
}
-static
-int lttng_trace_chunk_delete_post_release_owner(
- struct lttng_trace_chunk *trace_chunk)
+static int lttng_trace_chunk_delete_post_release_owner(struct lttng_trace_chunk *trace_chunk)
{
enum lttng_trace_chunk_status status;
size_t i, count;
LTTNG_ASSERT(trace_chunk->chunk_directory);
/* Remove empty directories. */
- count = lttng_dynamic_pointer_array_get_count(
- &trace_chunk->top_level_directories);
+ count = lttng_dynamic_pointer_array_get_count(&trace_chunk->top_level_directories);
for (i = 0; i < count; i++) {
- const char *top_level_name =
- (const char *) lttng_dynamic_pointer_array_get_pointer(
- &trace_chunk->top_level_directories, i);
+ const char *top_level_name = (const char *) lttng_dynamic_pointer_array_get_pointer(
+ &trace_chunk->top_level_directories, i);
- status = (lttng_trace_chunk_status) lttng_trace_chunk_remove_subdirectory_recursive(trace_chunk, top_level_name);
+ status = (lttng_trace_chunk_status) lttng_trace_chunk_remove_subdirectory_recursive(
+ trace_chunk, top_level_name);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Error recursively removing subdirectory '%s' file when deleting chunk",
- top_level_name);
+ top_level_name);
ret = -1;
break;
}
trace_chunk->chunk_directory = NULL;
if (trace_chunk->path && trace_chunk->path[0] != '\0') {
- status = (lttng_trace_chunk_status) lttng_directory_handle_remove_subdirectory(
- trace_chunk->session_output_directory,
- trace_chunk->path);
+ status = (lttng_trace_chunk_status)
+ lttng_directory_handle_remove_subdirectory(
+ trace_chunk->session_output_directory, trace_chunk->path);
if (status != LTTNG_TRACE_CHUNK_STATUS_OK) {
ERR("Error removing subdirectory '%s' file when deleting chunk",
- trace_chunk->path);
+ trace_chunk->path);
ret = -1;
}
}
* session daemon is the owner of the chunk. Unlink all files owned by each
* consumer daemon.
*/
-static
-int lttng_trace_chunk_delete_post_release(
- struct lttng_trace_chunk *trace_chunk)
+static int lttng_trace_chunk_delete_post_release(struct lttng_trace_chunk *trace_chunk)
{
if (!trace_chunk->chunk_directory) {
return 0;
}
}
-enum lttng_trace_chunk_status lttng_trace_chunk_get_close_command(
- struct lttng_trace_chunk *chunk,
- enum lttng_trace_chunk_command_type *command_type)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_get_close_command(struct lttng_trace_chunk *chunk,
+ enum lttng_trace_chunk_command_type *command_type)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
return status;
}
-enum lttng_trace_chunk_status lttng_trace_chunk_set_close_command(
- struct lttng_trace_chunk *chunk,
- enum lttng_trace_chunk_command_type close_command)
+enum lttng_trace_chunk_status
+lttng_trace_chunk_set_close_command(struct lttng_trace_chunk *chunk,
+ enum lttng_trace_chunk_command_type close_command)
{
enum lttng_trace_chunk_status status = LTTNG_TRACE_CHUNK_STATUS_OK;
if (close_command < LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED ||
- close_command >= LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX) {
+ close_command >= LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX) {
status = LTTNG_TRACE_CHUNK_STATUS_INVALID_ARGUMENT;
goto end;
}
pthread_mutex_lock(&chunk->lock);
if (chunk->close_command.is_set) {
DBG("Overriding trace chunk close command from \"%s\" to \"%s\"",
- lttng_trace_chunk_command_type_str(chunk->close_command.value),
- lttng_trace_chunk_command_type_str(close_command));
+ lttng_trace_chunk_command_type_str(chunk->close_command.value),
+ lttng_trace_chunk_command_type_str(close_command));
} else {
DBG("Setting trace chunk close command to \"%s\"",
- lttng_trace_chunk_command_type_str(close_command));
+ lttng_trace_chunk_command_type_str(close_command));
}
/*
* Unset close command for no-op for backward compatibility with relayd
return status;
}
-const char *lttng_trace_chunk_command_type_get_name(
- enum lttng_trace_chunk_command_type command)
+const char *lttng_trace_chunk_command_type_get_name(enum lttng_trace_chunk_command_type command)
{
switch (command) {
case LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED:
}
bool lttng_trace_chunk_ids_equal(const struct lttng_trace_chunk *chunk_a,
- const struct lttng_trace_chunk *chunk_b)
+ const struct lttng_trace_chunk *chunk_b)
{
bool equal = false;
return urcu_ref_get_unless_zero(&chunk->ref);
}
-static
-void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
+static void free_lttng_trace_chunk_registry_element(struct rcu_head *node)
{
- struct lttng_trace_chunk_registry_element *element = lttng::utils::container_of(
- node, <tng_trace_chunk_registry_element::rcu_node);
+ struct lttng_trace_chunk_registry_element *element =
+ lttng::utils::container_of(node, <tng_trace_chunk_registry_element::rcu_node);
free(element);
}
-static
-void lttng_trace_chunk_release(struct urcu_ref *ref)
+static void lttng_trace_chunk_release(struct urcu_ref *ref)
{
struct lttng_trace_chunk *chunk = lttng::utils::container_of(ref, <tng_trace_chunk::ref);
if (chunk->close_command.is_set) {
- chunk_command func = close_command_get_post_release_func(chunk->close_command.value);
+ chunk_command func =
+ close_command_get_post_release_func(chunk->close_command.value);
if (func(chunk)) {
ERR("Trace chunk post-release command %s has failed.",
- lttng_trace_chunk_command_type_str(chunk->close_command.value));
+ lttng_trace_chunk_command_type_str(chunk->close_command.value));
}
}
*/
lttng_trace_chunk_fini(chunk);
- element = lttng::utils::container_of(
- chunk, <tng_trace_chunk_registry_element::chunk);
+ element = lttng::utils::container_of(chunk,
+ <tng_trace_chunk_registry_element::chunk);
if (element->registry) {
rcu_read_lock();
- cds_lfht_del(element->registry->ht,
- &element->trace_chunk_registry_ht_node);
+ cds_lfht_del(element->registry->ht, &element->trace_chunk_registry_ht_node);
rcu_read_unlock();
- call_rcu(&element->rcu_node,
- free_lttng_trace_chunk_registry_element);
+ call_rcu(&element->rcu_node, free_lttng_trace_chunk_registry_element);
} else {
/* Never published, can be free'd immediately. */
- free_lttng_trace_chunk_registry_element(
- &element->rcu_node);
+ free_lttng_trace_chunk_registry_element(&element->rcu_node);
}
} else {
/* Not RCU-protected, free immediately. */
goto end;
}
- registry->ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
- CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+ registry->ht = cds_lfht_new(
+ DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
if (!registry->ht) {
goto error;
}
return NULL;
}
-void lttng_trace_chunk_registry_destroy(
- struct lttng_trace_chunk_registry *registry)
+void lttng_trace_chunk_registry_destroy(struct lttng_trace_chunk_registry *registry)
{
if (!registry) {
return;
free(registry);
}
-static
-struct lttng_trace_chunk_registry_element *
-lttng_trace_chunk_registry_element_create_from_chunk(
- struct lttng_trace_chunk *chunk, uint64_t session_id)
+static struct lttng_trace_chunk_registry_element *
+lttng_trace_chunk_registry_element_create_from_chunk(struct lttng_trace_chunk *chunk,
+ uint64_t session_id)
{
struct lttng_trace_chunk_registry_element *element =
zmalloc<lttng_trace_chunk_registry_element>();
lttng_trace_chunk_init(&element->chunk);
if (chunk->session_output_directory) {
/* Transferred ownership. */
- element->chunk.session_output_directory =
- chunk->session_output_directory;
+ element->chunk.session_output_directory = chunk->session_output_directory;
chunk->session_output_directory = NULL;
}
if (chunk->chunk_directory) {
}
struct lttng_trace_chunk *
-lttng_trace_chunk_registry_publish_chunk(
- struct lttng_trace_chunk_registry *registry,
- uint64_t session_id,
- struct lttng_trace_chunk *chunk)
+lttng_trace_chunk_registry_publish_chunk(struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id,
+ struct lttng_trace_chunk *chunk)
{
bool unused;
- return lttng_trace_chunk_registry_publish_chunk(
- registry, session_id, chunk, &unused);
+ return lttng_trace_chunk_registry_publish_chunk(registry, session_id, chunk, &unused);
}
struct lttng_trace_chunk *
-lttng_trace_chunk_registry_publish_chunk(
- struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, struct lttng_trace_chunk *chunk,
- bool *previously_published)
+lttng_trace_chunk_registry_publish_chunk(struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id,
+ struct lttng_trace_chunk *chunk,
+ bool *previously_published)
{
struct lttng_trace_chunk_registry_element *element;
unsigned long element_hash;
pthread_mutex_lock(&chunk->lock);
- element = lttng_trace_chunk_registry_element_create_from_chunk(chunk,
- session_id);
+ element = lttng_trace_chunk_registry_element_create_from_chunk(chunk, session_id);
pthread_mutex_unlock(&chunk->lock);
if (!element) {
goto end;
struct lttng_trace_chunk_registry_element *published_element;
published_node = cds_lfht_add_unique(registry->ht,
- element_hash,
- lttng_trace_chunk_registry_element_match,
- element,
- &element->trace_chunk_registry_ht_node);
+ element_hash,
+ lttng_trace_chunk_registry_element_match,
+ element,
+ &element->trace_chunk_registry_ht_node);
if (published_node == &element->trace_chunk_registry_ht_node) {
/* Successfully published the new element. */
element->registry = registry;
* already published and release the reference to the copy we
* created if successful.
*/
- published_element = lttng::utils::container_of(published_node,
- <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
+ published_element = lttng::utils::container_of(
+ published_node,
+ <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
published_chunk = &published_element->chunk;
if (lttng_trace_chunk_get(published_chunk)) {
lttng_trace_chunk_put(&element->chunk);
* IOW, holding a reference guarantees the existence of the object for the
* caller.
*/
-static
-struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, uint64_t *chunk_id)
+static struct lttng_trace_chunk *_lttng_trace_chunk_registry_find_chunk(
+ const struct lttng_trace_chunk_registry *registry, uint64_t session_id, uint64_t *chunk_id)
{
- lttng_trace_chunk_registry_element target_element {};
+ lttng_trace_chunk_registry_element target_element{};
target_element.chunk.id.is_set = !!chunk_id;
target_element.chunk.id.value = chunk_id ? *chunk_id : 0;
target_element.session_id = session_id;
- const unsigned long element_hash =
- lttng_trace_chunk_registry_element_hash(
- &target_element);
+ const unsigned long element_hash = lttng_trace_chunk_registry_element_hash(&target_element);
struct cds_lfht_node *published_node;
struct lttng_trace_chunk_registry_element *published_element;
struct lttng_trace_chunk *published_chunk = NULL;
goto end;
}
- published_element = lttng::utils::container_of(published_node,
- <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
+ published_element = lttng::utils::container_of(
+ published_node, <tng_trace_chunk_registry_element::trace_chunk_registry_ht_node);
if (lttng_trace_chunk_get(&published_element->chunk)) {
published_chunk = &published_element->chunk;
}
return published_chunk;
}
-struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_chunk(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, uint64_t chunk_id)
+struct lttng_trace_chunk *lttng_trace_chunk_registry_find_chunk(
+ const struct lttng_trace_chunk_registry *registry, uint64_t session_id, uint64_t chunk_id)
{
- return _lttng_trace_chunk_registry_find_chunk(registry,
- session_id, &chunk_id);
+ return _lttng_trace_chunk_registry_find_chunk(registry, session_id, &chunk_id);
}
-int lttng_trace_chunk_registry_chunk_exists(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id, uint64_t chunk_id, bool *chunk_exists)
+int lttng_trace_chunk_registry_chunk_exists(const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id,
+ uint64_t chunk_id,
+ bool *chunk_exists)
{
int ret = 0;
lttng_trace_chunk_registry_element target_element;
target_element.chunk.id.value = chunk_id;
target_element.session_id = session_id;
- const unsigned long element_hash =
- lttng_trace_chunk_registry_element_hash(
- &target_element);
+ const unsigned long element_hash = lttng_trace_chunk_registry_element_hash(&target_element);
struct cds_lfht_node *published_node;
struct cds_lfht_iter iter;
}
struct lttng_trace_chunk *
-lttng_trace_chunk_registry_find_anonymous_chunk(
- const struct lttng_trace_chunk_registry *registry,
- uint64_t session_id)
+lttng_trace_chunk_registry_find_anonymous_chunk(const struct lttng_trace_chunk_registry *registry,
+ uint64_t session_id)
{
- return _lttng_trace_chunk_registry_find_chunk(registry,
- session_id, NULL);
+ return _lttng_trace_chunk_registry_find_chunk(registry, session_id, NULL);
}
-unsigned int lttng_trace_chunk_registry_put_each_chunk(
- const struct lttng_trace_chunk_registry *registry)
+unsigned int
+lttng_trace_chunk_registry_put_each_chunk(const struct lttng_trace_chunk_registry *registry)
{
struct cds_lfht_iter iter;
struct lttng_trace_chunk_registry_element *chunk_element;
DBG("Releasing trace chunk registry to all trace chunks");
rcu_read_lock();
- cds_lfht_for_each_entry(registry->ht,
- &iter, chunk_element, trace_chunk_registry_ht_node) {
+ cds_lfht_for_each_entry (registry->ht, &iter, chunk_element, trace_chunk_registry_ht_node) {
const char *chunk_id_str = "none";
char chunk_id_buf[MAX_INT_DEC_LEN(uint64_t)];
if (chunk_element->chunk.id.is_set) {
int fmt_ret;
- fmt_ret = snprintf(chunk_id_buf, sizeof(chunk_id_buf),
- "%" PRIu64,
- chunk_element->chunk.id.value);
+ fmt_ret = snprintf(chunk_id_buf,
+ sizeof(chunk_id_buf),
+ "%" PRIu64,
+ chunk_element->chunk.id.value);
if (fmt_ret < 0 || fmt_ret >= sizeof(chunk_id_buf)) {
chunk_id_str = "formatting error";
} else {
}
DBG("Releasing reference to trace chunk: session_id = %" PRIu64
- "chunk_id = %s, name = \"%s\", status = %s",
- chunk_element->session_id,
- chunk_id_str,
- chunk_element->chunk.name ? : "none",
- chunk_element->chunk.close_command.is_set ?
- "open" : "closed");
+ "chunk_id = %s, name = \"%s\", status = %s",
+ chunk_element->session_id,
+ chunk_id_str,
+ chunk_element->chunk.name ?: "none",
+ chunk_element->chunk.close_command.is_set ? "open" : "closed");
pthread_mutex_unlock(&chunk_element->chunk.lock);
lttng_trace_chunk_put(&chunk_element->chunk);
trace_chunks_left++;
}
rcu_read_unlock();
- DBG("Released reference to %u trace chunks in %s()", trace_chunks_left,
- __FUNCTION__);
+ DBG("Released reference to %u trace chunks in %s()", trace_chunks_left, __FUNCTION__);
return trace_chunks_left;
}
*
*/
-#include <lttng/domain.h>
-#include <lttng/lttng-error.h>
-#include <lttng/tracker.h>
-
#include <common/dynamic-array.hpp>
#include <common/error.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/hashtable/utils.hpp>
#include <common/tracker.hpp>
-#include <stdbool.h>
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
+#include <lttng/tracker.h>
+#include <stdbool.h>
#include <type_traits>
namespace {
} LTTNG_PACKED;
} /* namespace */
-#define GET_INTEGRAL_COMM_VALUE(value_ptr, as_type) \
- ((as_type)(std::is_signed<as_type>::value ? (value_ptr)->u._signed : \
- (value_ptr)->u._unsigned))
+#define GET_INTEGRAL_COMM_VALUE(value_ptr, as_type) \
+ ((as_type) (std::is_signed<as_type>::value ? (value_ptr)->u._signed : \
+ (value_ptr)->u._unsigned))
-#define SET_INTEGRAL_COMM_VALUE(comm_value, val) \
+#define SET_INTEGRAL_COMM_VALUE(comm_value, val) \
if (std::is_signed<typeof(val)>::value) { \
- (comm_value)->u._signed = \
- (typeof((comm_value)->u._signed)) val; \
- } else { \
- (comm_value)->u._unsigned = \
- (typeof((comm_value)->u._unsigned)) val; \
+ (comm_value)->u._signed = (typeof((comm_value)->u._signed)) val; \
+ } else { \
+ (comm_value)->u._unsigned = (typeof((comm_value)->u._unsigned)) val; \
}
static inline bool is_virtual_process_attr(enum lttng_process_attr process_attr)
{
return process_attr == LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID ||
- process_attr == LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID ||
- process_attr == LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID;
+ process_attr == LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID ||
+ process_attr == LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID;
}
-static inline bool is_value_type_name(
- enum lttng_process_attr_value_type value_type)
+static inline bool is_value_type_name(enum lttng_process_attr_value_type value_type)
{
return value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ||
- value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME;
+ value_type == LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME;
}
-enum lttng_error_code process_attr_value_from_comm(
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- enum lttng_process_attr_value_type value_type,
- const struct process_attr_integral_value_comm *integral_value,
- const struct lttng_buffer_view *value_view,
- struct process_attr_value **_value)
+enum lttng_error_code
+process_attr_value_from_comm(enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ enum lttng_process_attr_value_type value_type,
+ const struct process_attr_integral_value_comm *integral_value,
+ const struct lttng_buffer_view *value_view,
+ struct process_attr_value **_value)
{
char *name = NULL;
enum lttng_error_code ret = LTTNG_OK;
goto error;
}
- if (!is_virtual_process_attr(process_attr) &&
- domain != LTTNG_DOMAIN_KERNEL) {
+ if (!is_virtual_process_attr(process_attr) && domain != LTTNG_DOMAIN_KERNEL) {
ERR("Non-virtual process attributes can only be used in the kernel domain");
ret = LTTNG_ERR_UNSUPPORTED_DOMAIN;
goto error;
}
/* Only expect a payload for name value types. */
- if (is_value_type_name(value_type) &&
- (!value_view || value_view->size == 0)) {
+ if (is_value_type_name(value_type) && (!value_view || value_view->size == 0)) {
ret = LTTNG_ERR_INVALID_PROTOCOL;
goto error;
- } else if (!is_value_type_name(value_type) && value_view &&
- value_view->size != 0) {
+ } else if (!is_value_type_name(value_type) && value_view && value_view->size != 0) {
ret = LTTNG_ERR_INVALID_PROTOCOL;
goto error;
}
ret = LTTNG_ERR_INVALID;
goto error;
}
- value->value.pid =
- GET_INTEGRAL_COMM_VALUE(integral_value, pid_t);
+ value->value.pid = GET_INTEGRAL_COMM_VALUE(integral_value, pid_t);
break;
case LTTNG_PROCESS_ATTR_USER_ID:
case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
switch (value_type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
- value->value.uid = GET_INTEGRAL_COMM_VALUE(
- integral_value, uid_t);
+ value->value.uid = GET_INTEGRAL_COMM_VALUE(integral_value, uid_t);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
if (!name) {
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
switch (value_type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
- value->value.gid = GET_INTEGRAL_COMM_VALUE(
- integral_value, gid_t);
+ value->value.gid = GET_INTEGRAL_COMM_VALUE(integral_value, gid_t);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME:
if (!name) {
goto end;
}
- lttng_dynamic_pointer_array_init(
- &values->array, process_attr_tracker_value_destructor);
+ lttng_dynamic_pointer_array_init(&values->array, process_attr_tracker_value_destructor);
end:
return values;
}
-unsigned int _lttng_process_attr_values_get_count(
- const struct lttng_process_attr_values *values)
+unsigned int _lttng_process_attr_values_get_count(const struct lttng_process_attr_values *values)
{
- return (unsigned int) lttng_dynamic_pointer_array_get_count(
- &values->array);
+ return (unsigned int) lttng_dynamic_pointer_array_get_count(&values->array);
}
-const struct process_attr_value *lttng_process_attr_tracker_values_get_at_index(
- const struct lttng_process_attr_values *values,
- unsigned int index)
+const struct process_attr_value *
+lttng_process_attr_tracker_values_get_at_index(const struct lttng_process_attr_values *values,
+ unsigned int index)
{
- return (process_attr_value *) lttng_dynamic_pointer_array_get_pointer(&values->array, index);
+ return (process_attr_value *) lttng_dynamic_pointer_array_get_pointer(&values->array,
+ index);
}
-static
-int process_attr_tracker_value_serialize(const struct process_attr_value *value,
- struct lttng_dynamic_buffer *buffer)
+static int process_attr_tracker_value_serialize(const struct process_attr_value *value,
+ struct lttng_dynamic_buffer *buffer)
{
int ret;
struct process_attr_tracker_value_comm value_comm = {
- .type = (int32_t) value->type,
- .value = {},
+ .type = (int32_t) value->type,
+ .value = {},
};
const char *name = NULL;
switch (value->type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
- SET_INTEGRAL_COMM_VALUE(
- &value_comm.value.integral, value->value.pid);
+ SET_INTEGRAL_COMM_VALUE(&value_comm.value.integral, value->value.pid);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
- SET_INTEGRAL_COMM_VALUE(
- &value_comm.value.integral, value->value.uid);
+ SET_INTEGRAL_COMM_VALUE(&value_comm.value.integral, value->value.uid);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
- SET_INTEGRAL_COMM_VALUE(
- &value_comm.value.integral, value->value.gid);
+ SET_INTEGRAL_COMM_VALUE(&value_comm.value.integral, value->value.gid);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
name = value->value.user_name;
value_comm.value.name_len = strlen(name) + 1;
}
- ret = lttng_dynamic_buffer_append(
- buffer, &value_comm, sizeof(value_comm));
+ ret = lttng_dynamic_buffer_append(buffer, &value_comm, sizeof(value_comm));
if (ret) {
goto end;
}
if (name) {
- ret = lttng_dynamic_buffer_append(
- buffer, name, value_comm.value.name_len);
+ ret = lttng_dynamic_buffer_append(buffer, name, value_comm.value.name_len);
}
end:
return ret;
}
-int lttng_process_attr_values_serialize(
- const struct lttng_process_attr_values *values,
- struct lttng_dynamic_buffer *buffer)
+int lttng_process_attr_values_serialize(const struct lttng_process_attr_values *values,
+ struct lttng_dynamic_buffer *buffer)
{
int ret;
unsigned int count, i;
for (i = 0; i < count; i++) {
const struct process_attr_value *value =
- lttng_process_attr_tracker_values_get_at_index(
- values, i);
+ lttng_process_attr_tracker_values_get_at_index(values, i);
ret = process_attr_tracker_value_serialize(value, buffer);
if (ret) {
return ret;
}
-ssize_t lttng_process_attr_values_create_from_buffer(
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- const struct lttng_buffer_view *buffer_view,
- struct lttng_process_attr_values **_values)
+ssize_t lttng_process_attr_values_create_from_buffer(enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ const struct lttng_buffer_view *buffer_view,
+ struct lttng_process_attr_values **_values)
{
ssize_t offset;
unsigned int i;
goto error;
}
- header_view = lttng_buffer_view_from_view(
- buffer_view, 0, sizeof(*header));
+ header_view = lttng_buffer_view_from_view(buffer_view, 0, sizeof(*header));
if (!lttng_buffer_view_is_valid(&header_view)) {
goto error;
}
* Check that the number of values is not absurdly large with respect to
* the received buffer's size.
*/
- if (buffer_view->size <
- header->count * sizeof(struct process_attr_tracker_value_comm)) {
+ if (buffer_view->size < header->count * sizeof(struct process_attr_tracker_value_comm)) {
goto error;
}
for (i = 0; i < (unsigned int) header->count; i++) {
struct lttng_buffer_view value_view;
struct lttng_buffer_view value_name_view = {};
- value_view = lttng_buffer_view_from_view(
- buffer_view, offset, sizeof(*value_comm));
+ value_view = lttng_buffer_view_from_view(buffer_view, offset, sizeof(*value_comm));
if (!lttng_buffer_view_is_valid(&value_view)) {
goto error;
}
if (is_value_type_name(type)) {
value_name_view = lttng_buffer_view_from_view(
- buffer_view, offset,
- value_comm->value.name_len);
+ buffer_view, offset, value_comm->value.name_len);
if (!lttng_buffer_view_is_valid(&value_name_view)) {
goto error;
}
offset += value_name_view.size;
}
- ret_code = process_attr_value_from_comm(domain, process_attr,
- type, &value_comm->value.integral,
- &value_name_view, &value);
+ ret_code = process_attr_value_from_comm(domain,
+ process_attr,
+ type,
+ &value_comm->value.integral,
+ &value_name_view,
+ &value);
if (ret_code != LTTNG_OK) {
goto error;
}
- ret = lttng_dynamic_pointer_array_add_pointer(
- &values->array, value);
+ ret = lttng_dynamic_pointer_array_add_pointer(&values->array, value);
if (ret) {
process_attr_value_destroy(value);
goto error;
free(values);
}
-struct process_attr_value *process_attr_value_copy(
- const struct process_attr_value *value)
+struct process_attr_value *process_attr_value_copy(const struct process_attr_value *value)
{
struct process_attr_value *new_value = NULL;
goto end;
}
if (is_value_type_name(value->type)) {
- const char *src =
- value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ?
- value->value.user_name :
- value->value.group_name;
+ const char *src = value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ?
+ value->value.user_name :
+ value->value.group_name;
char **dst = value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ?
- &new_value->value.user_name :
- &new_value->value.group_name;
+ &new_value->value.user_name :
+ &new_value->value.group_name;
new_value->type = value->type;
*dst = strdup(src);
switch (a->type) {
case LTTNG_PROCESS_ATTR_VALUE_TYPE_PID:
- hash ^= hash_key_ulong((void *) (unsigned long) a->value.pid,
- lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) (unsigned long) a->value.pid, lttng_ht_seed);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
- hash ^= hash_key_ulong((void *) (unsigned long) a->value.uid,
- lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) (unsigned long) a->value.uid, lttng_ht_seed);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
- hash ^= hash_key_ulong((void *) (unsigned long) a->value.gid,
- lttng_ht_seed);
+ hash ^= hash_key_ulong((void *) (unsigned long) a->value.gid, lttng_ht_seed);
break;
case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
hash ^= hash_key_str(a->value.user_name, lttng_ht_seed);
}
bool process_attr_tracker_value_equal(const struct process_attr_value *a,
- const struct process_attr_value *b)
+ const struct process_attr_value *b)
{
if (a->type != b->type) {
return false;
}
if (is_value_type_name(value->type)) {
free(value->type == LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME ?
- value->value.user_name :
- value->value.group_name);
+ value->value.user_name :
+ value->value.group_name);
}
free(value);
}
#include <common/optional.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
-#include <inttypes.h>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/condition/buffer-usage.h>
#include <lttng/condition/condition-internal.hpp>
#include <lttng/event-expr-internal.hpp>
#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/trigger/trigger-internal.hpp>
+
+#include <inttypes.h>
#include <pthread.h>
bool lttng_trigger_validate(const struct lttng_trigger *trigger)
}
valid = lttng_condition_validate(trigger->condition) &&
- lttng_action_validate(trigger->action);
+ lttng_action_validate(trigger->action);
end:
return valid;
}
-struct lttng_trigger *lttng_trigger_create(
- struct lttng_condition *condition,
- struct lttng_action *action)
+struct lttng_trigger *lttng_trigger_create(struct lttng_condition *condition,
+ struct lttng_action *action)
{
struct lttng_trigger *trigger = NULL;
* This API was exposed as such in 2.11. The client is not expected to call
* lttng_condition_destroy on the returned object.
*/
-struct lttng_condition *lttng_trigger_get_condition(
- struct lttng_trigger *trigger)
+struct lttng_condition *lttng_trigger_get_condition(struct lttng_trigger *trigger)
{
return trigger ? trigger->condition : NULL;
}
-const struct lttng_condition *lttng_trigger_get_const_condition(
- const struct lttng_trigger *trigger)
+const struct lttng_condition *lttng_trigger_get_const_condition(const struct lttng_trigger *trigger)
{
return trigger ? trigger->condition : NULL;
}
* This API was exposed as such in 2.11. The client is not expected to call
* lttng_action_destroy on the returned object.
*/
-struct lttng_action *lttng_trigger_get_action(
- struct lttng_trigger *trigger)
+struct lttng_action *lttng_trigger_get_action(struct lttng_trigger *trigger)
{
return trigger ? trigger->action : NULL;
}
-const struct lttng_action *lttng_trigger_get_const_action(
- const struct lttng_trigger *trigger)
+const struct lttng_action *lttng_trigger_get_const_action(const struct lttng_trigger *trigger)
{
return trigger ? trigger->action : NULL;
}
static void trigger_destroy_ref(struct urcu_ref *ref)
{
- struct lttng_trigger *trigger =
- lttng::utils::container_of(ref, <tng_trigger::ref);
+ struct lttng_trigger *trigger = lttng::utils::container_of(ref, <tng_trigger::ref);
struct lttng_action *action = lttng_trigger_get_action(trigger);
- struct lttng_condition *condition =
- lttng_trigger_get_condition(trigger);
+ struct lttng_condition *condition = lttng_trigger_get_condition(trigger);
LTTNG_ASSERT(action);
LTTNG_ASSERT(condition);
lttng_trigger_put(trigger);
}
-ssize_t lttng_trigger_create_from_payload(
- struct lttng_payload_view *src_view,
- struct lttng_trigger **_trigger)
+ssize_t lttng_trigger_create_from_payload(struct lttng_payload_view *src_view,
+ struct lttng_trigger **_trigger)
{
ssize_t ret, offset = 0, condition_size, action_size, name_size = 0;
struct lttng_condition *condition = NULL;
};
struct lttng_trigger *trigger = NULL;
const struct lttng_payload_view trigger_comm_view =
- lttng_payload_view_from_view(
- src_view, 0, sizeof(*trigger_comm));
+ lttng_payload_view_from_view(src_view, 0, sizeof(*trigger_comm));
if (!src_view || !_trigger) {
ret = -1;
if (trigger_comm->name_length != 0) {
/* Name. */
const struct lttng_payload_view name_view =
- lttng_payload_view_from_view(
- src_view, offset,
- trigger_comm->name_length);
+ lttng_payload_view_from_view(src_view, offset, trigger_comm->name_length);
if (!lttng_payload_view_is_valid(&name_view)) {
ret = -1;
}
name = name_view.buffer.data;
- if (!lttng_buffer_view_contains_string(&name_view.buffer, name,
- trigger_comm->name_length)) {
+ if (!lttng_buffer_view_contains_string(
+ &name_view.buffer, name, trigger_comm->name_length)) {
ret = -1;
goto end;
}
{
/* struct lttng_condition */
struct lttng_payload_view condition_view =
- lttng_payload_view_from_view(
- src_view, offset, -1);
+ lttng_payload_view_from_view(src_view, offset, -1);
- condition_size = lttng_condition_create_from_payload(&condition_view,
- &condition);
+ condition_size = lttng_condition_create_from_payload(&condition_view, &condition);
}
if (condition_size < 0) {
{
/* struct lttng_action */
struct lttng_payload_view action_view =
- lttng_payload_view_from_view(
- src_view, offset, -1);
+ lttng_payload_view_from_view(src_view, offset, -1);
action_size = lttng_action_create_from_payload(&action_view, &action);
}
action = NULL;
if (name) {
- const enum lttng_trigger_status status =
- lttng_trigger_set_name(trigger, name);
+ const enum lttng_trigger_status status = lttng_trigger_set_name(trigger, name);
if (status != LTTNG_TRIGGER_STATUS_OK) {
ret = -1;
* Both elements are stored contiguously, see their "*_comm" structure
* for the detailed format.
*/
-int lttng_trigger_serialize(const struct lttng_trigger *trigger,
- struct lttng_payload *payload)
+int lttng_trigger_serialize(const struct lttng_trigger *trigger, struct lttng_payload *payload)
{
int ret;
size_t header_offset, size_before_payload, size_name;
trigger_comm.is_hidden = lttng_trigger_is_hidden(trigger);
header_offset = payload->buffer.size;
- ret = lttng_dynamic_buffer_append(&payload->buffer, &trigger_comm,
- sizeof(trigger_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &trigger_comm, sizeof(trigger_comm));
if (ret) {
goto end;
}
size_before_payload = payload->buffer.size;
/* Trigger name. */
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, trigger->name, size_name);
+ ret = lttng_dynamic_buffer_append(&payload->buffer, trigger->name, size_name);
if (ret) {
goto end;
}
return ret;
}
-bool lttng_trigger_is_equal(
- const struct lttng_trigger *a, const struct lttng_trigger *b)
+bool lttng_trigger_is_equal(const struct lttng_trigger *a, const struct lttng_trigger *b)
{
if (!!a->name != !!b->name) {
/* Both must be either anonymous or named. */
}
if (!lttng_credentials_is_equal(lttng_trigger_get_credentials(a),
- lttng_trigger_get_credentials(b))) {
+ lttng_trigger_get_credentials(b))) {
return false;
}
trigger->is_hidden = true;
}
-enum lttng_trigger_status lttng_trigger_set_name(struct lttng_trigger *trigger,
- const char* name)
+enum lttng_trigger_status lttng_trigger_set_name(struct lttng_trigger *trigger, const char *name)
{
char *name_copy = NULL;
enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
return status;
}
-enum lttng_trigger_status lttng_trigger_get_name(
- const struct lttng_trigger *trigger, const char **name)
+enum lttng_trigger_status lttng_trigger_get_name(const struct lttng_trigger *trigger,
+ const char **name)
{
enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
return status;
}
-int lttng_trigger_assign_name(struct lttng_trigger *dst,
- const struct lttng_trigger *src)
+int lttng_trigger_assign_name(struct lttng_trigger *dst, const struct lttng_trigger *src)
{
int ret = 0;
enum lttng_trigger_status status;
return ret;
}
-void lttng_trigger_set_tracer_token(struct lttng_trigger *trigger,
- uint64_t token)
+void lttng_trigger_set_tracer_token(struct lttng_trigger *trigger, uint64_t token)
{
LTTNG_ASSERT(trigger);
LTTNG_OPTIONAL_SET(&trigger->tracer_token, token);
return LTTNG_OPTIONAL_GET(trigger->tracer_token);
}
-int lttng_trigger_generate_name(struct lttng_trigger *trigger,
- uint64_t unique_id)
+int lttng_trigger_generate_name(struct lttng_trigger *trigger, uint64_t unique_id)
{
int ret = 0;
char *generated_name = NULL;
return;
}
- urcu_ref_put(&trigger->ref , trigger_destroy_ref);
+ urcu_ref_put(&trigger->ref, trigger_destroy_ref);
}
static void delete_trigger_array_element(void *ptr)
return triggers;
}
-struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(
- const struct lttng_triggers *triggers, unsigned int index)
+struct lttng_trigger *lttng_triggers_borrow_mutable_at_index(const struct lttng_triggers *triggers,
+ unsigned int index)
{
struct lttng_trigger *trigger = NULL;
goto end;
}
- trigger = (struct lttng_trigger *)
- lttng_dynamic_pointer_array_get_pointer(
- &triggers->array, index);
+ trigger = (struct lttng_trigger *) lttng_dynamic_pointer_array_get_pointer(&triggers->array,
+ index);
end:
return trigger;
}
-int lttng_triggers_add(
- struct lttng_triggers *triggers, struct lttng_trigger *trigger)
+int lttng_triggers_add(struct lttng_triggers *triggers, struct lttng_trigger *trigger)
{
int ret;
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
while (i < trigger_count) {
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
if (lttng_trigger_is_hidden(trigger)) {
- ret = lttng_dynamic_pointer_array_remove_pointer(
- &triggers->array, i);
+ ret = lttng_dynamic_pointer_array_remove_pointer(&triggers->array, i);
if (ret) {
goto end;
}
return ret;
}
-const struct lttng_trigger *lttng_triggers_get_at_index(
- const struct lttng_triggers *triggers, unsigned int index)
+const struct lttng_trigger *lttng_triggers_get_at_index(const struct lttng_triggers *triggers,
+ unsigned int index)
{
return lttng_triggers_borrow_mutable_at_index(triggers, index);
}
-enum lttng_trigger_status lttng_triggers_get_count(const struct lttng_triggers *triggers, unsigned int *count)
+enum lttng_trigger_status lttng_triggers_get_count(const struct lttng_triggers *triggers,
+ unsigned int *count)
{
enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
free(triggers);
}
-int lttng_triggers_serialize(const struct lttng_triggers *triggers,
- struct lttng_payload *payload)
+int lttng_triggers_serialize(const struct lttng_triggers *triggers, struct lttng_payload *payload)
{
int ret;
unsigned int i, count;
triggers_comm.count = count;
/* Placeholder header; updated at the end. */
- ret = lttng_dynamic_buffer_append(&payload->buffer, &triggers_comm,
- sizeof(triggers_comm));
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &triggers_comm, sizeof(triggers_comm));
if (ret) {
goto end;
}
size_before_payload = payload->buffer.size;
for (i = 0; i < count; i++) {
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
LTTNG_ASSERT(trigger);
return ret;
}
-ssize_t lttng_triggers_create_from_payload(
- struct lttng_payload_view *src_view,
- struct lttng_triggers **triggers)
+ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *src_view,
+ struct lttng_triggers **triggers)
{
ssize_t ret, offset = 0, triggers_size = 0;
unsigned int i;
for (i = 0; i < triggers_comm->count; i++) {
struct lttng_trigger *trigger = NULL;
struct lttng_payload_view trigger_view =
- lttng_payload_view_from_view(src_view, offset, -1);
+ lttng_payload_view_from_view(src_view, offset, -1);
ssize_t trigger_size;
- trigger_size = lttng_trigger_create_from_payload(
- &trigger_view, &trigger);
+ trigger_size = lttng_trigger_create_from_payload(&trigger_view, &trigger);
if (trigger_size < 0) {
ret = trigger_size;
goto error;
return ret;
}
-const struct lttng_credentials *lttng_trigger_get_credentials(
- const struct lttng_trigger *trigger)
+const struct lttng_credentials *lttng_trigger_get_credentials(const struct lttng_trigger *trigger)
{
return &trigger->creds;
}
void lttng_trigger_set_credentials(struct lttng_trigger *trigger,
- const struct lttng_credentials *creds)
+ const struct lttng_credentials *creds)
{
/* Triggers do not use the group id to authenticate the user. */
LTTNG_ASSERT(creds);
LTTNG_OPTIONAL_UNSET(&trigger->creds.gid);
}
-enum lttng_trigger_status lttng_trigger_set_owner_uid(
- struct lttng_trigger *trigger, uid_t uid)
+enum lttng_trigger_status lttng_trigger_set_owner_uid(struct lttng_trigger *trigger, uid_t uid)
{
enum lttng_trigger_status ret = LTTNG_TRIGGER_STATUS_OK;
const uid_t euid = geteuid();
return ret;
}
-enum lttng_trigger_status lttng_trigger_get_owner_uid(
- const struct lttng_trigger *trigger, uid_t *uid)
+enum lttng_trigger_status lttng_trigger_get_owner_uid(const struct lttng_trigger *trigger,
+ uid_t *uid)
{
enum lttng_trigger_status ret = LTTNG_TRIGGER_STATUS_OK;
const struct lttng_credentials *creds = NULL;
- if (!trigger || !uid ) {
+ if (!trigger || !uid) {
ret = LTTNG_TRIGGER_STATUS_INVALID;
goto end;
}
- if (!trigger->creds.uid.is_set ) {
+ if (!trigger->creds.uid.is_set) {
ret = LTTNG_TRIGGER_STATUS_UNSET;
goto end;
}
return ret;
}
-enum lttng_domain_type lttng_trigger_get_underlying_domain_type_restriction(
- const struct lttng_trigger *trigger)
+enum lttng_domain_type
+lttng_trigger_get_underlying_domain_type_restriction(const struct lttng_trigger *trigger)
{
enum lttng_domain_type type = LTTNG_DOMAIN_NONE;
const struct lttng_event_rule *event_rule;
LTTNG_ASSERT(trigger->condition);
c_type = lttng_condition_get_type(trigger->condition);
- assert (c_type != LTTNG_CONDITION_TYPE_UNKNOWN);
+ assert(c_type != LTTNG_CONDITION_TYPE_UNKNOWN);
switch (c_type) {
case LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE:
break;
case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
/* Return the domain of the event rule. */
- c_status = lttng_condition_event_rule_matches_get_rule(
- trigger->condition, &event_rule);
+ c_status = lttng_condition_event_rule_matches_get_rule(trigger->condition,
+ &event_rule);
LTTNG_ASSERT(c_status == LTTNG_CONDITION_STATUS_OK);
type = lttng_event_rule_get_domain_type(event_rule);
break;
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
/* Return the domain of the channel being monitored. */
- c_status = lttng_condition_buffer_usage_get_domain_type(
- trigger->condition, &type);
+ c_status = lttng_condition_buffer_usage_get_domain_type(trigger->condition, &type);
LTTNG_ASSERT(c_status == LTTNG_CONDITION_STATUS_OK);
break;
default:
* Generate bytecode related to the trigger.
* On success LTTNG_OK. On error, returns lttng_error code.
*/
-enum lttng_error_code lttng_trigger_generate_bytecode(
- struct lttng_trigger *trigger,
- const struct lttng_credentials *creds)
+enum lttng_error_code lttng_trigger_generate_bytecode(struct lttng_trigger *trigger,
+ const struct lttng_credentials *creds)
{
enum lttng_error_code ret;
struct lttng_condition *condition = NULL;
{
struct lttng_event_rule *event_rule;
const enum lttng_condition_status condition_status =
- lttng_condition_event_rule_matches_borrow_rule_mutable(
- condition, &event_rule);
+ lttng_condition_event_rule_matches_borrow_rule_mutable(condition,
+ &event_rule);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
/* Generate the filter bytecode. */
- ret = lttng_event_rule_generate_filter_bytecode(
- event_rule, creds);
+ ret = lttng_event_rule_generate_filter_bytecode(event_rule, creds);
if (ret != LTTNG_OK) {
goto end;
}
/* Generate the capture bytecode. */
ret = lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
- condition);
+ condition);
if (ret != LTTNG_OK) {
goto end;
}
{
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- ©_buffer, 0, -1);
+ lttng_payload_view_from_payload(©_buffer, 0, -1);
- ret = lttng_condition_create_from_payload(
- &view, &condition_copy);
+ ret = lttng_condition_create_from_payload(&view, &condition_copy);
if (ret < 0) {
goto end;
}
{
struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- ©_buffer, 0, -1);
+ lttng_payload_view_from_payload(©_buffer, 0, -1);
- ret = lttng_action_create_from_payload(
- &view, &action_copy);
+ ret = lttng_action_create_from_payload(&view, &action_copy);
if (ret < 0) {
goto end;
}
goto error_cleanup_trigger;
}
- trigger_status = lttng_trigger_get_owner_uid(
- trigger, &trigger_owner_uid);
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner_uid);
switch (trigger_status) {
case LTTNG_TRIGGER_STATUS_OK:
LTTNG_OPTIONAL_SET(©->creds.uid, trigger_owner_uid);
bool lttng_trigger_needs_tracer_notifier(const struct lttng_trigger *trigger)
{
bool needs_tracer_notifier = false;
- const struct lttng_condition *condition =
- lttng_trigger_get_const_condition(trigger);
+ const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
switch (lttng_condition_get_type(condition)) {
case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
pthread_mutex_unlock(&trigger->lock);
}
-enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks)
+enum lttng_error_code
+lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks)
{
int ret;
enum lttng_error_code ret_code;
LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
/* Name. */
- ret = mi_lttng_writer_write_element_string(
- writer, config_element_name, trigger->name);
+ ret = mi_lttng_writer_write_element_string(writer, config_element_name, trigger->name);
if (ret) {
goto mi_error;
}
/* Owner uid. */
- ret = mi_lttng_writer_write_element_signed_int(writer,
- mi_lttng_element_trigger_owner_uid,
- (int64_t) owner_uid);
+ ret = mi_lttng_writer_write_element_signed_int(
+ writer, mi_lttng_element_trigger_owner_uid, (int64_t) owner_uid);
if (ret) {
goto mi_error;
}
/* Condition. */
condition = lttng_trigger_get_const_condition(trigger);
LTTNG_ASSERT(condition);
- ret_code = lttng_condition_mi_serialize(
- trigger, condition, writer, error_query_callbacks);
+ ret_code = lttng_condition_mi_serialize(trigger, condition, writer, error_query_callbacks);
if (ret_code != LTTNG_OK) {
goto end;
}
/* Action. */
action = lttng_trigger_get_const_action(trigger);
LTTNG_ASSERT(action);
- ret_code = lttng_action_mi_serialize(trigger, action, writer,
- error_query_callbacks, &action_path_indexes);
+ ret_code = lttng_action_mi_serialize(
+ trigger, action, writer, error_query_callbacks, &action_path_indexes);
if (ret_code != LTTNG_OK) {
goto end;
}
goto end;
}
- ret_code = lttng_error_query_results_mi_serialize(
- results, writer);
+ ret_code = lttng_error_query_results_mi_serialize(results, writer);
lttng_error_query_results_destroy(results);
if (ret_code != LTTNG_OK) {
goto end;
/* Used by qsort, which expects the semantics of strcmp(). */
static int compare_triggers_by_name(const void *a, const void *b)
{
- const struct lttng_trigger *trigger_a =
- *((const struct lttng_trigger **) a);
- const struct lttng_trigger *trigger_b =
- *((const struct lttng_trigger **) b);
+ const struct lttng_trigger *trigger_a = *((const struct lttng_trigger **) a);
+ const struct lttng_trigger *trigger_b = *((const struct lttng_trigger **) b);
const char *name_a, *name_b;
enum lttng_trigger_status trigger_status;
return strcmp(name_a, name_b);
}
-enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
- struct mi_writer *writer,
- const struct mi_lttng_error_query_callbacks
- *error_query_callbacks)
+enum lttng_error_code
+lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks)
{
int ret;
enum lttng_error_code ret_code;
for (i = 0; i < count; i++) {
int add_ret;
const char *unused_name;
- const struct lttng_trigger *trigger =
- lttng_triggers_get_at_index(triggers, i);
+ const struct lttng_trigger *trigger = lttng_triggers_get_at_index(triggers, i);
status = lttng_trigger_get_name(trigger, &unused_name);
switch (status) {
abort();
}
- add_ret = lttng_dynamic_pointer_array_add_pointer(
- &sorted_triggers, (void *) trigger);
+ add_ret =
+ lttng_dynamic_pointer_array_add_pointer(&sorted_triggers, (void *) trigger);
if (add_ret) {
ERR("Failed to lttng_trigger to sorting array.");
}
}
- qsort(sorted_triggers.array.buffer.data, count,
- sizeof(struct lttng_trigger *),
- compare_triggers_by_name);
+ qsort(sorted_triggers.array.buffer.data,
+ count,
+ sizeof(struct lttng_trigger *),
+ compare_triggers_by_name);
/* Open triggers element. */
ret = mi_lttng_writer_open_element(writer, mi_lttng_element_triggers);
for (i = 0; i < lttng_dynamic_pointer_array_get_count(&sorted_triggers); i++) {
const struct lttng_trigger *trigger =
- (const struct lttng_trigger *)
- lttng_dynamic_pointer_array_get_pointer(
- &sorted_triggers, i);
+ (const struct lttng_trigger *) lttng_dynamic_pointer_array_get_pointer(
+ &sorted_triggers, i);
lttng_trigger_mi_serialize(trigger, writer, error_query_callbacks);
}
*/
#define _LGPL_SOURCE
+#include "unix.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/fd-handle.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/common.hpp>
-#include <common/compat/errno.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/fd-handle.hpp>
-
-#include "unix.hpp"
-
/*
* Connect to unix socket using the path name.
*/
if (strlen(pathname) >= sizeof(s_un.sun_path)) {
ERR("unix socket address (\"%s\") is longer than the platform's limit (%zu > %zu).",
- pathname, strlen(pathname) + 1,
- sizeof(s_un.sun_path));
+ pathname,
+ strlen(pathname) + 1,
+ sizeof(s_un.sun_path));
ret = -ENAMETOOLONG;
goto error;
}
if (strlen(pathname) >= sizeof(s_un.sun_path)) {
ERR("unix socket address (\"%s\") is longer than the platform's limit (%zu > %zu).",
- pathname, strlen(pathname) + 1,
- sizeof(s_un.sun_path));
+ pathname,
+ strlen(pathname) + 1,
+ sizeof(s_un.sun_path));
ret = -ENAMETOOLONG;
goto error;
}
*/
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
- if (errno == EAGAIN || errno == EWOULDBLOCK ||
- errno == EPIPE) {
- DIAGNOSTIC_POP
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EPIPE) {
+ DIAGNOSTIC_POP
/*
* Nothing was recv.
*/
*/
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
- if (errno == EAGAIN || errno == EWOULDBLOCK ||
- errno == EPIPE) {
- DIAGNOSTIC_POP
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EPIPE) {
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was sent.
if (nb_fd > LTTCOMM_MAX_SEND_FDS)
return -EINVAL;
- msg.msg_control = (caddr_t)tmp;
+ msg.msg_control = (caddr_t) tmp;
msg.msg_controllen = CMSG_LEN(sizeof_fds);
cmptr = CMSG_FIRSTHDR(&msg);
*
* Returns the size of data sent, or negative error value.
*/
-static
-ssize_t _lttcomm_send_payload_view_fds_unix_sock(int sock,
- struct lttng_payload_view *view,
- bool blocking)
+static ssize_t
+_lttcomm_send_payload_view_fds_unix_sock(int sock, struct lttng_payload_view *view, bool blocking)
{
int i;
ssize_t ret;
* owns a reference to the fd_handles.
*/
for (i = 0; i < fd_count; i++) {
- struct fd_handle *handle =
- lttng_payload_view_pop_fd_handle(view);
+ struct fd_handle *handle = lttng_payload_view_pop_fd_handle(view);
const int raw_fd = fd_handle_get_fd(handle);
- const int add_ret = lttng_dynamic_array_add_element(
- &raw_fds, &raw_fd);
+ const int add_ret = lttng_dynamic_array_add_element(&raw_fds, &raw_fd);
fd_handle_put(handle);
if (add_ret) {
}
if (blocking) {
- ret = lttcomm_send_fds_unix_sock(sock,
- (const int *) raw_fds.buffer.data, fd_count);
+ ret = lttcomm_send_fds_unix_sock(sock, (const int *) raw_fds.buffer.data, fd_count);
} else {
- ret = lttcomm_send_fds_unix_sock_non_block(sock,
- (const int *) raw_fds.buffer.data, fd_count);
+ ret = lttcomm_send_fds_unix_sock_non_block(
+ sock, (const int *) raw_fds.buffer.data, fd_count);
}
end:
return ret;
}
-ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock,
- struct lttng_payload_view *view)
+ssize_t lttcomm_send_payload_view_fds_unix_sock(int sock, struct lttng_payload_view *view)
{
return _lttcomm_send_payload_view_fds_unix_sock(sock, view, true);
}
-ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock,
- struct lttng_payload_view *view)
+ssize_t lttcomm_send_payload_view_fds_unix_sock_non_block(int sock, struct lttng_payload_view *view)
{
return _lttcomm_send_payload_view_fds_unix_sock(sock, view, false);
}
if (nb_fd > LTTCOMM_MAX_SEND_FDS)
return -EINVAL;
- msg.msg_control = (caddr_t)tmp;
+ msg.msg_control = (caddr_t) tmp;
msg.msg_controllen = CMSG_LEN(sizeof_fds);
cmptr = CMSG_FIRSTHDR(&msg);
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was sent.
goto retry;
} else {
/* We consider EPIPE and EAGAIN as expected. */
- if (!lttng_opt_quiet &&
- (errno != EPIPE && errno != EAGAIN)) {
+ if (!lttng_opt_quiet && (errno != EPIPE && errno != EAGAIN)) {
PERROR("recvmsg");
}
goto end;
}
if (ret != 1) {
- fprintf(stderr, "Error: Received %zd bytes, expected %d\n",
- ret, 1);
+ fprintf(stderr, "Error: Received %zd bytes, expected %d\n", ret, 1);
goto end;
}
* now copy the fds to the fds ptr and return success.
*/
if (cmsg->cmsg_len != CMSG_LEN(sizeof_fds)) {
- fprintf(stderr, "Error: Received %zu bytes of"
+ fprintf(stderr,
+ "Error: Received %zu bytes of"
"ancillary data for FDs, expected %zu\n",
(size_t) cmsg->cmsg_len,
(size_t) CMSG_LEN(sizeof_fds));
return ret;
}
-static
-void close_raw_fd(void *ptr)
+static void close_raw_fd(void *ptr)
{
const int raw_fd = *((const int *) ptr);
}
}
-static
-enum lttng_error_code add_fds_to_payload(struct lttng_dynamic_array *raw_fds,
- struct lttng_payload *payload)
+static enum lttng_error_code add_fds_to_payload(struct lttng_dynamic_array *raw_fds,
+ struct lttng_payload *payload)
{
int i;
enum lttng_error_code ret_code = LTTNG_OK;
for (i = 0; i < fd_count; i++) {
int ret;
struct fd_handle *handle;
- int *raw_fd = (int *) lttng_dynamic_array_get_element(
- raw_fds, i);
+ int *raw_fd = (int *) lttng_dynamic_array_get_element(raw_fds, i);
LTTNG_ASSERT(*raw_fd != -1);
return ret_code;
}
-static
-ssize_t _lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
- struct lttng_payload *payload, bool blocking)
+static ssize_t _lttcomm_recv_payload_fds_unix_sock(int sock,
+ size_t nb_fd,
+ struct lttng_payload *payload,
+ bool blocking)
{
int i = 0;
enum lttng_error_code add_ret;
}
if (blocking) {
- ret = lttcomm_recv_fds_unix_sock(
- sock, (int *) raw_fds.buffer.data, nb_fd);
+ ret = lttcomm_recv_fds_unix_sock(sock, (int *) raw_fds.buffer.data, nb_fd);
} else {
ret = lttcomm_recv_fds_unix_sock_non_block(
- sock, (int *) raw_fds.buffer.data, nb_fd);
+ sock, (int *) raw_fds.buffer.data, nb_fd);
}
if (ret <= 0) {
add_ret = add_fds_to_payload(&raw_fds, payload);
if (add_ret != LTTNG_OK) {
- ret = - (int) add_ret;
+ ret = -(int) add_ret;
goto end;
}
return ret;
}
-ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd,
- struct lttng_payload *payload)
+ssize_t lttcomm_recv_payload_fds_unix_sock(int sock, size_t nb_fd, struct lttng_payload *payload)
{
return _lttcomm_recv_payload_fds_unix_sock(sock, nb_fd, payload, true);
}
-ssize_t lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd,
- struct lttng_payload *payload)
+ssize_t
+lttcomm_recv_payload_fds_unix_sock_non_block(int sock, size_t nb_fd, struct lttng_payload *payload)
{
return _lttcomm_recv_payload_fds_unix_sock(sock, nb_fd, payload, false);
}
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_LOGICAL_OP
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
/*
* This can happen in non blocking mode.
* Nothing was recv.
}
if (ret != 1) {
- fprintf(stderr, "Error: Received %zd bytes, expected %d\n",
- ret, 1);
+ fprintf(stderr, "Error: Received %zd bytes, expected %d\n", ret, 1);
goto end;
}
* now copy the fds to the fds ptr and return success.
*/
if (cmsg->cmsg_len != CMSG_LEN(sizeof_fds)) {
- fprintf(stderr, "Error: Received %zu bytes of"
+ fprintf(stderr,
+ "Error: Received %zu bytes of"
"ancillary data for FDs, expected %zu\n",
(size_t) cmsg->cmsg_len,
(size_t) CMSG_LEN(sizeof_fds));
cmptr->cmsg_type = LTTNG_SOCK_CREDS;
cmptr->cmsg_len = CMSG_LEN(sizeof_cred);
- creds = (lttng_sock_cred*) CMSG_DATA(cmptr);
+ creds = (lttng_sock_cred *) CMSG_DATA(cmptr);
LTTNG_SOCK_SET_UID_CRED(creds, geteuid());
LTTNG_SOCK_SET_GID_CRED(creds, getegid());
*
* Returns the size of received data, or negative error value.
*/
-ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
- lttng_sock_cred *creds)
+ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, lttng_sock_cred *creds)
{
struct msghdr msg;
struct iovec iov[1];
struct cmsghdr *cmptr;
size_t sizeof_cred = sizeof(lttng_sock_cred);
char anc_buf[CMSG_SPACE(sizeof_cred)];
-#endif /* __linux__, __CYGWIN__ */
+#endif /* __linux__, __CYGWIN__ */
LTTNG_ASSERT(sock);
LTTNG_ASSERT(buf);
goto end;
}
- if (cmptr->cmsg_level != SOL_SOCKET ||
- cmptr->cmsg_type != LTTNG_SOCK_CREDS) {
+ if (cmptr->cmsg_level != SOL_SOCKET || cmptr->cmsg_type != LTTNG_SOCK_CREDS) {
fprintf(stderr, "Didn't received any credentials\n");
ret = -1;
goto end;
}
if (cmptr->cmsg_len != CMSG_LEN(sizeof_cred)) {
- fprintf(stderr, "Error: Received %zu bytes of ancillary data, expected %zu\n",
- (size_t) cmptr->cmsg_len, (size_t) CMSG_LEN(sizeof_cred));
+ fprintf(stderr,
+ "Error: Received %zu bytes of ancillary data, expected %zu\n",
+ (size_t) cmptr->cmsg_len,
+ (size_t) CMSG_LEN(sizeof_cred));
ret = -1;
goto end;
}
}
#else
#error "Please implement credential support for your OS."
-#endif /* __linux__, __CYGWIN__ */
+#endif /* __linux__, __CYGWIN__ */
end:
return ret;
*/
#define _LGPL_SOURCE
-#include <arpa/inet.h>
-#include <common/compat/netdb.hpp>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
+#include "uri.hpp"
#include <common/common.hpp>
+#include <common/compat/netdb.hpp>
#include <common/defaults.hpp>
#include <common/utils.hpp>
-#include "uri.hpp"
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
#define LOOPBACK_ADDR_IPV4 "127.0.0.1"
#define LOOPBACK_ADDR_IPV6 "::1"
enum uri_proto_code {
- P_NET, P_NET6, P_FILE, P_TCP, P_TCP6,
+ P_NET,
+ P_NET6,
+ P_FILE,
+ P_TCP,
+ P_TCP6,
};
namespace {
};
/* Supported protocols */
-const struct uri_proto proto_uri[] = {
- { .name = "file", .leading_string = "file://", .code = P_FILE, .type = LTTNG_PROTO_TYPE_NONE, .dtype = LTTNG_DST_PATH },
- { .name = "net", .leading_string = "net://", .code = P_NET, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 },
- { .name = "net4", .leading_string = "net4://", .code = P_NET, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 },
- { .name = "net6", .leading_string = "net6://", .code = P_NET6, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV6 },
- { .name = "tcp", .leading_string = "tcp://", .code = P_TCP, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 },
- { .name = "tcp4", .leading_string = "tcp4://", .code = P_TCP, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV4 },
- { .name = "tcp6", .leading_string = "tcp6://", .code = P_TCP6, .type = LTTNG_TCP, .dtype = LTTNG_DST_IPV6 },
- /* Invalid proto marking the end of the array. */
- {}
-};
+const struct uri_proto proto_uri[] = { { .name = "file",
+ .leading_string = "file://",
+ .code = P_FILE,
+ .type = LTTNG_PROTO_TYPE_NONE,
+ .dtype = LTTNG_DST_PATH },
+ { .name = "net",
+ .leading_string = "net://",
+ .code = P_NET,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV4 },
+ { .name = "net4",
+ .leading_string = "net4://",
+ .code = P_NET,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV4 },
+ { .name = "net6",
+ .leading_string = "net6://",
+ .code = P_NET6,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV6 },
+ { .name = "tcp",
+ .leading_string = "tcp://",
+ .code = P_TCP,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV4 },
+ { .name = "tcp4",
+ .leading_string = "tcp4://",
+ .code = P_TCP,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV4 },
+ { .name = "tcp6",
+ .leading_string = "tcp6://",
+ .code = P_TCP6,
+ .type = LTTNG_TCP,
+ .dtype = LTTNG_DST_IPV6 },
+ /* Invalid proto marking the end of the array. */
+ {} };
} /* namespace */
/*
goto end;
}
- for (supported = &proto_uri[0];
- supported->leading_string != NULL; ++supported) {
- if (strncasecmp(uri_str, supported->leading_string,
- strlen(supported->leading_string)) == 0) {
+ for (supported = &proto_uri[0]; supported->leading_string != NULL; ++supported) {
+ if (strncasecmp(uri_str,
+ supported->leading_string,
+ strlen(supported->leading_string)) == 0) {
goto end;
}
}
PERROR("inet_ntop");
goto error;
}
- } else if (!strcmp(addr, "localhost") &&
- (af == AF_INET || af == AF_INET6)) {
+ } else if (!strcmp(addr, "localhost") && (af == AF_INET || af == AF_INET6)) {
/*
* Some systems may not have "localhost" defined in
* accordance with IETF RFC 6761. According to this RFC,
* done to accommodates systems which may want to start
* tracing before their network configured.
*/
- const char *loopback_addr = af == AF_INET ?
- LOOPBACK_ADDR_IPV4 : LOOPBACK_ADDR_IPV6;
+ const char *loopback_addr = af == AF_INET ? LOOPBACK_ADDR_IPV4 :
+ LOOPBACK_ADDR_IPV6;
const size_t loopback_addr_len = af == AF_INET ?
- sizeof(LOOPBACK_ADDR_IPV4) :
- sizeof(LOOPBACK_ADDR_IPV6);
+ sizeof(LOOPBACK_ADDR_IPV4) :
+ sizeof(LOOPBACK_ADDR_IPV6);
DBG2("Could not resolve localhost address, using fallback");
if (loopback_addr_len > size) {
* Set default URI attribute which is basically the given stream type and the
* default port if none is set in the URI.
*/
-static void set_default_uri_attr(struct lttng_uri *uri,
- enum lttng_stream_type stype)
+static void set_default_uri_attr(struct lttng_uri *uri, enum lttng_stream_type stype)
{
uri->stype = stype;
if (uri->dtype != LTTNG_DST_PATH && uri->port == 0) {
- uri->port = (stype == LTTNG_STREAM_CONTROL) ?
- DEFAULT_NETWORK_CONTROL_PORT : DEFAULT_NETWORK_DATA_PORT;
+ uri->port = (stype == LTTNG_STREAM_CONTROL) ? DEFAULT_NETWORK_CONTROL_PORT :
+ DEFAULT_NETWORK_DATA_PORT;
}
}
(void) snprintf(port, sizeof(port), "%s", "");
} else {
ipver = (uri->dtype == LTTNG_DST_IPV4) ? 4 : 6;
- addr = (ipver == 4) ? uri->dst.ipv4 : uri->dst.ipv6;
+ addr = (ipver == 4) ? uri->dst.ipv4 : uri->dst.ipv6;
(void) snprintf(proto, sizeof(proto), "tcp%d", ipver);
(void) snprintf(port, sizeof(port), ":%d", uri->port);
}
- ret = snprintf(dst, size, "%s://%s%s%s%s/%s", proto,
- (ipver == 6) ? "[" : "", addr, (ipver == 6) ? "]" : "",
- port, uri->subdir);
+ ret = snprintf(dst,
+ size,
+ "%s://%s%s%s%s/%s",
+ proto,
+ (ipver == 6) ? "[" : "",
+ addr,
+ (ipver == 6) ? "]" : "",
+ port,
+ uri->subdir);
if (ret < 0) {
PERROR("snprintf uri to url");
}
* Maximum of two ports is possible if P_NET/NET6. Bigger than that,
* two much stuff.
*/
- if ((i == 2 && (proto->code != P_NET && proto->code != P_NET6))
- || i > 2) {
+ if ((i == 2 && (proto->code != P_NET && proto->code != P_NET6)) || i > 2) {
break;
}
switch (proto->code) {
case P_NET:
- ret = set_ip_address(addr_f, AF_INET, tmp_uris[0].dst.ipv4,
- sizeof(tmp_uris[0].dst.ipv4));
+ ret = set_ip_address(
+ addr_f, AF_INET, tmp_uris[0].dst.ipv4, sizeof(tmp_uris[0].dst.ipv4));
if (ret < 0) {
goto free_error;
}
tmp_uris[1].port = data_port;
break;
case P_NET6:
- ret = set_ip_address(addr_f, AF_INET6, tmp_uris[0].dst.ipv6,
- sizeof(tmp_uris[0].dst.ipv6));
+ ret = set_ip_address(
+ addr_f, AF_INET6, tmp_uris[0].dst.ipv6, sizeof(tmp_uris[0].dst.ipv6));
if (ret < 0) {
goto free_error;
}
tmp_uris[1].port = data_port;
break;
case P_TCP:
- ret = set_ip_address(addr_f, AF_INET, tmp_uris[0].dst.ipv4,
- sizeof(tmp_uris[0].dst.ipv4));
+ ret = set_ip_address(
+ addr_f, AF_INET, tmp_uris[0].dst.ipv4, sizeof(tmp_uris[0].dst.ipv4));
if (ret < 0) {
goto free_error;
}
break;
case P_TCP6:
- ret = set_ip_address(addr_f, AF_INET6, tmp_uris[0].dst.ipv6,
- sizeof(tmp_uris[0].dst.ipv6));
+ ret = set_ip_address(
+ addr_f, AF_INET6, tmp_uris[0].dst.ipv6, sizeof(tmp_uris[0].dst.ipv6));
if (ret < 0) {
goto free_error;
}
end:
DBG3("URI dtype: %d, proto: %d, host: %s, subdir: %s, ctrl: %d, data: %d",
- proto->dtype, proto->type, (addr_f == NULL) ? "" : addr_f,
- (subdir_b == NULL) ? "" : subdir_b, ctrl_port, data_port);
+ proto->dtype,
+ proto->type,
+ (addr_f == NULL) ? "" : addr_f,
+ (subdir_b == NULL) ? "" : subdir_b,
+ ctrl_port,
+ data_port);
free(addr_f);
* Parse a string URL and creates URI(s) returning the size of the populated
* array.
*/
-ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
- struct lttng_uri **uris)
+ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url, struct lttng_uri **uris)
{
unsigned int equal = 1, idx = 0;
/* Add the "file://" size to the URL maximum size */
} else if (ret >= sizeof(url)) {
PERROR("snprintf file url is too long");
goto parse_error;
-
}
ctrl_url = url;
}
/* At this point, we know there is at least one URI in the array */
set_default_uri_attr(&ctrl_uris[0], LTTNG_STREAM_CONTROL);
- if (ctrl_uris[0].dtype == LTTNG_DST_PATH &&
- (data_url && *data_url != '\0')) {
+ if (ctrl_uris[0].dtype == LTTNG_DST_PATH && (data_url && *data_url != '\0')) {
ERR("Cannot have a data URL when destination is file://");
goto error;
}
if (ctrl_uri_count == 2) {
if (!equal) {
ERR("Control URL uses the net:// protocol and the data URL is "
- "different. Not allowed.");
+ "different. Not allowed.");
goto error;
} else {
set_default_uri_attr(&ctrl_uris[1], LTTNG_STREAM_DATA);
*/
#include "lttng/lttng-error.h"
-#include <common/compat/string.hpp>
+
#include <common/align.hpp>
+#include <common/compat/string.hpp>
#include <common/error.hpp>
#include <common/hashtable/hashtable.hpp>
#include <common/hashtable/utils.hpp>
#include <common/mi-lttng.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
-#include <fcntl.h>
+
#include <lttng/constant.h>
#include <lttng/userspace-probe-internal.hpp>
+
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-static
-int lttng_userspace_probe_location_function_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd_handle);
+static int lttng_userspace_probe_location_function_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd_handle);
-static
-int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd_handle);
+static int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd_handle);
-static
-enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
- const struct lttng_userspace_probe_location_lookup_method
- *method,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
+ const struct lttng_userspace_probe_location_lookup_method *method,
+ struct mi_writer *writer);
-static
-enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer);
-static
-enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer);
+static enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer);
enum lttng_userspace_probe_location_lookup_method_type
lttng_userspace_probe_location_lookup_method_get_type(
- const struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
return lookup_method ? lookup_method->type :
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_UNKNOWN;
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_UNKNOWN;
}
void lttng_userspace_probe_location_lookup_method_destroy(
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
- if (!lookup_method){
+ if (!lookup_method) {
return;
}
return ret;
}
-enum lttng_userspace_probe_location_type lttng_userspace_probe_location_get_type(
- const struct lttng_userspace_probe_location *location)
+enum lttng_userspace_probe_location_type
+lttng_userspace_probe_location_get_type(const struct lttng_userspace_probe_location *location)
{
- return location ? location->type :
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN;
+ return location ? location->type : LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN;
}
-static
-void lttng_userspace_probe_location_function_destroy(
- struct lttng_userspace_probe_location *location)
+static void
+lttng_userspace_probe_location_function_destroy(struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location_function *location_function = NULL;
LTTNG_ASSERT(location);
- location_function = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ location_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
LTTNG_ASSERT(location_function);
free(location);
}
-static
-void lttng_userspace_probe_location_tracepoint_destroy(
- struct lttng_userspace_probe_location *location)
+static void
+lttng_userspace_probe_location_tracepoint_destroy(struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location_tracepoint *location_tracepoint = NULL;
LTTNG_ASSERT(location);
- location_tracepoint = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ location_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(location_tracepoint);
free(location);
}
-void lttng_userspace_probe_location_destroy(
- struct lttng_userspace_probe_location *location)
+void lttng_userspace_probe_location_destroy(struct lttng_userspace_probe_location *location)
{
if (!location) {
return;
}
- lttng_userspace_probe_location_lookup_method_destroy(
- location->lookup_method);
+ lttng_userspace_probe_location_lookup_method_destroy(location->lookup_method);
switch (location->type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
/* Both are valid file descriptors. */
ret = fstat(a, &a_stat);
if (ret) {
- PERROR("Failed to fstat userspace probe location binary fd %d",
- a);
+ PERROR("Failed to fstat userspace probe location binary fd %d", a);
goto end;
}
ret = fstat(b, &b_stat);
if (ret) {
- PERROR("Failed to fstat userspace probe location binary fd %d",
- b);
+ PERROR("Failed to fstat userspace probe location binary fd %d", b);
goto end;
}
- is_equal = (a_stat.st_ino == b_stat.st_ino) &&
- (a_stat.st_dev == b_stat.st_dev);
+ is_equal = (a_stat.st_ino == b_stat.st_ino) && (a_stat.st_dev == b_stat.st_dev);
end:
return is_equal;
}
-static unsigned long lttng_userspace_probe_location_function_hash(
- const struct lttng_userspace_probe_location *location)
+static unsigned long
+lttng_userspace_probe_location_function_hash(const struct lttng_userspace_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION,
- lttng_ht_seed);
+ unsigned long hash = hash_key_ulong((void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION,
+ lttng_ht_seed);
struct lttng_userspace_probe_location_function *function_location =
- lttng::utils::container_of(
- location, <tng_userspace_probe_location_function::parent);
+ lttng::utils::container_of(location,
+ <tng_userspace_probe_location_function::parent);
hash ^= hash_key_str(function_location->function_name, lttng_ht_seed);
hash ^= hash_key_str(function_location->binary_path, lttng_ht_seed);
return hash;
}
-static bool lttng_userspace_probe_location_function_is_equal(
- const struct lttng_userspace_probe_location *_a,
- const struct lttng_userspace_probe_location *_b)
+static bool
+lttng_userspace_probe_location_function_is_equal(const struct lttng_userspace_probe_location *_a,
+ const struct lttng_userspace_probe_location *_b)
{
bool is_equal = false;
struct lttng_userspace_probe_location_function *a, *b;
- a = lttng::utils::container_of(_a,
- <tng_userspace_probe_location_function::parent);
- b = lttng::utils::container_of(_b,
- <tng_userspace_probe_location_function::parent);
+ a = lttng::utils::container_of(_a, <tng_userspace_probe_location_function::parent);
+ b = lttng::utils::container_of(_b, <tng_userspace_probe_location_function::parent);
if (a->instrumentation_type != b->instrumentation_type) {
goto end;
}
is_equal = fd_is_equal(a->binary_fd_handle ? fd_handle_get_fd(a->binary_fd_handle) : -1,
- b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
+ b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
end:
return is_equal;
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_create_no_check(const char *binary_path,
- const char *function_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method,
- bool open_binary)
+lttng_userspace_probe_location_function_create_no_check(
+ const char *binary_path,
+ const char *function_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method,
+ bool open_binary)
{
int binary_fd = -1;
struct fd_handle *binary_fd_handle = NULL;
location->binary_fd_handle = binary_fd_handle;
binary_fd_handle = NULL;
location->instrumentation_type =
- LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY;
+ LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY;
ret = &location->parent;
ret->lookup_method = lookup_method;
}
static unsigned long lttng_userspace_probe_location_tracepoint_hash(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
- unsigned long hash = hash_key_ulong(
- (void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT,
- lttng_ht_seed);
+ unsigned long hash = hash_key_ulong((void *) LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT,
+ lttng_ht_seed);
struct lttng_userspace_probe_location_tracepoint *tp_location = lttng::utils::container_of(
- location, <tng_userspace_probe_location_tracepoint::parent);
+ location, <tng_userspace_probe_location_tracepoint::parent);
hash ^= hash_key_str(tp_location->probe_name, lttng_ht_seed);
hash ^= hash_key_str(tp_location->provider_name, lttng_ht_seed);
return hash;
}
-static bool lttng_userspace_probe_location_tracepoint_is_equal(
- const struct lttng_userspace_probe_location *_a,
- const struct lttng_userspace_probe_location *_b)
+static bool
+lttng_userspace_probe_location_tracepoint_is_equal(const struct lttng_userspace_probe_location *_a,
+ const struct lttng_userspace_probe_location *_b)
{
bool is_equal = false;
struct lttng_userspace_probe_location_tracepoint *a, *b;
- a = lttng::utils::container_of(_a,
- <tng_userspace_probe_location_tracepoint::parent);
- b = lttng::utils::container_of(_b,
- <tng_userspace_probe_location_tracepoint::parent);
+ a = lttng::utils::container_of(_a, <tng_userspace_probe_location_tracepoint::parent);
+ b = lttng::utils::container_of(_b, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(a->probe_name);
LTTNG_ASSERT(b->probe_name);
}
is_equal = fd_is_equal(a->binary_fd_handle ? fd_handle_get_fd(a->binary_fd_handle) : -1,
- b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
+ b->binary_fd_handle ? fd_handle_get_fd(b->binary_fd_handle) : -1);
end:
return is_equal;
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_create_no_check(const char *binary_path,
- const char *provider_name, const char *probe_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method,
- bool open_binary)
+lttng_userspace_probe_location_tracepoint_create_no_check(
+ const char *binary_path,
+ const char *provider_name,
+ const char *probe_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method,
+ bool open_binary)
{
int binary_fd = -1;
struct fd_handle *binary_fd_handle = NULL;
return ret;
}
-struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_create(const char *binary_path,
- const char *function_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_function_create(
+ const char *binary_path,
+ const char *function_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
struct lttng_userspace_probe_location *ret = NULL;
goto end;
}
- switch (lttng_userspace_probe_location_lookup_method_get_type(
- lookup_method)) {
+ switch (lttng_userspace_probe_location_lookup_method_get_type(lookup_method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
break;
}
ret = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, lookup_method, true);
+ binary_path, function_name, lookup_method, true);
end:
return ret;
}
-struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_create(const char *binary_path,
- const char *provider_name, const char *probe_name,
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+struct lttng_userspace_probe_location *lttng_userspace_probe_location_tracepoint_create(
+ const char *binary_path,
+ const char *provider_name,
+ const char *probe_name,
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
struct lttng_userspace_probe_location *ret = NULL;
goto end;
}
- switch (lttng_userspace_probe_location_lookup_method_get_type(
- lookup_method)) {
+ switch (lttng_userspace_probe_location_lookup_method_get_type(lookup_method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
break;
default:
}
ret = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, lookup_method, true);
+ binary_path, provider_name, probe_name, lookup_method, true);
end:
return ret;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_function_elf_copy(
- const struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
struct lttng_userspace_probe_location_lookup_method *parent = NULL;
struct lttng_userspace_probe_location_lookup_method_elf *elf_method;
LTTNG_ASSERT(lookup_method);
LTTNG_ASSERT(lookup_method->type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF);
elf_method = zmalloc<lttng_userspace_probe_location_lookup_method_elf>();
if (!elf_method) {
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
- struct lttng_userspace_probe_location_lookup_method *lookup_method)
+ struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
struct lttng_userspace_probe_location_lookup_method *parent = NULL;
struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method;
LTTNG_ASSERT(lookup_method);
LTTNG_ASSERT(lookup_method->type ==
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT);
sdt_method = zmalloc<lttng_userspace_probe_location_lookup_method_sdt>();
if (!sdt_method) {
}
static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_function_copy(
- const struct lttng_userspace_probe_location *location)
+lttng_userspace_probe_location_function_copy(const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
struct lttng_userspace_probe_location *new_location = NULL;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
function_location = lttng::utils::container_of(
- location, <tng_userspace_probe_location_function::parent);
+ location, <tng_userspace_probe_location_function::parent);
/* Get probe location fields */
binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
/*
* Duplicate probe location method fields
*/
- lookup_type = lttng_userspace_probe_location_lookup_method_get_type(
- location->lookup_method);
+ lookup_type =
+ lttng_userspace_probe_location_lookup_method_get_type(location->lookup_method);
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- lookup_method =
- lttng_userspace_probe_location_lookup_method_function_elf_copy(
- location->lookup_method);
+ lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_copy(
+ location->lookup_method);
if (!lookup_method) {
goto error;
}
/* Create the probe_location */
new_location = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, lookup_method, false);
+ binary_path, function_name, lookup_method, false);
if (!new_location) {
goto destroy_lookup_method;
}
/* Set the duplicated fd to the new probe_location */
- if (lttng_userspace_probe_location_function_set_binary_fd_handle(new_location,
- function_location->binary_fd_handle) < 0) {
+ if (lttng_userspace_probe_location_function_set_binary_fd_handle(
+ new_location, function_location->binary_fd_handle) < 0) {
goto destroy_probe_location;
}
return new_location;
}
-static struct lttng_userspace_probe_location *
-lttng_userspace_probe_location_tracepoint_copy(
- const struct lttng_userspace_probe_location *location)
+static struct lttng_userspace_probe_location *lttng_userspace_probe_location_tracepoint_copy(
+ const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_lookup_method_type lookup_type;
struct lttng_userspace_probe_location *new_location = NULL;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
tracepoint_location = lttng::utils::container_of(
- location, <tng_userspace_probe_location_tracepoint::parent);
+ location, <tng_userspace_probe_location_tracepoint::parent);
/* Get probe location fields */
binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
/*
* Duplicate probe location method fields
*/
- lookup_type = lttng_userspace_probe_location_lookup_method_get_type(
- location->lookup_method);
+ lookup_type =
+ lttng_userspace_probe_location_lookup_method_get_type(location->lookup_method);
switch (lookup_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
- lookup_method =
- lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
- location->lookup_method);
+ lookup_method = lttng_userspace_probe_location_lookup_method_tracepoint_sdt_copy(
+ location->lookup_method);
if (!lookup_method) {
goto error;
}
/* Create the probe_location */
new_location = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, lookup_method, false);
+ binary_path, provider_name, probe_name, lookup_method, false);
if (!new_location) {
goto destroy_lookup_method;
}
/* Set the duplicated fd to the new probe_location */
- if (lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(new_location,
- tracepoint_location->binary_fd_handle) < 0) {
+ if (lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ new_location, tracepoint_location->binary_fd_handle) < 0) {
goto destroy_probe_location;
}
}
const char *lttng_userspace_probe_location_function_get_binary_path(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
const char *ret = NULL;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->binary_path;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_binary_path(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
const char *ret = NULL;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->binary_path;
end:
return ret;
}
const char *lttng_userspace_probe_location_function_get_function_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
const char *ret = NULL;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->function_name;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_probe_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
const char *ret = NULL;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->probe_name;
end:
return ret;
}
const char *lttng_userspace_probe_location_tracepoint_get_provider_name(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
const char *ret = NULL;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->provider_name;
end:
return ret;
}
int lttng_userspace_probe_location_function_get_binary_fd(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
int ret = -1;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
ret = function_location->binary_fd_handle ?
- fd_handle_get_fd(function_location->binary_fd_handle) : -1;
+ fd_handle_get_fd(function_location->binary_fd_handle) :
+ -1;
end:
return ret;
}
enum lttng_userspace_probe_location_function_instrumentation_type
lttng_userspace_probe_location_function_get_instrumentation_type(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
enum lttng_userspace_probe_location_function_instrumentation_type type;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
type = LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_UNKNOWN;
goto end;
}
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
type = function_location->instrumentation_type;
end:
return type;
enum lttng_userspace_probe_location_status
lttng_userspace_probe_location_function_set_instrumentation_type(
- const struct lttng_userspace_probe_location *location,
- enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type)
+ const struct lttng_userspace_probe_location *location,
+ enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type)
{
enum lttng_userspace_probe_location_status status =
- LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK;
+ LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK;
struct lttng_userspace_probe_location_function *function_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION ||
- instrumentation_type !=
- LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION ||
+ instrumentation_type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
status = LTTNG_USERSPACE_PROBE_LOCATION_STATUS_INVALID;
goto end;
}
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
function_location->instrumentation_type = instrumentation_type;
end:
return status;
}
int lttng_userspace_probe_location_tracepoint_get_binary_fd(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
int ret = -1;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
- tracepoint_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
ret = tracepoint_location->binary_fd_handle ?
- fd_handle_get_fd(tracepoint_location->binary_fd_handle) : -1;
+ fd_handle_get_fd(tracepoint_location->binary_fd_handle) :
+ -1;
end:
return ret;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_function_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location_lookup_method *ret = NULL;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
static struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_tracepoint_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location_lookup_method *ret = NULL;
- if (!location || lttng_userspace_probe_location_get_type(location) !=
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
+ if (!location ||
+ lttng_userspace_probe_location_get_type(location) !=
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT) {
ERR("Invalid argument(s) passed to '%s'", __FUNCTION__);
goto end;
}
const struct lttng_userspace_probe_location_lookup_method *
lttng_userspace_probe_location_get_lookup_method(
- const struct lttng_userspace_probe_location *location)
+ const struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location_lookup_method *ret = NULL;
LTTNG_ASSERT(location);
switch (location->type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- ret = lttng_userspace_probe_location_function_get_lookup_method(
- location);
+ ret = lttng_userspace_probe_location_function_get_lookup_method(location);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- ret = lttng_userspace_probe_location_tracepoint_get_lookup_method(
- location);
+ ret = lttng_userspace_probe_location_tracepoint_get_lookup_method(location);
break;
default:
ERR("Unknowned lookup method.");
return ret;
}
-static
-int lttng_userspace_probe_location_lookup_method_serialize(
- struct lttng_userspace_probe_location_lookup_method *method,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_lookup_method_serialize(
+ struct lttng_userspace_probe_location_lookup_method *method, struct lttng_payload *payload)
{
int ret;
- struct lttng_userspace_probe_location_lookup_method_comm
- lookup_method_comm;
+ struct lttng_userspace_probe_location_lookup_method_comm lookup_method_comm;
- lookup_method_comm.type = (int8_t) (method ? method->type :
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT);
+ lookup_method_comm.type =
+ (int8_t) (method ?
+ method->type :
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT);
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer, &lookup_method_comm,
- sizeof(lookup_method_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &lookup_method_comm, sizeof(lookup_method_comm));
if (ret) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_function_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_function_serialize(
+ const struct lttng_userspace_probe_location *location, struct lttng_payload *payload)
{
int ret;
size_t function_name_len, binary_path_len;
LTTNG_ASSERT(location);
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- location_function = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ location_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
if (!location_function->function_name || !location_function->binary_path) {
ret = -LTTNG_ERR_INVALID;
goto end;
location_function_comm.binary_path_len = binary_path_len + 1;
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_function_comm,
- sizeof(location_function_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_function_comm, sizeof(location_function_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_function->function_name,
- location_function_comm.function_name_len);
+ location_function->function_name,
+ location_function_comm.function_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_function->binary_path,
- location_function_comm.binary_path_len);
+ location_function->binary_path,
+ location_function_comm.binary_path_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_payload_push_fd_handle(
- payload, location_function->binary_fd_handle);
+ ret = lttng_payload_push_fd_handle(payload, location_function->binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
- ret = sizeof(location_function_comm) +
- location_function_comm.function_name_len +
- location_function_comm.binary_path_len;
+ ret = sizeof(location_function_comm) + location_function_comm.function_name_len +
+ location_function_comm.binary_path_len;
end:
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+static int lttng_userspace_probe_location_tracepoint_serialize(
+ const struct lttng_userspace_probe_location *location, struct lttng_payload *payload)
{
int ret;
size_t probe_name_len, provider_name_len, binary_path_len;
LTTNG_ASSERT(location);
LTTNG_ASSERT(lttng_userspace_probe_location_get_type(location) ==
- LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
+ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
- location_tracepoint = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
- if (!location_tracepoint->probe_name ||
- !location_tracepoint->provider_name ||
- !location_tracepoint->binary_path) {
+ location_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
+ if (!location_tracepoint->probe_name || !location_tracepoint->provider_name ||
+ !location_tracepoint->binary_path) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
if (payload) {
ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_tracepoint_comm,
- sizeof(location_tracepoint_comm));
+ &location_tracepoint_comm,
+ sizeof(location_tracepoint_comm));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->probe_name,
- location_tracepoint_comm.probe_name_len);
+ location_tracepoint->probe_name,
+ location_tracepoint_comm.probe_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->provider_name,
- location_tracepoint_comm.provider_name_len);
+ location_tracepoint->provider_name,
+ location_tracepoint_comm.provider_name_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
ret = lttng_dynamic_buffer_append(&payload->buffer,
- location_tracepoint->binary_path,
- location_tracepoint_comm.binary_path_len);
+ location_tracepoint->binary_path,
+ location_tracepoint_comm.binary_path_len);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_payload_push_fd_handle(
- payload, location_tracepoint->binary_fd_handle);
+ ret = lttng_payload_push_fd_handle(payload, location_tracepoint->binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
- ret = sizeof(location_tracepoint_comm) +
- location_tracepoint_comm.probe_name_len +
- location_tracepoint_comm.provider_name_len +
- location_tracepoint_comm.binary_path_len;
+ ret = sizeof(location_tracepoint_comm) + location_tracepoint_comm.probe_name_len +
+ location_tracepoint_comm.provider_name_len +
+ location_tracepoint_comm.binary_path_len;
end:
return ret;
}
-int lttng_userspace_probe_location_serialize(
- const struct lttng_userspace_probe_location *location,
- struct lttng_payload *payload)
+int lttng_userspace_probe_location_serialize(const struct lttng_userspace_probe_location *location,
+ struct lttng_payload *payload)
{
int ret, buffer_use = 0;
struct lttng_userspace_probe_location_comm location_generic_comm;
location_generic_comm.type = (int8_t) location->type;
if (payload) {
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- &location_generic_comm,
- sizeof(location_generic_comm));
+ ret = lttng_dynamic_buffer_append(
+ &payload->buffer, &location_generic_comm, sizeof(location_generic_comm));
if (ret) {
goto end;
}
switch (lttng_userspace_probe_location_get_type(location)) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- ret = lttng_userspace_probe_location_function_serialize(
- location, payload);
+ ret = lttng_userspace_probe_location_function_serialize(location, payload);
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- ret = lttng_userspace_probe_location_tracepoint_serialize(
- location, payload);
+ ret = lttng_userspace_probe_location_tracepoint_serialize(location, payload);
break;
default:
ERR("Unsupported probe location type");
}
buffer_use += ret;
- ret = lttng_userspace_probe_location_lookup_method_serialize(
- location->lookup_method, payload);
+ ret = lttng_userspace_probe_location_lookup_method_serialize(location->lookup_method,
+ payload);
if (ret < 0) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_function_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+static int lttng_userspace_probe_location_function_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_function_comm *location_function_comm;
const char *function_name_src, *binary_path_src;
goto end;
}
- location_function_comm =
- (typeof(location_function_comm)) view->buffer.data;
+ location_function_comm = (typeof(location_function_comm)) view->buffer.data;
expected_size = sizeof(*location_function_comm) +
- location_function_comm->function_name_len +
- location_function_comm->binary_path_len;
+ location_function_comm->function_name_len + location_function_comm->binary_path_len;
if (view->buffer.size < expected_size) {
ret = -LTTNG_ERR_INVALID;
}
function_name_src = view->buffer.data + sizeof(*location_function_comm);
- binary_path_src = function_name_src +
- location_function_comm->function_name_len;
+ binary_path_src = function_name_src + location_function_comm->function_name_len;
- if (!lttng_buffer_view_contains_string(&view->buffer, function_name_src,
- location_function_comm->function_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, function_name_src, location_function_comm->function_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, binary_path_src,
- location_function_comm->binary_path_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, binary_path_src, location_function_comm->binary_path_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
*location = lttng_userspace_probe_location_function_create_no_check(
- binary_path, function_name, NULL, false);
+ binary_path, function_name, NULL, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_userspace_probe_location_function_set_binary_fd_handle(
- *location, binary_fd_handle);
+ ret = lttng_userspace_probe_location_function_set_binary_fd_handle(*location,
+ binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+static int lttng_userspace_probe_location_tracepoint_create_from_payload(
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_tracepoint_comm *location_tracepoint_comm;
const char *probe_name_src, *provider_name_src, *binary_path_src;
goto end;
}
- location_tracepoint_comm =
- (typeof(location_tracepoint_comm)) view->buffer.data;
+ location_tracepoint_comm = (typeof(location_tracepoint_comm)) view->buffer.data;
expected_size = sizeof(*location_tracepoint_comm) +
- location_tracepoint_comm->probe_name_len +
- location_tracepoint_comm->provider_name_len +
- location_tracepoint_comm->binary_path_len;
+ location_tracepoint_comm->probe_name_len +
+ location_tracepoint_comm->provider_name_len +
+ location_tracepoint_comm->binary_path_len;
if (view->buffer.size < expected_size) {
ret = -LTTNG_ERR_INVALID;
}
probe_name_src = view->buffer.data + sizeof(*location_tracepoint_comm);
- provider_name_src = probe_name_src +
- location_tracepoint_comm->probe_name_len;
- binary_path_src = provider_name_src +
- location_tracepoint_comm->provider_name_len;
+ provider_name_src = probe_name_src + location_tracepoint_comm->probe_name_len;
+ binary_path_src = provider_name_src + location_tracepoint_comm->provider_name_len;
- if (!lttng_buffer_view_contains_string(&view->buffer, probe_name_src,
- location_tracepoint_comm->probe_name_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, probe_name_src, location_tracepoint_comm->probe_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, provider_name_src,
- location_tracepoint_comm->provider_name_len)) {
+ if (!lttng_buffer_view_contains_string(&view->buffer,
+ provider_name_src,
+ location_tracepoint_comm->provider_name_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (!lttng_buffer_view_contains_string(&view->buffer, binary_path_src,
- location_tracepoint_comm->binary_path_len)) {
+ if (!lttng_buffer_view_contains_string(
+ &view->buffer, binary_path_src, location_tracepoint_comm->binary_path_len)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
}
*location = lttng_userspace_probe_location_tracepoint_create_no_check(
- binary_path, provider_name, probe_name, NULL, false);
+ binary_path, provider_name, probe_name, NULL, false);
if (!(*location)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- *location, binary_fd_handle);
+ ret = lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(*location,
+ binary_fd_handle);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int lttng_userspace_probe_location_lookup_method_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location_lookup_method **lookup_method)
+static int lttng_userspace_probe_location_lookup_method_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_userspace_probe_location_lookup_method **lookup_method)
{
int ret;
struct lttng_userspace_probe_location_lookup_method_comm *lookup_comm;
}
lookup_comm = (typeof(lookup_comm)) view->buffer.data;
- type = (enum lttng_userspace_probe_location_lookup_method_type)
- lookup_comm->type;
+ type = (enum lttng_userspace_probe_location_lookup_method_type) lookup_comm->type;
switch (type) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
*lookup_method = NULL;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
- *lookup_method =
- lttng_userspace_probe_location_lookup_method_function_elf_create();
+ *lookup_method = lttng_userspace_probe_location_lookup_method_function_elf_create();
if (!(*lookup_method)) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
int lttng_userspace_probe_location_create_from_payload(
- struct lttng_payload_view *view,
- struct lttng_userspace_probe_location **location)
+ struct lttng_payload_view *view, struct lttng_userspace_probe_location **location)
{
struct lttng_userspace_probe_location_lookup_method *lookup_method;
enum lttng_userspace_probe_location_type type;
int ret;
struct lttng_userspace_probe_location_comm *probe_location_comm;
struct lttng_payload_view probe_location_comm_view =
- lttng_payload_view_from_view(
- view, 0, sizeof(*probe_location_comm));
+ lttng_payload_view_from_view(view, 0, sizeof(*probe_location_comm));
LTTNG_ASSERT(view);
LTTNG_ASSERT(location);
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_userspace_probe_location_function_create_from_payload(
- &location_view, location);
+ ret = lttng_userspace_probe_location_function_create_from_payload(&location_view,
+ location);
if (ret < 0) {
goto end;
}
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
{
struct lttng_payload_view location_view =
- lttng_payload_view_from_view(view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
- ret = lttng_userspace_probe_location_tracepoint_create_from_payload(
- &location_view, location);
+ ret = lttng_userspace_probe_location_tracepoint_create_from_payload(&location_view,
+ location);
if (ret < 0) {
goto end;
}
{
struct lttng_payload_view lookup_method_view =
- lttng_payload_view_from_view(
- view, consumed, -1);
+ lttng_payload_view_from_view(view, consumed, -1);
ret = lttng_userspace_probe_location_lookup_method_create_from_payload(
- &lookup_method_view, &lookup_method);
+ &lookup_method_view, &lookup_method);
}
if (ret < 0) {
ret = -LTTNG_ERR_INVALID;
return ret;
}
-static
-int lttng_userspace_probe_location_function_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd)
+static int lttng_userspace_probe_location_function_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd)
{
int ret = 0;
struct lttng_userspace_probe_location_function *function_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION);
- function_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ function_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
fd_handle_put(function_location->binary_fd_handle);
fd_handle_get(binary_fd);
function_location->binary_fd_handle = binary_fd;
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
- struct lttng_userspace_probe_location *location,
- struct fd_handle *binary_fd)
+static int lttng_userspace_probe_location_tracepoint_set_binary_fd_handle(
+ struct lttng_userspace_probe_location *location, struct fd_handle *binary_fd)
{
int ret = 0;
struct lttng_userspace_probe_location_tracepoint *tracepoint_location;
LTTNG_ASSERT(location);
LTTNG_ASSERT(location->type == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT);
- tracepoint_location = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ tracepoint_location = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
fd_handle_put(tracepoint_location->binary_fd_handle);
fd_handle_get(binary_fd);
tracepoint_location->binary_fd_handle = binary_fd;
return ret;
}
-static
-int lttng_userspace_probe_location_function_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+static int lttng_userspace_probe_location_function_flatten(
+ const struct lttng_userspace_probe_location *location, struct lttng_dynamic_buffer *buffer)
{
struct lttng_userspace_probe_location_lookup_method_elf flat_lookup_method;
struct lttng_userspace_probe_location_function *probe_function;
LTTNG_ASSERT(location);
- if (location->lookup_method && location->lookup_method->type !=
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF) {
+ if (location->lookup_method &&
+ location->lookup_method->type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- probe_function = lttng::utils::container_of(location,
- <tng_userspace_probe_location_function::parent);
+ probe_function = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_function::parent);
LTTNG_ASSERT(probe_function->function_name);
LTTNG_ASSERT(probe_function->binary_path);
- storage_needed +=
- sizeof(struct lttng_userspace_probe_location_function);
+ storage_needed += sizeof(struct lttng_userspace_probe_location_function);
function_name_len = strlen(probe_function->function_name) + 1;
binary_path_len = strlen(probe_function->binary_path) + 1;
storage_needed += function_name_len + binary_path_len;
}
if (lttng_dynamic_buffer_get_capacity_left(buffer) < storage_needed) {
- ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->size + storage_needed);
+ ret = lttng_dynamic_buffer_set_capacity(buffer, buffer->size + storage_needed);
if (ret) {
goto end;
}
*/
if (location->lookup_method) {
flat_probe.parent.lookup_method =
- (struct lttng_userspace_probe_location_lookup_method *)
- (flat_probe_start + sizeof(flat_probe) +
- function_name_len + binary_path_len + padding_needed);
+ (struct lttng_userspace_probe_location_lookup_method
+ *) (flat_probe_start + sizeof(flat_probe) + function_name_len +
+ binary_path_len + padding_needed);
} else {
flat_probe.parent.lookup_method = NULL;
}
flat_probe.function_name = flat_probe_start + sizeof(flat_probe);
flat_probe.binary_path = flat_probe.function_name + function_name_len;
flat_probe.binary_fd_handle = NULL;
- ret = lttng_dynamic_buffer_append(buffer, &flat_probe,
- sizeof(flat_probe));
+ ret = lttng_dynamic_buffer_append(buffer, &flat_probe, sizeof(flat_probe));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_function->function_name, function_name_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_function->function_name, function_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_function->binary_path, binary_path_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_function->binary_path, binary_path_len);
if (ret) {
goto end;
}
/* Insert padding before the lookup method. */
- ret = lttng_dynamic_buffer_set_size(buffer,
- buffer->size + padding_needed);
+ ret = lttng_dynamic_buffer_set_size(buffer, buffer->size + padding_needed);
if (ret) {
goto end;
}
memset(&flat_lookup_method, 0, sizeof(flat_lookup_method));
flat_lookup_method.parent.type =
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF;
- ret = lttng_dynamic_buffer_append(buffer,
- &flat_lookup_method, sizeof(flat_lookup_method));
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF;
+ ret = lttng_dynamic_buffer_append(buffer, &flat_lookup_method, sizeof(flat_lookup_method));
if (ret) {
goto end;
}
return ret;
}
-static
-int lttng_userspace_probe_location_tracepoint_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+static int lttng_userspace_probe_location_tracepoint_flatten(
+ const struct lttng_userspace_probe_location *location, struct lttng_dynamic_buffer *buffer)
{
struct lttng_userspace_probe_location_lookup_method_sdt flat_lookup_method;
struct lttng_userspace_probe_location_tracepoint *probe_tracepoint;
LTTNG_ASSERT(location);
/* Only SDT tracepoints are supported at the moment */
- if (location->lookup_method && location->lookup_method->type !=
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT) {
+ if (location->lookup_method &&
+ location->lookup_method->type !=
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- probe_tracepoint = lttng::utils::container_of(location,
- <tng_userspace_probe_location_tracepoint::parent);
+ probe_tracepoint = lttng::utils::container_of(
+ location, <tng_userspace_probe_location_tracepoint::parent);
LTTNG_ASSERT(probe_tracepoint->probe_name);
LTTNG_ASSERT(probe_tracepoint->provider_name);
LTTNG_ASSERT(probe_tracepoint->binary_path);
if (location->lookup_method) {
/* NOTE: elf look-up method is assumed here. */
- storage_needed +=
- sizeof(struct lttng_userspace_probe_location_lookup_method_elf);
+ storage_needed += sizeof(struct lttng_userspace_probe_location_lookup_method_elf);
}
/*
}
if (lttng_dynamic_buffer_get_capacity_left(buffer) < storage_needed) {
- ret = lttng_dynamic_buffer_set_capacity(buffer,
- buffer->size + storage_needed);
+ ret = lttng_dynamic_buffer_set_capacity(buffer, buffer->size + storage_needed);
if (ret) {
goto end;
}
*/
if (location->lookup_method) {
flat_probe.parent.lookup_method =
- (struct lttng_userspace_probe_location_lookup_method *)
- (flat_probe_start + sizeof(flat_probe) +
- probe_name_len + provider_name_len +
- binary_path_len + padding_needed);
+ (struct lttng_userspace_probe_location_lookup_method
+ *) (flat_probe_start + sizeof(flat_probe) + probe_name_len +
+ provider_name_len + binary_path_len + padding_needed);
} else {
flat_probe.parent.lookup_method = NULL;
}
}
/* Append all the fields to the buffer */
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->probe_name, probe_name_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_tracepoint->probe_name, probe_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->provider_name, provider_name_len);
+ ret = lttng_dynamic_buffer_append(
+ buffer, probe_tracepoint->provider_name, provider_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buffer,
- probe_tracepoint->binary_path, binary_path_len);
+ ret = lttng_dynamic_buffer_append(buffer, probe_tracepoint->binary_path, binary_path_len);
if (ret) {
goto end;
}
memset(&flat_lookup_method, 0, sizeof(flat_lookup_method));
flat_lookup_method.parent.type =
- LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT;
- ret = lttng_dynamic_buffer_append(buffer,
- &flat_lookup_method, sizeof(flat_lookup_method));
+ LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT;
+ ret = lttng_dynamic_buffer_append(buffer, &flat_lookup_method, sizeof(flat_lookup_method));
if (ret) {
goto end;
}
return ret;
}
-int lttng_userspace_probe_location_flatten(
- const struct lttng_userspace_probe_location *location,
- struct lttng_dynamic_buffer *buffer)
+int lttng_userspace_probe_location_flatten(const struct lttng_userspace_probe_location *location,
+ struct lttng_dynamic_buffer *buffer)
{
int ret;
if (!location) {
return ret;
}
-struct lttng_userspace_probe_location *lttng_userspace_probe_location_copy(
- const struct lttng_userspace_probe_location *location)
+struct lttng_userspace_probe_location *
+lttng_userspace_probe_location_copy(const struct lttng_userspace_probe_location *location)
{
struct lttng_userspace_probe_location *new_location = NULL;
enum lttng_userspace_probe_location_type type;
type = lttng_userspace_probe_location_get_type(location);
switch (type) {
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
- new_location =
- lttng_userspace_probe_location_function_copy(location);
+ new_location = lttng_userspace_probe_location_function_copy(location);
if (!new_location) {
goto err;
}
break;
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- new_location =
- lttng_userspace_probe_location_tracepoint_copy(location);
+ new_location = lttng_userspace_probe_location_tracepoint_copy(location);
if (!new_location) {
goto err;
}
}
bool lttng_userspace_probe_location_lookup_method_is_equal(
- const struct lttng_userspace_probe_location_lookup_method *a,
- const struct lttng_userspace_probe_location_lookup_method *b)
+ const struct lttng_userspace_probe_location_lookup_method *a,
+ const struct lttng_userspace_probe_location_lookup_method *b)
{
bool is_equal = false;
return is_equal;
}
-bool lttng_userspace_probe_location_is_equal(
- const struct lttng_userspace_probe_location *a,
- const struct lttng_userspace_probe_location *b)
+bool lttng_userspace_probe_location_is_equal(const struct lttng_userspace_probe_location *a,
+ const struct lttng_userspace_probe_location *b)
{
bool is_equal = false;
goto end;
}
- if (!lttng_userspace_probe_location_lookup_method_is_equal(
- a->lookup_method, b->lookup_method)) {
+ if (!lttng_userspace_probe_location_lookup_method_is_equal(a->lookup_method,
+ b->lookup_method)) {
goto end;
}
return is_equal;
}
-unsigned long lttng_userspace_probe_location_hash(
- const struct lttng_userspace_probe_location *location)
+unsigned long
+lttng_userspace_probe_location_hash(const struct lttng_userspace_probe_location *location)
{
return location->hash(location);
}
-enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+enum lttng_error_code
+lttng_userspace_probe_location_mi_serialize(const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer)
{
- typedef enum lttng_error_code (*mi_fp)(
- const struct lttng_userspace_probe_location *,
- struct mi_writer *);
+ typedef enum lttng_error_code (*mi_fp)(const struct lttng_userspace_probe_location *,
+ struct mi_writer *);
int ret;
enum lttng_error_code ret_code;
}
/* Open userspace probe location element. */
- ret = mi_lttng_writer_open_element(
- writer, mi_lttng_element_userspace_probe_location);
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_userspace_probe_location);
if (ret) {
goto mi_error;
}
}
enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
- const struct lttng_userspace_probe_location_lookup_method
- *method,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location_lookup_method *method, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
switch (lttng_userspace_probe_location_lookup_method_get_type(method)) {
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
break;
case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
type_element_str =
- mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
break;
default:
abort();
/* Open userspace probe location lookup method element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_lookup_method);
+ mi_lttng_element_userspace_probe_location_lookup_method);
if (ret) {
goto mi_error;
}
}
static enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
const char *probe_name = NULL;
const char *provider_name = NULL;
const char *binary_path = NULL;
- const struct lttng_userspace_probe_location_lookup_method
- *lookup_method = NULL;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
- probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
- location);
- provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
- location);
- binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
- location);
- lookup_method = lttng_userspace_probe_location_tracepoint_get_lookup_method(
- location);
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
+ lookup_method = lttng_userspace_probe_location_tracepoint_get_lookup_method(location);
/* Open userspace probe location tracepoint element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_tracepoint);
+ mi_lttng_element_userspace_probe_location_tracepoint);
if (ret) {
goto mi_error;
}
/* Probe name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_tracepoint_probe_name,
- probe_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name,
+ probe_name);
if (ret) {
goto mi_error;
}
/* Provider name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_tracepoint_provider_name,
- provider_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name,
+ provider_name);
if (ret) {
goto mi_error;
}
/* Binary path. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto mi_error;
}
/* The lookup method. */
- ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
- lookup_method, writer);
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(lookup_method, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
}
static enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
- const struct lttng_userspace_probe_location *location,
- struct mi_writer *writer)
+ const struct lttng_userspace_probe_location *location, struct mi_writer *writer)
{
int ret;
enum lttng_error_code ret_code;
const char *function_name = NULL;
const char *binary_path = NULL;
const char *instrumentation_type_str = NULL;
- enum lttng_userspace_probe_location_function_instrumentation_type
- instrumentation_type;
- const struct lttng_userspace_probe_location_lookup_method
- *lookup_method = NULL;
+ enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type;
+ const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
LTTNG_ASSERT(location);
LTTNG_ASSERT(writer);
- function_name = lttng_userspace_probe_location_function_get_function_name(
- location);
- binary_path = lttng_userspace_probe_location_function_get_binary_path(
- location);
+ function_name = lttng_userspace_probe_location_function_get_function_name(location);
+ binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
instrumentation_type =
- lttng_userspace_probe_location_function_get_instrumentation_type(
- location);
- lookup_method = lttng_userspace_probe_location_function_get_lookup_method(
- location);
+ lttng_userspace_probe_location_function_get_instrumentation_type(location);
+ lookup_method = lttng_userspace_probe_location_function_get_lookup_method(location);
switch (instrumentation_type) {
case LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY:
instrumentation_type_str =
- mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
break;
default:
abort();
/* Open userspace probe location function element. */
ret = mi_lttng_writer_open_element(writer,
- mi_lttng_element_userspace_probe_location_function);
+ mi_lttng_element_userspace_probe_location_function);
if (ret) {
goto mi_error;
}
/* Function name. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_function_name,
- function_name);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_function_name, function_name);
if (ret) {
goto mi_error;
}
/* Binary path. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_binary_path,
- binary_path);
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_userspace_probe_location_binary_path, binary_path);
if (ret) {
goto mi_error;
}
/* Instrumentation type. */
- ret = mi_lttng_writer_write_element_string(writer,
- mi_lttng_element_userspace_probe_location_function_instrumentation_type,
- instrumentation_type_str);
+ ret = mi_lttng_writer_write_element_string(
+ writer,
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type,
+ instrumentation_type_str);
if (ret) {
goto mi_error;
}
/* The lookup method. */
- ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
- lookup_method, writer);
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(lookup_method, writer);
if (ret_code != LTTNG_OK) {
goto end;
}
*/
#define _LGPL_SOURCE
+#include "ust-consumer.hpp"
+
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/fcntl.hpp>
+#include <common/consumer/consumer-metadata-cache.hpp>
+#include <common/consumer/consumer-stream.hpp>
+#include <common/consumer/consumer-timer.hpp>
+#include <common/consumer/consumer.hpp>
+#include <common/index/index.hpp>
+#include <common/optional.hpp>
+#include <common/relayd/relayd.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/shm.hpp>
+#include <common/utils.hpp>
+
#include <lttng/ust-ctl.h>
#include <lttng/ust-sigbus.h>
+
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <inttypes.h>
#include <poll.h>
#include <pthread.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <inttypes.h>
#include <unistd.h>
#include <urcu/list.h>
-#include <signal.h>
-#include <stdbool.h>
-#include <stdint.h>
-#include <bin/lttng-consumerd/health-consumerd.hpp>
-#include <common/common.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/relayd/relayd.hpp>
-#include <common/compat/fcntl.hpp>
-#include <common/compat/endian.hpp>
-#include <common/consumer/consumer-metadata-cache.hpp>
-#include <common/consumer/consumer-stream.hpp>
-#include <common/consumer/consumer-timer.hpp>
-#include <common/utils.hpp>
-#include <common/index/index.hpp>
-#include <common/consumer/consumer.hpp>
-#include <common/shm.hpp>
-#include <common/optional.hpp>
-
-#include "ust-consumer.hpp"
-
-#define INT_MAX_STR_LEN 12 /* includes \0 */
+#define INT_MAX_STR_LEN 12 /* includes \0 */
extern struct lttng_consumer_global_data the_consumer_data;
extern int consumer_poll_timeout;
* Returns 0 on success or else a negative value.
*/
static int add_channel(struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret = 0;
*
* Return NULL on error else the newly allocated stream object.
*/
-static struct lttng_consumer_stream *allocate_stream(int cpu, int key,
- struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx, int *_alloc_ret)
+static struct lttng_consumer_stream *allocate_stream(int cpu,
+ int key,
+ struct lttng_consumer_channel *channel,
+ struct lttng_consumer_local_data *ctx,
+ int *_alloc_ret)
{
int alloc_ret;
struct lttng_consumer_stream *stream = NULL;
LTTNG_ASSERT(channel);
LTTNG_ASSERT(ctx);
- stream = consumer_stream_create(
- channel,
- channel->key,
- key,
- channel->name,
- channel->relayd_id,
- channel->session_id,
- channel->trace_chunk,
- cpu,
- &alloc_ret,
- channel->type,
- channel->monitor);
+ stream = consumer_stream_create(channel,
+ channel->key,
+ key,
+ channel->name,
+ channel->relayd_id,
+ channel->session_id,
+ channel->trace_chunk,
+ cpu,
+ &alloc_ret,
+ channel->type,
+ channel->monitor);
if (stream == NULL) {
switch (alloc_ret) {
case -ENOENT:
* Returns 0 on success else a negative value.
*/
static int send_stream_to_thread(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret;
struct lttng_pipe *stream_pipe;
ret = lttng_pipe_write(stream_pipe, &stream, sizeof(stream));
if (ret < 0) {
ERR("Consumer write %s stream to pipe %d",
- stream->metadata_flag ? "metadata" : "data",
- lttng_pipe_get_writefd(stream_pipe));
+ stream->metadata_flag ? "metadata" : "data",
+ lttng_pipe_get_writefd(stream_pipe));
if (stream->metadata_flag) {
consumer_del_stream_for_metadata(stream);
} else {
return ret;
}
-static
-int get_stream_shm_path(char *stream_shm_path, const char *shm_path, int cpu)
+static int get_stream_shm_path(char *stream_shm_path, const char *shm_path, int cpu)
{
- char cpu_nr[INT_MAX_STR_LEN]; /* int max len */
+ char cpu_nr[INT_MAX_STR_LEN]; /* int max len */
int ret;
strncpy(stream_shm_path, shm_path, PATH_MAX);
PERROR("snprintf");
goto end;
}
- strncat(stream_shm_path, cpu_nr,
- PATH_MAX - strlen(stream_shm_path) - 1);
+ strncat(stream_shm_path, cpu_nr, PATH_MAX - strlen(stream_shm_path) - 1);
ret = 0;
end:
return ret;
* Return 0 on success else a negative value.
*/
static int create_ust_streams(struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret, cpu = 0;
struct lttng_ust_ctl_consumer_stream *ustream;
*/
cds_list_add_tail(&stream->send_node, &channel->streams.head);
- ret = lttng_ust_ctl_get_max_subbuf_size(stream->ustream,
- &stream->max_sb_size);
+ ret = lttng_ust_ctl_get_max_subbuf_size(stream->ustream, &stream->max_sb_size);
if (ret < 0) {
- ERR("lttng_ust_ctl_get_max_subbuf_size failed for stream %s",
- stream->name);
+ ERR("lttng_ust_ctl_get_max_subbuf_size failed for stream %s", stream->name);
goto error;
}
}
DBG("UST consumer add stream %s (key: %" PRIu64 ") with relayd id %" PRIu64,
- stream->name, stream->key, stream->relayd_stream_id);
+ stream->name,
+ stream->key,
+ stream->relayd_stream_id);
/* Set next CPU stream. */
channel->streams.count = ++cpu;
if (channel->monitor) {
/* Set metadata poll pipe if we created one */
memcpy(stream->ust_metadata_poll_pipe,
- ust_metadata_pipe,
- sizeof(ust_metadata_pipe));
+ ust_metadata_pipe,
+ sizeof(ust_metadata_pipe));
}
}
pthread_mutex_unlock(&stream->lock);
return ret;
}
-static int open_ust_stream_fd(struct lttng_consumer_channel *channel, int cpu,
- const struct lttng_credentials *session_credentials)
+static int open_ust_stream_fd(struct lttng_consumer_channel *channel,
+ int cpu,
+ const struct lttng_credentials *session_credentials)
{
char shm_path[PATH_MAX];
int ret;
goto error_shm_path;
}
return run_as_open(shm_path,
- O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR,
- lttng_credentials_get_uid(session_credentials),
- lttng_credentials_get_gid(session_credentials));
+ O_RDWR | O_CREAT | O_EXCL,
+ S_IRUSR | S_IWUSR,
+ lttng_credentials_get_uid(session_credentials),
+ lttng_credentials_get_gid(session_credentials));
error_shm_path:
return -1;
* Return 0 on success or else a negative value.
*/
static int create_ust_channel(struct lttng_consumer_channel *channel,
- struct lttng_ust_ctl_consumer_channel_attr *attr,
- struct lttng_ust_ctl_consumer_channel **ust_chanp)
+ struct lttng_ust_ctl_consumer_channel_attr *attr,
+ struct lttng_ust_ctl_consumer_channel **ust_chanp)
{
int ret, nr_stream_fds, i, j;
int *stream_fds;
LTTNG_ASSERT(channel->buffer_credentials.is_set);
DBG3("Creating channel to ustctl with attr: [overwrite: %d, "
- "subbuf_size: %" PRIu64 ", num_subbuf: %" PRIu64 ", "
- "switch_timer_interval: %u, read_timer_interval: %u, "
- "output: %d, type: %d", attr->overwrite, attr->subbuf_size,
- attr->num_subbuf, attr->switch_timer_interval,
- attr->read_timer_interval, attr->output, attr->type);
+ "subbuf_size: %" PRIu64 ", num_subbuf: %" PRIu64 ", "
+ "switch_timer_interval: %u, read_timer_interval: %u, "
+ "output: %d, type: %d",
+ attr->overwrite,
+ attr->subbuf_size,
+ attr->num_subbuf,
+ attr->switch_timer_interval,
+ attr->read_timer_interval,
+ attr->output,
+ attr->type);
if (channel->type == CONSUMER_CHANNEL_TYPE_METADATA)
nr_stream_fds = 1;
goto error_alloc;
}
for (i = 0; i < nr_stream_fds; i++) {
- stream_fds[i] = open_ust_stream_fd(channel, i,
- &channel->buffer_credentials.value);
+ stream_fds[i] = open_ust_stream_fd(channel, i, &channel->buffer_credentials.value);
if (stream_fds[i] < 0) {
ret = -1;
goto error_open;
if (channel->shm_path[0]) {
char shm_path[PATH_MAX];
- closeret = get_stream_shm_path(shm_path,
- channel->shm_path, j);
+ closeret = get_stream_shm_path(shm_path, channel->shm_path, j);
if (closeret) {
ERR("Cannot get stream shm path");
}
closeret = run_as_unlink(shm_path,
- lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
- channel->buffer_credentials)),
- lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
- channel->buffer_credentials)));
+ lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
+ channel->buffer_credentials)),
+ lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
+ channel->buffer_credentials)));
if (closeret) {
PERROR("unlink %s", shm_path);
}
/* Try to rmdir all directories under shm_path root. */
if (channel->root_shm_path[0]) {
(void) run_as_rmdir_recursive(channel->root_shm_path,
- lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
- channel->buffer_credentials)),
- lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
- channel->buffer_credentials)),
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
+ channel->buffer_credentials)),
+ lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
+ channel->buffer_credentials)),
+ LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
}
free(stream_fds);
error_alloc:
* Return 0 on success or else a negative value.
*/
static int send_channel_to_sessiond_and_relayd(int sock,
- struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx, int *relayd_error)
+ struct lttng_consumer_channel *channel,
+ struct lttng_consumer_local_data *ctx,
+ int *relayd_error)
{
int ret, ret_code = LTTCOMM_CONSUMERD_SUCCESS;
struct lttng_consumer_stream *stream;
DBG("UST consumer sending channel %s to sessiond", channel->name);
if (channel->relayd_id != (uint64_t) -1ULL) {
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
-
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
health_code_update();
/* Try to send the stream to the relayd if one is available. */
DBG("Sending stream %" PRIu64 " of channel \"%s\" to relayd",
- stream->key, channel->name);
+ stream->key,
+ channel->name);
ret = consumer_send_relayd_stream(stream, stream->chan->pathname);
if (ret < 0) {
/*
}
/* The channel was sent successfully to the sessiond at this point. */
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
-
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
health_code_update();
/* Send stream to session daemon. */
* MUST be destroyed by consumer_del_channel().
*/
static int ask_channel(struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_channel *channel,
- struct lttng_ust_ctl_consumer_channel_attr *attr)
+ struct lttng_consumer_channel *channel,
+ struct lttng_ust_ctl_consumer_channel_attr *attr)
{
int ret;
* On error, return a negative value else 0 on success.
*/
static int send_streams_to_thread(struct lttng_consumer_channel *channel,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret = 0;
struct lttng_consumer_stream *stream, *stmp;
LTTNG_ASSERT(ctx);
/* Send streams to the corresponding thread. */
- cds_list_for_each_entry_safe(stream, stmp, &channel->streams.head,
- send_node) {
-
+ cds_list_for_each_entry_safe (stream, stmp, &channel->streams.head, send_node) {
health_code_update();
/* Sending the stream to the thread. */
/* For each stream of the channel id, flush it. */
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct,
- &channel->key, &iter.iter, stream, node_channel_id.node) {
-
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
health_code_update();
pthread_mutex_lock(&stream->lock);
if (!stream->quiescent) {
ret = lttng_ust_ctl_flush_buffer(stream->ustream, 0);
if (ret) {
- ERR("Failed to flush buffer while flushing channel: channel key = %" PRIu64 ", channel name = '%s'",
- chan_key, channel->name);
+ ERR("Failed to flush buffer while flushing channel: channel key = %" PRIu64
+ ", channel name = '%s'",
+ chan_key,
+ channel->name);
ret = LTTNG_ERR_BUFFER_FLUSH_FAILED;
pthread_mutex_unlock(&stream->lock);
goto error;
}
stream->quiescent = true;
}
-next:
+ next:
pthread_mutex_unlock(&stream->lock);
}
/* For each stream of the channel id, clear quiescent state. */
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct,
- &channel->key, &iter.iter, stream, node_channel_id.node) {
-
+ ht->hash_fct(&channel->key, lttng_ht_seed),
+ ht->match_fct,
+ &channel->key,
+ &iter.iter,
+ stream,
+ node_channel_id.node)
+ {
health_code_update();
pthread_mutex_lock(&stream->lock);
/* Send metadata stream to relayd if needed. */
if (metadata->metadata_stream->net_seq_idx != (uint64_t) -1ULL) {
- ret = consumer_send_relayd_stream(metadata->metadata_stream,
- metadata->pathname);
+ ret = consumer_send_relayd_stream(metadata->metadata_stream, metadata->pathname);
if (ret < 0) {
ret = LTTCOMM_CONSUMERD_ERROR_METADATA;
goto error;
}
- ret = consumer_send_relayd_streams_sent(
- metadata->metadata_stream->net_seq_idx);
+ ret = consumer_send_relayd_streams_sent(metadata->metadata_stream->net_seq_idx);
if (ret < 0) {
ret = LTTCOMM_CONSUMERD_RELAYD_FAIL;
goto error;
* Returns 0 on success, < 0 on error
*/
static int snapshot_metadata(struct lttng_consumer_channel *metadata_channel,
- uint64_t key, char *path, uint64_t relayd_id,
- struct lttng_consumer_local_data *ctx)
+ uint64_t key,
+ char *path,
+ uint64_t relayd_id,
+ struct lttng_consumer_local_data *ctx)
{
int ret = 0;
struct lttng_consumer_stream *metadata_stream;
LTTNG_ASSERT(ctx);
ASSERT_RCU_READ_LOCKED();
- DBG("UST consumer snapshot metadata with key %" PRIu64 " at path %s",
- key, path);
+ DBG("UST consumer snapshot metadata with key %" PRIu64 " at path %s", key, path);
rcu_read_lock();
metadata_stream->net_seq_idx = relayd_id;
ret = consumer_send_relayd_stream(metadata_stream, path);
} else {
- ret = consumer_stream_create_output_files(metadata_stream,
- false);
+ ret = consumer_stream_create_output_files(metadata_stream, false);
}
if (ret < 0) {
goto error_stream;
return ret;
}
-static
-int get_current_subbuf_addr(struct lttng_consumer_stream *stream,
- const char **addr)
+static int get_current_subbuf_addr(struct lttng_consumer_stream *stream, const char **addr)
{
int ret;
unsigned long mmap_offset;
mmap_base = (const char *) lttng_ust_ctl_get_mmap_base(stream->ustream);
if (!mmap_base) {
- ERR("Failed to get mmap base for stream `%s`",
- stream->name);
+ ERR("Failed to get mmap base for stream `%s`", stream->name);
ret = -EPERM;
goto error;
}
*addr = mmap_base + mmap_offset;
error:
return ret;
-
}
/*
* Returns 0 on success, < 0 on error
*/
static int snapshot_channel(struct lttng_consumer_channel *channel,
- uint64_t key, char *path, uint64_t relayd_id,
- uint64_t nb_packets_per_stream,
- struct lttng_consumer_local_data *ctx)
+ uint64_t key,
+ char *path,
+ uint64_t relayd_id,
+ uint64_t nb_packets_per_stream,
+ struct lttng_consumer_local_data *ctx)
{
int ret;
unsigned use_relayd = 0;
LTTNG_ASSERT(!channel->monitor);
DBG("UST consumer snapshot channel %" PRIu64, key);
- cds_list_for_each_entry(stream, &channel->streams.head, send_node) {
+ cds_list_for_each_entry (stream, &channel->streams.head, send_node) {
health_code_update();
/* Lock stream because we are about to change its state. */
goto error_close_stream;
}
} else {
- ret = consumer_stream_create_output_files(stream,
- false);
+ ret = consumer_stream_create_output_files(stream, false);
if (ret < 0) {
goto error_close_stream;
}
- DBG("UST consumer snapshot stream (%" PRIu64 ")",
- stream->key);
+ DBG("UST consumer snapshot stream (%" PRIu64 ")", stream->key);
}
/*
if (!stream->quiescent) {
ret = lttng_ust_ctl_flush_buffer(stream->ustream, 0);
if (ret < 0) {
- ERR("Failed to flush buffer during snapshot of channel: channel key = %" PRIu64 ", channel name = '%s'",
- channel->key, channel->name);
+ ERR("Failed to flush buffer during snapshot of channel: channel key = %" PRIu64
+ ", channel name = '%s'",
+ channel->key,
+ channel->name);
goto error_unlock;
}
}
* daemon should never send a maximum stream size that is lower than
* subbuffer size.
*/
- consumed_pos = consumer_get_consume_start_pos(consumed_pos,
- produced_pos, nb_packets_per_stream,
- stream->max_sb_size);
+ consumed_pos = consumer_get_consume_start_pos(
+ consumed_pos, produced_pos, nb_packets_per_stream, stream->max_sb_size);
while ((long) (consumed_pos - produced_pos) < 0) {
ssize_t read_len;
goto error_put_subbuf;
}
- subbuf_view = lttng_buffer_view_init(
- subbuf_addr, 0, padded_len);
+ subbuf_view = lttng_buffer_view_init(subbuf_addr, 0, padded_len);
read_len = lttng_consumer_on_read_subbuffer_mmap(
- stream, &subbuf_view, padded_len - len);
+ stream, &subbuf_view, padded_len - len);
if (use_relayd) {
if (read_len != len) {
ret = -EPERM;
return ret;
}
-static
-void metadata_stream_reset_cache_consumed_position(
- struct lttng_consumer_stream *stream)
+static void metadata_stream_reset_cache_consumed_position(struct lttng_consumer_stream *stream)
{
ASSERT_LOCKED(stream->lock);
- DBG("Reset metadata cache of session %" PRIu64,
- stream->chan->session_id);
+ DBG("Reset metadata cache of session %" PRIu64, stream->chan->session_id);
stream->ust_metadata_pushed = 0;
}
* the metadata cache flush to concurrently progress in order to
* complete.
*/
-int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset,
- uint64_t len, uint64_t version,
- struct lttng_consumer_channel *channel, int timer, int wait)
+int lttng_ustconsumer_recv_metadata(int sock,
+ uint64_t key,
+ uint64_t offset,
+ uint64_t len,
+ uint64_t version,
+ struct lttng_consumer_channel *channel,
+ int timer,
+ int wait)
{
int ret, ret_code = LTTCOMM_CONSUMERD_SUCCESS;
char *metadata_str;
pthread_mutex_lock(&channel->metadata_cache->lock);
cache_write_status = consumer_metadata_cache_write(
- channel->metadata_cache, offset, len, version,
- metadata_str);
+ channel->metadata_cache, offset, len, version, metadata_str);
pthread_mutex_unlock(&channel->metadata_cache->lock);
switch (cache_write_status) {
case CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE:
*/
if (channel->metadata_stream != NULL) {
pthread_mutex_lock(&channel->metadata_stream->lock);
- metadata_stream_reset_cache_consumed_position(
- channel->metadata_stream);
+ metadata_stream_reset_cache_consumed_position(channel->metadata_stream);
pthread_mutex_unlock(&channel->metadata_stream->lock);
} else {
/* Validate we are in snapshot mode. */
* Return 1 on success else a negative value or 0.
*/
int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
- int sock, struct pollfd *consumer_sockpoll)
+ int sock,
+ struct pollfd *consumer_sockpoll)
{
int ret_func;
enum lttcomm_return_code ret_code = LTTCOMM_CONSUMERD_SUCCESS;
ret_recv = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg));
if (ret_recv != sizeof(msg)) {
DBG("Consumer received unexpected message size %zd (expects %zu)",
- ret_recv, sizeof(msg));
+ ret_recv,
+ sizeof(msg));
/*
* The ret value might 0 meaning an orderly shutdown but this is ok
* since the caller handles this.
*/
if (ret_recv > 0) {
- lttng_consumer_send_error(ctx,
- LTTCOMM_CONSUMERD_ERROR_RECV_CMD);
+ lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD);
ret_recv = -1;
}
return ret_recv;
uint32_t major = msg.u.relayd_sock.major;
uint32_t minor = msg.u.relayd_sock.minor;
enum lttcomm_sock_proto protocol =
- (enum lttcomm_sock_proto) msg.u.relayd_sock
- .relayd_socket_protocol;
+ (enum lttcomm_sock_proto) msg.u.relayd_sock.relayd_socket_protocol;
/* Session daemon status message are handled in the following call. */
consumer_add_relayd_socket(msg.u.relayd_sock.net_index,
- msg.u.relayd_sock.type, ctx, sock,
- consumer_sockpoll, msg.u.relayd_sock.session_id,
- msg.u.relayd_sock.relayd_session_id, major,
- minor, protocol);
+ msg.u.relayd_sock.type,
+ ctx,
+ sock,
+ consumer_sockpoll,
+ msg.u.relayd_sock.session_id,
+ msg.u.relayd_sock.relayd_session_id,
+ major,
+ minor,
+ protocol);
goto end_nosignal;
}
case LTTNG_CONSUMER_DESTROY_RELAYD:
is_data_pending = consumer_data_pending(id);
/* Send back returned value to session daemon */
- ret_send = lttcomm_send_unix_sock(sock, &is_data_pending,
- sizeof(is_data_pending));
+ ret_send = lttcomm_send_unix_sock(sock, &is_data_pending, sizeof(is_data_pending));
if (ret_send < 0) {
- DBG("Error when sending the data pending ret code: %zd",
- ret_send);
+ DBG("Error when sending the data pending ret code: %zd", ret_send);
goto error_fatal;
}
/* Create a plain object and reserve a channel key. */
channel = consumer_allocate_channel(
- msg.u.ask_channel.key,
- msg.u.ask_channel.session_id,
- msg.u.ask_channel.chunk_id.is_set ?
- &chunk_id : NULL,
- msg.u.ask_channel.pathname,
- msg.u.ask_channel.name,
- msg.u.ask_channel.relayd_id,
- (enum lttng_event_output) msg.u.ask_channel.output,
- msg.u.ask_channel.tracefile_size,
- msg.u.ask_channel.tracefile_count,
- msg.u.ask_channel.session_id_per_pid,
- msg.u.ask_channel.monitor,
- msg.u.ask_channel.live_timer_interval,
- msg.u.ask_channel.is_live,
- msg.u.ask_channel.root_shm_path,
- msg.u.ask_channel.shm_path);
+ msg.u.ask_channel.key,
+ msg.u.ask_channel.session_id,
+ msg.u.ask_channel.chunk_id.is_set ? &chunk_id : NULL,
+ msg.u.ask_channel.pathname,
+ msg.u.ask_channel.name,
+ msg.u.ask_channel.relayd_id,
+ (enum lttng_event_output) msg.u.ask_channel.output,
+ msg.u.ask_channel.tracefile_size,
+ msg.u.ask_channel.tracefile_count,
+ msg.u.ask_channel.session_id_per_pid,
+ msg.u.ask_channel.monitor,
+ msg.u.ask_channel.live_timer_interval,
+ msg.u.ask_channel.is_live,
+ msg.u.ask_channel.root_shm_path,
+ msg.u.ask_channel.shm_path);
if (!channel) {
goto end_channel_error;
}
- LTTNG_OPTIONAL_SET(&channel->buffer_credentials,
- buffer_credentials);
+ LTTNG_OPTIONAL_SET(&channel->buffer_credentials, buffer_credentials);
/*
* Assign UST application UID to the channel. This value is ignored for
attr.read_timer_interval = msg.u.ask_channel.read_timer_interval;
attr.chan_id = msg.u.ask_channel.chan_id;
memcpy(attr.uuid, msg.u.ask_channel.uuid, sizeof(attr.uuid));
- attr.blocking_timeout= msg.u.ask_channel.blocking_timeout;
+ attr.blocking_timeout = msg.u.ask_channel.blocking_timeout;
/* Match channel buffer type to the UST abi. */
switch (msg.u.ask_channel.output) {
if (msg.u.ask_channel.type == LTTNG_UST_ABI_CHAN_METADATA) {
int ret_allocate;
- ret_allocate = consumer_metadata_cache_allocate(
- channel);
+ ret_allocate = consumer_metadata_cache_allocate(channel);
if (ret_allocate < 0) {
ERR("Allocating metadata cache");
goto end_channel_error;
} else {
int monitor_start_ret;
- consumer_timer_live_start(channel,
- msg.u.ask_channel.live_timer_interval);
+ consumer_timer_live_start(channel, msg.u.ask_channel.live_timer_interval);
monitor_start_ret = consumer_timer_monitor_start(
- channel,
- msg.u.ask_channel.monitor_timer_interval);
+ channel, msg.u.ask_channel.monitor_timer_interval);
if (monitor_start_ret < 0) {
ERR("Starting channel monitoring timer failed");
goto end_channel_error;
health_code_update();
/* Send the channel to sessiond (and relayd, if applicable). */
- ret = send_channel_to_sessiond_and_relayd(
- sock, found_channel, ctx, &relayd_err);
+ ret = send_channel_to_sessiond_and_relayd(sock, found_channel, ctx, &relayd_err);
if (ret < 0) {
if (relayd_err) {
/*
}
/* List MUST be empty after or else it could be reused. */
LTTNG_ASSERT(cds_list_empty(&found_channel->streams.head));
-end_get_channel:
+ end_get_channel:
goto end_msg_sessiond;
-error_get_channel_fatal:
+ error_get_channel_fatal:
goto error_fatal;
-end_get_channel_nosignal:
+ end_get_channel_nosignal:
goto end_nosignal;
}
case LTTNG_CONSUMER_DESTROY_CHANNEL:
{
int ret;
- ret = clear_quiescent_channel(
- msg.u.clear_quiescent_channel.key);
+ ret = clear_quiescent_channel(msg.u.clear_quiescent_channel.key);
if (ret != 0) {
ret_code = (lttcomm_return_code) ret;
}
uint64_t version = msg.u.push_metadata.version;
struct lttng_consumer_channel *found_channel;
- DBG("UST consumer push metadata key %" PRIu64 " of len %" PRIu64, key,
- len);
+ DBG("UST consumer push metadata key %" PRIu64 " of len %" PRIu64, key, len);
found_channel = consumer_find_channel(key);
if (!found_channel) {
health_code_update();
- ret = lttng_ustconsumer_recv_metadata(sock, key, offset, len,
- version, found_channel, 0, 1);
+ ret = lttng_ustconsumer_recv_metadata(
+ sock, key, offset, len, version, found_channel, 0, 1);
if (ret < 0) {
/* error receiving from sessiond */
goto error_push_metadata_fatal;
ret_code = (lttcomm_return_code) ret;
goto end_push_metadata_msg_sessiond;
}
-end_push_metadata_msg_sessiond:
+ end_push_metadata_msg_sessiond:
goto end_msg_sessiond;
-error_push_metadata_fatal:
+ error_push_metadata_fatal:
goto error_fatal;
}
case LTTNG_CONSUMER_SETUP_METADATA:
int ret_snapshot;
ret_snapshot = snapshot_metadata(found_channel,
- key,
- msg.u.snapshot_channel.pathname,
- msg.u.snapshot_channel.relayd_id,
- ctx);
+ key,
+ msg.u.snapshot_channel.pathname,
+ msg.u.snapshot_channel.relayd_id,
+ ctx);
if (ret_snapshot < 0) {
ERR("Snapshot metadata failed");
ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED;
} else {
int ret_snapshot;
- ret_snapshot = snapshot_channel(found_channel,
- key,
- msg.u.snapshot_channel.pathname,
- msg.u.snapshot_channel.relayd_id,
- msg.u.snapshot_channel
- .nb_packets_per_stream,
- ctx);
+ ret_snapshot = snapshot_channel(
+ found_channel,
+ key,
+ msg.u.snapshot_channel.pathname,
+ msg.u.snapshot_channel.relayd_id,
+ msg.u.snapshot_channel.nb_packets_per_stream,
+ ctx);
if (ret_snapshot < 0) {
ERR("Snapshot channel failed");
ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED;
uint64_t id = msg.u.discarded_events.session_id;
uint64_t key = msg.u.discarded_events.channel_key;
- DBG("UST consumer discarded events command for session id %"
- PRIu64, id);
+ DBG("UST consumer discarded events command for session id %" PRIu64, id);
rcu_read_lock();
pthread_mutex_lock(&the_consumer_data.lock);
*/
discarded_events = 0;
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&id, lttng_ht_seed),
- ht->match_fct, &id,
- &iter.iter, stream, node_session_id.node) {
+ ht->hash_fct(&id, lttng_ht_seed),
+ ht->match_fct,
+ &id,
+ &iter.iter,
+ stream,
+ node_session_id.node)
+ {
if (stream->chan->key == key) {
discarded_events = stream->chan->discarded_events;
break;
pthread_mutex_unlock(&the_consumer_data.lock);
rcu_read_unlock();
- DBG("UST consumer discarded events command for session id %"
- PRIu64 ", channel key %" PRIu64, id, key);
+ DBG("UST consumer discarded events command for session id %" PRIu64
+ ", channel key %" PRIu64,
+ id,
+ key);
health_code_update();
}
case LTTNG_CONSUMER_LOST_PACKETS:
{
- int ret;
+ int ret;
uint64_t lost_packets;
struct lttng_ht_iter iter;
struct lttng_ht *ht;
uint64_t id = msg.u.lost_packets.session_id;
uint64_t key = msg.u.lost_packets.channel_key;
- DBG("UST consumer lost packets command for session id %"
- PRIu64, id);
+ DBG("UST consumer lost packets command for session id %" PRIu64, id);
rcu_read_lock();
pthread_mutex_lock(&the_consumer_data.lock);
* to extract the information we need, we default to 0 if not
* found (no packets lost if the channel is not yet in use).
*/
- lost_packets = 0;
+ lost_packets = 0;
cds_lfht_for_each_entry_duplicate(ht->ht,
- ht->hash_fct(&id, lttng_ht_seed),
- ht->match_fct, &id,
- &iter.iter, stream, node_session_id.node) {
+ ht->hash_fct(&id, lttng_ht_seed),
+ ht->match_fct,
+ &id,
+ &iter.iter,
+ stream,
+ node_session_id.node)
+ {
if (stream->chan->key == key) {
- lost_packets = stream->chan->lost_packets;
+ lost_packets = stream->chan->lost_packets;
break;
}
}
pthread_mutex_unlock(&the_consumer_data.lock);
rcu_read_unlock();
- DBG("UST consumer lost packets command for session id %"
- PRIu64 ", channel key %" PRIu64, id, key);
+ DBG("UST consumer lost packets command for session id %" PRIu64
+ ", channel key %" PRIu64,
+ id,
+ key);
health_code_update();
/* Send back returned value to session daemon */
- ret = lttcomm_send_unix_sock(sock, &lost_packets,
- sizeof(lost_packets));
+ ret = lttcomm_send_unix_sock(sock, &lost_packets, sizeof(lost_packets));
if (ret < 0) {
PERROR("send lost packets");
goto error_fatal;
}
case LTTNG_CONSUMER_SET_CHANNEL_MONITOR_PIPE:
{
- int channel_monitor_pipe, ret_send,
- ret_set_channel_monitor_pipe;
+ int channel_monitor_pipe, ret_send, ret_set_channel_monitor_pipe;
ssize_t ret_recv;
ret_code = LTTCOMM_CONSUMERD_SUCCESS;
goto error_fatal;
}
- ret_recv = lttcomm_recv_fds_unix_sock(
- sock, &channel_monitor_pipe, 1);
+ ret_recv = lttcomm_recv_fds_unix_sock(sock, &channel_monitor_pipe, 1);
if (ret_recv != sizeof(channel_monitor_pipe)) {
ERR("Failed to receive channel monitor pipe");
goto error_fatal;
DBG("Received channel monitor pipe (%d)", channel_monitor_pipe);
ret_set_channel_monitor_pipe =
- consumer_timer_thread_set_channel_monitor_pipe(
- channel_monitor_pipe);
+ consumer_timer_thread_set_channel_monitor_pipe(channel_monitor_pipe);
if (!ret_set_channel_monitor_pipe) {
int flags;
int ret_fcntl;
}
flags = ret_fcntl;
- ret_fcntl = fcntl(channel_monitor_pipe, F_SETFL,
- flags | O_NONBLOCK);
+ ret_fcntl = fcntl(channel_monitor_pipe, F_SETFL, flags | O_NONBLOCK);
if (ret_fcntl == -1) {
PERROR("fcntl set O_NONBLOCK flag of the channel monitoring pipe");
goto error_fatal;
* this channel.
*/
rotate_channel = lttng_consumer_rotate_channel(
- found_channel, key,
- msg.u.rotate_channel.relayd_id);
+ found_channel, key, msg.u.rotate_channel.relayd_id);
if (rotate_channel < 0) {
ERR("Rotate channel failed");
ret_code = LTTCOMM_CONSUMERD_ROTATION_FAIL;
int ret_rotate_read_streams;
ret_rotate_read_streams =
- lttng_consumer_rotate_ready_streams(
- found_channel, key);
+ lttng_consumer_rotate_ready_streams(found_channel, key);
if (ret_rotate_read_streams < 0) {
ERR("Rotate channel failed");
}
}
break;
-end_rotate_channel_nosignal:
+ end_rotate_channel_nosignal:
goto end_nosignal;
}
case LTTNG_CONSUMER_CLEAR_CHANNEL:
} else {
int ret_clear_channel;
- ret_clear_channel = lttng_consumer_clear_channel(
- found_channel);
+ ret_clear_channel = lttng_consumer_clear_channel(found_channel);
if (ret_clear_channel) {
ERR("Clear channel failed key %" PRIu64, key);
ret_code = (lttcomm_return_code) ret_clear_channel;
int ret_send_status;
lttng_uuid sessiond_uuid;
- std::copy(std::begin(msg.u.init.sessiond_uuid), std::end(msg.u.init.sessiond_uuid),
- sessiond_uuid.begin());
+ std::copy(std::begin(msg.u.init.sessiond_uuid),
+ std::end(msg.u.init.sessiond_uuid),
+ sessiond_uuid.begin());
ret_code = lttng_consumer_init_command(ctx, sessiond_uuid);
health_code_update();
ret_send_status = consumer_send_status_msg(sock, ret_code);
case LTTNG_CONSUMER_CREATE_TRACE_CHUNK:
{
const struct lttng_credentials credentials = {
- .uid = LTTNG_OPTIONAL_INIT_VALUE(msg.u.create_trace_chunk.credentials.value.uid),
- .gid = LTTNG_OPTIONAL_INIT_VALUE(msg.u.create_trace_chunk.credentials.value.gid),
+ .uid = LTTNG_OPTIONAL_INIT_VALUE(
+ msg.u.create_trace_chunk.credentials.value.uid),
+ .gid = LTTNG_OPTIONAL_INIT_VALUE(
+ msg.u.create_trace_chunk.credentials.value.gid),
};
- const bool is_local_trace =
- !msg.u.create_trace_chunk.relayd_id.is_set;
- const uint64_t relayd_id =
- msg.u.create_trace_chunk.relayd_id.value;
- const char *chunk_override_name =
- *msg.u.create_trace_chunk.override_name ?
- msg.u.create_trace_chunk.override_name :
- NULL;
+ const bool is_local_trace = !msg.u.create_trace_chunk.relayd_id.is_set;
+ const uint64_t relayd_id = msg.u.create_trace_chunk.relayd_id.value;
+ const char *chunk_override_name = *msg.u.create_trace_chunk.override_name ?
+ msg.u.create_trace_chunk.override_name :
+ NULL;
struct lttng_directory_handle *chunk_directory_handle = NULL;
/*
ssize_t ret_recv;
/* Acnowledge the reception of the command. */
- ret_send_status = consumer_send_status_msg(
- sock, LTTCOMM_CONSUMERD_SUCCESS);
+ ret_send_status = consumer_send_status_msg(sock, LTTCOMM_CONSUMERD_SUCCESS);
if (ret_send_status < 0) {
/* Somehow, the session daemon is not responding anymore. */
goto end_nosignal;
/*
* Receive trace chunk domain dirfd.
*/
- ret_recv = lttcomm_recv_fds_unix_sock(
- sock, &chunk_dirfd, 1);
+ ret_recv = lttcomm_recv_fds_unix_sock(sock, &chunk_dirfd, 1);
if (ret_recv != sizeof(chunk_dirfd)) {
ERR("Failed to receive trace chunk domain directory file descriptor");
goto error_fatal;
}
- DBG("Received trace chunk domain directory fd (%d)",
- chunk_dirfd);
- chunk_directory_handle = lttng_directory_handle_create_from_dirfd(
- chunk_dirfd);
+ DBG("Received trace chunk domain directory fd (%d)", chunk_dirfd);
+ chunk_directory_handle =
+ lttng_directory_handle_create_from_dirfd(chunk_dirfd);
if (!chunk_directory_handle) {
ERR("Failed to initialize chunk domain directory handle from directory file descriptor");
if (close(chunk_dirfd)) {
}
ret_code = lttng_consumer_create_trace_chunk(
- !is_local_trace ? &relayd_id : NULL,
- msg.u.create_trace_chunk.session_id,
- msg.u.create_trace_chunk.chunk_id,
- (time_t) msg.u.create_trace_chunk
- .creation_timestamp,
- chunk_override_name,
- msg.u.create_trace_chunk.credentials.is_set ?
- &credentials :
- NULL,
- chunk_directory_handle);
+ !is_local_trace ? &relayd_id : NULL,
+ msg.u.create_trace_chunk.session_id,
+ msg.u.create_trace_chunk.chunk_id,
+ (time_t) msg.u.create_trace_chunk.creation_timestamp,
+ chunk_override_name,
+ msg.u.create_trace_chunk.credentials.is_set ? &credentials : NULL,
+ chunk_directory_handle);
lttng_directory_handle_put(chunk_directory_handle);
goto end_msg_sessiond;
}
case LTTNG_CONSUMER_CLOSE_TRACE_CHUNK:
{
enum lttng_trace_chunk_command_type close_command =
- (lttng_trace_chunk_command_type)
- msg.u.close_trace_chunk.close_command.value;
- const uint64_t relayd_id =
- msg.u.close_trace_chunk.relayd_id.value;
+ (lttng_trace_chunk_command_type) msg.u.close_trace_chunk.close_command.value;
+ const uint64_t relayd_id = msg.u.close_trace_chunk.relayd_id.value;
struct lttcomm_consumer_close_trace_chunk_reply reply;
char closed_trace_chunk_path[LTTNG_PATH_MAX] = {};
int ret;
ret_code = lttng_consumer_close_trace_chunk(
- msg.u.close_trace_chunk.relayd_id.is_set ?
- &relayd_id :
- NULL,
- msg.u.close_trace_chunk.session_id,
- msg.u.close_trace_chunk.chunk_id,
- (time_t) msg.u.close_trace_chunk.close_timestamp,
- msg.u.close_trace_chunk.close_command.is_set ?
- &close_command :
- NULL, closed_trace_chunk_path);
+ msg.u.close_trace_chunk.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.close_trace_chunk.session_id,
+ msg.u.close_trace_chunk.chunk_id,
+ (time_t) msg.u.close_trace_chunk.close_timestamp,
+ msg.u.close_trace_chunk.close_command.is_set ? &close_command : NULL,
+ closed_trace_chunk_path);
reply.ret_code = ret_code;
reply.path_length = strlen(closed_trace_chunk_path) + 1;
ret = lttcomm_send_unix_sock(sock, &reply, sizeof(reply));
if (ret != sizeof(reply)) {
goto error_fatal;
}
- ret = lttcomm_send_unix_sock(sock, closed_trace_chunk_path,
- reply.path_length);
+ ret = lttcomm_send_unix_sock(sock, closed_trace_chunk_path, reply.path_length);
if (ret != reply.path_length) {
goto error_fatal;
}
}
case LTTNG_CONSUMER_TRACE_CHUNK_EXISTS:
{
- const uint64_t relayd_id =
- msg.u.trace_chunk_exists.relayd_id.value;
+ const uint64_t relayd_id = msg.u.trace_chunk_exists.relayd_id.value;
ret_code = lttng_consumer_trace_chunk_exists(
- msg.u.trace_chunk_exists.relayd_id.is_set ?
- &relayd_id : NULL,
- msg.u.trace_chunk_exists.session_id,
- msg.u.trace_chunk_exists.chunk_id);
+ msg.u.trace_chunk_exists.relayd_id.is_set ? &relayd_id : NULL,
+ msg.u.trace_chunk_exists.session_id,
+ msg.u.trace_chunk_exists.chunk_id);
goto end_msg_sessiond;
}
case LTTNG_CONSUMER_OPEN_CHANNEL_PACKETS:
{
const uint64_t key = msg.u.open_channel_packets.key;
- struct lttng_consumer_channel *found_channel =
- consumer_find_channel(key);
+ struct lttng_consumer_channel *found_channel = consumer_find_channel(key);
if (found_channel) {
pthread_mutex_lock(&found_channel->lock);
- ret_code = lttng_consumer_open_channel_packets(
- found_channel);
+ ret_code = lttng_consumer_open_channel_packets(found_channel);
pthread_mutex_unlock(&found_channel->lock);
} else {
/*
return ret_func;
}
-int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
- int producer_active)
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream, int producer_active)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
*
* Returns 0 on success, < 0 on error.
*/
-int lttng_ustconsumer_sample_snapshot_positions(
- struct lttng_consumer_stream *stream)
+int lttng_ustconsumer_sample_snapshot_positions(struct lttng_consumer_stream *stream)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
*
* Returns 0 on success, < 0 on error
*/
-int lttng_ustconsumer_get_produced_snapshot(
- struct lttng_consumer_stream *stream, unsigned long *pos)
+int lttng_ustconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
*
* Returns 0 on success, < 0 on error
*/
-int lttng_ustconsumer_get_consumed_snapshot(
- struct lttng_consumer_stream *stream, unsigned long *pos)
+int lttng_ustconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
+ unsigned long *pos)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
return lttng_ust_ctl_snapshot_get_consumed(stream->ustream, pos);
}
-int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
- int producer)
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream, int producer)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
return lttng_ust_ctl_clear_buffer(stream->ustream);
}
-int lttng_ustconsumer_get_current_timestamp(
- struct lttng_consumer_stream *stream, uint64_t *ts)
+int lttng_ustconsumer_get_current_timestamp(struct lttng_consumer_stream *stream, uint64_t *ts)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
return lttng_ust_ctl_get_current_timestamp(stream->ustream, ts);
}
-int lttng_ustconsumer_get_sequence_number(
- struct lttng_consumer_stream *stream, uint64_t *seq)
+int lttng_ustconsumer_get_sequence_number(struct lttng_consumer_stream *stream, uint64_t *seq)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream->ustream);
ERR("Cannot get stream shm path");
}
ret = run_as_unlink(shm_path,
- lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
- chan->buffer_credentials)),
- lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
- chan->buffer_credentials)));
+ lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
+ chan->buffer_credentials)),
+ lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
+ chan->buffer_credentials)));
if (ret) {
PERROR("unlink %s", shm_path);
}
lttng_ust_ctl_destroy_channel(chan->uchan);
/* Try to rmdir all directories under shm_path root. */
if (chan->root_shm_path[0]) {
- (void) run_as_rmdir_recursive(chan->root_shm_path,
- lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(
- chan->buffer_credentials)),
- lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(
- chan->buffer_credentials)),
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ (void) run_as_rmdir_recursive(
+ chan->root_shm_path,
+ lttng_credentials_get_uid(LTTNG_OPTIONAL_GET_PTR(chan->buffer_credentials)),
+ lttng_credentials_get_gid(LTTNG_OPTIONAL_GET_PTR(chan->buffer_credentials)),
+ LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
}
free(chan->stream_fds);
}
* Returns the number of bytes pushed from the cache into the ring buffer, or a
* negative value on error.
*/
-static
-int commit_one_metadata_packet(struct lttng_consumer_stream *stream)
+static int commit_one_metadata_packet(struct lttng_consumer_stream *stream)
{
ssize_t write_len;
int ret;
pthread_mutex_lock(&stream->chan->metadata_cache->lock);
- if (stream->chan->metadata_cache->contents.size ==
- stream->ust_metadata_pushed) {
+ if (stream->chan->metadata_cache->contents.size == stream->ust_metadata_pushed) {
/*
* In the context of a user space metadata channel, a
* change in version can be detected in two ways:
* occur as part of the pre-consume) until the metadata size
* exceeded the cache size.
*/
- if (stream->metadata_version !=
- stream->chan->metadata_cache->version) {
+ if (stream->metadata_version != stream->chan->metadata_cache->version) {
metadata_stream_reset_cache_consumed_position(stream);
consumer_stream_metadata_set_version(stream,
- stream->chan->metadata_cache->version);
+ stream->chan->metadata_cache->version);
} else {
ret = 0;
goto end;
}
}
- write_len = lttng_ust_ctl_write_one_packet_to_channel(stream->chan->uchan,
- &stream->chan->metadata_cache->contents.data[stream->ust_metadata_pushed],
- stream->chan->metadata_cache->contents.size -
- stream->ust_metadata_pushed);
+ write_len = lttng_ust_ctl_write_one_packet_to_channel(
+ stream->chan->uchan,
+ &stream->chan->metadata_cache->contents.data[stream->ust_metadata_pushed],
+ stream->chan->metadata_cache->contents.size - stream->ust_metadata_pushed);
LTTNG_ASSERT(write_len != 0);
if (write_len < 0) {
ERR("Writing one metadata packet");
}
stream->ust_metadata_pushed += write_len;
- LTTNG_ASSERT(stream->chan->metadata_cache->contents.size >=
- stream->ust_metadata_pushed);
+ LTTNG_ASSERT(stream->chan->metadata_cache->contents.size >= stream->ust_metadata_pushed);
ret = write_len;
/*
return ret;
}
-
/*
* Sync metadata meaning request them to the session daemon and snapshot to the
* metadata thread can consumer them.
*
* The RCU read side lock must be held by the caller.
*/
-enum sync_metadata_status lttng_ustconsumer_sync_metadata(
- struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_stream *metadata_stream)
+enum sync_metadata_status
+lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data *ctx,
+ struct lttng_consumer_stream *metadata_stream)
{
int ret;
enum sync_metadata_status status;
*/
if (consumer_stream_is_deleted(metadata_stream)) {
DBG("Metadata stream %" PRIu64 " was deleted during the metadata synchronization",
- metadata_stream->key);
+ metadata_stream->key);
status = SYNC_METADATA_STATUS_NO_DATA;
goto end;
}
ret = lttng_ust_ctl_snapshot(metadata_stream->ustream);
if (ret < 0) {
- ERR("Failed to take a snapshot of the metadata ring-buffer positions, ret = %d", ret);
+ ERR("Failed to take a snapshot of the metadata ring-buffer positions, ret = %d",
+ ret);
status = SYNC_METADATA_STATUS_ERROR;
goto end;
}
* Return 0 on success else a negative value.
*/
static int notify_if_more_data(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx)
+ struct lttng_consumer_local_data *ctx)
{
int ret;
struct lttng_ust_ctl_consumer_stream *ustream;
}
static int extract_common_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+ struct stream_subbuffer *subbuf)
{
int ret;
- ret = lttng_ust_ctl_get_subbuf_size(
- stream->ustream, &subbuf->info.data.subbuf_size);
+ ret = lttng_ust_ctl_get_subbuf_size(stream->ustream, &subbuf->info.data.subbuf_size);
if (ret) {
goto end;
}
- ret = lttng_ust_ctl_get_padded_subbuf_size(
- stream->ustream, &subbuf->info.data.padded_subbuf_size);
+ ret = lttng_ust_ctl_get_padded_subbuf_size(stream->ustream,
+ &subbuf->info.data.padded_subbuf_size);
if (ret) {
goto end;
}
}
static int extract_metadata_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+ struct stream_subbuffer *subbuf)
{
int ret;
}
static int extract_data_subbuffer_info(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuf)
+ struct stream_subbuffer *subbuf)
{
int ret;
goto end;
}
- ret = lttng_ust_ctl_get_packet_size(
- stream->ustream, &subbuf->info.data.packet_size);
+ ret = lttng_ust_ctl_get_packet_size(stream->ustream, &subbuf->info.data.packet_size);
if (ret < 0) {
PERROR("Failed to get sub-buffer packet size");
goto end;
}
- ret = lttng_ust_ctl_get_content_size(
- stream->ustream, &subbuf->info.data.content_size);
+ ret = lttng_ust_ctl_get_content_size(stream->ustream, &subbuf->info.data.content_size);
if (ret < 0) {
PERROR("Failed to get sub-buffer content size");
goto end;
}
- ret = lttng_ust_ctl_get_timestamp_begin(
- stream->ustream, &subbuf->info.data.timestamp_begin);
+ ret = lttng_ust_ctl_get_timestamp_begin(stream->ustream,
+ &subbuf->info.data.timestamp_begin);
if (ret < 0) {
PERROR("Failed to get sub-buffer begin timestamp");
goto end;
}
- ret = lttng_ust_ctl_get_timestamp_end(
- stream->ustream, &subbuf->info.data.timestamp_end);
+ ret = lttng_ust_ctl_get_timestamp_end(stream->ustream, &subbuf->info.data.timestamp_end);
if (ret < 0) {
PERROR("Failed to get sub-buffer end timestamp");
goto end;
}
- ret = lttng_ust_ctl_get_events_discarded(
- stream->ustream, &subbuf->info.data.events_discarded);
+ ret = lttng_ust_ctl_get_events_discarded(stream->ustream,
+ &subbuf->info.data.events_discarded);
if (ret) {
PERROR("Failed to get sub-buffer events discarded count");
goto end;
}
ret = lttng_ust_ctl_get_sequence_number(stream->ustream,
- &subbuf->info.data.sequence_number.value);
+ &subbuf->info.data.sequence_number.value);
if (ret) {
/* May not be supported by older LTTng-modules. */
if (ret != -ENOTTY) {
subbuf->info.data.sequence_number.is_set = true;
}
- ret = lttng_ust_ctl_get_stream_id(
- stream->ustream, &subbuf->info.data.stream_id);
+ ret = lttng_ust_ctl_get_stream_id(stream->ustream, &subbuf->info.data.stream_id);
if (ret < 0) {
PERROR("Failed to get stream id");
goto end;
}
ret = lttng_ust_ctl_get_instance_id(stream->ustream,
- &subbuf->info.data.stream_instance_id.value);
+ &subbuf->info.data.stream_instance_id.value);
if (ret) {
/* May not be supported by older LTTng-modules. */
if (ret != -ENOTTY) {
}
static int get_next_subbuffer_common(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+ struct stream_subbuffer *subbuffer)
{
int ret;
const char *addr;
- ret = stream->read_subbuffer_ops.extract_subbuffer_info(
- stream, subbuffer);
+ ret = stream->read_subbuffer_ops.extract_subbuffer_info(stream, subbuffer);
if (ret) {
goto end;
}
goto end;
}
- subbuffer->buffer.buffer = lttng_buffer_view_init(
- addr, 0, subbuffer->info.data.padded_subbuf_size);
+ subbuffer->buffer.buffer =
+ lttng_buffer_view_init(addr, 0, subbuffer->info.data.padded_subbuf_size);
LTTNG_ASSERT(subbuffer->buffer.buffer.data != NULL);
end:
return ret;
}
-static enum get_next_subbuffer_status get_next_subbuffer(
- struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status get_next_subbuffer(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer)
{
int ret;
enum get_next_subbuffer_status status;
status = GET_NEXT_SUBBUFFER_STATUS_OK;
break;
case -ENODATA:
- case -EAGAIN:
+ case -EAGAIN:
/*
* The caller only expects -ENODATA when there is no data to
* read, but the kernel tracer returns -EAGAIN when there is
return status;
}
-static enum get_next_subbuffer_status get_next_subbuffer_metadata(
- struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer)
+static enum get_next_subbuffer_status
+get_next_subbuffer_metadata(struct lttng_consumer_stream *stream,
+ struct stream_subbuffer *subbuffer)
{
int ret;
bool cache_empty;
} else {
pthread_mutex_lock(&stream->chan->metadata_cache->lock);
cache_empty = stream->chan->metadata_cache->contents.size ==
- stream->ust_metadata_pushed;
+ stream->ust_metadata_pushed;
pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
}
} while (!got_subbuffer);
}
static int put_next_subbuffer(struct lttng_consumer_stream *stream,
- struct stream_subbuffer *subbuffer __attribute__((unused)))
+ struct stream_subbuffer *subbuffer __attribute__((unused)))
{
const int ret = lttng_ust_ctl_put_next_subbuf(stream->ustream);
}
static int signal_metadata(struct lttng_consumer_stream *stream,
- struct lttng_consumer_local_data *ctx __attribute__((unused)))
+ struct lttng_consumer_local_data *ctx __attribute__((unused)))
{
ASSERT_LOCKED(stream->metadata_rdv_lock);
return pthread_cond_broadcast(&stream->metadata_rdv) ? -errno : 0;
}
-static int lttng_ustconsumer_set_stream_ops(
- struct lttng_consumer_stream *stream)
+static int lttng_ustconsumer_set_stream_ops(struct lttng_consumer_stream *stream)
{
int ret = 0;
stream->read_subbuffer_ops.on_wake_up = consumer_stream_ust_on_wake_up;
if (stream->metadata_flag) {
- stream->read_subbuffer_ops.get_next_subbuffer =
- get_next_subbuffer_metadata;
- stream->read_subbuffer_ops.extract_subbuffer_info =
- extract_metadata_subbuffer_info;
+ stream->read_subbuffer_ops.get_next_subbuffer = get_next_subbuffer_metadata;
+ stream->read_subbuffer_ops.extract_subbuffer_info = extract_metadata_subbuffer_info;
stream->read_subbuffer_ops.reset_metadata =
- metadata_stream_reset_cache_consumed_position;
+ metadata_stream_reset_cache_consumed_position;
if (stream->chan->is_live) {
stream->read_subbuffer_ops.on_sleep = signal_metadata;
- ret = consumer_stream_enable_metadata_bucketization(
- stream);
+ ret = consumer_stream_enable_metadata_bucketization(stream);
if (ret) {
goto end;
}
}
} else {
- stream->read_subbuffer_ops.get_next_subbuffer =
- get_next_subbuffer;
- stream->read_subbuffer_ops.extract_subbuffer_info =
- extract_data_subbuffer_info;
+ stream->read_subbuffer_ops.get_next_subbuffer = get_next_subbuffer;
+ stream->read_subbuffer_ops.extract_subbuffer_info = extract_data_subbuffer_info;
stream->read_subbuffer_ops.on_sleep = notify_if_more_data;
if (stream->chan->is_live) {
- stream->read_subbuffer_ops.send_live_beacon =
- consumer_flush_ust_index;
+ stream->read_subbuffer_ops.send_live_beacon = consumer_flush_ust_index;
}
}
* no current trace chunk on the parent channel.
*/
if (stream->net_seq_idx == (uint64_t) -1ULL && stream->chan->monitor &&
- stream->chan->trace_chunk) {
+ stream->chan->trace_chunk) {
ret = consumer_stream_create_output_files(stream, true);
if (ret) {
goto error;
* whetnever ust_metadata_pushed is incremented, the associated
* metadata has been consumed from the metadata stream.
*/
- DBG("UST consumer metadata pending check: contiguous %" PRIu64 " vs pushed %" PRIu64,
- contiguous, pushed);
+ DBG("UST consumer metadata pending check: contiguous %" PRIu64
+ " vs pushed %" PRIu64,
+ contiguous,
+ pushed);
LTTNG_ASSERT(((int64_t) (contiguous - pushed)) >= 0);
if ((contiguous != pushed) ||
- (((int64_t) contiguous - pushed) > 0 || contiguous == 0)) {
- ret = 1; /* Data is pending */
+ (((int64_t) contiguous - pushed) > 0 || contiguous == 0)) {
+ ret = 1; /* Data is pending */
goto end;
}
} else {
*/
ret = lttng_ust_ctl_put_subbuf(stream->ustream);
LTTNG_ASSERT(ret == 0);
- ret = 1; /* Data is pending */
+ ret = 1; /* Data is pending */
goto end;
}
}
DBG("UST consumer closing all metadata streams");
rcu_read_lock();
- cds_lfht_for_each_entry(metadata_ht->ht, &iter.iter, stream,
- node.node) {
-
+ cds_lfht_for_each_entry (metadata_ht->ht, &iter.iter, stream, node.node) {
health_code_update();
pthread_mutex_lock(&stream->chan->lock);
lttng_ustconsumer_close_metadata(stream->chan);
pthread_mutex_unlock(&stream->chan->lock);
-
}
rcu_read_unlock();
}
* pushed out due to concurrent interaction with the session daemon.
*/
int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
- struct lttng_consumer_channel *channel, int timer, int wait)
+ struct lttng_consumer_channel *channel,
+ int timer,
+ int wait)
{
struct lttcomm_metadata_request_msg request;
struct lttcomm_consumer_msg msg;
request.uid = channel->ust_app_uid;
request.key = channel->key;
- DBG("Sending metadata request to sessiond, session id %" PRIu64
- ", per-pid %" PRIu64 ", app UID %u and channel key %" PRIu64,
- request.session_id, request.session_id_per_pid, request.uid,
- request.key);
+ DBG("Sending metadata request to sessiond, session id %" PRIu64 ", per-pid %" PRIu64
+ ", app UID %u and channel key %" PRIu64,
+ request.session_id,
+ request.session_id_per_pid,
+ request.uid,
+ request.key);
pthread_mutex_lock(&ctx->metadata_socket_lock);
health_code_update();
- ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request,
- sizeof(request));
+ ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request, sizeof(request));
if (ret < 0) {
ERR("Asking metadata to sessiond");
goto end;
health_code_update();
/* Receive the metadata from sessiond */
- ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, &msg,
- sizeof(msg));
+ ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, &msg, sizeof(msg));
if (ret != sizeof(msg)) {
- DBG("Consumer received unexpected message size %d (expects %zu)",
- ret, sizeof(msg));
+ DBG("Consumer received unexpected message size %d (expects %zu)", ret, sizeof(msg));
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD);
/*
* The ret value might 0 meaning an orderly shutdown but this is ok
if (msg.cmd_type == LTTNG_ERR_UND) {
/* No registry found */
- (void) consumer_send_status_msg(ctx->consumer_metadata_socket,
- ret_code);
+ (void) consumer_send_status_msg(ctx->consumer_metadata_socket, ret_code);
ret = 0;
goto end;
} else if (msg.cmd_type != LTTNG_CONSUMER_PUSH_METADATA) {
health_code_update();
/* Tell session daemon we are ready to receive the metadata. */
- ret = consumer_send_status_msg(ctx->consumer_metadata_socket,
- LTTCOMM_CONSUMERD_SUCCESS);
+ ret = consumer_send_status_msg(ctx->consumer_metadata_socket, LTTCOMM_CONSUMERD_SUCCESS);
if (ret < 0 || len == 0) {
/*
* Somehow, the session daemon is not responding anymore or there is
health_code_update();
- ret = lttng_ustconsumer_recv_metadata(ctx->consumer_metadata_socket,
- key, offset, len, version, channel, timer, wait);
+ ret = lttng_ustconsumer_recv_metadata(
+ ctx->consumer_metadata_socket, key, offset, len, version, channel, timer, wait);
if (ret >= 0) {
/*
* Only send the status msg if the sessiond is alive meaning a positive
/*
* Return the ustctl call for the get stream id.
*/
-int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
- uint64_t *stream_id)
+int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream, uint64_t *stream_id)
{
LTTNG_ASSERT(stream);
LTTNG_ASSERT(stream_id);
*/
#define _LGPL_SOURCE
-#include <ctype.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <pwd.h>
-#include <stdlib.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
+#include "defaults.hpp"
+#include "time.hpp"
+#include "utils.hpp"
#include <common/common.hpp>
#include <common/compat/directory-handle.hpp>
#include <common/readwrite.hpp>
#include <common/runas.hpp>
#include <common/string-utils/format.hpp>
+
#include <lttng/constant.h>
-#include "defaults.hpp"
-#include "time.hpp"
-#include "utils.hpp"
+#include <ctype.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
-#define PROC_MEMINFO_PATH "/proc/meminfo"
-#define PROC_MEMINFO_MEMAVAILABLE_LINE "MemAvailable:"
-#define PROC_MEMINFO_MEMTOTAL_LINE "MemTotal:"
+#define PROC_MEMINFO_PATH "/proc/meminfo"
+#define PROC_MEMINFO_MEMAVAILABLE_LINE "MemAvailable:"
+#define PROC_MEMINFO_MEMTOTAL_LINE "MemTotal:"
/* The length of the longest field of `/proc/meminfo`. */
-#define PROC_MEMINFO_FIELD_MAX_NAME_LEN 20
+#define PROC_MEMINFO_FIELD_MAX_NAME_LEN 20
#if (PROC_MEMINFO_FIELD_MAX_NAME_LEN == 20)
#define MAX_NAME_LEN_SCANF_IS_A_BROKEN_API "19"
#error MAX_NAME_LEN_SCANF_IS_A_BROKEN_API must be updated to match (PROC_MEMINFO_FIELD_MAX_NAME_LEN - 1)
#endif
-#define FALLBACK_USER_BUFLEN 16384
+#define FALLBACK_USER_BUFLEN 16384
#define FALLBACK_GROUP_BUFLEN 16384
/*
LTTNG_ASSERT(filepath);
- fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR |S_IWUSR | S_IRGRP | S_IROTH);
+ fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
PERROR("open file %s", filepath);
ret = -1;
PERROR("fdopen file %s", filepath);
ret = -1;
if (close(fd)) {
- PERROR("Failed to close `%s` file descriptor while handling fdopen error", filepath);
+ PERROR("Failed to close `%s` file descriptor while handling fdopen error",
+ filepath);
}
goto error;
LTTNG_ASSERT(filepath);
memset(&lock, 0, sizeof(lock));
- fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR |
- S_IRGRP | S_IWGRP);
+ fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (fd < 0) {
PERROR("open lock file %s", filepath);
fd = -1;
ret = fcntl(fd, F_SETLK, &lock);
if (ret == -1) {
PERROR("fcntl lock file");
- ERR("Could not get lock file %s, another instance is running.",
- filepath);
+ ERR("Could not get lock file %s, another instance is running.", filepath);
if (close(fd)) {
PERROR("close lock file");
}
goto end;
}
ret = lttng_directory_handle_create_subdirectory_as_user(
- handle, path, mode,
- (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
end:
lttng_directory_handle_put(handle);
return ret;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive_as_user(
- handle, path, mode,
- (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
end:
lttng_directory_handle_put(handle);
return ret;
*
* Return 0 on success or else a negative value.
*/
-int utils_stream_file_path(const char *path_name, const char *file_name,
- uint64_t size, uint64_t count, const char *suffix,
- char *out_stream_path, size_t stream_path_len)
+int utils_stream_file_path(const char *path_name,
+ const char *file_name,
+ uint64_t size,
+ uint64_t count,
+ const char *suffix,
+ char *out_stream_path,
+ size_t stream_path_len)
{
int ret;
char count_str[MAX_INT_DEC_LEN(count) + 1] = {};
const char *path_separator;
- if (path_name && (path_name[0] == '\0' ||
- path_name[strlen(path_name) - 1] == '/')) {
+ if (path_name && (path_name[0] == '\0' || path_name[strlen(path_name) - 1] == '/')) {
path_separator = "";
} else {
path_separator = "/";
}
- path_name = path_name ? : "";
- suffix = suffix ? : "";
+ path_name = path_name ?: "";
+ suffix = suffix ?: "";
if (size > 0) {
- ret = snprintf(count_str, sizeof(count_str), "_%" PRIu64,
- count);
+ ret = snprintf(count_str, sizeof(count_str), "_%" PRIu64, count);
LTTNG_ASSERT(ret > 0 && ret < sizeof(count_str));
}
- ret = snprintf(out_stream_path, stream_path_len, "%s%s%s%s%s",
- path_name, path_separator, file_name, count_str,
- suffix);
+ ret = snprintf(out_stream_path,
+ stream_path_len,
+ "%s%s%s%s%s",
+ path_name,
+ path_separator,
+ file_name,
+ count_str,
+ suffix);
if (ret < 0 || ret >= stream_path_len) {
ERR("Truncation occurred while formatting stream path");
ret = -1;
*
* @return 0 on success, -1 on failure.
*/
-int utils_parse_size_suffix(const char * const str, uint64_t * const size)
+int utils_parse_size_suffix(const char *const str, uint64_t *const size)
{
int ret;
uint64_t base_size;
*
* @return 0 on success, -1 on failure.
*/
-int utils_parse_time_suffix(char const * const str, uint64_t * const time_us)
+int utils_parse_time_suffix(char const *const str, uint64_t *const time_us)
{
int ret;
uint64_t base_time;
int r;
asm("bsrl %1,%0\n\t"
- "jnz 1f\n\t"
- "movl $-1,%0\n\t"
- "1:\n\t"
- : "=r" (r) : "rm" (x));
+ "jnz 1f\n\t"
+ "movl $-1,%0\n\t"
+ "1:\n\t"
+ : "=r"(r)
+ : "rm"(x));
return r + 1;
}
#define HAS_FLS_U32
#endif
#if defined(__x86_64) && defined(__LP64__)
-static inline
-unsigned int fls_u64(uint64_t x)
+static inline unsigned int fls_u64(uint64_t x)
{
long r;
"jnz 1f\n\t"
"movq $-1,%0\n\t"
"1:\n\t"
- : "=r" (r) : "rm" (x));
+ : "=r"(r)
+ : "rm"(x));
return r + 1;
}
#define HAS_FLS_U64
#endif
#ifndef HAS_FLS_U64
-static __attribute__((unused))
-unsigned int fls_u64(uint64_t x)
+static __attribute__((unused)) unsigned int fls_u64(uint64_t x)
{
unsigned int r = 64;
ret = strftime(dst, len, format, timeinfo);
DIAGNOSTIC_POP
if (ret == 0) {
- ERR("Unable to strftime with format %s at dst %p of len %zu", format,
- dst, len);
+ ERR("Unable to strftime with format %s at dst %p of len %zu", format, dst, len);
}
return ret;
ret = lttng_dynamic_buffer_set_size(&buffer, new_len);
if (ret) {
- ERR("Failed to grow group info buffer to %zu bytes",
- new_len);
+ ERR("Failed to grow group info buffer to %zu bytes", new_len);
ret = -1;
goto error;
}
}
if (ret) {
if (ret == ESRCH) {
- DBG("Could not find group file entry for group name '%s'",
- name);
+ DBG("Could not find group file entry for group name '%s'", name);
} else {
- PERROR("Failed to get group file entry for group name '%s'",
- name);
+ PERROR("Failed to get group file entry for group name '%s'", name);
}
ret = -1;
* of elements in the long_options array. Returns NULL if the string's
* allocation fails.
*/
-char *utils_generate_optstring(const struct option *long_options,
- size_t opt_count)
+char *utils_generate_optstring(const struct option *long_options, size_t opt_count)
{
int i;
size_t string_len = opt_count, str_pos = 0;
return DEFAULT_MAN_BIN_PATH;
}
-int utils_show_help(int section, const char *page_name,
- const char *help_msg)
+int utils_show_help(int section, const char *page_name, const char *help_msg)
{
char section_string[8];
const char *man_bin_path = get_man_bin_path();
* be installed outside /usr, in which case its man pages are
* not located in the default /usr/share/man directory.
*/
- ret = execlp(man_bin_path, "man", "-M", MANPATH,
- section_string, page_name, NULL);
+ ret = execlp(man_bin_path, "man", "-M", MANPATH, section_string, page_name, NULL);
end:
return ret;
}
-static
-int read_proc_meminfo_field(const char *field, uint64_t *value)
+static int read_proc_meminfo_field(const char *field, uint64_t *value)
{
int ret;
FILE *proc_meminfo;
PERROR("Failed to fopen() " PROC_MEMINFO_PATH);
ret = -1;
goto fopen_error;
- }
+ }
/*
* Read the contents of /proc/meminfo line by line to find the right
uint64_t value_kb;
ret = fscanf(proc_meminfo,
- "%" MAX_NAME_LEN_SCANF_IS_A_BROKEN_API "s %" SCNu64 " kB\n",
- name, &value_kb);
+ "%" MAX_NAME_LEN_SCANF_IS_A_BROKEN_API "s %" SCNu64 " kB\n",
+ name,
+ &value_kb);
if (ret == EOF) {
/*
* fscanf() returning EOF can indicate EOF or an error.
*/
DBG("Working directory \"%s\" is not writable", path);
} else {
- PERROR("Failed to check if working directory \"%s\" is writable",
- path);
+ PERROR("Failed to check if working directory \"%s\" is writable", path);
}
}
} else {
*uid = p.pw_uid;
DBG("Lookup of tracker UID/VUID: name '%s' maps to uid %" PRId64,
- user_name, (int64_t) *uid);
+ user_name,
+ (int64_t) *uid);
ret_val = LTTNG_OK;
}
break;
return ret_val;
}
-enum lttng_error_code utils_group_id_from_name(
- const char *group_name, gid_t *gid)
+enum lttng_error_code utils_group_id_from_name(const char *group_name, gid_t *gid)
{
struct group g, *gres;
int ret;
} else {
*gid = g.gr_gid;
DBG("Lookup of tracker GID/GUID: name '%s' maps to gid %" PRId64,
- group_name, (int64_t) *gid);
+ group_name,
+ (int64_t) *gid);
ret_val = LTTNG_OK;
}
break;
return ret_val;
}
-int utils_parse_unsigned_long_long(const char *str,
- unsigned long long *value)
+int utils_parse_unsigned_long_long(const char *str, unsigned long long *value)
{
int ret;
char *endptr;
if (errno != 0) {
/* Don't print an error; allow the caller to log a better error. */
DBG("Failed to parse string as unsigned long long number: string = '%s', errno = %d",
- str, errno);
+ str,
+ errno);
ret = -1;
goto end;
}
/* Not the end of the string or empty string. */
if (*endptr || endptr == str) {
- DBG("Failed to parse string as unsigned long long number: string = '%s'",
- str);
+ DBG("Failed to parse string as unsigned long long number: string = '%s'", str);
ret = -1;
goto end;
}
*
*/
+#include "uuid.hpp"
+
#include <common/compat/string.hpp>
#include <common/error.hpp>
#include <common/format.hpp>
#include <string.h>
#include <time.h>
-#include "uuid.hpp"
-
namespace {
const lttng_uuid nil_uuid = {};
bool lttng_uuid_is_init;
}
/* Scan to a temporary location in case of a partial match. */
- if (sscanf(str_in, LTTNG_UUID_FMT, LTTNG_UUID_SCAN_VALUES(uuid_scan)) !=
- LTTNG_UUID_LEN) {
+ if (sscanf(str_in, LTTNG_UUID_FMT, LTTNG_UUID_SCAN_VALUES(uuid_scan)) != LTTNG_UUID_LEN) {
ret = -1;
goto end;
}
srand(lttng::random::produce_best_effort_random_seed());
} catch (std::exception& e) {
ERR("Failed to initialize random seed during generation of UUID: %s",
- e.what());
+ e.what());
ret = -1;
goto end;
}
*
*/
-#include "waiter.hpp"
-#include <urcu/uatomic.h>
-#include <urcu/futex.h>
#include "error.hpp"
+#include "waiter.hpp"
+
#include <poll.h>
+#include <urcu/futex.h>
+#include <urcu/uatomic.h>
/*
* Number of busy-loop attempts before waiting on futex.
enum waiter_state {
/* WAITER_WAITING is compared directly (futex compares it). */
- WAITER_WAITING = 0,
+ WAITER_WAITING = 0,
/* non-zero are used as masks. */
- WAITER_WOKEN_UP = (1 << 0),
- WAITER_RUNNING = (1 << 1),
- WAITER_TEARDOWN = (1 << 2),
+ WAITER_WOKEN_UP = (1 << 0),
+ WAITER_RUNNING = (1 << 1),
+ WAITER_TEARDOWN = (1 << 2),
};
void lttng_waiter_init(struct lttng_waiter *waiter)
goto skip_futex_wait;
case EINTR:
/* Retry if interrupted by signal. */
- break; /* Get out of switch. Check again. */
+ break; /* Get out of switch. Check again. */
default:
/* Unexpected error. */
PERROR("futex_noasync");
LTTNG_ASSERT(uatomic_read(&waiter->state) == WAITER_WAITING);
uatomic_set(&waiter->state, WAITER_WOKEN_UP);
if (!(uatomic_read(&waiter->state) & WAITER_RUNNING)) {
- if (futex_noasync(&waiter->state, FUTEX_WAKE, 1,
- NULL, NULL, 0) < 0) {
+ if (futex_noasync(&waiter->state, FUTEX_WAKE, 1, NULL, NULL, 0) < 0) {
PERROR("futex_noasync");
abort();
}
*
*/
-#include <lttng/notification/notification-internal.hpp>
-#include <lttng/notification/channel-internal.hpp>
-#include <lttng/condition/condition-internal.hpp>
-#include <lttng/endpoint.h>
+#include "lttng-ctl-helper.hpp"
+
+#include <common/compat/poll.hpp>
#include <common/defaults.hpp>
-#include <common/error.hpp>
#include <common/dynamic-buffer.hpp>
-#include <common/utils.hpp>
-#include <common/defaults.hpp>
-#include <common/payload.hpp>
+#include <common/error.hpp>
#include <common/payload-view.hpp>
+#include <common/payload.hpp>
#include <common/unix.hpp>
-#include "lttng-ctl-helper.hpp"
-#include <common/compat/poll.hpp>
+#include <common/utils.hpp>
-static
-int handshake(struct lttng_notification_channel *channel);
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/endpoint.h>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+
+static int handshake(struct lttng_notification_channel *channel);
/*
* Populates the reception buffer with the next complete message.
* The caller must acquire the channel's lock.
*/
-static
-int receive_message(struct lttng_notification_channel *channel)
+static int receive_message(struct lttng_notification_channel *channel)
{
ssize_t ret;
struct lttng_notification_channel_message msg;
}
/* Add message header at buffer's start. */
- ret = lttng_dynamic_buffer_append(&channel->reception_payload.buffer, &msg,
- sizeof(msg));
+ ret = lttng_dynamic_buffer_append(&channel->reception_payload.buffer, &msg, sizeof(msg));
if (ret) {
goto error;
}
/* Reserve space for the payload. */
ret = lttng_dynamic_buffer_set_size(&channel->reception_payload.buffer,
- channel->reception_payload.buffer.size + msg.size);
+ channel->reception_payload.buffer.size + msg.size);
if (ret) {
goto error;
}
/* Receive message payload. */
- ret = lttcomm_recv_unix_sock(channel->socket,
- channel->reception_payload.buffer.data + sizeof(msg), msg.size);
+ ret = lttcomm_recv_unix_sock(
+ channel->socket, channel->reception_payload.buffer.data + sizeof(msg), msg.size);
if (ret < (ssize_t) msg.size) {
ret = -1;
goto error;
skip_payload:
/* Receive message fds. */
if (msg.fds != 0) {
- ret = lttcomm_recv_payload_fds_unix_sock(channel->socket,
- msg.fds, &channel->reception_payload);
+ ret = lttcomm_recv_payload_fds_unix_sock(
+ channel->socket, msg.fds, &channel->reception_payload);
if (ret < sizeof(int) * msg.fds) {
ret = -1;
goto error;
goto end;
}
-static
-enum lttng_notification_channel_message_type get_current_message_type(
- struct lttng_notification_channel *channel)
+static enum lttng_notification_channel_message_type
+get_current_message_type(struct lttng_notification_channel *channel)
{
struct lttng_notification_channel_message *msg;
LTTNG_ASSERT(channel->reception_payload.buffer.size >= sizeof(*msg));
- msg = (struct lttng_notification_channel_message *)
- channel->reception_payload.buffer.data;
+ msg = (struct lttng_notification_channel_message *) channel->reception_payload.buffer.data;
return (enum lttng_notification_channel_message_type) msg->type;
}
-static
-struct lttng_notification *create_notification_from_current_message(
- struct lttng_notification_channel *channel)
+static struct lttng_notification *
+create_notification_from_current_message(struct lttng_notification_channel *channel)
{
ssize_t ret;
struct lttng_notification *notification = NULL;
if (channel->reception_payload.buffer.size <=
- sizeof(struct lttng_notification_channel_message)) {
+ sizeof(struct lttng_notification_channel_message)) {
goto end;
}
{
struct lttng_payload_view view = lttng_payload_view_from_payload(
- &channel->reception_payload,
- sizeof(struct lttng_notification_channel_message),
- -1);
+ &channel->reception_payload,
+ sizeof(struct lttng_notification_channel_message),
+ -1);
- ret = lttng_notification_create_from_payload(
- &view, ¬ification);
+ ret = lttng_notification_create_from_payload(&view, ¬ification);
}
- if (ret != channel->reception_payload.buffer.size -
- sizeof(struct lttng_notification_channel_message)) {
+ if (ret !=
+ channel->reception_payload.buffer.size -
+ sizeof(struct lttng_notification_channel_message)) {
lttng_notification_destroy(notification);
notification = NULL;
goto end;
return notification;
}
-struct lttng_notification_channel *lttng_notification_channel_create(
- struct lttng_endpoint *endpoint)
+struct lttng_notification_channel *
+lttng_notification_channel_create(struct lttng_endpoint *endpoint)
{
int fd, ret;
bool is_in_tracing_group = false, is_root = false;
char *sock_path = NULL;
struct lttng_notification_channel *channel = NULL;
- if (!endpoint ||
- endpoint != lttng_session_daemon_notification_endpoint) {
+ if (!endpoint || endpoint != lttng_session_daemon_notification_endpoint) {
goto end;
}
}
if (is_root || is_in_tracing_group) {
- ret = lttng_strncpy(sock_path,
- DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK,
- LTTNG_PATH_MAX);
+ ret = lttng_strncpy(
+ sock_path, DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK, LTTNG_PATH_MAX);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
/* Fallback to local session daemon. */
- ret = snprintf(sock_path, LTTNG_PATH_MAX,
- DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
- utils_get_home_dir());
+ ret = snprintf(sock_path,
+ LTTNG_PATH_MAX,
+ DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
+ utils_get_home_dir());
if (ret < 0 || ret >= LTTNG_PATH_MAX) {
goto error;
}
}
enum lttng_notification_channel_status
-lttng_notification_channel_get_next_notification(
- struct lttng_notification_channel *channel,
- struct lttng_notification **_notification)
+lttng_notification_channel_get_next_notification(struct lttng_notification_channel *channel,
+ struct lttng_notification **_notification)
{
int ret;
struct lttng_notification *notification = NULL;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_poll_event events;
if (!channel || !_notification) {
/* Deliver one of the pending notifications. */
pending_notification = cds_list_first_entry(
- &channel->pending_notifications.list,
- struct pending_notification,
- node);
+ &channel->pending_notifications.list, struct pending_notification, node);
notification = pending_notification->notification;
if (!notification) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED;
switch (get_current_message_type(channel)) {
case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION:
- notification = create_notification_from_current_message(
- channel);
+ notification = create_notification_from_current_message(channel);
if (!notification) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
goto end_clean_poll;
return status;
}
-static
-int enqueue_dropped_notification(
- struct lttng_notification_channel *channel)
+static int enqueue_dropped_notification(struct lttng_notification_channel *channel)
{
int ret = 0;
struct pending_notification *pending_notification;
- struct cds_list_head *last_element =
- channel->pending_notifications.list.prev;
+ struct cds_list_head *last_element = channel->pending_notifications.list.prev;
- pending_notification = caa_container_of(last_element,
- struct pending_notification, node);
+ pending_notification = caa_container_of(last_element, struct pending_notification, node);
if (!pending_notification->notification) {
/*
* The last enqueued notification indicates dropped
goto end;
}
- if (channel->pending_notifications.count >=
- DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT &&
- pending_notification->notification) {
+ if (channel->pending_notifications.count >= DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT &&
+ pending_notification->notification) {
/*
* Discard the last enqueued notification to indicate
* that notifications were dropped at this point.
*/
- lttng_notification_destroy(
- pending_notification->notification);
+ lttng_notification_destroy(pending_notification->notification);
pending_notification->notification = NULL;
goto end;
}
goto end;
}
CDS_INIT_LIST_HEAD(&pending_notification->node);
- cds_list_add(&pending_notification->node,
- &channel->pending_notifications.list);
+ cds_list_add(&pending_notification->node, &channel->pending_notifications.list);
channel->pending_notifications.count++;
end:
return ret;
}
-static
-int enqueue_notification_from_current_message(
- struct lttng_notification_channel *channel)
+static int enqueue_notification_from_current_message(struct lttng_notification_channel *channel)
{
int ret = 0;
struct lttng_notification *notification;
struct pending_notification *pending_notification;
- if (channel->pending_notifications.count >=
- DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT) {
+ if (channel->pending_notifications.count >= DEFAULT_CLIENT_MAX_QUEUED_NOTIFICATIONS_COUNT) {
/* Drop the notification. */
ret = enqueue_dropped_notification(channel);
goto end;
}
pending_notification->notification = notification;
- cds_list_add(&pending_notification->node,
- &channel->pending_notifications.list);
+ cds_list_add(&pending_notification->node, &channel->pending_notifications.list);
channel->pending_notifications.count++;
end:
return ret;
}
enum lttng_notification_channel_status
-lttng_notification_channel_has_pending_notification(
- struct lttng_notification_channel *channel,
- bool *_notification_pending)
+lttng_notification_channel_has_pending_notification(struct lttng_notification_channel *channel,
+ bool *_notification_pending)
{
int ret;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_poll_event events;
if (!channel || !_notification_pending) {
return status;
}
-static
-int receive_command_reply(struct lttng_notification_channel *channel,
- enum lttng_notification_channel_status *status)
+static int receive_command_reply(struct lttng_notification_channel *channel,
+ enum lttng_notification_channel_status *status)
{
int ret;
struct lttng_notification_channel_command_reply *reply;
case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_COMMAND_REPLY:
goto exit_loop;
case LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION:
- ret = enqueue_notification_from_current_message(
- channel);
+ ret = enqueue_notification_from_current_message(channel);
if (ret) {
goto end;
}
{
struct lttng_notification_channel_command_handshake *handshake;
- handshake = (struct lttng_notification_channel_command_handshake *)
- (channel->reception_payload.buffer.data +
- sizeof(struct lttng_notification_channel_message));
+ handshake = (struct lttng_notification_channel_command_handshake
+ *) (channel->reception_payload.buffer.data +
+ sizeof(struct lttng_notification_channel_message));
channel->version.major = handshake->major;
channel->version.minor = handshake->minor;
channel->version.set = true;
exit_loop:
if (channel->reception_payload.buffer.size <
- (sizeof(struct lttng_notification_channel_message) +
- sizeof(*reply))) {
+ (sizeof(struct lttng_notification_channel_message) + sizeof(*reply))) {
/* Invalid message received. */
ret = -1;
goto end;
}
- reply = (struct lttng_notification_channel_command_reply *)
- (channel->reception_payload.buffer.data +
- sizeof(struct lttng_notification_channel_message));
+ reply = (struct lttng_notification_channel_command_reply
+ *) (channel->reception_payload.buffer.data +
+ sizeof(struct lttng_notification_channel_message));
*status = (enum lttng_notification_channel_status) reply->status;
end:
return ret;
}
-static
-int handshake(struct lttng_notification_channel *channel)
+static int handshake(struct lttng_notification_channel *channel)
{
ssize_t ret;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_notification_channel_command_handshake handshake = {
.major = LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR,
.minor = LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR,
pthread_mutex_lock(&channel->lock);
- ret = lttcomm_send_creds_unix_sock(channel->socket, send_buffer,
- sizeof(send_buffer));
+ ret = lttcomm_send_creds_unix_sock(channel->socket, send_buffer, sizeof(send_buffer));
if (ret < 0) {
goto end_unlock;
}
return ret;
}
-static
-enum lttng_notification_channel_status send_condition_command(
- struct lttng_notification_channel *channel,
- enum lttng_notification_channel_message_type type,
- const struct lttng_condition *condition)
+static enum lttng_notification_channel_status
+send_condition_command(struct lttng_notification_channel *channel,
+ enum lttng_notification_channel_message_type type,
+ const struct lttng_condition *condition)
{
int socket;
ssize_t ret;
- enum lttng_notification_channel_status status =
- LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
+ enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
struct lttng_payload payload;
struct lttng_notification_channel_message cmd_header;
}
LTTNG_ASSERT(type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE ||
- type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE);
+ type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE);
pthread_mutex_lock(&channel->lock);
socket = channel->socket;
goto end_unlock;
}
- ret = lttng_dynamic_buffer_append(&payload.buffer, &cmd_header,
- sizeof(cmd_header));
+ ret = lttng_dynamic_buffer_append(&payload.buffer, &cmd_header, sizeof(cmd_header));
if (ret) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
goto end_unlock;
/* Update payload length. */
((struct lttng_notification_channel_message *) payload.buffer.data)->size =
- (uint32_t) (payload.buffer.size - sizeof(cmd_header));
+ (uint32_t) (payload.buffer.size - sizeof(cmd_header));
{
- struct lttng_payload_view pv =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- const int fd_count =
- lttng_payload_view_get_fd_handle_count(&pv);
+ struct lttng_payload_view pv = lttng_payload_view_from_payload(&payload, 0, -1);
+ const int fd_count = lttng_payload_view_get_fd_handle_count(&pv);
/* Update fd count. */
((struct lttng_notification_channel_message *) payload.buffer.data)->fds =
(uint32_t) fd_count;
- ret = lttcomm_send_unix_sock(
- socket, pv.buffer.data, pv.buffer.size);
+ ret = lttcomm_send_unix_sock(socket, pv.buffer.data, pv.buffer.size);
if (ret < 0) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
goto end_unlock;
/* Pass fds if present. */
if (fd_count > 0) {
- ret = lttcomm_send_payload_view_fds_unix_sock(socket,
- &pv);
+ ret = lttcomm_send_payload_view_fds_unix_sock(socket, &pv);
if (ret < 0) {
status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR;
goto end_unlock;
return status;
}
-enum lttng_notification_channel_status lttng_notification_channel_subscribe(
- struct lttng_notification_channel *channel,
- const struct lttng_condition *condition)
+enum lttng_notification_channel_status
+lttng_notification_channel_subscribe(struct lttng_notification_channel *channel,
+ const struct lttng_condition *condition)
{
- return send_condition_command(channel,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE,
- condition);
+ return send_condition_command(
+ channel, LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE, condition);
}
-enum lttng_notification_channel_status lttng_notification_channel_unsubscribe(
- struct lttng_notification_channel *channel,
- const struct lttng_condition *condition)
+enum lttng_notification_channel_status
+lttng_notification_channel_unsubscribe(struct lttng_notification_channel *channel,
+ const struct lttng_condition *condition)
{
- return send_condition_command(channel,
- LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE,
- condition);
+ return send_condition_command(
+ channel, LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNSUBSCRIBE, condition);
}
-void lttng_notification_channel_destroy(
- struct lttng_notification_channel *channel)
+void lttng_notification_channel_destroy(struct lttng_notification_channel *channel)
{
if (!channel) {
return;
*/
#define _LGPL_SOURCE
-#include <algorithm>
-#include <string.h>
+#include "lttng-ctl-helper.hpp"
-#include <lttng/lttng-error.h>
-#include <lttng/clear.h>
-#include <lttng/clear-handle.h>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/macros.hpp>
+#include <common/buffer-view.hpp>
#include <common/compat/poll.hpp>
#include <common/dynamic-buffer.hpp>
-#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
#include <common/optional.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
-#include "lttng-ctl-helper.hpp"
+#include <lttng/clear-handle.h>
+#include <lttng/clear.h>
+#include <lttng/lttng-error.h>
+
+#include <algorithm>
+#include <string.h>
enum communication_state {
COMMUNICATION_STATE_RECEIVE_LTTNG_MSG,
free(handle);
}
-static
-struct lttng_clear_handle *lttng_clear_handle_create(int sessiond_socket)
+static struct lttng_clear_handle *lttng_clear_handle_create(int sessiond_socket)
{
int ret;
struct lttng_clear_handle *handle = zmalloc<lttng_clear_handle>();
goto error;
}
- ret = lttng_poll_add(&handle->communication.events, sessiond_socket,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(&handle->communication.events, sessiond_socket, LPOLLIN | LPOLLRDHUP);
if (ret) {
goto error;
}
- handle->communication.bytes_left_to_receive =
- sizeof(struct lttcomm_lttng_msg);
+ handle->communication.bytes_left_to_receive = sizeof(struct lttcomm_lttng_msg);
handle->communication.state = COMMUNICATION_STATE_RECEIVE_LTTNG_MSG;
end:
return handle;
return NULL;
}
-static
-int handle_state_transition(struct lttng_clear_handle *handle)
+static int handle_state_transition(struct lttng_clear_handle *handle)
{
int ret = 0;
case COMMUNICATION_STATE_RECEIVE_LTTNG_MSG:
{
const struct lttcomm_lttng_msg *msg =
- (typeof(msg)) handle->communication.buffer.data;
+ (typeof(msg)) handle->communication.buffer.data;
LTTNG_OPTIONAL_SET(&handle->clear_return_code,
- (enum lttng_error_code) msg->ret_code);
+ (enum lttng_error_code) msg->ret_code);
if (handle->clear_return_code.value != LTTNG_OK) {
handle->communication.state = COMMUNICATION_STATE_END;
break;
handle->communication.state = COMMUNICATION_STATE_END;
handle->communication.bytes_left_to_receive = 0;
LTTNG_OPTIONAL_SET(&handle->communication.data_size, 0);
- ret = lttng_dynamic_buffer_set_size(
- &handle->communication.buffer, 0);
+ ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer, 0);
LTTNG_ASSERT(!ret);
break;
}
return ret;
}
-static
-int handle_incoming_data(struct lttng_clear_handle *handle)
+static int handle_incoming_data(struct lttng_clear_handle *handle)
{
int ret;
ssize_t comm_ret;
/* Reserve space for reception. */
ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer,
- original_buffer_size + handle->communication.bytes_left_to_receive);
+ original_buffer_size +
+ handle->communication.bytes_left_to_receive);
if (ret) {
goto end;
}
comm_ret = lttcomm_recv_unix_sock(handle->communication.socket,
- handle->communication.buffer.data + original_buffer_size,
- handle->communication.bytes_left_to_receive);
+ handle->communication.buffer.data + original_buffer_size,
+ handle->communication.bytes_left_to_receive);
if (comm_ret <= 0) {
ret = -1;
goto end;
if (handle->communication.bytes_left_to_receive == 0) {
ret = handle_state_transition(handle);
} else {
- ret = lttng_dynamic_buffer_set_size(
- &handle->communication.buffer,
- original_buffer_size + comm_ret);
+ ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer,
+ original_buffer_size + comm_ret);
}
end:
return ret;
}
extern enum lttng_clear_handle_status
- lttng_clear_handle_wait_for_completion(
- struct lttng_clear_handle *handle, int timeout_ms)
+lttng_clear_handle_wait_for_completion(struct lttng_clear_handle *handle, int timeout_ms)
{
enum lttng_clear_handle_status status;
unsigned long time_left_ms = 0;
}
while (handle->communication.state != COMMUNICATION_STATE_END &&
- (time_left_ms || !has_timeout)) {
+ (time_left_ms || !has_timeout)) {
int ret;
uint32_t revents;
struct timespec current_time, diff;
unsigned long diff_ms;
ret = lttng_poll_wait(&handle->communication.events,
- has_timeout ? time_left_ms : -1);
+ has_timeout ? time_left_ms : -1);
if (ret == 0) {
/* timeout */
break;
if (revents & LPOLLIN) {
ret = handle_incoming_data(handle);
if (ret) {
- handle->communication.state =
- COMMUNICATION_STATE_ERROR;
+ handle->communication.state = COMMUNICATION_STATE_ERROR;
status = LTTNG_CLEAR_HANDLE_STATUS_ERROR;
goto end;
}
status = LTTNG_CLEAR_HANDLE_STATUS_ERROR;
goto end;
}
- DBG("%lums elapsed while waiting for session clear completion",
- diff_ms);
+ DBG("%lums elapsed while waiting for session clear completion", diff_ms);
diff_ms = std::max(diff_ms, 1UL);
diff_ms = std::min(diff_ms, time_left_ms);
time_left_ms -= diff_ms;
}
status = handle->communication.state == COMMUNICATION_STATE_END ?
- LTTNG_CLEAR_HANDLE_STATUS_COMPLETED :
- LTTNG_CLEAR_HANDLE_STATUS_TIMEOUT;
+ LTTNG_CLEAR_HANDLE_STATUS_COMPLETED :
+ LTTNG_CLEAR_HANDLE_STATUS_TIMEOUT;
end:
return status;
}
extern enum lttng_clear_handle_status
- lttng_clear_handle_get_result(
- const struct lttng_clear_handle *handle,
- enum lttng_error_code *result)
+lttng_clear_handle_get_result(const struct lttng_clear_handle *handle,
+ enum lttng_error_code *result)
{
- enum lttng_clear_handle_status status =
- LTTNG_CLEAR_HANDLE_STATUS_OK;
+ enum lttng_clear_handle_status status = LTTNG_CLEAR_HANDLE_STATUS_OK;
if (!handle->clear_return_code.is_set) {
status = LTTNG_CLEAR_HANDLE_STATUS_INVALID;
* Clear the session
*/
enum lttng_error_code lttng_clear_session(const char *session_name,
- struct lttng_clear_handle **_handle)
+ struct lttng_clear_handle **_handle)
{
enum lttng_error_code ret_code = LTTNG_OK;
struct lttng_clear_handle *handle = NULL;
ret_code = LTTNG_ERR_INVALID;
goto error;
}
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret_code = LTTNG_ERR_INVALID;
goto error;
*/
#include <lttng/lttng-export.h>
+
#include <stddef.h>
/*
*
*/
-#include <lttng/destruction-handle.h>
-#include <lttng/rotation.h>
+#include "lttng-ctl-helper.hpp"
-#include <common/optional.hpp>
+#include <common/buffer-view.hpp>
#include <common/compat/poll.hpp>
#include <common/compat/time.hpp>
-#include <common/macros.hpp>
-#include <common/compat/poll.hpp>
#include <common/dynamic-buffer.hpp>
-#include <common/buffer-view.hpp>
+#include <common/macros.hpp>
+#include <common/optional.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <lttng/destruction-handle.h>
#include <lttng/location-internal.hpp>
-#include "lttng-ctl-helper.hpp"
+#include <lttng/rotation.h>
#include <algorithm>
#include <stdbool.h>
free(handle);
}
-static
-struct lttng_destruction_handle *lttng_destruction_handle_create(
- int sessiond_socket)
+static struct lttng_destruction_handle *lttng_destruction_handle_create(int sessiond_socket)
{
int ret;
struct lttng_destruction_handle *handle = zmalloc<lttng_destruction_handle>();
goto error;
}
- ret = lttng_poll_add(&handle->communication.events, sessiond_socket,
- LPOLLIN | LPOLLRDHUP);
+ ret = lttng_poll_add(&handle->communication.events, sessiond_socket, LPOLLIN | LPOLLRDHUP);
if (ret) {
goto error;
}
- handle->communication.bytes_left_to_receive =
- sizeof(struct lttcomm_lttng_msg);
+ handle->communication.bytes_left_to_receive = sizeof(struct lttcomm_lttng_msg);
handle->communication.state = COMMUNICATION_STATE_RECEIVE_LTTNG_MSG;
end:
return handle;
return NULL;
}
-static
-int handle_state_transition(struct lttng_destruction_handle *handle)
+static int handle_state_transition(struct lttng_destruction_handle *handle)
{
int ret = 0;
case COMMUNICATION_STATE_RECEIVE_LTTNG_MSG:
{
const struct lttcomm_lttng_msg *msg =
- (typeof(msg)) handle->communication.buffer.data;
+ (typeof(msg)) handle->communication.buffer.data;
LTTNG_OPTIONAL_SET(&handle->destruction_return_code,
- (enum lttng_error_code) msg->ret_code);
+ (enum lttng_error_code) msg->ret_code);
if (handle->destruction_return_code.value != LTTNG_OK) {
handle->communication.state = COMMUNICATION_STATE_END;
break;
- } else if (msg->cmd_header_size != sizeof(struct lttcomm_session_destroy_command_header) ||
- msg->data_size > DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE) {
+ } else if (msg->cmd_header_size !=
+ sizeof(struct lttcomm_session_destroy_command_header) ||
+ msg->data_size > DEFAULT_MAX_TRACE_ARCHIVE_LOCATION_PAYLOAD_SIZE) {
handle->communication.state = COMMUNICATION_STATE_ERROR;
ret = -1;
break;
}
- handle->communication.state =
- COMMUNICATION_STATE_RECEIVE_COMMAND_HEADER;
- handle->communication.bytes_left_to_receive =
- msg->cmd_header_size;
- LTTNG_OPTIONAL_SET(&handle->communication.data_size,
- msg->data_size);
- ret = lttng_dynamic_buffer_set_size(
- &handle->communication.buffer, 0);
+ handle->communication.state = COMMUNICATION_STATE_RECEIVE_COMMAND_HEADER;
+ handle->communication.bytes_left_to_receive = msg->cmd_header_size;
+ LTTNG_OPTIONAL_SET(&handle->communication.data_size, msg->data_size);
+ ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer, 0);
LTTNG_ASSERT(!ret);
break;
}
case COMMUNICATION_STATE_RECEIVE_COMMAND_HEADER:
{
const struct lttcomm_session_destroy_command_header *hdr =
- (typeof(hdr)) handle->communication.buffer.data;
+ (typeof(hdr)) handle->communication.buffer.data;
LTTNG_OPTIONAL_SET(&handle->rotation_state,
- (enum lttng_rotation_state) hdr->rotation_state);
+ (enum lttng_rotation_state) hdr->rotation_state);
switch (handle->rotation_state.value) {
case LTTNG_ROTATION_STATE_COMPLETED:
- handle->communication.state =
- COMMUNICATION_STATE_RECEIVE_PAYLOAD;
+ handle->communication.state = COMMUNICATION_STATE_RECEIVE_PAYLOAD;
handle->communication.bytes_left_to_receive =
- LTTNG_OPTIONAL_GET(handle->communication.data_size);
+ LTTNG_OPTIONAL_GET(handle->communication.data_size);
break;
case LTTNG_ROTATION_STATE_ERROR:
case LTTNG_ROTATION_STATE_NO_ROTATION:
ssize_t location_ret;
struct lttng_trace_archive_location *location;
const struct lttng_buffer_view view =
- lttng_buffer_view_from_dynamic_buffer(
- &handle->communication.buffer, 0, -1);
+ lttng_buffer_view_from_dynamic_buffer(&handle->communication.buffer, 0, -1);
- location_ret = lttng_trace_archive_location_create_from_buffer(
- &view, &location);
+ location_ret = lttng_trace_archive_location_create_from_buffer(&view, &location);
if (location_ret < 0) {
ERR("Failed to deserialize trace archive location");
handle->communication.state = COMMUNICATION_STATE_ERROR;
return ret;
}
-static
-int handle_incoming_data(struct lttng_destruction_handle *handle)
+static int handle_incoming_data(struct lttng_destruction_handle *handle)
{
int ret;
ssize_t comm_ret;
/* Reserve space for reception. */
ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer,
- original_buffer_size + handle->communication.bytes_left_to_receive);
+ original_buffer_size +
+ handle->communication.bytes_left_to_receive);
if (ret) {
goto end;
}
comm_ret = lttcomm_recv_unix_sock(handle->communication.socket,
- handle->communication.buffer.data + original_buffer_size,
- handle->communication.bytes_left_to_receive);
+ handle->communication.buffer.data + original_buffer_size,
+ handle->communication.bytes_left_to_receive);
if (comm_ret <= 0) {
ret = -1;
goto end;
if (handle->communication.bytes_left_to_receive == 0) {
ret = handle_state_transition(handle);
} else {
- ret = lttng_dynamic_buffer_set_size(
- &handle->communication.buffer,
- original_buffer_size + comm_ret);
+ ret = lttng_dynamic_buffer_set_size(&handle->communication.buffer,
+ original_buffer_size + comm_ret);
}
end:
return ret;
}
enum lttng_destruction_handle_status
-lttng_destruction_handle_wait_for_completion(
- struct lttng_destruction_handle *handle, int timeout_ms)
+lttng_destruction_handle_wait_for_completion(struct lttng_destruction_handle *handle,
+ int timeout_ms)
{
enum lttng_destruction_handle_status status;
unsigned long time_left_ms = 0;
}
while (handle->communication.state != COMMUNICATION_STATE_END &&
- (time_left_ms || !has_timeout)) {
+ (time_left_ms || !has_timeout)) {
int ret;
uint32_t revents;
struct timespec current_time, diff;
unsigned long diff_ms;
ret = lttng_poll_wait(&handle->communication.events,
- has_timeout ? time_left_ms : -1);
+ has_timeout ? time_left_ms : -1);
if (ret == 0) {
/* timeout */
break;
if (revents & LPOLLIN) {
ret = handle_incoming_data(handle);
if (ret) {
- handle->communication.state =
- COMMUNICATION_STATE_ERROR;
+ handle->communication.state = COMMUNICATION_STATE_ERROR;
status = LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR;
goto end;
}
status = LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR;
goto end;
}
- DBG("%lums elapsed while waiting for session destruction completion",
- diff_ms);
+ DBG("%lums elapsed while waiting for session destruction completion", diff_ms);
diff_ms = std::max(diff_ms, 1UL);
diff_ms = std::min(diff_ms, time_left_ms);
time_left_ms -= diff_ms;
}
status = handle->communication.state == COMMUNICATION_STATE_END ?
- LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED :
- LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT;
+ LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED :
+ LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT;
end:
return status;
}
enum lttng_destruction_handle_status
-lttng_destruction_handle_get_rotation_state(
- const struct lttng_destruction_handle *handle,
- enum lttng_rotation_state *rotation_state)
+lttng_destruction_handle_get_rotation_state(const struct lttng_destruction_handle *handle,
+ enum lttng_rotation_state *rotation_state)
{
- enum lttng_destruction_handle_status status =
- LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ enum lttng_destruction_handle_status status = LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
if (!handle || !rotation_state) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
}
enum lttng_destruction_handle_status
-lttng_destruction_handle_get_archive_location(
- const struct lttng_destruction_handle *handle,
- const struct lttng_trace_archive_location **location)
+lttng_destruction_handle_get_archive_location(const struct lttng_destruction_handle *handle,
+ const struct lttng_trace_archive_location **location)
{
- enum lttng_destruction_handle_status status =
- LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ enum lttng_destruction_handle_status status = LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
if (!handle || !location) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
}
enum lttng_destruction_handle_status
-lttng_destruction_handle_get_result(
- const struct lttng_destruction_handle *handle,
- enum lttng_error_code *result)
+lttng_destruction_handle_get_result(const struct lttng_destruction_handle *handle,
+ enum lttng_error_code *result)
{
- enum lttng_destruction_handle_status status =
- LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ enum lttng_destruction_handle_status status = LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
if (!handle || !result) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
}
enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
- struct lttng_destruction_handle **_handle)
+ struct lttng_destruction_handle **_handle)
{
int ret;
ssize_t comm_ret;
goto error;
}
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret_code = LTTNG_ERR_INVALID;
goto error;
*/
#define _LGPL_SOURCE
-#include <stddef.h>
-
#include <common/error.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <lttng/event-internal.hpp>
#include <lttng/event.h>
#include <lttng/lttng-error.h>
#include <lttng/userspace-probe-internal.hpp>
+#include <stddef.h>
+
struct lttng_event *lttng_event_create(void)
{
struct lttng_event *event;
if (event_extended) {
if (event_extended->probe_location) {
- lttng_userspace_probe_location_destroy(
- event_extended->probe_location);
+ lttng_userspace_probe_location_destroy(event_extended->probe_location);
}
free(event_extended);
}
free(event);
}
-int lttng_event_get_filter_expression(struct lttng_event *event,
- const char **filter_expression)
+int lttng_event_get_filter_expression(struct lttng_event *event, const char **filter_expression)
{
int ret = 0;
struct lttng_event_extended *event_extended;
}
int lttng_event_get_exclusion_name(struct lttng_event *event,
- size_t index, const char **exclusion_name)
+ size_t index,
+ const char **exclusion_name)
{
int ret = 0;
struct lttng_event_extended *event_extended;
goto end;
}
- *exclusion_name = event_extended->exclusions.strings +
- (index * LTTNG_SYMBOL_NAME_LEN);
+ *exclusion_name = event_extended->exclusions.strings + (index * LTTNG_SYMBOL_NAME_LEN);
end:
return ret;
}
}
int lttng_event_set_userspace_probe_location(struct lttng_event *event,
- struct lttng_userspace_probe_location *probe_location)
+ struct lttng_userspace_probe_location *probe_location)
{
int ret = 0;
struct lttng_event_extended *event_extended;
event_extended = (struct lttng_event_extended *) event->extended.ptr;
LTTNG_ASSERT(event_extended);
if (event_extended->probe_location) {
- lttng_userspace_probe_location_destroy(
- event_extended->probe_location);
+ lttng_userspace_probe_location_destroy(event_extended->probe_location);
}
event_extended->probe_location = probe_location;
end:
*/
#define _LGPL_SOURCE
-#include <string.h>
-#include <limits.h>
+#include "lttng-ctl-helper.hpp"
-#include <lttng/lttng-error.h>
-#include <lttng/load.h>
-#include <lttng/load-internal.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/compat/string.hpp>
#include <common/config/session-config.hpp>
-#include <common/uri.hpp>
#include <common/macros.hpp>
-#include <common/compat/string.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
-#include "lttng-ctl-helper.hpp"
+#include <lttng/load-internal.hpp>
+#include <lttng/load.h>
+#include <lttng/lttng-error.h>
+
+#include <limits.h>
+#include <string.h>
struct lttng_load_session_attr *lttng_load_session_attr_create(void)
{
return zmalloc<lttng_load_session_attr>();
}
-static
-void reset_load_session_attr_urls(struct lttng_load_session_attr *attr)
+static void reset_load_session_attr_urls(struct lttng_load_session_attr *attr)
{
free(attr->raw_override_url);
free(attr->raw_override_path_url);
* Refuse override name if the objective is to load multiple session
* since this operation is ambiguous while loading multiple session.
*/
- if (attr->override_attr->session_name
- && attr->session_name[0] == '\0') {
+ if (attr->override_attr->session_name && attr->session_name[0] == '\0') {
ret = -LTTNG_ERR_INVALID;
goto end;
}
return ret;
}
-const char *lttng_load_session_attr_get_session_name(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_session_name(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-const char *lttng_load_session_attr_get_input_url(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_input_url(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-int lttng_load_session_attr_get_overwrite(
- struct lttng_load_session_attr *attr)
+int lttng_load_session_attr_get_overwrite(struct lttng_load_session_attr *attr)
{
return attr ? attr->overwrite : -LTTNG_ERR_INVALID;
}
-const char *lttng_load_session_attr_get_override_ctrl_url(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_override_ctrl_url(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-const char *lttng_load_session_attr_get_override_data_url(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_override_data_url(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-const char *lttng_load_session_attr_get_override_url(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_override_url(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
}
if ((attr->override_attr->path_url ||
- (attr->override_attr->ctrl_url &&
- attr->override_attr->data_url))) {
+ (attr->override_attr->ctrl_url && attr->override_attr->data_url))) {
ret = attr->raw_override_url;
}
end:
return ret;
}
-const char *lttng_load_session_attr_get_override_session_name(
- struct lttng_load_session_attr *attr)
+const char *lttng_load_session_attr_get_override_session_name(struct lttng_load_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-int lttng_load_session_attr_set_session_name(
- struct lttng_load_session_attr *attr, const char *session_name)
+int lttng_load_session_attr_set_session_name(struct lttng_load_session_attr *attr,
+ const char *session_name)
{
int ret = 0;
goto error;
}
- ret = lttng_strncpy(attr->session_name, session_name,
- sizeof(attr->session_name));
+ ret = lttng_strncpy(attr->session_name, session_name, sizeof(attr->session_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-int lttng_load_session_attr_set_input_url(
- struct lttng_load_session_attr *attr, const char *url)
+int lttng_load_session_attr_set_input_url(struct lttng_load_session_attr *attr, const char *url)
{
int ret = 0;
size_t len;
}
/* Copy string plus the NULL terminated byte. */
- ret = lttng_strncpy(attr->input_url, uris[0].dst.path,
- sizeof(attr->input_url));
+ ret = lttng_strncpy(attr->input_url, uris[0].dst.path, sizeof(attr->input_url));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-int lttng_load_session_attr_set_overwrite(
- struct lttng_load_session_attr *attr, int overwrite)
+int lttng_load_session_attr_set_overwrite(struct lttng_load_session_attr *attr, int overwrite)
{
int ret = 0;
return ret;
}
-int lttng_load_session_attr_set_override_ctrl_url(
- struct lttng_load_session_attr *attr, const char *url)
+int lttng_load_session_attr_set_override_ctrl_url(struct lttng_load_session_attr *attr,
+ const char *url)
{
int ret = 0;
ssize_t ret_size;
return ret;
}
-int lttng_load_session_attr_set_override_data_url(
- struct lttng_load_session_attr *attr, const char *url)
+int lttng_load_session_attr_set_override_data_url(struct lttng_load_session_attr *attr,
+ const char *url)
{
int ret = 0;
ssize_t ret_size;
return ret;
}
-int lttng_load_session_attr_set_override_url(
- struct lttng_load_session_attr *attr, const char *url)
+int lttng_load_session_attr_set_override_url(struct lttng_load_session_attr *attr, const char *url)
{
int ret = 0;
ssize_t ret_size;
return ret;
}
-int lttng_load_session_attr_set_override_session_name(
- struct lttng_load_session_attr *attr, const char *session_name)
+int lttng_load_session_attr_set_override_session_name(struct lttng_load_session_attr *attr,
+ const char *session_name)
{
int ret = 0;
size_t len;
- if (!attr ||!session_name) {
+ if (!attr || !session_name) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
goto end;
}
- attr->override_attr->session_name = lttng_strndup(session_name,
- len);
+ attr->override_attr->session_name = lttng_strndup(session_name, len);
if (!attr->override_attr->session_name) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
url = attr->input_url[0] != '\0' ? attr->input_url : NULL;
- session_name = attr->session_name[0] != '\0' ?
- attr->session_name : NULL;
+ session_name = attr->session_name[0] != '\0' ? attr->session_name : NULL;
- ret = config_load_session(url, session_name, attr->overwrite, 0,
- attr->override_attr);
+ ret = config_load_session(url, session_name, attr->overwrite, 0, attr->override_attr);
end:
return ret;
*/
#define _LGPL_SOURCE
-#include <unistd.h>
-#include <sys/types.h>
-#include <stdint.h>
-#include <limits.h>
-#include <string.h>
-#include <lttng/health-internal.hpp>
+#include "lttng-ctl-helper.hpp"
-#include <bin/lttng-sessiond/health-sessiond.hpp>
-#include <bin/lttng-consumerd/health-consumerd.hpp>
-#include <bin/lttng-relayd/health-relayd.hpp>
+#include <common/compat/errno.hpp>
#include <common/defaults.hpp>
#include <common/utils.hpp>
-#include <common/compat/errno.hpp>
-#include "lttng-ctl-helper.hpp"
+#include <lttng/health-internal.hpp>
+
+#include <bin/lttng-consumerd/health-consumerd.hpp>
+#include <bin/lttng-relayd/health-relayd.hpp>
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <limits.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
enum health_component {
HEALTH_COMPONENT_SESSIOND,
struct lttng_health_thread thread[];
};
-static
-const char *get_sessiond_thread_name(health_type_sessiond type) {
- switch (type)
- {
+static const char *get_sessiond_thread_name(health_type_sessiond type)
+{
+ switch (type) {
case HEALTH_SESSIOND_TYPE_CMD:
return "Session daemon command";
case HEALTH_SESSIOND_TYPE_APP_MANAGE:
abort();
};
-static
-const char *get_consumerd_thread_name(health_type_consumerd type) {
+static const char *get_consumerd_thread_name(health_type_consumerd type)
+{
switch (type) {
case HEALTH_CONSUMERD_TYPE_CHANNEL:
return "Consumer daemon channel";
abort();
};
-static
-const char *get_relayd_thread_name(health_type_relayd type)
+static const char *get_relayd_thread_name(health_type_relayd type)
{
switch (type) {
case HEALTH_RELAYD_TYPE_DISPATCHER:
abort();
}
-static
-const char *get_thread_name(int comp, int nr)
+static const char *get_thread_name(int comp, int nr)
{
switch (comp) {
case HEALTH_COMPONENT_SESSIOND:
*
* Returns 0 on success or a negative errno.
*/
-static
-int set_health_socket_path(struct lttng_health *lh,
- int tracing_group)
+static int set_health_socket_path(struct lttng_health *lh, int tracing_group)
{
uid_t uid;
const char *home;
} else {
return 0;
}
- break; /* Unreached */
+ break; /* Unreached */
default:
return -EINVAL;
}
uid = getuid();
if (uid == 0 || tracing_group) {
- ret = lttng_strncpy(lh->health_sock_path,
- global_str,
- sizeof(lh->health_sock_path));
+ ret = lttng_strncpy(lh->health_sock_path, global_str, sizeof(lh->health_sock_path));
return ret == 0 ? 0 : -EINVAL;
}
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
- ret = snprintf(lh->health_sock_path, sizeof(lh->health_sock_path),
- home_str, home);
+ ret = snprintf(lh->health_sock_path, sizeof(lh->health_sock_path), home_str, home);
DIAGNOSTIC_POP
if ((ret < 0) || (ret >= sizeof(lh->health_sock_path))) {
return -ENOMEM;
return 0;
}
-static
-struct lttng_health *lttng_health_create(enum health_component hc,
- unsigned int nr_threads)
+static struct lttng_health *lttng_health_create(enum health_component hc, unsigned int nr_threads)
{
struct lttng_health *lh;
int i;
}
lh->component = hc;
- lh->state = UINT64_MAX; /* All bits in error initially */
+ lh->state = UINT64_MAX; /* All bits in error initially */
lh->nr_threads = nr_threads;
for (i = 0; i < nr_threads; i++) {
lh->thread[i].p = lh;
{
struct lttng_health *lh;
- lh = lttng_health_create(HEALTH_COMPONENT_SESSIOND,
- NR_HEALTH_SESSIOND_TYPES);
+ lh = lttng_health_create(HEALTH_COMPONENT_SESSIOND, NR_HEALTH_SESSIOND_TYPES);
if (!lh) {
return NULL;
}
return lh;
}
-struct lttng_health *
- lttng_health_create_consumerd(enum lttng_health_consumerd consumerd)
+struct lttng_health *lttng_health_create_consumerd(enum lttng_health_consumerd consumerd)
{
struct lttng_health *lh;
- lh = lttng_health_create(HEALTH_COMPONENT_CONSUMERD,
- NR_HEALTH_CONSUMERD_TYPES);
+ lh = lttng_health_create(HEALTH_COMPONENT_CONSUMERD, NR_HEALTH_CONSUMERD_TYPES);
if (!lh) {
return NULL;
}
goto error;
}
- lh = lttng_health_create(HEALTH_COMPONENT_RELAYD,
- NR_HEALTH_RELAYD_TYPES);
+ lh = lttng_health_create(HEALTH_COMPONENT_RELAYD, NR_HEALTH_RELAYD_TYPES);
if (!lh) {
goto error;
}
- ret = lttng_strncpy(lh->health_sock_path, path,
- sizeof(lh->health_sock_path));
+ ret = lttng_strncpy(lh->health_sock_path, path, sizeof(lh->health_sock_path));
if (ret) {
goto error;
}
memset(&msg, 0, sizeof(msg));
msg.cmd = HEALTH_CMD_CHECK;
- ret = lttcomm_send_unix_sock(sock, (void *)&msg, sizeof(msg));
+ ret = lttcomm_send_unix_sock(sock, (void *) &msg, sizeof(msg));
if (ret < 0) {
ret = -1;
goto close_error;
}
- ret = lttcomm_recv_unix_sock(sock, (void *)&reply, sizeof(reply));
+ ret = lttcomm_recv_unix_sock(sock, (void *) &reply, sizeof(reply));
if (ret < 0) {
ret = -1;
goto close_error;
}
close_error:
- {
- int closeret;
+{
+ int closeret;
- closeret = close(sock);
- LTTNG_ASSERT(!closeret);
- }
+ closeret = close(sock);
+ LTTNG_ASSERT(!closeret);
+}
error:
if (ret >= 0)
return health->nr_threads;
}
-const struct lttng_health_thread *
- lttng_health_get_thread(const struct lttng_health *health,
- unsigned int nth_thread)
+const struct lttng_health_thread *lttng_health_get_thread(const struct lttng_health *health,
+ unsigned int nth_thread)
{
if (!health || nth_thread >= health->nr_threads) {
return NULL;
return NULL;
}
nr = thread - &thread->p->thread[0];
- return get_thread_name (thread->p->component, nr);
+ return get_thread_name(thread->p->component, nr);
}
*/
#define _LGPL_SOURCE
-#include <grp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
+#include "lttng-ctl-helper.hpp"
-#include <common/bytecode/bytecode.hpp>
#include <common/align.hpp>
+#include <common/bytecode/bytecode.hpp>
#include <common/common.hpp>
#include <common/compat/errno.hpp>
#include <common/compat/string.hpp>
#include <common/defaults.hpp>
#include <common/dynamic-array.hpp>
#include <common/dynamic-buffer.hpp>
+#include <common/filter/filter-ast.hpp>
+#include <common/filter/filter-parser.hpp>
+#include <common/filter/memstream.hpp>
#include <common/payload-view.hpp>
#include <common/payload.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/unix.hpp>
#include <common/uri.hpp>
#include <common/utils.hpp>
+
#include <lttng/channel-internal.hpp>
#include <lttng/destruction-handle.h>
#include <lttng/endpoint.h>
#include <lttng/trigger/trigger-internal.hpp>
#include <lttng/userspace-probe-internal.hpp>
-#include "lttng-ctl-helper.hpp"
-#include <common/filter/filter-ast.hpp>
-#include <common/filter/filter-parser.hpp>
-#include <common/filter/memstream.hpp>
+#include <grp.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
-#define COPY_DOMAIN_PACKED(dst, src) \
-do { \
- struct lttng_domain _tmp_domain; \
- \
- lttng_ctl_copy_lttng_domain(&_tmp_domain, &src); \
- dst = _tmp_domain; \
-} while (0)
+#define COPY_DOMAIN_PACKED(dst, src) \
+ do { \
+ struct lttng_domain _tmp_domain; \
+ \
+ lttng_ctl_copy_lttng_domain(&_tmp_domain, &src); \
+ dst = _tmp_domain; \
+ } while (0)
/* Socket to session daemon for communication */
static int sessiond_socket = -1;
*
* If domain is unknown, default domain will be the kernel.
*/
-void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
- struct lttng_domain *src)
+void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src)
{
if (src && dst) {
switch (src->type) {
goto end;
}
- DBG("LSM cmd type: '%s' (%d)", lttcomm_sessiond_command_str((lttcomm_sessiond_command) lsm->cmd_type),
- lsm->cmd_type);
+ DBG("LSM cmd type: '%s' (%d)",
+ lttcomm_sessiond_command_str((lttcomm_sessiond_command) lsm->cmd_type),
+ lsm->cmd_type);
- ret = lttcomm_send_creds_unix_sock(sessiond_socket, lsm,
- sizeof(struct lttcomm_session_msg));
+ ret = lttcomm_send_creds_unix_sock(
+ sessiond_socket, lsm, sizeof(struct lttcomm_session_msg));
if (ret < 0) {
ret = -LTTNG_ERR_FATAL;
}
int ret;
const size_t original_payload_size = payload->buffer.size;
- ret = lttng_dynamic_buffer_set_size(
- &payload->buffer, payload->buffer.size + len);
+ ret = lttng_dynamic_buffer_set_size(&payload->buffer, payload->buffer.size + len);
if (ret) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
- ret = recv_data_sessiond(
- payload->buffer.data + original_payload_size, len);
+ ret = recv_data_sessiond(payload->buffer.data + original_payload_size, len);
end:
return ret;
}
return ret;
}
-static enum lttng_error_code check_enough_available_memory(
- uint64_t num_bytes_requested_per_cpu)
+static enum lttng_error_code check_enough_available_memory(uint64_t num_bytes_requested_per_cpu)
{
int ret;
enum lttng_error_code ret_code;
goto end;
}
- num_bytes_requested_total =
- num_bytes_requested_per_cpu * (uint64_t) num_cpu;
+ num_bytes_requested_total = num_bytes_requested_per_cpu * (uint64_t) num_cpu;
/*
* Try to get the `MemAvail` field of `/proc/meminfo`. This is the most
*/
static int set_session_daemon_path(void)
{
- int in_tgroup = 0; /* In tracing group. */
+ int in_tgroup = 0; /* In tracing group. */
uid_t uid;
uid = getuid();
if ((uid == 0) || in_tgroup == 1) {
const int ret = lttng_strncpy(sessiond_sock_path,
- DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
- sizeof(sessiond_sock_path));
+ DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
+ sizeof(sessiond_sock_path));
if (ret) {
goto error;
* With GNU C >= 2.1, snprintf returns the required size
* (excluding closing null)
*/
- ret = snprintf(sessiond_sock_path, sizeof(sessiond_sock_path),
- DEFAULT_HOME_CLIENT_UNIX_SOCK, utils_get_home_dir());
+ ret = snprintf(sessiond_sock_path,
+ sizeof(sessiond_sock_path),
+ DEFAULT_HOME_CLIENT_UNIX_SOCK,
+ utils_get_home_dir());
if ((ret < 0) || (ret >= sizeof(sessiond_sock_path))) {
goto error;
}
return ret;
}
-static int recv_sessiond_optional_data(size_t len, void **user_buf,
- size_t *user_len)
+static int recv_sessiond_optional_data(size_t len, void **user_buf, size_t *user_len)
{
int ret = 0;
char *buf = NULL;
* Return size of data (only payload, not header) or a negative error code.
*/
int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
- const int *fds, size_t nb_fd, const void *vardata,
- size_t vardata_len, void **user_payload_buf,
- void **user_cmd_header_buf, size_t *user_cmd_header_len)
+ const int *fds,
+ size_t nb_fd,
+ const void *vardata,
+ size_t vardata_len,
+ void **user_payload_buf,
+ void **user_cmd_header_buf,
+ size_t *user_cmd_header_len)
{
int ret;
size_t payload_len;
}
/* Get command header from data transmission */
- ret = recv_sessiond_optional_data(llm.cmd_header_size,
- user_cmd_header_buf, user_cmd_header_len);
+ ret = recv_sessiond_optional_data(
+ llm.cmd_header_size, user_cmd_header_buf, user_cmd_header_len);
if (ret < 0) {
goto end;
}
/* Get payload from data transmission */
- ret = recv_sessiond_optional_data(llm.data_size, user_payload_buf,
- &payload_len);
+ ret = recv_sessiond_optional_data(llm.data_size, user_payload_buf, &payload_len);
if (ret < 0) {
goto end;
}
return ret;
}
-int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message,
- struct lttng_payload *reply)
+int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, struct lttng_payload *reply)
{
int ret;
struct lttcomm_lttng_msg llm;
}
/* Send command to session daemon */
- ret = lttcomm_send_creds_unix_sock(sessiond_socket, message->buffer.data,
- message->buffer.size);
+ ret = lttcomm_send_creds_unix_sock(
+ sessiond_socket, message->buffer.data, message->buffer.size);
if (ret < 0) {
ret = -LTTNG_ERR_FATAL;
goto end;
}
if (fd_count > 0) {
- ret = lttcomm_send_payload_view_fds_unix_sock(sessiond_socket,
- message);
+ ret = lttcomm_send_payload_view_fds_unix_sock(sessiond_socket, message);
if (ret < 0) {
ret = -LTTNG_ERR_FATAL;
goto end;
}
if (llm.fd_count > 0) {
- ret = lttcomm_recv_payload_fds_unix_sock(
- sessiond_socket, llm.fd_count, reply);
+ ret = lttcomm_recv_payload_fds_unix_sock(sessiond_socket, llm.fd_count, reply);
if (ret < 0) {
goto end;
}
}
/* Don't return the llm header to the caller. */
- memmove(reply->buffer.data, reply->buffer.data + sizeof(llm),
- reply->buffer.size - sizeof(llm));
- ret = lttng_dynamic_buffer_set_size(
- &reply->buffer, reply->buffer.size - sizeof(llm));
+ memmove(reply->buffer.data,
+ reply->buffer.data + sizeof(llm),
+ reply->buffer.size - sizeof(llm));
+ ret = lttng_dynamic_buffer_set_size(&reply->buffer, reply->buffer.size - sizeof(llm));
if (ret) {
/* Can't happen as size is reduced. */
abort();
*
* The returned pointer will be NULL in case of malloc() error.
*/
-struct lttng_handle *lttng_create_handle(const char *session_name,
- struct lttng_domain *domain)
+struct lttng_handle *lttng_create_handle(const char *session_name, struct lttng_domain *domain)
{
int ret;
struct lttng_handle *handle = NULL;
}
/* Copy session name */
- ret = lttng_strncpy(handle->session_name, session_name ? : "",
- sizeof(handle->session_name));
+ ret = lttng_strncpy(handle->session_name, session_name ?: "", sizeof(handle->session_name));
if (ret) {
goto error;
}
*
* Returns size of returned session payload data or a negative error code.
*/
-int lttng_register_consumer(struct lttng_handle *handle,
- const char *socket_path)
+int lttng_register_consumer(struct lttng_handle *handle, const char *socket_path)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGISTER_CONSUMER;
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_strncpy(lsm.u.reg.path, socket_path,
- sizeof(lsm.u.reg.path));
+ ret = lttng_strncpy(lsm.u.reg.path, socket_path, sizeof(lsm.u.reg.path));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_START_TRACE;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_STOP_TRACE;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
* Returns the size of the returned payload data or a negative error code.
*/
int lttng_add_context(struct lttng_handle *handle,
- struct lttng_event_context *ctx,
- const char *event_name __attribute__((unused)),
- const char *channel_name)
+ struct lttng_event_context *ctx,
+ const char *event_name __attribute__((unused)),
+ const char *channel_name)
{
int ret;
struct lttcomm_session_msg lsm = {
}
/* If no channel name, send empty string. */
- ret = lttng_strncpy(lsm.u.context.channel_name, channel_name ?: "",
- sizeof(lsm.u.context.channel_name));
+ ret = lttng_strncpy(
+ lsm.u.context.channel_name, channel_name ?: "", sizeof(lsm.u.context.channel_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
{
struct lttng_payload reply;
struct lttng_payload_view payload_view =
- lttng_payload_view_from_payload(&payload, 0,
- -1);
+ lttng_payload_view_from_payload(&payload, 0, -1);
lttng_payload_init(&reply);
ret = lttng_ctl_ask_sessiond_payload(&payload_view, &reply);
* Returns size of returned session payload data or a negative error code.
*/
int lttng_enable_event(struct lttng_handle *handle,
- struct lttng_event *ev, const char *channel_name)
+ struct lttng_event *ev,
+ const char *channel_name)
{
- return lttng_enable_event_with_exclusions(handle, ev, channel_name,
- NULL, 0, NULL);
+ return lttng_enable_event_with_exclusions(handle, ev, channel_name, NULL, 0, NULL);
}
/*
* Return size of returned session payload data if OK.
*/
int lttng_enable_event_with_filter(struct lttng_handle *handle,
- struct lttng_event *event, const char *channel_name,
- const char *filter_expression)
+ struct lttng_event *event,
+ const char *channel_name,
+ const char *filter_expression)
{
- return lttng_enable_event_with_exclusions(handle, event, channel_name,
- filter_expression, 0, NULL);
+ return lttng_enable_event_with_exclusions(
+ handle, event, channel_name, filter_expression, 0, NULL);
}
/*
/* Don't add filter for the '*' event. */
if (strcmp(ev->name, "*") != 0) {
if (filter) {
- err = asprintf(&agent_filter, "(%s) && (logger_name == \"%s\")", filter,
- ev->name);
+ err = asprintf(
+ &agent_filter, "(%s) && (logger_name == \"%s\")", filter, ev->name);
} else {
err = asprintf(&agent_filter, "logger_name == \"%s\"", ev->name);
}
if (filter || agent_filter) {
char *new_filter;
- err = asprintf(&new_filter, "(%s) && (int_loglevel %s %d)",
- agent_filter ? agent_filter : filter, op,
- ev->loglevel);
+ err = asprintf(&new_filter,
+ "(%s) && (int_loglevel %s %d)",
+ agent_filter ? agent_filter : filter,
+ op,
+ ev->loglevel);
if (agent_filter) {
free(agent_filter);
}
agent_filter = new_filter;
} else {
- err = asprintf(&agent_filter, "int_loglevel %s %d", op,
- ev->loglevel);
+ err = asprintf(&agent_filter, "int_loglevel %s %d", op, ev->loglevel);
}
if (err < 0) {
PERROR("asprintf");
* Returns size of returned session payload data or a negative error code.
*/
int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
- struct lttng_event *ev, const char *channel_name,
- const char *original_filter_expression,
- int exclusion_count, char **exclusion_list)
+ struct lttng_event *ev,
+ const char *channel_name,
+ const char *original_filter_expression,
+ int exclusion_count,
+ char **exclusion_list)
{
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_ENABLE_EVENT,
}
/* Parse filter expression. */
- if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL
- || handle->domain.type == LTTNG_DOMAIN_LOG4J
- || handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+ if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL ||
+ handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+ handle->domain.type == LTTNG_DOMAIN_PYTHON) {
if (handle->domain.type == LTTNG_DOMAIN_JUL ||
- handle->domain.type == LTTNG_DOMAIN_LOG4J ||
- handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+ handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+ handle->domain.type == LTTNG_DOMAIN_PYTHON) {
char *agent_filter;
/* Setup agent filter if needed. */
}
}
- if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) ==
- LTTNG_FILTER_MAX_LEN) {
+ if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) == LTTNG_FILTER_MAX_LEN) {
ret = -LTTNG_ERR_FILTER_INVAL;
goto error;
}
goto error;
}
- bytecode_len = bytecode_get_len(&ctx->bytecode->b) +
- sizeof(ctx->bytecode->b);
+ bytecode_len = bytecode_get_len(&ctx->bytecode->b) + sizeof(ctx->bytecode->b);
if (bytecode_len > LTTNG_FILTER_MAX_LEN) {
ret = -LTTNG_ERR_FILTER_INVAL;
goto error;
}
serialize:
- ret = lttng_event_serialize(ev, exclusion_count, exclusion_list,
- filter_expression, bytecode_len,
- (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
- &payload);
+ ret = lttng_event_serialize(ev,
+ exclusion_count,
+ exclusion_list,
+ filter_expression,
+ bytecode_len,
+ (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
+ &payload);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
/* If no channel name, send empty string. */
- ret = lttng_strncpy(lsm.u.enable.channel_name, channel_name ?: "",
- sizeof(lsm.u.enable.channel_name));
+ ret = lttng_strncpy(
+ lsm.u.enable.channel_name, channel_name ?: "", sizeof(lsm.u.enable.channel_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
/* Session name */
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
lsm.u.enable.length = (uint32_t) payload.buffer.size;
{
- struct lttng_payload_view view = lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
int fd_count = lttng_payload_view_get_fd_handle_count(&view);
int fd_to_send;
LTTNG_ASSERT(fd_count == 0 || fd_count == 1);
if (fd_count == 1) {
- struct fd_handle *h =
- lttng_payload_view_pop_fd_handle(&view);
+ struct fd_handle *h = lttng_payload_view_pop_fd_handle(&view);
if (!h) {
goto error;
lsm.fd_count = fd_count;
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- fd_count ? &fd_to_send : NULL, fd_count,
- view.buffer.size ? view.buffer.data : NULL,
- view.buffer.size, NULL, NULL, 0);
+ fd_count ? &fd_to_send : NULL,
+ fd_count,
+ view.buffer.size ? view.buffer.data : NULL,
+ view.buffer.size,
+ NULL,
+ NULL,
+ 0);
}
error:
}
int lttng_disable_event_ext(struct lttng_handle *handle,
- struct lttng_event *ev, const char *channel_name,
- const char *original_filter_expression)
+ struct lttng_event *ev,
+ const char *channel_name,
+ const char *original_filter_expression)
{
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_DISABLE_EVENT,
}
/* Parse filter expression. */
- if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL
- || handle->domain.type == LTTNG_DOMAIN_LOG4J
- || handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+ if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL ||
+ handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+ handle->domain.type == LTTNG_DOMAIN_PYTHON) {
if (handle->domain.type == LTTNG_DOMAIN_JUL ||
- handle->domain.type == LTTNG_DOMAIN_LOG4J ||
- handle->domain.type == LTTNG_DOMAIN_PYTHON) {
+ handle->domain.type == LTTNG_DOMAIN_LOG4J ||
+ handle->domain.type == LTTNG_DOMAIN_PYTHON) {
char *agent_filter;
/* Setup agent filter if needed. */
}
}
- if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) ==
- LTTNG_FILTER_MAX_LEN) {
+ if (strnlen(filter_expression, LTTNG_FILTER_MAX_LEN) == LTTNG_FILTER_MAX_LEN) {
ret = -LTTNG_ERR_FILTER_INVAL;
goto error;
}
goto error;
}
- bytecode_len = bytecode_get_len(&ctx->bytecode->b) +
- sizeof(ctx->bytecode->b);
+ bytecode_len = bytecode_get_len(&ctx->bytecode->b) + sizeof(ctx->bytecode->b);
if (bytecode_len > LTTNG_FILTER_MAX_LEN) {
ret = -LTTNG_ERR_FILTER_INVAL;
goto error;
}
serialize:
- ret = lttng_event_serialize(ev, 0, NULL,
- filter_expression, bytecode_len,
- (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
- &payload);
+ ret = lttng_event_serialize(ev,
+ 0,
+ NULL,
+ filter_expression,
+ bytecode_len,
+ (ctx && bytecode_len) ? &ctx->bytecode->b : NULL,
+ &payload);
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
/* If no channel name, send empty string. */
- ret = lttng_strncpy(lsm.u.disable.channel_name, channel_name ?: "",
- sizeof(lsm.u.disable.channel_name));
+ ret = lttng_strncpy(
+ lsm.u.disable.channel_name, channel_name ?: "", sizeof(lsm.u.disable.channel_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
/* Session name */
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
lsm.u.disable.length = (uint32_t) payload.buffer.size;
{
- struct lttng_payload_view view = lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
int fd_count = lttng_payload_view_get_fd_handle_count(&view);
int fd_to_send;
LTTNG_ASSERT(fd_count == 0 || fd_count == 1);
if (fd_count == 1) {
- struct fd_handle *h =
- lttng_payload_view_pop_fd_handle(&view);
+ struct fd_handle *h = lttng_payload_view_pop_fd_handle(&view);
if (!h) {
goto error;
}
ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
- fd_count ? &fd_to_send : NULL, fd_count,
- view.buffer.size ? view.buffer.data : NULL,
- view.buffer.size, NULL, NULL, 0);
+ fd_count ? &fd_to_send : NULL,
+ fd_count,
+ view.buffer.size ? view.buffer.data : NULL,
+ view.buffer.size,
+ NULL,
+ NULL,
+ 0);
}
error:
* If no channel name is specified, the default 'channel0' is used.
* Returns size of returned session payload data or a negative error code.
*/
-int lttng_disable_event(struct lttng_handle *handle, const char *name,
- const char *channel_name)
+int lttng_disable_event(struct lttng_handle *handle, const char *name, const char *channel_name)
{
int ret;
struct lttng_event ev;
* Enable channel per domain
* Returns size of returned session payload data or a negative error code.
*/
-int lttng_enable_channel(struct lttng_handle *handle,
- struct lttng_channel *in_chan)
+int lttng_enable_channel(struct lttng_handle *handle, struct lttng_channel *in_chan)
{
enum lttng_error_code ret_code;
int ret;
* Verify that the amount of memory required to create the requested
* buffer is available on the system at the moment.
*/
- if (in_chan->attr.num_subbuf >
- UINT64_MAX / in_chan->attr.subbuf_size) {
+ if (in_chan->attr.num_subbuf > UINT64_MAX / in_chan->attr.subbuf_size) {
/* Overflow */
ret = -LTTNG_ERR_OVERFLOW;
goto end;
}
- total_buffer_size_needed_per_cpu =
- in_chan->attr.num_subbuf * in_chan->attr.subbuf_size;
- ret_code = check_enough_available_memory(
- total_buffer_size_needed_per_cpu);
+ total_buffer_size_needed_per_cpu = in_chan->attr.num_subbuf * in_chan->attr.subbuf_size;
+ ret_code = check_enough_available_memory(total_buffer_size_needed_per_cpu);
if (ret_code != LTTNG_OK) {
ret = -ret_code;
goto end;
/* Populate the channel extended attribute if necessary. */
if (!channel->attr.extended.ptr) {
- struct lttng_channel_extended *extended =
- zmalloc<lttng_channel_extended>();
+ struct lttng_channel_extended *extended = zmalloc<lttng_channel_extended>();
if (!extended) {
ret = -LTTNG_ERR_NOMEM;
goto end;
}
- lttng_channel_set_default_extended_attr(
- &handle->domain, extended);
+ lttng_channel_set_default_extended_attr(&handle->domain, extended);
channel->attr.extended.ptr = extended;
}
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_ENABLE_CHANNEL;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
lsm.u.channel.length = buffer.size;
- ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
- &lsm, buffer.data, buffer.size, NULL);
+ ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buffer.data, buffer.size, NULL);
end:
lttng_channel_destroy(channel);
lttng_dynamic_buffer_reset(&buffer);
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_DISABLE_CHANNEL;
- ret = lttng_strncpy(lsm.u.disable.channel_name, name,
- sizeof(lsm.u.disable.channel_name));
+ ret = lttng_strncpy(lsm.u.disable.channel_name, name, sizeof(lsm.u.disable.channel_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
* Returns the number of lttng_event entries in events;
* on error, returns a negative value.
*/
-int lttng_list_tracepoints(struct lttng_handle *handle,
- struct lttng_event **events)
+int lttng_list_tracepoints(struct lttng_handle *handle, struct lttng_event **events)
{
- enum lttng_error_code ret_code;
- int ret, total_payload_received;
- char *reception_buffer = NULL;
- struct lttcomm_session_msg lsm = {
+ enum lttng_error_code ret_code;
+ int ret, total_payload_received;
+ char *reception_buffer = NULL;
+ struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_TRACEPOINTS,
.session = {},
.domain = {},
.u = {},
.fd_count = 0,
};
- struct lttcomm_list_command_header *cmd_header = NULL;
- size_t cmd_header_len;
- unsigned int nb_events = 0;
+ struct lttcomm_list_command_header *cmd_header = NULL;
+ size_t cmd_header_len;
+ unsigned int nb_events = 0;
- if (handle == NULL) {
- ret = -LTTNG_ERR_INVALID;
- goto end;
- }
+ if (handle == NULL) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
- COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
+ COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
- (void **) &reception_buffer, (void **) &cmd_header,
- &cmd_header_len);
- if (ret < 0) {
- goto end;
- }
+ ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ (void **) &reception_buffer,
+ (void **) &cmd_header,
+ &cmd_header_len);
+ if (ret < 0) {
+ goto end;
+ }
- total_payload_received = ret;
+ total_payload_received = ret;
- if (!cmd_header) {
- ret = -LTTNG_ERR_UNK;
- goto end;
- }
+ if (!cmd_header) {
+ ret = -LTTNG_ERR_UNK;
+ goto end;
+ }
- if (cmd_header->count > INT_MAX) {
- ret = -LTTNG_ERR_OVERFLOW;
- goto end;
- }
+ if (cmd_header->count > INT_MAX) {
+ ret = -LTTNG_ERR_OVERFLOW;
+ goto end;
+ }
- nb_events = (unsigned int) cmd_header->count;
+ nb_events = (unsigned int) cmd_header->count;
{
struct lttng_buffer_view events_view =
- lttng_buffer_view_init(reception_buffer, 0,
- total_payload_received);
+ lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
struct lttng_payload_view events_payload_view =
- lttng_payload_view_from_buffer_view(
- &events_view, 0, -1);
+ lttng_payload_view_from_buffer_view(&events_view, 0, -1);
ret_code = lttng_events_create_and_flatten_from_payload(
- &events_payload_view, nb_events, events);
+ &events_payload_view, nb_events, events);
if (ret_code != LTTNG_OK) {
ret = -ret_code;
goto end;
ret = (int) nb_events;
end:
- free(cmd_header);
- free(reception_buffer);
- return ret;
+ free(cmd_header);
+ free(reception_buffer);
+ return ret;
}
/*
* Returns the number of lttng_event_field entries in events;
* on error, returns a negative value.
*/
-int lttng_list_tracepoint_fields(struct lttng_handle *handle,
- struct lttng_event_field **fields)
+int lttng_list_tracepoint_fields(struct lttng_handle *handle, struct lttng_event_field **fields)
{
enum lttng_error_code ret_code;
int ret;
{
lttng_payload_view message_view =
- lttng_payload_view_init_from_buffer(
- (const char *) &lsm, 0,
- sizeof(lsm));
+ lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
if (ret < 0) {
}
{
- const lttng_buffer_view cmd_header_view =
- lttng_buffer_view_from_dynamic_buffer(
- &reply.buffer, 0, sizeof(*cmd_header));
+ const lttng_buffer_view cmd_header_view = lttng_buffer_view_from_dynamic_buffer(
+ &reply.buffer, 0, sizeof(*cmd_header));
if (!lttng_buffer_view_is_valid(&cmd_header_view)) {
ret = -LTTNG_ERR_INVALID_PROTOCOL;
goto end;
}
- cmd_header = (struct lttcomm_list_command_header *)
- cmd_header_view.data;
+ cmd_header = (struct lttcomm_list_command_header *) cmd_header_view.data;
}
if (cmd_header->count > INT_MAX) {
{
lttng_payload_view reply_view =
- lttng_payload_view_from_payload(&reply,
- sizeof(*cmd_header), -1);
+ lttng_payload_view_from_payload(&reply, sizeof(*cmd_header), -1);
ret_code = lttng_event_fields_create_and_flatten_from_payload(
- &reply_view, nb_event_fields, fields);
+ &reply_view, nb_event_fields, fields);
if (ret_code != LTTNG_OK) {
ret = -ret_code;
goto end;
*/
int lttng_list_syscalls(struct lttng_event **events)
{
- enum lttng_error_code ret_code;
- int ret, total_payload_received;
- char *reception_buffer = NULL;
- struct lttcomm_session_msg lsm = {};
- struct lttcomm_list_command_header *cmd_header = NULL;
- size_t cmd_header_len;
- uint32_t nb_events = 0;
-
- if (!events) {
- ret = -LTTNG_ERR_INVALID;
- goto end;
- }
-
- lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_SYSCALLS;
- /* Force kernel domain for system calls. */
- lsm.domain.type = LTTNG_DOMAIN_KERNEL;
-
- ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
- (void **) &reception_buffer, (void **) &cmd_header,
- &cmd_header_len);
- if (ret < 0) {
- goto end;
- }
- total_payload_received = ret;
-
- if (!cmd_header) {
- ret = -LTTNG_ERR_UNK;
- goto end;
- }
-
- if (cmd_header->count > INT_MAX) {
- ret = -LTTNG_ERR_OVERFLOW;
- goto end;
- }
-
- nb_events = (unsigned int) cmd_header->count;
-
- {
- const struct lttng_buffer_view events_view =
- lttng_buffer_view_init(reception_buffer, 0,
- total_payload_received);
+ enum lttng_error_code ret_code;
+ int ret, total_payload_received;
+ char *reception_buffer = NULL;
+ struct lttcomm_session_msg lsm = {};
+ struct lttcomm_list_command_header *cmd_header = NULL;
+ size_t cmd_header_len;
+ uint32_t nb_events = 0;
+
+ if (!events) {
+ ret = -LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_SYSCALLS;
+ /* Force kernel domain for system calls. */
+ lsm.domain.type = LTTNG_DOMAIN_KERNEL;
+
+ ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ (void **) &reception_buffer,
+ (void **) &cmd_header,
+ &cmd_header_len);
+ if (ret < 0) {
+ goto end;
+ }
+ total_payload_received = ret;
+
+ if (!cmd_header) {
+ ret = -LTTNG_ERR_UNK;
+ goto end;
+ }
+
+ if (cmd_header->count > INT_MAX) {
+ ret = -LTTNG_ERR_OVERFLOW;
+ goto end;
+ }
+
+ nb_events = (unsigned int) cmd_header->count;
+
+ {
+ const struct lttng_buffer_view events_view =
+ lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
struct lttng_payload_view events_payload_view =
- lttng_payload_view_from_buffer_view(
- &events_view, 0, -1);
+ lttng_payload_view_from_buffer_view(&events_view, 0, -1);
- ret_code = lttng_events_create_and_flatten_from_payload(
- &events_payload_view, nb_events, events);
- if (ret_code != LTTNG_OK) {
- ret = -ret_code;
- goto end;
- }
- }
+ ret_code = lttng_events_create_and_flatten_from_payload(
+ &events_payload_view, nb_events, events);
+ if (ret_code != LTTNG_OK) {
+ ret = -ret_code;
+ goto end;
+ }
+ }
- ret = (int) nb_events;
+ ret = (int) nb_events;
end:
- free(reception_buffer);
- free(cmd_header);
- return ret;
+ free(reception_buffer);
+ free(cmd_header);
+ return ret;
}
/*
return error_get_str(code);
}
-enum lttng_error_code lttng_create_session_ext(
- struct lttng_session_descriptor *session_descriptor)
+enum lttng_error_code lttng_create_session_ext(struct lttng_session_descriptor *session_descriptor)
{
enum lttng_error_code ret_code;
struct lttcomm_session_msg lsm = {
}
sessiond_must_generate_ouput =
- !lttng_session_descriptor_is_output_destination_initialized(
- session_descriptor);
+ !lttng_session_descriptor_is_output_destination_initialized(session_descriptor);
if (sessiond_must_generate_ouput) {
const char *home_dir = utils_get_home_dir();
size_t home_dir_len = home_dir ? strlen(home_dir) + 1 : 0;
}
lsm.u.create_session.home_dir_size = (uint16_t) home_dir_len;
- ret = lttng_dynamic_buffer_append(&payload, home_dir,
- home_dir_len);
+ ret = lttng_dynamic_buffer_append(&payload, home_dir, home_dir_len);
if (ret) {
ret_code = LTTNG_ERR_NOMEM;
goto end;
}
descriptor_size = payload.size;
- ret = lttng_session_descriptor_serialize(session_descriptor,
- &payload);
+ ret = lttng_session_descriptor_serialize(session_descriptor, &payload);
if (ret) {
ret_code = LTTNG_ERR_INVALID;
goto end;
lsm.u.create_session.session_descriptor_size = descriptor_size;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, payload.data,
- payload.size, &reply);
+ reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+ &lsm, payload.data, payload.size, &reply);
if (reply_ret < 0) {
ret_code = (lttng_error_code) -reply_ret;
goto end;
}
reply_view = lttng_buffer_view_init((const char *) reply, 0, reply_ret);
- ret = lttng_session_descriptor_create_from_buffer(&reply_view,
- &descriptor_reply);
+ ret = lttng_session_descriptor_create_from_buffer(&reply_view, &descriptor_reply);
if (ret < 0) {
ret_code = LTTNG_ERR_FATAL;
goto end;
ret = -LTTNG_ERR_INVALID;
goto end;
}
- descriptor = lttng_session_descriptor_local_create(name,
- uris[0].dst.path);
+ descriptor = lttng_session_descriptor_local_create(name, uris[0].dst.path);
break;
case 2:
- descriptor = lttng_session_descriptor_network_create(name, url,
- NULL);
+ descriptor = lttng_session_descriptor_network_create(name, url, NULL);
break;
default:
ret = -LTTNG_ERR_INVALID;
/*
* If the user does not specify a custom subdir, use the session name.
*/
- if (size > 0 && uris[0].dtype != LTTNG_DST_PATH &&
- strlen(uris[0].subdir) == 0) {
- ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s",
- name);
+ if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
+ ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
if (ret < 0) {
PERROR("Failed to set session name as network destination sub-directory");
ret = -LTTNG_ERR_FATAL;
ret = -LTTNG_ERR_INVALID;
goto end;
}
- descriptor = lttng_session_descriptor_snapshot_local_create(
- name,
- uris[0].dst.path);
+ descriptor = lttng_session_descriptor_snapshot_local_create(name, uris[0].dst.path);
break;
case 2:
- descriptor = lttng_session_descriptor_snapshot_network_create(
- name,
- snapshot_url,
- NULL);
+ descriptor =
+ lttng_session_descriptor_snapshot_network_create(name, snapshot_url, NULL);
break;
default:
ret = -LTTNG_ERR_INVALID;
*
* Return 0 on success else a negative LTTng error code.
*/
-int lttng_create_session_live(const char *name, const char *url,
- unsigned int timer_interval)
+int lttng_create_session_live(const char *name, const char *url, unsigned int timer_interval)
{
int ret;
enum lttng_error_code ret_code;
if (url) {
descriptor = lttng_session_descriptor_live_network_create(
- name, url, NULL, timer_interval);
+ name, url, NULL, timer_interval);
} else {
- descriptor = lttng_session_descriptor_live_create(
- name, timer_interval);
+ descriptor = lttng_session_descriptor_live_create(name, timer_interval);
}
if (!descriptor) {
ret = -LTTNG_ERR_INVALID;
{
int ret;
struct lttcomm_session_msg lsm;
- const size_t session_size = sizeof(struct lttng_session) +
- sizeof(struct lttng_session_extended);
+ const size_t session_size =
+ sizeof(struct lttng_session) + sizeof(struct lttng_session_extended);
size_t session_count, i;
struct lttng_session_extended *sessions_extended_begin;
struct lttng_session *sessions = NULL;
* be subsequently freed.
*/
*out_sessions = NULL;
- ret = lttng_ctl_ask_sessiond(&lsm, (void**) &sessions);
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) &sessions);
if (ret <= 0) {
goto end;
}
goto end;
}
session_count = (size_t) ret / session_size;
- sessions_extended_begin = (struct lttng_session_extended *)
- (&sessions[session_count]);
+ sessions_extended_begin = (struct lttng_session_extended *) (&sessions[session_count]);
/* Set extended session info pointers. */
for (i = 0; i < session_count; i++) {
struct lttng_session *session = &sessions[i];
- struct lttng_session_extended *extended =
- &(sessions_extended_begin[i]);
+ struct lttng_session_extended *extended = &(sessions_extended_begin[i]);
session->extended.ptr = extended;
}
return ret;
}
-enum lttng_error_code lttng_session_get_creation_time(
- const struct lttng_session *session, uint64_t *creation_time)
+enum lttng_error_code lttng_session_get_creation_time(const struct lttng_session *session,
+ uint64_t *creation_time)
{
enum lttng_error_code ret = LTTNG_OK;
struct lttng_session_extended *extended;
return ret;
}
-int lttng_set_session_shm_path(const char *session_name,
- const char *shm_path)
+int lttng_set_session_shm_path(const char *session_name, const char *shm_path)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SET_SESSION_SHM_PATH;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_strncpy(lsm.u.set_shm_path.shm_path, shm_path ?: "",
- sizeof(lsm.u.set_shm_path.shm_path));
+ ret = lttng_strncpy(
+ lsm.u.set_shm_path.shm_path, shm_path ?: "", sizeof(lsm.u.set_shm_path.shm_path));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
* Returns the number of lttng_domain entries in domains;
* on error, returns a negative value.
*/
-int lttng_list_domains(const char *session_name,
- struct lttng_domain **domains)
+int lttng_list_domains(const char *session_name, struct lttng_domain **domains)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_DOMAINS;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
- ret = lttng_ctl_ask_sessiond(&lsm, (void**) domains);
+ ret = lttng_ctl_ask_sessiond(&lsm, (void **) domains);
if (ret < 0) {
goto error;
}
* Returns the number of lttng_channel entries in channels;
* on error, returns a negative value.
*/
-int lttng_list_channels(struct lttng_handle *handle,
- struct lttng_channel **channels)
+int lttng_list_channels(struct lttng_handle *handle, struct lttng_channel **channels)
{
int ret, total_payload_received;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_CHANNELS;
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
COPY_DOMAIN_PACKED(lsm.domain, handle->domain);
- ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm, NULL, 0, NULL, 0,
- (void **) &reception_buffer, (void **) &cmd_header,
- &cmd_header_len);
+ ret = lttng_ctl_ask_sessiond_fds_varlen(&lsm,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ (void **) &reception_buffer,
+ (void **) &cmd_header,
+ &cmd_header_len);
if (ret < 0) {
goto end;
}
{
enum lttng_error_code ret_code;
const struct lttng_buffer_view events_view =
- lttng_buffer_view_init(reception_buffer, 0,
- total_payload_received);
+ lttng_buffer_view_init(reception_buffer, 0, total_payload_received);
ret_code = lttng_channels_create_and_flatten_from_buffer(
- &events_view, cmd_header->count, channels);
+ &events_view, cmd_header->count, channels);
if (ret_code != LTTNG_OK) {
ret = -ret_code;
goto end;
* on error, returns a negative value.
*/
int lttng_list_events(struct lttng_handle *handle,
- const char *channel_name, struct lttng_event **events)
+ const char *channel_name,
+ struct lttng_event **events)
{
int ret;
struct lttcomm_session_msg lsm = {};
struct lttng_payload reply;
struct lttng_payload_view lsm_view =
- lttng_payload_view_init_from_buffer(
- (const char *) &lsm, 0, sizeof(lsm));
+ lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
unsigned int nb_events = 0;
lttng_payload_init(&reply);
/* Initialize command parameters. */
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_LIST_EVENTS;
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- ret = lttng_strncpy(lsm.u.list.channel_name, channel_name,
- sizeof(lsm.u.list.channel_name));
+ ret = lttng_strncpy(lsm.u.list.channel_name, channel_name, sizeof(lsm.u.list.channel_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
{
- const struct lttcomm_list_command_header *cmd_reply_header =
- NULL;
+ const struct lttcomm_list_command_header *cmd_reply_header = NULL;
const lttng_payload_view cmd_reply_header_view =
- lttng_payload_view_from_payload(&reply, 0,
- sizeof(*cmd_reply_header));
+ lttng_payload_view_from_payload(&reply, 0, sizeof(*cmd_reply_header));
if (!lttng_payload_view_is_valid(&cmd_reply_header_view)) {
ret = -LTTNG_ERR_INVALID_PROTOCOL;
}
cmd_reply_header = (const struct lttcomm_list_command_header *)
- cmd_reply_header_view.buffer
- .data;
+ cmd_reply_header_view.buffer.data;
if (cmd_reply_header->count > INT_MAX) {
ret = -LTTNG_ERR_OVERFLOW;
goto end;
{
enum lttng_error_code ret_code;
lttng_payload_view cmd_reply_payload = lttng_payload_view_from_payload(
- &reply,
- sizeof(struct lttcomm_list_command_header), -1);
+ &reply, sizeof(struct lttcomm_list_command_header), -1);
ret_code = lttng_events_create_and_flatten_from_payload(
- &cmd_reply_payload, nb_events, events);
+ &cmd_reply_payload, nb_events, events);
if (ret_code != LTTNG_OK) {
ret = -((int) ret_code);
goto end;
}
int lttng_calibrate(struct lttng_handle *handle __attribute__((unused)),
- struct lttng_calibrate *calibrate __attribute__((unused)))
+ struct lttng_calibrate *calibrate __attribute__((unused)))
{
/*
* This command was removed in LTTng 2.9.
* Set default channel attributes.
* If either or both of the arguments are null, attr content is zeroe'd.
*/
-void lttng_channel_set_default_attr(struct lttng_domain *domain,
- struct lttng_channel_attr *attr)
+void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr)
{
struct lttng_channel_extended *extended;
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
- attr->switch_timer_interval =
- DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
+ attr->switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
attr->read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
attr->subbuf_size = default_get_kernel_channel_subbuf_size();
attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
attr->subbuf_size = default_get_ust_uid_channel_subbuf_size();
attr->num_subbuf = DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM;
attr->output = DEFAULT_UST_UID_CHANNEL_OUTPUT;
- attr->switch_timer_interval =
- DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
- attr->read_timer_interval =
- DEFAULT_UST_UID_CHANNEL_READ_TIMER;
+ attr->switch_timer_interval = DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER;
+ attr->read_timer_interval = DEFAULT_UST_UID_CHANNEL_READ_TIMER;
break;
case LTTNG_BUFFER_PER_PID:
default:
attr->subbuf_size = default_get_ust_pid_channel_subbuf_size();
attr->num_subbuf = DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM;
attr->output = DEFAULT_UST_PID_CHANNEL_OUTPUT;
- attr->switch_timer_interval =
- DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
- attr->read_timer_interval =
- DEFAULT_UST_PID_CHANNEL_READ_TIMER;
+ attr->switch_timer_interval = DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER;
+ attr->read_timer_interval = DEFAULT_UST_PID_CHANNEL_READ_TIMER;
break;
}
default:
}
int lttng_channel_get_discarded_event_count(struct lttng_channel *channel,
- uint64_t *discarded_events)
+ uint64_t *discarded_events)
{
int ret = 0;
struct lttng_channel_extended *chan_ext;
return ret;
}
-int lttng_channel_get_lost_packet_count(struct lttng_channel *channel,
- uint64_t *lost_packets)
+int lttng_channel_get_lost_packet_count(struct lttng_channel *channel, uint64_t *lost_packets)
{
int ret = 0;
struct lttng_channel_extended *chan_ext;
}
int lttng_channel_get_monitor_timer_interval(struct lttng_channel *chan,
- uint64_t *monitor_timer_interval)
+ uint64_t *monitor_timer_interval)
{
int ret = 0;
goto end;
}
- *monitor_timer_interval = ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->monitor_timer_interval;
+ *monitor_timer_interval =
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval;
end:
return ret;
}
int lttng_channel_set_monitor_timer_interval(struct lttng_channel *chan,
- uint64_t monitor_timer_interval)
+ uint64_t monitor_timer_interval)
{
int ret = 0;
goto end;
}
- ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->monitor_timer_interval =
- monitor_timer_interval;
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval =
+ monitor_timer_interval;
end:
return ret;
}
-int lttng_channel_get_blocking_timeout(struct lttng_channel *chan,
- int64_t *blocking_timeout)
+int lttng_channel_get_blocking_timeout(struct lttng_channel *chan, int64_t *blocking_timeout)
{
int ret = 0;
goto end;
}
- *blocking_timeout = ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->blocking_timeout;
+ *blocking_timeout =
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->blocking_timeout;
end:
return ret;
}
-int lttng_channel_set_blocking_timeout(struct lttng_channel *chan,
- int64_t blocking_timeout)
+int lttng_channel_set_blocking_timeout(struct lttng_channel *chan, int64_t blocking_timeout)
{
int ret = 0;
int64_t msec_timeout;
goto end;
}
- ((struct lttng_channel_extended *)
- chan->attr.extended.ptr)->blocking_timeout =
- blocking_timeout;
+ ((struct lttng_channel_extended *) chan->attr.extended.ptr)->blocking_timeout =
+ blocking_timeout;
end:
return ret;
}
* Return 0 on success, else a negative value.
*/
int lttng_set_consumer_url(struct lttng_handle *handle,
- const char *control_url, const char *data_url)
+ const char *control_url,
+ const char *data_url)
{
int ret;
ssize_t size;
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SET_CONSUMER_URI;
- ret = lttng_strncpy(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, handle->session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
lsm.u.uri.size = size;
- ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, uris,
- sizeof(struct lttng_uri) * size, NULL);
+ ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
+ &lsm, uris, sizeof(struct lttng_uri) * size, NULL);
free(uris);
error:
/*
* [OBSOLETE]
*/
-extern "C"
-LTTNG_EXPORT int lttng_enable_consumer(struct lttng_handle *handle);
+extern "C" LTTNG_EXPORT int lttng_enable_consumer(struct lttng_handle *handle);
int lttng_enable_consumer(struct lttng_handle *handle __attribute__((unused)))
{
return -ENOSYS;
/*
* [OBSOLETE]
*/
-extern "C"
-LTTNG_EXPORT int lttng_disable_consumer(struct lttng_handle *handle);
+extern "C" LTTNG_EXPORT int lttng_disable_consumer(struct lttng_handle *handle);
int lttng_disable_consumer(struct lttng_handle *handle __attribute__((unused)))
{
return -ENOSYS;
/*
* [OBSOLETE]
*/
-extern "C"
-LTTNG_EXPORT int _lttng_create_session_ext(const char *name, const char *url,
- const char *datetime);
+extern "C" LTTNG_EXPORT int
+_lttng_create_session_ext(const char *name, const char *url, const char *datetime);
int _lttng_create_session_ext(const char *name __attribute__((unused)),
- const char *url __attribute__((unused)),
- const char *datetime __attribute__((unused)))
+ const char *url __attribute__((unused)),
+ const char *datetime __attribute__((unused)))
{
return -ENOSYS;
}
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_DATA_PENDING;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGENERATE_METADATA;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_REGENERATE_STATEDUMP;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
return ret;
}
-static
-int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
- bool generate_name)
+static int
+_lttng_register_trigger(struct lttng_trigger *trigger, const char *name, bool generate_name)
{
int ret;
struct lttcomm_session_msg lsm = {
* "safety" checks.
*/
const struct lttng_credentials *trigger_creds =
- lttng_trigger_get_credentials(trigger);
+ lttng_trigger_get_credentials(trigger);
if (!lttng_credentials_is_equal_uid(trigger_creds, &user_creds)) {
if (lttng_credentials_get_uid(&user_creds) != 0) {
goto end_unset_name;
}
- domain_type = lttng_trigger_get_underlying_domain_type_restriction(
- trigger);
+ domain_type = lttng_trigger_get_underlying_domain_type_restriction(trigger);
lsm.domain.type = domain_type;
{
struct lttng_payload_view message_view =
- lttng_payload_view_from_payload(
- &message, 0, -1);
+ lttng_payload_view_from_payload(&message, 0, -1);
- message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
- &message_view);
+ message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
if (ret < 0) {
goto end_unset_name;
{
struct lttng_payload_view reply_view =
- lttng_payload_view_from_payload(
- &reply, 0, reply.buffer.size);
+ lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
- ret = lttng_trigger_create_from_payload(
- &reply_view, &reply_trigger);
+ ret = lttng_trigger_create_from_payload(&reply_view, &reply_trigger);
if (ret < 0) {
ret = -LTTNG_ERR_INVALID_PROTOCOL;
goto end_unset_name;
return _lttng_register_trigger(trigger, NULL, false);
}
-enum lttng_error_code lttng_register_trigger_with_name(
- struct lttng_trigger *trigger, const char *name)
+enum lttng_error_code lttng_register_trigger_with_name(struct lttng_trigger *trigger,
+ const char *name)
{
const int ret = _lttng_register_trigger(trigger, name, false);
- return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+ return ret == 0 ? LTTNG_OK : (enum lttng_error_code) - ret;
}
-enum lttng_error_code lttng_register_trigger_with_automatic_name(
- struct lttng_trigger *trigger)
+enum lttng_error_code lttng_register_trigger_with_automatic_name(struct lttng_trigger *trigger)
{
- const int ret = _lttng_register_trigger(trigger, nullptr, true);
+ const int ret = _lttng_register_trigger(trigger, nullptr, true);
- return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+ return ret == 0 ? LTTNG_OK : (enum lttng_error_code) - ret;
}
-enum lttng_error_code lttng_error_query_execute(
- const struct lttng_error_query *query,
- const struct lttng_endpoint *endpoint,
- struct lttng_error_query_results **results)
+enum lttng_error_code lttng_error_query_execute(const struct lttng_error_query *query,
+ const struct lttng_endpoint *endpoint,
+ struct lttng_error_query_results **results)
{
int ret;
enum lttng_error_code ret_code;
}
message_lsm = (struct lttcomm_session_msg *) message.buffer.data;
- message_lsm->u.error_query.length =
- (uint32_t) message.buffer.size - sizeof(lsm);
+ message_lsm->u.error_query.length = (uint32_t) message.buffer.size - sizeof(lsm);
{
struct lttng_payload_view message_view =
- lttng_payload_view_from_payload(
- &message, 0, -1);
+ lttng_payload_view_from_payload(&message, 0, -1);
- message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
- &message_view);
+ message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
if (ret < 0) {
- ret_code =(lttng_error_code) -ret;
+ ret_code = (lttng_error_code) -ret;
goto end;
}
}
{
ssize_t reply_create_ret;
struct lttng_payload_view reply_view =
- lttng_payload_view_from_payload(
- &reply, 0, reply.buffer.size);
+ lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
- reply_create_ret = lttng_error_query_results_create_from_payload(
- &reply_view, results);
+ reply_create_ret =
+ lttng_error_query_results_create_from_payload(&reply_view, results);
if (reply_create_ret < 0) {
ret_code = LTTNG_ERR_INVALID_PROTOCOL;
goto end;
* credentials passed on the socket. These check are all
* "safety" checks.
*/
- const struct lttng_credentials *trigger_creds =
- lttng_trigger_get_credentials(copy);
+ const struct lttng_credentials *trigger_creds = lttng_trigger_get_credentials(copy);
if (!lttng_credentials_is_equal_uid(trigger_creds, &user_creds)) {
if (lttng_credentials_get_uid(&user_creds) != 0) {
ret = -LTTNG_ERR_EPERM;
/*
* This is needed to populate the trigger object size for the command
* header and number of fds sent.
- */
+ */
message_lsm = (struct lttcomm_session_msg *) message.buffer.data;
message_lsm->u.trigger.length = (uint32_t) message.buffer.size - sizeof(lsm);
{
struct lttng_payload_view message_view =
- lttng_payload_view_from_payload(
- &message, 0, -1);
+ lttng_payload_view_from_payload(&message, 0, -1);
/*
* Update the message header with the number of fd that will be
* sent.
*/
- message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(
- &message_view);
+ message_lsm->fd_count = lttng_payload_view_get_fd_handle_count(&message_view);
ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
if (ret < 0) {
struct lttng_triggers *local_triggers = NULL;
struct lttng_payload reply;
struct lttng_payload_view lsm_view =
- lttng_payload_view_init_from_buffer(
- (const char *) &lsm, 0, sizeof(lsm));
+ lttng_payload_view_init_from_buffer((const char *) &lsm, 0, sizeof(lsm));
lttng_payload_init(&reply);
ret = lttng_ctl_ask_sessiond_payload(&lsm_view, &reply);
if (ret < 0) {
- ret_code = (enum lttng_error_code) -ret;
+ ret_code = (enum lttng_error_code) - ret;
goto end;
}
{
struct lttng_payload_view reply_view =
- lttng_payload_view_from_payload(
- &reply, 0, reply.buffer.size);
+ lttng_payload_view_from_payload(&reply, 0, reply.buffer.size);
- ret = lttng_triggers_create_from_payload(
- &reply_view, &local_triggers);
+ ret = lttng_triggers_create_from_payload(&reply_view, &local_triggers);
if (ret < 0) {
ret_code = LTTNG_ERR_FATAL;
goto end;
*/
#define _LGPL_SOURCE
-#include <string.h>
+#include "lttng-ctl-helper.hpp"
+
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <lttng/lttng-error.h>
-#include <lttng/rotation.h>
#include <lttng/location-internal.hpp>
+#include <lttng/lttng-error.h>
#include <lttng/rotate-internal.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/macros.hpp>
+#include <lttng/rotation.h>
-#include "lttng-ctl-helper.hpp"
+#include <string.h>
-static
-enum lttng_rotation_status ask_rotation_info(
- struct lttng_rotation_handle *rotation_handle,
- struct lttng_rotation_get_info_return **info)
+static enum lttng_rotation_status ask_rotation_info(struct lttng_rotation_handle *rotation_handle,
+ struct lttng_rotation_get_info_return **info)
{
/* lsm.get_rotation_state.rotation_id */
struct lttcomm_session_msg lsm;
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_ROTATION_GET_INFO;
lsm.u.get_rotation_info.rotation_id = rotation_handle->rotation_id;
- ret = lttng_strncpy(lsm.session.name, rotation_handle->session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(
+ lsm.session.name, rotation_handle->session_name, sizeof(lsm.session.name));
if (ret) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
end:
return status;
-
}
-static
-struct lttng_trace_archive_location *
-create_trace_archive_location_from_get_info(
- const struct lttng_rotation_get_info_return *info)
+static struct lttng_trace_archive_location *
+create_trace_archive_location_from_get_info(const struct lttng_rotation_get_info_return *info)
{
struct lttng_trace_archive_location *location;
switch (info->location_type) {
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL:
location = lttng_trace_archive_location_local_create(
- info->location.local.absolute_path);
+ info->location.local.absolute_path);
break;
case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY:
location = lttng_trace_archive_location_relay_create(
- info->location.relay.host,
- (lttng_trace_archive_location_relay_protocol_type) info->location.relay.protocol,
- info->location.relay.ports.control,
- info->location.relay.ports.data,
- info->location.relay.relative_path);
+ info->location.relay.host,
+ (lttng_trace_archive_location_relay_protocol_type)
+ info->location.relay.protocol,
+ info->location.relay.ports.control,
+ info->location.relay.ports.data,
+ info->location.relay.relative_path);
break;
default:
location = NULL;
return location;
}
-enum lttng_rotation_status lttng_rotation_handle_get_state(
- struct lttng_rotation_handle *rotation_handle,
- enum lttng_rotation_state *state)
+enum lttng_rotation_status
+lttng_rotation_handle_get_state(struct lttng_rotation_handle *rotation_handle,
+ enum lttng_rotation_state *state)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_get_info_return *info = NULL;
}
*state = (enum lttng_rotation_state) info->status;
- if (rotation_handle->archive_location ||
- *state != LTTNG_ROTATION_STATE_COMPLETED) {
+ if (rotation_handle->archive_location || *state != LTTNG_ROTATION_STATE_COMPLETED) {
/*
* The path is only provided by the sessiond once
* the session rotation is completed, but not expired.
* Cache the location since the rotation may expire before the user
* has a chance to query it.
*/
- rotation_handle->archive_location =
- create_trace_archive_location_from_get_info(info);
+ rotation_handle->archive_location = create_trace_archive_location_from_get_info(info);
if (!rotation_handle->archive_location) {
status = LTTNG_ROTATION_STATUS_ERROR;
goto end;
return status;
}
-enum lttng_rotation_status lttng_rotation_handle_get_archive_location(
- struct lttng_rotation_handle *rotation_handle,
- const struct lttng_trace_archive_location **location)
+enum lttng_rotation_status
+lttng_rotation_handle_get_archive_location(struct lttng_rotation_handle *rotation_handle,
+ const struct lttng_trace_archive_location **location)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_get_info_return *info = NULL;
goto end;
}
- if ((enum lttng_rotation_state) info->status !=
- LTTNG_ROTATION_STATE_COMPLETED) {
+ if ((enum lttng_rotation_state) info->status != LTTNG_ROTATION_STATE_COMPLETED) {
status = LTTNG_ROTATION_STATUS_UNAVAILABLE;
goto end;
}
- rotation_handle->archive_location =
- create_trace_archive_location_from_get_info(info);
+ rotation_handle->archive_location = create_trace_archive_location_from_get_info(info);
if (!rotation_handle->archive_location) {
status = LTTNG_ROTATION_STATUS_ERROR;
goto end;
return status;
}
-void lttng_rotation_handle_destroy(
- struct lttng_rotation_handle *rotation_handle)
+void lttng_rotation_handle_destroy(struct lttng_rotation_handle *rotation_handle)
{
if (!rotation_handle) {
return;
free(rotation_handle);
}
-static
-int init_rotation_handle(struct lttng_rotation_handle *rotation_handle,
- const char *session_name,
- struct lttng_rotate_session_return *rotate_return)
+static int init_rotation_handle(struct lttng_rotation_handle *rotation_handle,
+ const char *session_name,
+ struct lttng_rotate_session_return *rotate_return)
{
int ret;
- ret = lttng_strncpy(rotation_handle->session_name, session_name,
- sizeof(rotation_handle->session_name));
+ ret = lttng_strncpy(
+ rotation_handle->session_name, session_name, sizeof(rotation_handle->session_name));
if (ret) {
goto end;
}
* Return 0 on success else a negative LTTng error code.
*/
int lttng_rotate_session(const char *session_name,
- struct lttng_rotation_immediate_descriptor *descriptor __attribute__((unused)),
- struct lttng_rotation_handle **rotation_handle)
+ struct lttng_rotation_immediate_descriptor *descriptor
+ __attribute__((unused)),
+ struct lttng_rotation_handle **rotation_handle)
{
struct lttcomm_session_msg lsm;
struct lttng_rotate_session_return *rotate_return = NULL;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_ROTATE_SESSION;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
/* Source length already validated. */
LTTNG_ASSERT(ret == 0);
* just its type) must be passed so that the session daemon can
* validate that is exists before clearing it.
*/
-static
-enum lttng_rotation_status lttng_rotation_update_schedule(
- const char *session_name,
- const struct lttng_rotation_schedule *schedule,
- bool add)
+static enum lttng_rotation_status lttng_rotation_update_schedule(
+ const char *session_name, const struct lttng_rotation_schedule *schedule, bool add)
{
struct lttcomm_session_msg lsm;
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_ROTATION_SET_SCHEDULE;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
/* Source length already validated. */
LTTNG_ASSERT(ret == 0);
{
uint64_t threshold;
- status = lttng_rotation_schedule_size_threshold_get_threshold(
- schedule, &threshold);
+ status = lttng_rotation_schedule_size_threshold_get_threshold(schedule, &threshold);
if (status != LTTNG_ROTATION_STATUS_OK) {
if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
status = LTTNG_ROTATION_STATUS_INVALID;
{
uint64_t period;
- status = lttng_rotation_schedule_periodic_get_period(
- schedule, &period);
+ status = lttng_rotation_schedule_periodic_get_period(schedule, &period);
if (status != LTTNG_ROTATION_STATUS_OK) {
if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
status = LTTNG_ROTATION_STATUS_INVALID;
return status;
}
-static
-struct lttng_rotation_schedules *lttng_rotation_schedules_create(void)
+static struct lttng_rotation_schedules *lttng_rotation_schedules_create(void)
{
return zmalloc<lttng_rotation_schedules>();
}
-static
-void lttng_schedules_add(struct lttng_rotation_schedules *schedules,
- struct lttng_rotation_schedule *schedule)
+static void lttng_schedules_add(struct lttng_rotation_schedules *schedules,
+ struct lttng_rotation_schedule *schedule)
{
schedules->schedules[schedules->count++] = schedule;
}
-static
-int get_schedules(const char *session_name,
- struct lttng_rotation_schedules **_schedules)
+static int get_schedules(const char *session_name, struct lttng_rotation_schedules **_schedules)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SESSION_LIST_ROTATION_SCHEDULES;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
status = lttng_rotation_schedule_periodic_set_period(
- periodic, schedules_comm->periodic.value);
+ periodic, schedules_comm->periodic.value);
if (status != LTTNG_ROTATION_STATUS_OK) {
/*
* This would imply that the session daemon returned
}
status = lttng_rotation_schedule_size_threshold_set_threshold(
- size, schedules_comm->size.value);
+ size, schedules_comm->size.value);
if (status != LTTNG_ROTATION_STATUS_OK) {
/*
* This would imply that the session daemon returned
return ret;
}
-enum lttng_rotation_schedule_type lttng_rotation_schedule_get_type(
- const struct lttng_rotation_schedule *schedule)
+enum lttng_rotation_schedule_type
+lttng_rotation_schedule_get_type(const struct lttng_rotation_schedule *schedule)
{
return schedule ? schedule->type : LTTNG_ROTATION_SCHEDULE_TYPE_UNKNOWN;
}
-struct lttng_rotation_schedule *
-lttng_rotation_schedule_size_threshold_create(void)
+struct lttng_rotation_schedule *lttng_rotation_schedule_size_threshold_create(void)
{
struct lttng_rotation_schedule_size_threshold *schedule;
}
enum lttng_rotation_status
-lttng_rotation_schedule_size_threshold_get_threshold(
- const struct lttng_rotation_schedule *schedule,
- uint64_t *size_threshold_bytes)
+lttng_rotation_schedule_size_threshold_get_threshold(const struct lttng_rotation_schedule *schedule,
+ uint64_t *size_threshold_bytes)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_size_threshold *size_schedule;
if (!schedule || !size_threshold_bytes ||
- schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
size_schedule = lttng::utils::container_of(schedule,
- <tng_rotation_schedule_size_threshold::parent);
+ <tng_rotation_schedule_size_threshold::parent);
if (size_schedule->size.set) {
*size_threshold_bytes = size_schedule->size.bytes;
} else {
}
enum lttng_rotation_status
-lttng_rotation_schedule_size_threshold_set_threshold(
- struct lttng_rotation_schedule *schedule,
- uint64_t size_threshold_bytes)
+lttng_rotation_schedule_size_threshold_set_threshold(struct lttng_rotation_schedule *schedule,
+ uint64_t size_threshold_bytes)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_size_threshold *size_schedule;
- if (!schedule || size_threshold_bytes == 0 ||
- size_threshold_bytes == -1ULL ||
- schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
+ if (!schedule || size_threshold_bytes == 0 || size_threshold_bytes == -1ULL ||
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
size_schedule = lttng::utils::container_of(schedule,
- <tng_rotation_schedule_size_threshold::parent);
+ <tng_rotation_schedule_size_threshold::parent);
size_schedule->size.bytes = size_threshold_bytes;
size_schedule->size.set = true;
end:
return status;
}
-struct lttng_rotation_schedule *
-lttng_rotation_schedule_periodic_create(void)
+struct lttng_rotation_schedule *lttng_rotation_schedule_periodic_create(void)
{
struct lttng_rotation_schedule_periodic *schedule;
}
enum lttng_rotation_status
-lttng_rotation_schedule_periodic_get_period(
- const struct lttng_rotation_schedule *schedule,
- uint64_t *period_us)
+lttng_rotation_schedule_periodic_get_period(const struct lttng_rotation_schedule *schedule,
+ uint64_t *period_us)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_periodic *periodic_schedule;
- if (!schedule || !period_us ||
- schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
+ if (!schedule || !period_us || schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
- periodic_schedule = lttng::utils::container_of(schedule,
- <tng_rotation_schedule_periodic::parent);
+ periodic_schedule =
+ lttng::utils::container_of(schedule, <tng_rotation_schedule_periodic::parent);
if (periodic_schedule->period.set) {
*period_us = periodic_schedule->period.us;
} else {
}
enum lttng_rotation_status
-lttng_rotation_schedule_periodic_set_period(
- struct lttng_rotation_schedule *schedule,
- uint64_t period_us)
+lttng_rotation_schedule_periodic_set_period(struct lttng_rotation_schedule *schedule,
+ uint64_t period_us)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_periodic *periodic_schedule;
if (!schedule || period_us == 0 || period_us == -1ULL ||
- schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
- periodic_schedule = lttng::utils::container_of(schedule,
- <tng_rotation_schedule_periodic::parent);
+ periodic_schedule =
+ lttng::utils::container_of(schedule, <tng_rotation_schedule_periodic::parent);
periodic_schedule->period.us = period_us;
periodic_schedule->period.set = true;
end:
free(schedule);
}
-void lttng_rotation_schedules_destroy(
- struct lttng_rotation_schedules *schedules)
+void lttng_rotation_schedules_destroy(struct lttng_rotation_schedules *schedules)
{
unsigned int i;
free(schedules);
}
-
-enum lttng_rotation_status lttng_rotation_schedules_get_count(
- const struct lttng_rotation_schedules *schedules,
- unsigned int *count)
+enum lttng_rotation_status
+lttng_rotation_schedules_get_count(const struct lttng_rotation_schedules *schedules,
+ unsigned int *count)
{
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
return status;
}
-const struct lttng_rotation_schedule *lttng_rotation_schedules_get_at_index(
- const struct lttng_rotation_schedules *schedules,
- unsigned int index)
+const struct lttng_rotation_schedule *
+lttng_rotation_schedules_get_at_index(const struct lttng_rotation_schedules *schedules,
+ unsigned int index)
{
const struct lttng_rotation_schedule *schedule = NULL;
return schedule;
}
-enum lttng_rotation_status lttng_session_add_rotation_schedule(
- const char *session_name,
- const struct lttng_rotation_schedule *schedule)
+enum lttng_rotation_status
+lttng_session_add_rotation_schedule(const char *session_name,
+ const struct lttng_rotation_schedule *schedule)
{
return lttng_rotation_update_schedule(session_name, schedule, true);
}
-enum lttng_rotation_status lttng_session_remove_rotation_schedule(
- const char *session_name,
- const struct lttng_rotation_schedule *schedule)
+enum lttng_rotation_status
+lttng_session_remove_rotation_schedule(const char *session_name,
+ const struct lttng_rotation_schedule *schedule)
{
return lttng_rotation_update_schedule(session_name, schedule, false);
}
-int lttng_session_list_rotation_schedules(
- const char *session_name,
- struct lttng_rotation_schedules **schedules)
+int lttng_session_list_rotation_schedules(const char *session_name,
+ struct lttng_rotation_schedules **schedules)
{
return get_schedules(session_name, schedules);
}
*/
#define _LGPL_SOURCE
-#include <string.h>
+#include "lttng-ctl-helper.hpp"
+
+#include <common/sessiond-comm/sessiond-comm.hpp>
#include <lttng/lttng-error.h>
-#include <lttng/save.h>
#include <lttng/save-internal.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/save.h>
-#include "lttng-ctl-helper.hpp"
+#include <string.h>
struct lttng_save_session_attr *lttng_save_session_attr_create(void)
{
}
}
-const char *lttng_save_session_attr_get_session_name(
- struct lttng_save_session_attr *attr)
+const char *lttng_save_session_attr_get_session_name(struct lttng_save_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-const char *lttng_save_session_attr_get_output_url(
- struct lttng_save_session_attr *attr)
+const char *lttng_save_session_attr_get_output_url(struct lttng_save_session_attr *attr)
{
const char *ret = NULL;
return ret;
}
-int lttng_save_session_attr_get_overwrite(
- struct lttng_save_session_attr *attr)
+int lttng_save_session_attr_get_overwrite(struct lttng_save_session_attr *attr)
{
return attr ? attr->overwrite : -LTTNG_ERR_INVALID;
}
-int lttng_save_session_attr_get_omit_name(
- struct lttng_save_session_attr *attr)
+int lttng_save_session_attr_get_omit_name(struct lttng_save_session_attr *attr)
{
return attr ? attr->omit_name : -LTTNG_ERR_INVALID;
}
-int lttng_save_session_attr_get_omit_output(
- struct lttng_save_session_attr *attr)
+int lttng_save_session_attr_get_omit_output(struct lttng_save_session_attr *attr)
{
return attr ? attr->omit_output : -LTTNG_ERR_INVALID;
}
-int lttng_save_session_attr_set_session_name(
- struct lttng_save_session_attr *attr, const char *session_name)
+int lttng_save_session_attr_set_session_name(struct lttng_save_session_attr *attr,
+ const char *session_name)
{
int ret = 0;
goto error;
}
- ret = lttng_strncpy(attr->session_name, session_name,
- sizeof(attr->session_name));
+ ret = lttng_strncpy(attr->session_name, session_name, sizeof(attr->session_name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-int lttng_save_session_attr_set_output_url(
- struct lttng_save_session_attr *attr, const char *url)
+int lttng_save_session_attr_set_output_url(struct lttng_save_session_attr *attr, const char *url)
{
int ret = 0;
size_t len;
}
/* Copy string plus the NULL terminated byte. */
- ret = lttng_strncpy(attr->configuration_url, uris[0].dst.path,
- sizeof(attr->configuration_url));
+ ret = lttng_strncpy(
+ attr->configuration_url, uris[0].dst.path, sizeof(attr->configuration_url));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
return ret;
}
-int lttng_save_session_attr_set_overwrite(
- struct lttng_save_session_attr *attr, int overwrite)
+int lttng_save_session_attr_set_overwrite(struct lttng_save_session_attr *attr, int overwrite)
{
int ret = 0;
return ret;
}
-int lttng_save_session_attr_set_omit_name(
- struct lttng_save_session_attr *attr, int omit_name)
+int lttng_save_session_attr_set_omit_name(struct lttng_save_session_attr *attr, int omit_name)
{
int ret = 0;
return ret;
}
-int lttng_save_session_attr_set_omit_output(
- struct lttng_save_session_attr *attr, int omit_output)
+int lttng_save_session_attr_set_omit_output(struct lttng_save_session_attr *attr, int omit_output)
{
int ret = 0;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SAVE_SESSION;
- memcpy(&lsm.u.save_session.attr, attr,
- sizeof(struct lttng_save_session_attr));
+ memcpy(&lsm.u.save_session.attr, attr, sizeof(struct lttng_save_session_attr));
ret = lttng_ctl_ask_sessiond(&lsm, NULL);
end:
return ret;
*/
#define _LGPL_SOURCE
-#include <string.h>
+#include "lttng-ctl-helper.hpp"
#include <common/sessiond-comm/sessiond-comm.hpp>
+
#include <lttng/lttng-error.h>
-#include <lttng/snapshot.h>
#include <lttng/snapshot-internal.hpp>
+#include <lttng/snapshot.h>
-#include "lttng-ctl-helper.hpp"
+#include <string.h>
/*
* Add an output object to a session identified by name.
*
* Return 0 on success or else a negative LTTNG_ERR code.
*/
-int lttng_snapshot_add_output(const char *session_name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_add_output(const char *session_name, struct lttng_snapshot_output *output)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_ADD_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- memcpy(&lsm.u.snapshot_output.output, output,
- sizeof(lsm.u.snapshot_output.output));
+ memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output));
ret = lttng_ctl_ask_sessiond(&lsm, (void **) &reply);
if (ret < 0) {
*
* Return 0 on success or else a negative LTTNG_ERR code.
*/
-int lttng_snapshot_del_output(const char *session_name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_del_output(const char *session_name, struct lttng_snapshot_output *output)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_DEL_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- memcpy(&lsm.u.snapshot_output.output, output,
- sizeof(lsm.u.snapshot_output.output));
+ memcpy(&lsm.u.snapshot_output.output, output, sizeof(lsm.u.snapshot_output.output));
ret = lttng_ctl_ask_sessiond(&lsm, NULL);
end:
* Return 0 on success or else a negative LTTNG_ERR code and the list pointer
* is untouched.
*/
-int lttng_snapshot_list_output(const char *session_name,
- struct lttng_snapshot_output_list **list)
+int lttng_snapshot_list_output(const char *session_name, struct lttng_snapshot_output_list **list)
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_LIST_OUTPUT;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto error;
* Return the next object on success or else NULL indicating the end of the
* list.
*/
-struct lttng_snapshot_output *lttng_snapshot_output_list_get_next(
- struct lttng_snapshot_output_list *list)
+struct lttng_snapshot_output *
+lttng_snapshot_output_list_get_next(struct lttng_snapshot_output_list *list)
{
struct lttng_snapshot_output *output = NULL;
* Return 0 on success or else a negative LTTNG_ERR value.
*/
int lttng_snapshot_record(const char *session_name,
- struct lttng_snapshot_output *output,
- int wait __attribute__((unused)))
+ struct lttng_snapshot_output *output,
+ int wait __attribute__((unused)))
{
int ret;
struct lttcomm_session_msg lsm;
memset(&lsm, 0, sizeof(lsm));
lsm.cmd_type = LTTCOMM_SESSIOND_COMMAND_SNAPSHOT_RECORD;
- ret = lttng_strncpy(lsm.session.name, session_name,
- sizeof(lsm.session.name));
+ ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name));
if (ret) {
ret = -LTTNG_ERR_INVALID;
goto end;
* record.
*/
if (output) {
- memcpy(&lsm.u.snapshot_record.output, output,
- sizeof(lsm.u.snapshot_record.output));
+ memcpy(&lsm.u.snapshot_record.output, output, sizeof(lsm.u.snapshot_record.output));
}
/* The wait param is ignored. */
return output->id;
}
-const char *lttng_snapshot_output_get_name(
- const struct lttng_snapshot_output *output)
+const char *lttng_snapshot_output_get_name(const struct lttng_snapshot_output *output)
{
return output->name;
}
return output->ctrl_url;
}
-uint64_t lttng_snapshot_output_get_maxsize(
- const struct lttng_snapshot_output *output)
+uint64_t lttng_snapshot_output_get_maxsize(const struct lttng_snapshot_output *output)
{
return output->max_size;
}
* Setter family functions for snapshot output.
*/
-int lttng_snapshot_output_set_id(uint32_t id,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_id(uint32_t id, struct lttng_snapshot_output *output)
{
if (!output || id == 0) {
return -LTTNG_ERR_INVALID;
return 0;
}
-int lttng_snapshot_output_set_size(uint64_t size,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_size(uint64_t size, struct lttng_snapshot_output *output)
{
if (!output) {
return -LTTNG_ERR_INVALID;
return 0;
}
-int lttng_snapshot_output_set_name(const char *name,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_name(const char *name, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_ctrl_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_ctrl_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_data_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_data_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
return ret;
}
-int lttng_snapshot_output_set_local_path(const char *path,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_local_path(const char *path, struct lttng_snapshot_output *output)
{
int ret;
struct lttng_uri *uris = NULL;
return ret;
}
-int lttng_snapshot_output_set_network_url(const char *url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_network_url(const char *url, struct lttng_snapshot_output *output)
{
int ret;
struct lttng_uri *uris = NULL;
goto end;
}
- if (uris[0].dtype != LTTNG_DST_IPV4 &&
- uris[0].dtype != LTTNG_DST_IPV6) {
+ if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (uris[1].dtype != LTTNG_DST_IPV4 &&
- uris[1].dtype != LTTNG_DST_IPV6) {
+ if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
return ret;
}
-int lttng_snapshot_output_set_network_urls(
- const char *ctrl_url, const char *data_url,
- struct lttng_snapshot_output *output)
+int lttng_snapshot_output_set_network_urls(const char *ctrl_url,
+ const char *data_url,
+ struct lttng_snapshot_output *output)
{
int ret;
struct lttng_uri *uris = NULL;
goto end;
}
- if (uris[0].dtype != LTTNG_DST_IPV4 &&
- uris[0].dtype != LTTNG_DST_IPV6) {
+ if (uris[0].dtype != LTTNG_DST_IPV4 && uris[0].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
- if (uris[1].dtype != LTTNG_DST_IPV4 &&
- uris[1].dtype != LTTNG_DST_IPV6) {
+ if (uris[1].dtype != LTTNG_DST_IPV4 && uris[1].dtype != LTTNG_DST_IPV6) {
ret = -LTTNG_ERR_INVALID;
goto end;
}
*
*/
-#include <lttng/domain.h>
-#include <lttng/lttng-error.h>
-
#include "lttng-ctl-helper.hpp"
+
#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/tracker.hpp>
+
+#include <lttng/domain.h>
+#include <lttng/lttng-error.h>
#include <lttng/tracker.h>
+
#include <type_traits>
struct lttng_process_attr_tracker_handle {
struct lttng_process_attr_values *inclusion_set;
};
-void lttng_process_attr_tracker_handle_destroy(
- struct lttng_process_attr_tracker_handle *tracker)
+void lttng_process_attr_tracker_handle_destroy(struct lttng_process_attr_tracker_handle *tracker)
{
if (!tracker) {
return;
free(tracker);
}
-enum lttng_error_code lttng_session_get_tracker_handle(const char *session_name,
- enum lttng_domain_type domain,
- enum lttng_process_attr process_attr,
- struct lttng_process_attr_tracker_handle **out_tracker_handle)
+enum lttng_error_code
+lttng_session_get_tracker_handle(const char *session_name,
+ enum lttng_domain_type domain,
+ enum lttng_process_attr process_attr,
+ struct lttng_process_attr_tracker_handle **out_tracker_handle)
{
enum lttng_error_code ret_code = LTTNG_OK;
struct lttng_process_attr_tracker_handle *handle = NULL;
* Use the `get_tracking_policy` command to validate the tracker's
* existence.
*/
- status = lttng_process_attr_tracker_handle_get_tracking_policy(
- handle, &policy);
+ status = lttng_process_attr_tracker_handle_get_tracking_policy(handle, &policy);
switch (status) {
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK:
break;
return ret_code;
}
-enum lttng_process_attr_tracker_handle_status
-lttng_process_attr_tracker_handle_get_tracking_policy(
- const struct lttng_process_attr_tracker_handle *tracker,
- enum lttng_tracking_policy *policy)
+enum lttng_process_attr_tracker_handle_status lttng_process_attr_tracker_handle_get_tracking_policy(
+ const struct lttng_process_attr_tracker_handle *tracker, enum lttng_tracking_policy *policy)
{
void *reply = NULL;
int reply_ret, copy_ret;
enum lttng_process_attr_tracker_handle_status status =
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_GET_POLICY,
.session = {},
goto end;
}
- copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name,
- sizeof(lsm.session.name));
+ copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name, sizeof(lsm.session.name));
if (copy_ret) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID;
goto end;
lsm.domain.type = tracker->domain;
lsm.u.process_attr_tracker_get_tracking_policy.process_attr =
- (int32_t) tracker->process_attr;
+ (int32_t) tracker->process_attr;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
- &lsm, NULL, 0, &reply);
+ reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, NULL, 0, &reply);
if (reply_ret != sizeof(uint32_t)) {
if (reply_ret == -LTTNG_ERR_SESSION_NOT_EXIST ||
- reply_ret == -LTTNG_ERR_SESS_NOT_FOUND) {
+ reply_ret == -LTTNG_ERR_SESS_NOT_FOUND) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST;
} else {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR;
return status;
}
-enum lttng_process_attr_tracker_handle_status
-lttng_process_attr_tracker_handle_set_tracking_policy(
- const struct lttng_process_attr_tracker_handle *tracker,
- enum lttng_tracking_policy policy)
+enum lttng_process_attr_tracker_handle_status lttng_process_attr_tracker_handle_set_tracking_policy(
+ const struct lttng_process_attr_tracker_handle *tracker, enum lttng_tracking_policy policy)
{
int reply_ret, copy_ret;
enum lttng_process_attr_tracker_handle_status status =
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_SET_POLICY,
.session = {},
goto end;
}
- copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name,
- sizeof(lsm.session.name));
+ copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name, sizeof(lsm.session.name));
if (copy_ret) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID;
goto end;
lsm.domain.type = tracker->domain;
lsm.u.process_attr_tracker_set_tracking_policy.process_attr =
- (int32_t) tracker->process_attr;
- lsm.u.process_attr_tracker_set_tracking_policy.tracking_policy =
- (int32_t) policy;
+ (int32_t) tracker->process_attr;
+ lsm.u.process_attr_tracker_set_tracking_policy.tracking_policy = (int32_t) policy;
/* Command returns a session descriptor on success. */
reply_ret = lttng_ctl_ask_sessiond(&lsm, NULL);
return status;
}
-#define DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(command_upper, \
- command_lower, process_attr_name, value_type_name, \
- value_type_c, value_type_enum) \
- enum lttng_process_attr_tracker_handle_status \
- lttng_process_attr_##process_attr_name##_tracker_handle_##command_lower##_##value_type_name( \
- const struct lttng_process_attr_tracker_handle \
- *tracker, \
- value_type_c value) \
- { \
- int ret; \
- enum lttng_process_attr_tracker_handle_status status = \
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK; \
- struct lttcomm_session_msg lsm = { \
- .cmd_type = LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_##command_upper##_INCLUDE_VALUE, \
- .session = {}, \
- .domain = {}, \
- .u = {}, \
- .fd_count = 0, \
- }; \
- \
- if (!tracker) { \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
- goto end; \
- } \
- \
- ret = lttng_strncpy(lsm.session.name, tracker->session_name, \
- sizeof(lsm.session.name)); \
- if (ret) { \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
- goto end; \
- } \
- \
- lsm.domain.type = tracker->domain; \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .process_attr = \
- (int32_t) tracker->process_attr; \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .value_type = (uint32_t) \
- LTTNG_PROCESS_ATTR_VALUE_TYPE_##value_type_enum; \
- \
- if (std::is_signed<value_type_c>::value) { \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .integral_value.u._signed = value; \
- } else { \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .integral_value.u._unsigned = value; \
- } \
- \
- ret = lttng_ctl_ask_sessiond(&lsm, NULL); \
- if (ret < 0) { \
- switch (-ret) { \
- case LTTNG_ERR_PROCESS_ATTR_EXISTS: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_EXISTS; \
- break; \
- case LTTNG_ERR_PROCESS_ATTR_MISSING: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_MISSING; \
- break; \
- case LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY; \
- break; \
- default: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR; \
- } \
- } \
- end: \
- return status; \
- }
-
-#define DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(command_upper, \
- command_lower, process_attr_name, value_type_name, \
- value_type_enum) \
- enum lttng_process_attr_tracker_handle_status \
- lttng_process_attr_##process_attr_name##_tracker_handle_##command_lower##_##value_type_name( \
- const struct lttng_process_attr_tracker_handle \
- *tracker, \
- const char *value) \
- { \
- int ret; \
- enum lttng_process_attr_tracker_handle_status status = \
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK; \
- struct lttcomm_session_msg lsm = { \
- .cmd_type = LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_##command_upper##_INCLUDE_VALUE, \
- .session = {}, \
- .domain = {}, \
- .u = {}, \
- .fd_count = 0, \
- }; \
- const size_t len = value ? strlen(value) + 1 : 0; \
- \
- if (!tracker || !value) { \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
- goto end; \
- } \
- \
- ret = lttng_strncpy(lsm.session.name, tracker->session_name, \
- sizeof(lsm.session.name)); \
- if (ret) { \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
- goto end; \
- } \
- \
- lsm.domain.type = tracker->domain; \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .process_attr = \
- (int32_t) tracker->process_attr; \
- lsm.u.process_attr_tracker_add_remove_include_value.name_len = \
- (uint32_t) len; \
- lsm.u.process_attr_tracker_add_remove_include_value \
- .value_type = (uint32_t) \
- LTTNG_PROCESS_ATTR_VALUE_TYPE_##value_type_enum; \
- \
- ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header( \
- &lsm, value, len, NULL); \
- if (ret < 0) { \
- switch (-ret) { \
- case LTTNG_ERR_PROCESS_ATTR_EXISTS: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_EXISTS; \
- break; \
- case LTTNG_ERR_PROCESS_ATTR_MISSING: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_MISSING; \
- break; \
- case LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY; \
- break; \
- case LTTNG_ERR_USER_NOT_FOUND: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_USER_NOT_FOUND; \
- break; \
- case LTTNG_ERR_GROUP_NOT_FOUND: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_GROUP_NOT_FOUND; \
- break; \
- default: \
- status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR; \
- } \
- } \
- end: \
- return status; \
+#define DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(command_upper, \
+ command_lower, \
+ process_attr_name, \
+ value_type_name, \
+ value_type_c, \
+ value_type_enum) \
+ enum lttng_process_attr_tracker_handle_status \
+ lttng_process_attr_##process_attr_name##_tracker_handle_##command_lower##_##value_type_name( \
+ const struct lttng_process_attr_tracker_handle *tracker, \
+ value_type_c value) \
+ { \
+ int ret; \
+ enum lttng_process_attr_tracker_handle_status status = \
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK; \
+ struct lttcomm_session_msg lsm = { \
+ .cmd_type = \
+ LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_##command_upper##_INCLUDE_VALUE, \
+ .session = {}, \
+ .domain = {}, \
+ .u = {}, \
+ .fd_count = 0, \
+ }; \
+ \
+ if (!tracker) { \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ ret = lttng_strncpy( \
+ lsm.session.name, tracker->session_name, sizeof(lsm.session.name)); \
+ if (ret) { \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ lsm.domain.type = tracker->domain; \
+ lsm.u.process_attr_tracker_add_remove_include_value.process_attr = \
+ (int32_t) tracker->process_attr; \
+ lsm.u.process_attr_tracker_add_remove_include_value.value_type = \
+ (uint32_t) LTTNG_PROCESS_ATTR_VALUE_TYPE_##value_type_enum; \
+ \
+ if (std::is_signed<value_type_c>::value) { \
+ lsm.u.process_attr_tracker_add_remove_include_value.integral_value.u \
+ ._signed = value; \
+ } else { \
+ lsm.u.process_attr_tracker_add_remove_include_value.integral_value.u \
+ ._unsigned = value; \
+ } \
+ \
+ ret = lttng_ctl_ask_sessiond(&lsm, NULL); \
+ if (ret < 0) { \
+ switch (-ret) { \
+ case LTTNG_ERR_PROCESS_ATTR_EXISTS: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_EXISTS; \
+ break; \
+ case LTTNG_ERR_PROCESS_ATTR_MISSING: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_MISSING; \
+ break; \
+ case LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY: \
+ status = \
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY; \
+ break; \
+ default: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR; \
+ } \
+ } \
+ end: \
+ return status; \
+ }
+
+#define DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC( \
+ command_upper, command_lower, process_attr_name, value_type_name, value_type_enum) \
+ enum lttng_process_attr_tracker_handle_status \
+ lttng_process_attr_##process_attr_name##_tracker_handle_##command_lower##_##value_type_name( \
+ const struct lttng_process_attr_tracker_handle *tracker, \
+ const char *value) \
+ { \
+ int ret; \
+ enum lttng_process_attr_tracker_handle_status status = \
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK; \
+ struct lttcomm_session_msg lsm = { \
+ .cmd_type = \
+ LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_##command_upper##_INCLUDE_VALUE, \
+ .session = {}, \
+ .domain = {}, \
+ .u = {}, \
+ .fd_count = 0, \
+ }; \
+ const size_t len = value ? strlen(value) + 1 : 0; \
+ \
+ if (!tracker || !value) { \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ ret = lttng_strncpy( \
+ lsm.session.name, tracker->session_name, sizeof(lsm.session.name)); \
+ if (ret) { \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ lsm.domain.type = tracker->domain; \
+ lsm.u.process_attr_tracker_add_remove_include_value.process_attr = \
+ (int32_t) tracker->process_attr; \
+ lsm.u.process_attr_tracker_add_remove_include_value.name_len = (uint32_t) len; \
+ lsm.u.process_attr_tracker_add_remove_include_value.value_type = \
+ (uint32_t) LTTNG_PROCESS_ATTR_VALUE_TYPE_##value_type_enum; \
+ \
+ ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, value, len, NULL); \
+ if (ret < 0) { \
+ switch (-ret) { \
+ case LTTNG_ERR_PROCESS_ATTR_EXISTS: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_EXISTS; \
+ break; \
+ case LTTNG_ERR_PROCESS_ATTR_MISSING: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_MISSING; \
+ break; \
+ case LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY: \
+ status = \
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY; \
+ break; \
+ case LTTNG_ERR_USER_NOT_FOUND: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_USER_NOT_FOUND; \
+ break; \
+ case LTTNG_ERR_GROUP_NOT_FOUND: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_GROUP_NOT_FOUND; \
+ break; \
+ default: \
+ status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR; \
+ } \
+ } \
+ end: \
+ return status; \
}
/* PID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, process_id, pid, pid_t, PID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, process_id, pid, pid_t, PID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, process_id, pid, pid_t, PID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, process_id, pid, pid_t, PID);
/* VPID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, virtual_process_id, pid, pid_t, PID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, virtual_process_id, pid, pid_t, PID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, virtual_process_id, pid, pid_t, PID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, virtual_process_id, pid, pid_t, PID);
/* UID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, user_id, uid, uid_t, UID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, user_id, uid, uid_t, UID);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- ADD, add, user_id, user_name, USER_NAME);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- REMOVE, remove, user_id, user_name, USER_NAME);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, user_id, uid, uid_t, UID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, user_id, uid, uid_t, UID);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(ADD, add, user_id, user_name, USER_NAME);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(REMOVE, remove, user_id, user_name, USER_NAME);
/* VUID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, virtual_user_id, uid, uid_t, UID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, virtual_user_id, uid, uid_t, UID);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- ADD, add, virtual_user_id, user_name, USER_NAME);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- REMOVE, remove, virtual_user_id, user_name, USER_NAME);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, virtual_user_id, uid, uid_t, UID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, virtual_user_id, uid, uid_t, UID);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(ADD, add, virtual_user_id, user_name, USER_NAME);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(REMOVE, remove, virtual_user_id, user_name, USER_NAME);
/* GID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, group_id, gid, gid_t, GID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, group_id, gid, gid_t, GID);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- ADD, add, group_id, group_name, GROUP_NAME);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- REMOVE, remove, group_id, group_name, GROUP_NAME);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, group_id, gid, gid_t, GID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, group_id, gid, gid_t, GID);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(ADD, add, group_id, group_name, GROUP_NAME);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(REMOVE, remove, group_id, group_name, GROUP_NAME);
/* VGID */
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- ADD, add, virtual_group_id, gid, gid_t, GID);
-DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(
- REMOVE, remove, virtual_group_id, gid, gid_t, GID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(ADD, add, virtual_group_id, gid, gid_t, GID);
+DEFINE_TRACKER_ADD_REMOVE_INTEGRAL_VALUE_FUNC(REMOVE, remove, virtual_group_id, gid, gid_t, GID);
+DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(ADD, add, virtual_group_id, group_name, GROUP_NAME);
DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- ADD, add, virtual_group_id, group_name, GROUP_NAME);
-DEFINE_TRACKER_ADD_REMOVE_STRING_VALUE_FUNC(
- REMOVE, remove, virtual_group_id, group_name, GROUP_NAME);
+ REMOVE, remove, virtual_group_id, group_name, GROUP_NAME);
-enum lttng_process_attr_tracker_handle_status
-lttng_process_attr_tracker_handle_get_inclusion_set(
- struct lttng_process_attr_tracker_handle *tracker,
- const struct lttng_process_attr_values **values)
+enum lttng_process_attr_tracker_handle_status lttng_process_attr_tracker_handle_get_inclusion_set(
+ struct lttng_process_attr_tracker_handle *tracker,
+ const struct lttng_process_attr_values **values)
{
char *reply = NULL;
int reply_ret, copy_ret;
enum lttng_process_attr_tracker_handle_status status =
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK;
struct lttcomm_session_msg lsm = {
.cmd_type = LTTCOMM_SESSIOND_COMMAND_PROCESS_ATTR_TRACKER_GET_INCLUSION_SET,
.session = {},
lttng_process_attr_values_destroy(tracker->inclusion_set);
tracker->inclusion_set = NULL;
- copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name,
- sizeof(lsm.session.name));
+ copy_ret = lttng_strncpy(lsm.session.name, tracker->session_name, sizeof(lsm.session.name));
if (copy_ret) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID;
goto end;
lsm.domain.type = tracker->domain;
lsm.u.process_attr_tracker_get_tracking_policy.process_attr =
- (int32_t) tracker->process_attr;
+ (int32_t) tracker->process_attr;
/* Command returns a session descriptor on success. */
- reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(
- &lsm, NULL, 0, (void **) &reply);
+ reply_ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, NULL, 0, (void **) &reply);
if (reply_ret < 0) {
if (reply_ret == -LTTNG_ERR_SESSION_NOT_EXIST) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_SESSION_DOES_NOT_EXIST;
- } else if (reply_ret ==
- -LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY) {
+ } else if (reply_ret == -LTTNG_ERR_PROCESS_ATTR_TRACKER_INVALID_TRACKING_POLICY) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY;
} else {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_ERROR;
goto end;
}
- inclusion_set_ret = lttng_process_attr_values_create_from_buffer(
- tracker->domain, tracker->process_attr,
- &inclusion_set_view, &tracker->inclusion_set);
+ inclusion_set_ret = lttng_process_attr_values_create_from_buffer(tracker->domain,
+ tracker->process_attr,
+ &inclusion_set_view,
+ &tracker->inclusion_set);
if (inclusion_set_ret < 0) {
status = LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_COMMUNICATION_ERROR;
goto end;
return status;
}
-enum lttng_process_attr_values_status lttng_process_attr_values_get_count(
- const struct lttng_process_attr_values *values,
- unsigned int *count)
+enum lttng_process_attr_values_status
+lttng_process_attr_values_get_count(const struct lttng_process_attr_values *values,
+ unsigned int *count)
{
- enum lttng_process_attr_values_status status =
- LTTNG_PROCESS_ATTR_VALUES_STATUS_OK;
+ enum lttng_process_attr_values_status status = LTTNG_PROCESS_ATTR_VALUES_STATUS_OK;
if (!values || !count) {
status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID;
return status;
}
-enum lttng_process_attr_value_type lttng_process_attr_values_get_type_at_index(
- const struct lttng_process_attr_values *values,
- unsigned int index)
+enum lttng_process_attr_value_type
+lttng_process_attr_values_get_type_at_index(const struct lttng_process_attr_values *values,
+ unsigned int index)
{
enum lttng_process_attr_value_type type;
const struct process_attr_value *value;
return type;
}
-#define DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER( \
- value_type_name, value_type, expected_value_type) \
- enum lttng_process_attr_values_status \
- lttng_process_attr_values_get_##value_type_name##_at_index( \
- const struct lttng_process_attr_values \
- *values, \
- unsigned int index, \
- value_type *out_value) \
- { \
- enum lttng_process_attr_values_status status = \
- LTTNG_PROCESS_ATTR_VALUES_STATUS_OK; \
- const struct process_attr_value *value; \
- \
- if (!values) { \
- status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \
- goto end; \
- } \
- \
- if (_lttng_process_attr_values_get_count(values) <= index) { \
- status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \
- goto end; \
- } \
- \
- value = lttng_process_attr_tracker_values_get_at_index( \
- values, index); \
- if (value->type != \
- LTTNG_PROCESS_ATTR_VALUE_TYPE_##expected_value_type) { \
- status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID_TYPE; \
- goto end; \
- } \
- *out_value = value->value.value_type_name; \
- end: \
- return status; \
+#define DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(value_type_name, value_type, expected_value_type) \
+ enum lttng_process_attr_values_status \
+ lttng_process_attr_values_get_##value_type_name##_at_index( \
+ const struct lttng_process_attr_values *values, \
+ unsigned int index, \
+ value_type *out_value) \
+ { \
+ enum lttng_process_attr_values_status status = \
+ LTTNG_PROCESS_ATTR_VALUES_STATUS_OK; \
+ const struct process_attr_value *value; \
+ \
+ if (!values) { \
+ status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ if (_lttng_process_attr_values_get_count(values) <= index) { \
+ status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID; \
+ goto end; \
+ } \
+ \
+ value = lttng_process_attr_tracker_values_get_at_index(values, index); \
+ if (value->type != LTTNG_PROCESS_ATTR_VALUE_TYPE_##expected_value_type) { \
+ status = LTTNG_PROCESS_ATTR_VALUES_STATUS_INVALID_TYPE; \
+ goto end; \
+ } \
+ *out_value = value->value.value_type_name; \
+ end: \
+ return status; \
}
DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(pid, pid_t, PID);
DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(user_name, const char *, USER_NAME);
DEFINE_LTTNG_PROCESS_ATTR_VALUES_GETTER(group_name, const char *, GROUP_NAME);
-static enum lttng_error_code handle_status_to_error_code(
- enum lttng_process_attr_tracker_handle_status handle_status)
+static enum lttng_error_code
+handle_status_to_error_code(enum lttng_process_attr_tracker_handle_status handle_status)
{
switch (handle_status) {
case LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY:
}
process_attr = handle->domain.type == LTTNG_DOMAIN_KERNEL ?
- LTTNG_PROCESS_ATTR_PROCESS_ID :
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID;
+ LTTNG_PROCESS_ATTR_PROCESS_ID :
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID;
- ret_code = lttng_session_get_tracker_handle(handle->session_name,
- handle->domain.type,
- process_attr, &tracker_handle);
+ ret_code = lttng_session_get_tracker_handle(
+ handle->session_name, handle->domain.type, process_attr, &tracker_handle);
if (ret_code != LTTNG_OK) {
goto end;
}
if (pid == -1) {
handle_status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- LTTNG_TRACKING_POLICY_INCLUDE_ALL);
+ tracker_handle, LTTNG_TRACKING_POLICY_INCLUDE_ALL);
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
- handle_status = lttng_process_attr_tracker_handle_get_tracking_policy(
- tracker_handle, &policy);
+ handle_status =
+ lttng_process_attr_tracker_handle_get_tracking_policy(tracker_handle, &policy);
if (handle_status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret_code = handle_status_to_error_code(handle_status);
goto end;
if (policy != LTTNG_TRACKING_POLICY_INCLUDE_SET) {
handle_status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- LTTNG_TRACKING_POLICY_INCLUDE_SET);
+ tracker_handle, LTTNG_TRACKING_POLICY_INCLUDE_SET);
if (handle_status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
handle_status = process_attr == LTTNG_PROCESS_ATTR_PROCESS_ID ?
- lttng_process_attr_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) pid) :
- lttng_process_attr_virtual_process_id_tracker_handle_add_pid(
- tracker_handle,
- (pid_t) pid);
+ lttng_process_attr_process_id_tracker_handle_add_pid(tracker_handle, (pid_t) pid) :
+ lttng_process_attr_virtual_process_id_tracker_handle_add_pid(tracker_handle,
+ (pid_t) pid);
ret_code = handle_status_to_error_code(handle_status);
end:
lttng_process_attr_tracker_handle_destroy(tracker_handle);
}
process_attr = handle->domain.type == LTTNG_DOMAIN_KERNEL ?
- LTTNG_PROCESS_ATTR_PROCESS_ID :
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID;
- ret_code = lttng_session_get_tracker_handle(handle->session_name,
- handle->domain.type, process_attr, &tracker_handle);
+ LTTNG_PROCESS_ATTR_PROCESS_ID :
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID;
+ ret_code = lttng_session_get_tracker_handle(
+ handle->session_name, handle->domain.type, process_attr, &tracker_handle);
if (ret_code != LTTNG_OK) {
goto end;
}
if (pid == -1) {
handle_status = lttng_process_attr_tracker_handle_set_tracking_policy(
- tracker_handle,
- LTTNG_TRACKING_POLICY_EXCLUDE_ALL);
+ tracker_handle, LTTNG_TRACKING_POLICY_EXCLUDE_ALL);
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
- handle_status = lttng_process_attr_tracker_handle_get_tracking_policy(
- tracker_handle, &policy);
+ handle_status =
+ lttng_process_attr_tracker_handle_get_tracking_policy(tracker_handle, &policy);
if (handle_status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
handle_status = process_attr == LTTNG_PROCESS_ATTR_PROCESS_ID ?
- lttng_process_attr_process_id_tracker_handle_remove_pid(
- tracker_handle,
- (pid_t) pid) :
- lttng_process_attr_virtual_process_id_tracker_handle_remove_pid(
- tracker_handle,
- (pid_t) pid);
+ lttng_process_attr_process_id_tracker_handle_remove_pid(tracker_handle,
+ (pid_t) pid) :
+ lttng_process_attr_virtual_process_id_tracker_handle_remove_pid(tracker_handle,
+ (pid_t) pid);
if (handle_status == LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY) {
ret_code = LTTNG_ERR_PID_NOT_TRACKED;
}
* Returns 0 on success, else a negative LTTng error code.
*/
int lttng_list_tracker_pids(struct lttng_handle *handle,
- int *_enabled,
- int32_t **_pids,
- size_t *_nr_pids)
+ int *_enabled,
+ int32_t **_pids,
+ size_t *_nr_pids)
{
enum lttng_error_code ret_code;
struct lttng_process_attr_tracker_handle *tracker_handle = NULL;
}
ret_code = lttng_session_get_tracker_handle(handle->session_name,
- handle->domain.type,
- LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID, &tracker_handle);
+ handle->domain.type,
+ LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID,
+ &tracker_handle);
if (ret_code != LTTNG_OK) {
goto end;
}
while (true) {
- handle_status = lttng_process_attr_tracker_handle_get_inclusion_set(
- tracker_handle, &values);
- if (handle_status ==
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
+ handle_status = lttng_process_attr_tracker_handle_get_inclusion_set(tracker_handle,
+ &values);
+ if (handle_status == LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
policy = LTTNG_TRACKING_POLICY_INCLUDE_SET;
break;
} else if (handle_status !=
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY) {
+ LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_INVALID_TRACKING_POLICY) {
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
handle_status = lttng_process_attr_tracker_handle_get_tracking_policy(
- tracker_handle, &policy);
- if (handle_status !=
- LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
+ tracker_handle, &policy);
+ if (handle_status != LTTNG_PROCESS_ATTR_TRACKER_HANDLE_STATUS_OK) {
ret_code = handle_status_to_error_code(handle_status);
goto end;
}
case LTTNG_TRACKING_POLICY_INCLUDE_SET:
{
const enum lttng_process_attr_values_status values_status =
- lttng_process_attr_values_get_count(
- values, &pid_count);
+ lttng_process_attr_values_get_count(values, &pid_count);
if (values_status != LTTNG_PROCESS_ATTR_VALUES_STATUS_OK) {
ret_code = LTTNG_ERR_UNK;
for (i = 0; i < pid_count; i++) {
pid_t pid;
const enum lttng_process_attr_values_status values_status =
- lttng_process_attr_values_get_pid_at_index(
- values, i, &pid);
+ lttng_process_attr_values_get_pid_at_index(values, i, &pid);
if (values_status != LTTNG_PROCESS_ATTR_VALUES_STATUS_OK) {
ret_code = LTTNG_ERR_UNK;
#undef _FORTIFY_SOURCE
#endif
+#include <common/compat/time.hpp>
+#include <common/error.hpp>
+
#include <fcntl.h>
#include <limits.h>
#include <poll.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/time.hpp>
-#include <common/error.hpp>
-
#define BUF_SIZE 256
-#define NB_FD 1
-#define MAX_FDS 2047
-#define NR_ITER 1000 /* for stress-tests */
+#define NB_FD 1
+#define MAX_FDS 2047
+#define NR_ITER 1000 /* for stress-tests */
-#define MIN_NR_FDS 5 /* the minimum number of open FDs required for the test to run */
+#define MIN_NR_FDS 5 /* the minimum number of open FDs required for the test to run */
#define BIG_SELECT_FD 1022
#define MSEC_PER_USEC 1000
test_case_cb run;
bool produces_validation_info;
int timeout;
-} test_cases [] =
-{
+} test_cases[] = {
{ .run = run_working_cases, .produces_validation_info = true, .timeout = -1 },
{ .run = run_working_cases, .produces_validation_info = true, .timeout = 1 },
{ .run = pselect_invalid_fd, .produces_validation_info = false, .timeout = 0 },
};
} /* namespace */
-static
-void test_select_big(void)
+static void test_select_big(void)
{
fd_set rfds, wfds, exfds;
struct timeval tv;
return;
}
-static
-void test_pselect(void)
+static void test_pselect(void)
{
fd_set rfds;
struct timespec tv;
}
}
-static
-void test_select(void)
+static void test_select(void)
{
fd_set rfds;
struct timeval tv;
}
}
-static
-void test_poll(void)
+static void test_poll(void)
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
int ret;
ufds[0].fd = wait_fd;
- ufds[0].events = POLLIN|POLLPRI;
+ ufds[0].events = POLLIN | POLLPRI;
ret = poll(ufds, 1, timeout);
}
}
-static
-void test_ppoll(void)
+static void test_ppoll(void)
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
struct timespec ts;
ufds[0].fd = wait_fd;
- ufds[0].events = POLLIN|POLLPRI;
+ ufds[0].events = POLLIN | POLLPRI;
if (timeout > 0) {
ts.tv_sec = 0;
ret = ppoll(ufds, 1, NULL, NULL);
}
-
if (ret < 0) {
PERROR("ppoll");
} else if (ret > 0) {
}
}
-static
-void test_ppoll_big(FILE *validation_output_file __attribute__((unused)))
+static void test_ppoll_big(FILE *validation_output_file __attribute__((unused)))
{
struct pollfd ufds[MAX_FDS];
char buf[BUF_SIZE];
PERROR("dup");
}
ufds[i].fd = fds[i];
- ufds[i].events = POLLIN|POLLPRI;
+ ufds[i].events = POLLIN | POLLPRI;
}
ret = ppoll(ufds, MAX_FDS, NULL, NULL);
return;
}
-static
-void test_epoll(FILE *validation_output_file)
+static void test_epoll(FILE *validation_output_file)
{
int ret, epollfd;
char buf[BUF_SIZE];
goto end;
}
- ret = fprintf(validation_output_file,
- ", \"epoll_wait_fd\": %i", epollfd);
+ ret = fprintf(validation_output_file, ", \"epoll_wait_fd\": %i", epollfd);
if (ret < 0) {
PERROR("[epoll] Failed to write test validation output");
goto error;
return;
}
-static
-void test_epoll_pwait(FILE *validation_output_file)
+static void test_epoll_pwait(FILE *validation_output_file)
{
int ret, epollfd;
char buf[BUF_SIZE];
goto end;
}
- ret = fprintf(validation_output_file,
- ", \"epoll_pwait_fd\": %i", epollfd);
+ ret = fprintf(validation_output_file, ", \"epoll_pwait_fd\": %i", epollfd);
if (ret < 0) {
PERROR("[epoll_pwait] Failed to write test validation output");
goto error;
return;
}
-static
-void run_working_cases(FILE *validation_output_file)
+static void run_working_cases(FILE *validation_output_file)
{
int ret;
int pipe_fds[2];
* segfault (eventually with a "*** stack smashing detected ***" message).
* The event should contain an array of 100 FDs filled with garbage.
*/
-static
-void ppoll_fds_buffer_overflow(
- FILE *validation_output_file __attribute__((unused)))
+static void ppoll_fds_buffer_overflow(FILE *validation_output_file __attribute__((unused)))
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
int ret;
ufds[0].fd = wait_fd;
- ufds[0].events = POLLIN|POLLPRI;
+ ufds[0].events = POLLIN | POLLPRI;
ret = syscall(SYS_ppoll, ufds, 100, NULL, NULL);
* cleanly fail with a "Invalid argument".
* The event should contain an empty array of FDs and overflow = 1.
*/
-static
-void ppoll_fds_ulong_max(FILE *validation_output_file __attribute__((unused)))
+static void ppoll_fds_ulong_max(FILE *validation_output_file __attribute__((unused)))
{
struct pollfd ufds[NB_FD];
char buf[BUF_SIZE];
int ret;
ufds[0].fd = wait_fd;
- ufds[0].events = POLLIN|POLLPRI;
+ ufds[0].events = POLLIN | POLLPRI;
ret = syscall(SYS_ppoll, ufds, ULONG_MAX, NULL, NULL);
if (ret < 0) {
* Pass an invalid file descriptor to pselect6(). The syscall should return
* -EBADF. The recorded event should contain a "ret = -EBADF (-9)".
*/
-static
-void pselect_invalid_fd(FILE *validation_output_file __attribute__((unused)))
+static void pselect_invalid_fd(FILE *validation_output_file __attribute__((unused)))
{
fd_set rfds;
int ret;
* Invalid pointer as writefds, should output a ppoll event
* with 0 FDs.
*/
-static
-void pselect_invalid_pointer(
- FILE *validation_output_file __attribute__((unused)))
+static void pselect_invalid_pointer(FILE *validation_output_file __attribute__((unused)))
{
fd_set rfds;
int ret;
FD_ZERO(&rfds);
FD_SET(wait_fd, &rfds);
- ret = syscall(SYS_pselect6, 1, &rfds, (fd_set *) invalid, NULL, NULL,
- NULL);
+ ret = syscall(SYS_pselect6, 1, &rfds, (fd_set *) invalid, NULL, NULL, NULL);
if (ret == -1) {
/* Expected error. */
} else if (ret) {
* Pass an invalid pointer to epoll_pwait, should fail with
* "Bad address", the event returns 0 FDs.
*/
-static
-void epoll_pwait_invalid_pointer(FILE *validation_output_file)
+static void epoll_pwait_invalid_pointer(FILE *validation_output_file)
{
int ret, epollfd;
char buf[BUF_SIZE];
goto end;
}
- ret = fprintf(validation_output_file,
- "{ \"epollfd\": %i, \"pid\": %i }", epollfd,
- getpid());
+ ret = fprintf(
+ validation_output_file, "{ \"epollfd\": %i, \"pid\": %i }", epollfd, getpid());
if (ret < 0) {
PERROR("[epoll_pwait] Failed to write test validation output");
goto error;
goto error;
}
- ret = syscall(SYS_epoll_pwait, epollfd,
- (struct epoll_event *) invalid, 1, -1, NULL);
+ ret = syscall(SYS_epoll_pwait, epollfd, (struct epoll_event *) invalid, 1, -1, NULL);
if (ret == 1) {
ret = read(wait_fd, buf, BUF_SIZE);
* Set maxevents to INT_MAX, should output "Invalid argument"
* The event should return an empty array.
*/
-static
-void epoll_pwait_int_max(FILE *validation_output_file)
+static void epoll_pwait_int_max(FILE *validation_output_file)
{
int ret, epollfd;
char buf[BUF_SIZE];
goto end;
}
- ret = fprintf(validation_output_file,
- "{ \"epollfd\": %i, \"pid\": %i }", epollfd,
- getpid());
+ ret = fprintf(
+ validation_output_file, "{ \"epollfd\": %i, \"pid\": %i }", epollfd, getpid());
if (ret < 0) {
PERROR("[epoll_pwait] Failed to write test validation output");
goto error;
goto error;
}
- ret = syscall(SYS_epoll_pwait, epollfd, &epoll_event, INT_MAX, -1,
- NULL);
+ ret = syscall(SYS_epoll_pwait, epollfd, &epoll_event, INT_MAX, -1, NULL);
if (ret == 1) {
ret = read(wait_fd, buf, BUF_SIZE);
return;
}
-static
-void *ppoll_writer(void *arg)
+static void *ppoll_writer(void *arg)
{
struct ppoll_thread_data *data = (struct ppoll_thread_data *) arg;
while (!stop_thread) {
- memset(data->ufds, data->value,
- MAX_FDS * sizeof(struct pollfd));
+ memset(data->ufds, data->value, MAX_FDS * sizeof(struct pollfd));
usleep(100);
}
return NULL;
}
-static
-void do_ppoll(int *fds, struct pollfd *ufds)
+static void do_ppoll(int *fds, struct pollfd *ufds)
{
int i, ret;
struct timespec ts;
for (i = 0; i < MAX_FDS; i++) {
ufds[i].fd = fds[i];
- ufds[i].events = POLLIN|POLLPRI;
+ ufds[i].events = POLLIN | POLLPRI;
}
ret = ppoll(ufds, MAX_FDS, &ts, NULL);
}
}
-static
-void stress_ppoll(int *fds, int value)
+static void stress_ppoll(int *fds, int value)
{
pthread_t writer;
int iter, ret;
*
* ppoll should work as expected and the trace should be readable at the end.
*/
-static
-void ppoll_concurrent_write(
- FILE *validation_output_file __attribute__((unused)))
+static void ppoll_concurrent_write(FILE *validation_output_file __attribute__((unused)))
{
int i, ret, fds[MAX_FDS];
return;
}
-static
-void *epoll_pwait_writer(void *addr)
+static void *epoll_pwait_writer(void *addr)
{
srand(time(NULL));
* buffer allocated for the returned data. This should randomly segfault.
* The trace should be readable and no kernel OOPS should occur.
*/
-static
-void epoll_pwait_concurrent_munmap(FILE *validation_output_file)
+static void epoll_pwait_concurrent_munmap(FILE *validation_output_file)
{
int ret, epollfd, i, fds[MAX_FDS];
char buf[BUF_SIZE];
goto end;
}
- ret = fprintf(validation_output_file,
- "{ \"epollfd\": %i, \"pid\": %i }", epollfd,
- getpid());
+ ret = fprintf(
+ validation_output_file, "{ \"epollfd\": %i, \"pid\": %i }", epollfd, getpid());
if (ret < 0) {
PERROR("[epoll_pwait] Failed to write test validation output");
goto error;
}
epoll_event = (struct epoll_event *) mmap(NULL,
- MAX_FDS * sizeof(struct epoll_event),
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1,
- 0);
+ MAX_FDS * sizeof(struct epoll_event),
+ PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1,
+ 0);
if (epoll_event == MAP_FAILED) {
PERROR("mmap");
goto error;
}
}
stop_thread = 0;
- ret = pthread_create(&writer, NULL, &epoll_pwait_writer,
- (void *) epoll_event);
+ ret = pthread_create(&writer, NULL, &epoll_pwait_writer, (void *) epoll_event);
if (ret != 0) {
fprintf(stderr, "[error] pthread_create\n");
goto error_unmap;
return;
}
-static
-void print_list(void)
+static void print_list(void)
{
fprintf(stderr, "Test list (-t X):\n");
- fprintf(stderr, "\t1: Working cases for select, pselect6, poll, ppoll "
- "and epoll, waiting for input\n");
- fprintf(stderr, "\t2: Timeout cases (1ms) for select, pselect6, poll, "
- "ppoll and epoll\n");
+ fprintf(stderr,
+ "\t1: Working cases for select, pselect6, poll, ppoll "
+ "and epoll, waiting for input\n");
+ fprintf(stderr,
+ "\t2: Timeout cases (1ms) for select, pselect6, poll, "
+ "ppoll and epoll\n");
fprintf(stderr, "\t3: pselect with an invalid fd\n");
fprintf(stderr, "\t4: ppoll with %d FDs\n", MAX_FDS);
- fprintf(stderr, "\t5: ppoll buffer overflow, should segfault, waits "
- "for input\n");
- fprintf(stderr, "\t6: pselect with an invalid pointer, waits for "
- "input\n");
+ fprintf(stderr,
+ "\t5: ppoll buffer overflow, should segfault, waits "
+ "for input\n");
+ fprintf(stderr,
+ "\t6: pselect with an invalid pointer, waits for "
+ "input\n");
fprintf(stderr, "\t7: ppoll with ulong_max fds, waits for input\n");
- fprintf(stderr, "\t8: epoll_pwait with an invalid pointer, waits for "
- "input\n");
- fprintf(stderr, "\t9: epoll_pwait with maxevents set to INT_MAX, "
- "waits for input\n");
- fprintf(stderr, "\t10: ppoll with concurrent updates of the structure "
- "from user-space, stress test (3000 iterations), "
- "waits for input + timeout 1ms\n");
- fprintf(stderr, "\t11: epoll_pwait with concurrent munmap of the buffer "
- "from user-space, should randomly segfault, run "
- "multiple times, waits for input + timeout 1ms\n");
+ fprintf(stderr,
+ "\t8: epoll_pwait with an invalid pointer, waits for "
+ "input\n");
+ fprintf(stderr,
+ "\t9: epoll_pwait with maxevents set to INT_MAX, "
+ "waits for input\n");
+ fprintf(stderr,
+ "\t10: ppoll with concurrent updates of the structure "
+ "from user-space, stress test (3000 iterations), "
+ "waits for input + timeout 1ms\n");
+ fprintf(stderr,
+ "\t11: epoll_pwait with concurrent munmap of the buffer "
+ "from user-space, should randomly segfault, run "
+ "multiple times, waits for input + timeout 1ms\n");
}
int main(int argc, const char **argv)
FILE *test_validation_output_file = NULL;
const char *test_validation_output_file_path = NULL;
struct poptOption optionsTable[] = {
- { "test", 't', POPT_ARG_INT, &test, 0,
- "Test to run", NULL },
- { "list", 'l', 0, 0, 'l',
- "List of tests (-t X)", NULL },
- { "validation-file", 'o', POPT_ARG_STRING, &test_validation_output_file_path, 0,
- "Test case output", NULL },
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0, NULL, NULL }
+ { "test", 't', POPT_ARG_INT, &test, 0, "Test to run", NULL },
+ { "list", 'l', 0, 0, 'l', "List of tests (-t X)", NULL },
+ { "validation-file",
+ 'o',
+ POPT_ARG_STRING,
+ &test_validation_output_file_path,
+ 0,
+ "Test case output",
+ NULL },
+ POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
const struct test_case *test_case;
test_validation_output_file = fopen(test_validation_output_file_path, "w+");
if (!test_validation_output_file) {
PERROR("Failed to create test validation output file at '%s'",
- test_validation_output_file_path);
+ test_validation_output_file_path);
ret = -1;
goto end;
}
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <common/common.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/errno.hpp>
#include <common/compat/time.hpp>
-#include <sys/types.h>
-#include <inttypes.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
+#include <common/index/ctf-index.hpp>
#include <lttng/lttng.h>
-#include <urcu/list.h>
-#include <common/common.hpp>
-
#include <bin/lttng-relayd/lttng-viewer-abi.hpp>
-#include <common/index/ctf-index.hpp>
-
-#include <common/compat/errno.hpp>
-#include <common/compat/endian.hpp>
-
+#include <fcntl.h>
+#include <inttypes.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <tap/tap.h>
+#include <unistd.h>
+#include <urcu/list.h>
-#define SESSION1 "test1"
+#define SESSION1 "test1"
#define RELAYD_URL "net://localhost"
#define LIVE_TIMER 2000000
};
} /* namespace */
-static
-ssize_t lttng_live_recv(int fd, void *buf, size_t len)
+static ssize_t lttng_live_recv(int fd, void *buf, size_t len)
{
ssize_t ret;
size_t copied = 0, to_copy = len;
copied += ret;
to_copy -= ret;
}
- } while ((ret > 0 && to_copy > 0)
- || (ret < 0 && errno == EINTR));
+ } while ((ret > 0 && to_copy > 0) || (ret < 0 && errno == EINTR));
if (ret > 0)
ret = copied;
/* ret = 0 means orderly shutdown, ret < 0 is error. */
return ret;
}
-static
-ssize_t lttng_live_send(int fd, const void *buf, size_t len)
+static ssize_t lttng_live_send(int fd, const void *buf, size_t len)
{
ssize_t ret;
return ret;
}
-static
-int connect_viewer(const char *hostname)
+static int connect_viewer(const char *hostname)
{
struct hostent *host;
struct sockaddr_in server_addr;
server_addr.sin_addr = *((struct in_addr *) host->h_addr);
bzero(&(server_addr.sin_zero), 8);
- if (connect(control_sock, (struct sockaddr *) &server_addr,
- sizeof(struct sockaddr)) == -1) {
+ if (connect(control_sock, (struct sockaddr *) &server_addr, sizeof(struct sockaddr)) ==
+ -1) {
PERROR("Connect");
ret = -1;
goto end;
return ret;
}
-static
-int establish_connection(void)
+static int establish_connection(void)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_connect connect;
/*
* Returns the number of sessions, should be 1 during the unit test.
*/
-static
-int list_sessions(uint64_t *session_id)
+static int list_sessions(uint64_t *session_id)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_list_sessions list;
return -1;
}
-static
-int create_viewer_session(void)
+static int create_viewer_session(void)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_create_session_response resp;
return -1;
}
-static
-int attach_session(uint64_t id)
+static int attach_session(uint64_t id)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_attach_session_request rq;
session->streams[i].ctf_trace_id = be64toh(stream.ctf_trace_id);
session->streams[i].first_read = 1;
- session->streams[i].mmap_base = mmap(NULL, mmap_size,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ session->streams[i].mmap_base = mmap(
+ NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (session->streams[i].mmap_base == MAP_FAILED) {
diag("mmap error");
goto error;
return -1;
}
-static
-int get_metadata(void)
+static int get_metadata(void)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_metadata rq;
return -1;
}
-static
-int get_next_index(void)
+static int get_next_index(void)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_next_index rq;
memset(&rq, 0, sizeof(rq));
rq.stream_id = htobe64(session->streams[id].id);
-retry:
+ retry:
ret_len = lttng_live_send(control_sock, &cmd, sizeof(cmd));
if (ret_len < 0) {
diag("Error sending cmd");
diag("Got LTTNG_VIEWER_INDEX_ERR");
goto error;
default:
- diag("Unknown reply status during LTTNG_VIEWER_GET_NEXT_INDEX (%d)", be32toh(rp.status));
+ diag("Unknown reply status during LTTNG_VIEWER_GET_NEXT_INDEX (%d)",
+ be32toh(rp.status));
goto error;
}
if (first_packet_stream_id < 0) {
first_packet_len = be64toh(rp.packet_size) / CHAR_BIT;
first_packet_stream_id = id;
diag("Got first packet index with offset %d and len %d",
- first_packet_offset, first_packet_len);
+ first_packet_offset,
+ first_packet_len);
}
}
return 0;
return -1;
}
-static
-int get_data_packet(int id, uint64_t offset,
- uint64_t len)
+static int get_data_packet(int id, uint64_t offset, uint64_t len)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_packet rq;
return -1;
}
-static
-int detach_viewer_session(uint64_t id)
+static int detach_viewer_session(uint64_t id)
{
struct lttng_viewer_cmd cmd;
struct lttng_viewer_detach_session_response resp;
ok(ret == 0, "Connect viewer to relayd");
ret = establish_connection();
- ok(ret == 0, "Established connection and version check with %d.%d",
- VERSION_MAJOR, VERSION_MINOR);
+ ok(ret == 0,
+ "Established connection and version check with %d.%d",
+ VERSION_MAJOR,
+ VERSION_MINOR);
ret = list_sessions(&session_id);
ok(ret > 0, "List sessions : %d session(s)", ret);
ret = get_next_index();
ok(ret == 0, "Get one index per stream");
- ret = get_data_packet(first_packet_stream_id, first_packet_offset,
- first_packet_len);
+ ret = get_data_packet(first_packet_stream_id, first_packet_offset, first_packet_len);
ok(ret == 0,
- "Get one data packet for stream %d, offset %d, len %d",
- first_packet_stream_id, first_packet_offset,
- first_packet_len);
+ "Get one data packet for stream %d, offset %d, len %d",
+ first_packet_stream_id,
+ first_packet_offset,
+ first_packet_len);
ret = detach_viewer_session(session_id);
ok(ret == 0, "Detach viewer session");
#include <common/compat/getenv.hpp>
#include <common/consumer/consumer.hpp>
-#include <common/pipe.hpp>
#include <common/error.hpp>
-#include <unistd.h>
-#include <stdbool.h>
+#include <common/pipe.hpp>
+
#include <lttng/constant.h>
#include <lttng/lttng-export.h>
-#include <fcntl.h>
+
#include <dlfcn.h>
+#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <unistd.h>
static char *pause_pipe_path;
static struct lttng_pipe *pause_pipe;
int lttng_opt_mi;
int lttng_opt_quiet;
-static
-void __attribute__((destructor)) pause_pipe_fini(void)
+static void __attribute__((destructor)) pause_pipe_fini(void)
{
int ret;
int ret = 0;
const char *pause_pipe_path_prefix, *domain;
- pause_pipe_path_prefix = lttng_secure_getenv(
- "CONSUMER_PAUSE_PIPE_PATH");
+ pause_pipe_path_prefix = lttng_secure_getenv("CONSUMER_PAUSE_PIPE_PATH");
if (!pause_pipe_path_prefix) {
ret = -1;
goto end;
*/
data_consumption_state = (int *) dlsym(NULL, "data_consumption_paused");
LTTNG_ASSERT(data_consumption_state);
- lttng_consumer_get_type = (lttng_consumer_type (*)()) dlsym(NULL, "lttng_consumer_get_type");
+ lttng_consumer_get_type = (lttng_consumer_type(*)()) dlsym(NULL, "lttng_consumer_get_type");
LTTNG_ASSERT(lttng_consumer_get_type);
switch (lttng_consumer_get_type()) {
abort();
}
- ret = asprintf(&pause_pipe_path, "%s-%s", pause_pipe_path_prefix,
- domain);
+ ret = asprintf(&pause_pipe_path, "%s-%s", pause_pipe_path_prefix, domain);
if (ret < 1) {
ERR("Failed to allocate pause pipe path");
goto end;
}
DBG("Creating pause pipe at %s", pause_pipe_path);
- pause_pipe = lttng_pipe_named_open(pause_pipe_path,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, O_NONBLOCK);
+ pause_pipe = lttng_pipe_named_open(
+ pause_pipe_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, O_NONBLOCK);
if (!pause_pipe) {
ERR("Failed to create pause pipe at %s", pause_pipe_path);
ret = -1;
if (value_read) {
*data_consumption_state = !!value;
DBG("Message received on pause pipe: %s data consumption",
- *data_consumption_state ? "paused" : "resumed");
+ *data_consumption_state ? "paused" : "resumed");
}
end:
return ret;
#define _GNU_SOURCE
#endif
-#include <unistd.h>
+#include <common/error.hpp>
+#include <common/pipe.hpp>
+
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-
-#include <common/pipe.hpp>
-#include <common/error.hpp>
+#include <unistd.h>
int lttng_opt_verbose;
int lttng_opt_mi;
*
*/
+#include <common/compat/errno.hpp>
+#include <common/macros.hpp>
+
+#include <lttng/lttng.h>
+
+#include <fcntl.h>
+#include <inttypes.h>
#include <math.h>
+#include <poll.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <poll.h>
-
-#include <common/compat/errno.hpp>
-#include <common/macros.hpp>
-#include <lttng/lttng.h>
-
+#include <sys/types.h>
#include <tap/tap.h>
+#include <unistd.h>
#define FIELD_NAME_MAX_LEN 256
};
} /* namespace */
-static
-const char *field_value_type_to_str(enum lttng_event_field_value_type type)
+static const char *field_value_type_to_str(enum lttng_event_field_value_type type)
{
switch (type) {
case LTTNG_EVENT_FIELD_VALUE_TYPE_UNKNOWN:
}
static int validate_type(const struct lttng_event_field_value *event_field,
- enum lttng_event_field_value_type expect)
+ enum lttng_event_field_value_type expect)
{
int ret;
enum lttng_event_field_value_type value;
goto end;
}
- ok(expect == value, "Expected field type %s, got %s",
- field_value_type_to_str(expect),
- field_value_type_to_str(value));
+ ok(expect == value,
+ "Expected field type %s, got %s",
+ field_value_type_to_str(expect),
+ field_value_type_to_str(value));
ret = expect != value;
/*
* Validate unsigned captured field against the iteration number.
*/
-static int validate_unsigned_int_field(
- const struct lttng_event_field_value *event_field,
- unsigned int expected_value)
+static int validate_unsigned_int_field(const struct lttng_event_field_value *event_field,
+ unsigned int expected_value)
{
int ret;
uint64_t value;
enum lttng_event_field_value_status status;
- ret = validate_type(
- event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT);
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT);
if (ret) {
goto end;
}
- status = lttng_event_field_value_unsigned_int_get_value(
- event_field, &value);
+ status = lttng_event_field_value_unsigned_int_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
ok(value == (uint64_t) expected_value,
- "Expected unsigned integer value %u, got %" PRIu64,
- expected_value, value);
+ "Expected unsigned integer value %u, got %" PRIu64,
+ expected_value,
+ value);
ret = value != (uint64_t) expected_value;
/*
* Validate signed captured field.
*/
-static int validate_signed_int_field(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_signed_int_field(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
int ret;
const int64_t expected = -1;
/* Unused. */
(void) iteration;
- ret = validate_type(
- event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT);
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT);
if (ret) {
goto end;
}
- status = lttng_event_field_value_signed_int_get_value(
- event_field, &value);
+ status = lttng_event_field_value_signed_int_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_signed_int_get_value returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
ok(value == expected,
- "Expected signed integer value %" PRId64
- ", got %" PRId64,
- expected, value);
+ "Expected signed integer value %" PRId64 ", got %" PRId64,
+ expected,
+ value);
ret = value != expected;
/*
* Validate array of unsigned int.
*/
-static int validate_array_unsigned_int_field(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_array_unsigned_int_field(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
int ret;
enum lttng_event_field_value_status status;
goto end;
}
- ok(count == expected, "Expected %d subelements, got %d", expected,
- count);
+ ok(count == expected, "Expected %d subelements, got %d", expected, count);
if (count != expected) {
ret = 1;
goto end;
const struct lttng_event_field_value *value;
status = lttng_event_field_value_array_get_element_at_index(
- event_field, i - 1, &value);
+ event_field, i - 1, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
return ret;
}
-static int validate_array_unsigned_int_field_at_index(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int
+validate_array_unsigned_int_field_at_index(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
int ret;
const uint64_t expected_value = 2;
/* Unused. */
(void) iteration;
- ret = validate_type(
- event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT);
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT);
if (ret) {
goto end;
}
- status = lttng_event_field_value_unsigned_int_get_value(
- event_field, &value);
+ status = lttng_event_field_value_unsigned_int_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
ok(value == expected_value,
- "Expected unsigned integer value %" PRIu64 ", got %" PRIu64,
- expected_value, value);
+ "Expected unsigned integer value %" PRIu64 ", got %" PRIu64,
+ expected_value,
+ value);
ret = 0;
end:
* Value: "test" encoded in UTF-8: [116, 101, 115, 116]
*/
static int validate_seqfield1(const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+ unsigned int iteration)
{
int ret;
enum lttng_event_field_value_status status;
unsigned int i, count;
- const unsigned int expect[] = {116, 101, 115, 116};
+ const unsigned int expect[] = { 116, 101, 115, 116 };
const size_t array_count = sizeof(expect) / sizeof(*expect);
/* Unused. */
status = lttng_event_field_value_array_get_length(event_field, &count);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_array_get_length returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
- ok(count == array_count, "Expected %zu array sub-elements, got %d",
- array_count, count);
+ ok(count == array_count, "Expected %zu array sub-elements, got %d", array_count, count);
if (count != array_count) {
ret = 1;
goto end;
for (i = 0; i < count; i++) {
const struct lttng_event_field_value *value;
- status = lttng_event_field_value_array_get_element_at_index(
- event_field, i, &value);
+ status = lttng_event_field_value_array_get_element_at_index(event_field, i, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
return ret;
}
-static int validate_string(
- const struct lttng_event_field_value *event_field,
- const char *expect)
+static int validate_string(const struct lttng_event_field_value *event_field, const char *expect)
{
int ret;
const char *value = NULL;
status = lttng_event_field_value_string_get_value(event_field, &value);
if (!value) {
fail("lttng_event_field_value_array_get_length returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
- ok(!strcmp(value, expect), "Expected string value \"%s\", got \"%s\"",
- expect, value);
+ ok(!strcmp(value, expect), "Expected string value \"%s\", got \"%s\"", expect, value);
ret = 0;
end:
/*
* Validate string. Expected value is "test".
*/
-static int validate_string_test(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_string_test(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
- const char * const expect = "test";
+ const char *const expect = "test";
/* Unused. */
(void) iteration;
/*
* Validate escaped string. Expected value is "\*".
*/
-static int validate_string_escaped(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_string_escaped(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
- const char * const expect = "\\*";
+ const char *const expect = "\\*";
/* Unused. */
(void) iteration;
/*
* Validate real field.
*/
-static int validate_real(
- const struct lttng_event_field_value *event_field,
- double expect)
+static int validate_real(const struct lttng_event_field_value *event_field, double expect)
{
int ret;
double value;
status = lttng_event_field_value_real_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_real_get_value returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
/*
* Validate floatfield.
*/
-static int validate_floatfield(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_floatfield(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
const double expect = 2222.0;
/*
* Validate doublefield.
*/
-static int validate_doublefield(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_doublefield(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
const double expect = 2.0;
/*
* Validate enum0: enum0 = ( "AUTO: EXPECT 0" : container = 0 )
*/
-static int validate_enum0(const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_enum0(const struct lttng_event_field_value *event_field, unsigned int iteration)
{
int ret;
enum lttng_event_field_value_status status;
/* Unused. */
(void) iteration;
- ret = validate_type(event_field,
- LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM);
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM);
if (ret) {
goto end;
}
- status = lttng_event_field_value_unsigned_int_get_value(
- event_field, &value);
+ status = lttng_event_field_value_unsigned_int_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
- (int) status);
+ (int) status);
ret = 1;
goto end;
}
ok(value == expected_value,
- "Expected enum value %" PRIu64 ", got %" PRIu64,
- expected_value, value);
+ "Expected enum value %" PRIu64 ", got %" PRIu64,
+ expected_value,
+ value);
end:
return ret;
*
* We expect 2 labels here.
*/
-static int validate_enumnegative(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_enumnegative(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
int ret;
enum lttng_event_field_value_status status;
/* Unused. */
(void) iteration;
- ret = validate_type(event_field,
- LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM);
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM);
if (ret) {
goto end;
}
- status = lttng_event_field_value_signed_int_get_value(
- event_field, &value);
+ status = lttng_event_field_value_signed_int_get_value(event_field, &value);
if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("lttng_event_field_value_unsigned_int_get_value");
ret = 1;
}
ok(value == expected_value,
- "Expected enum value %" PRId64 ", got %" PRId64,
- expected_value, value);
+ "Expected enum value %" PRId64 ", got %" PRId64,
+ expected_value,
+ value);
end:
return ret;
}
-static int validate_context_procname_ust(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_context_procname_ust(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
/* Unused. */
(void) iteration;
return validate_string(event_field, "gen-ust-events");
}
-static int validate_context_procname_kernel(
- const struct lttng_event_field_value *event_field,
- unsigned int iteration)
+static int validate_context_procname_kernel(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
{
/* Unused. */
(void) iteration;
struct capture_base_field_tuple test_capture_base_fields[] = {
{ "DOESNOTEXIST", FIELD_TYPE_PAYLOAD, false, false, NULL, NULL },
- { "intfield", FIELD_TYPE_PAYLOAD, true, true, validate_unsigned_int_field, validate_unsigned_int_field },
- { "longfield", FIELD_TYPE_PAYLOAD, true, true, validate_unsigned_int_field, validate_unsigned_int_field },
- { "signedfield", FIELD_TYPE_PAYLOAD, true, true, validate_signed_int_field, validate_signed_int_field },
- { "arrfield1", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "intfield",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_unsigned_int_field,
+ validate_unsigned_int_field },
+ { "longfield",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_unsigned_int_field,
+ validate_unsigned_int_field },
+ { "signedfield",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_signed_int_field,
+ validate_signed_int_field },
+ { "arrfield1",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_array_unsigned_int_field,
+ validate_array_unsigned_int_field },
{ "arrfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
- { "arrfield3", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "arrfield3",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_array_unsigned_int_field,
+ validate_array_unsigned_int_field },
{ "seqfield1", FIELD_TYPE_PAYLOAD, true, true, validate_seqfield1, validate_seqfield1 },
{ "seqfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
- { "seqfield3", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
- { "seqfield4", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
- { "arrfield1[1]", FIELD_TYPE_ARRAY_FIELD, true, true, validate_array_unsigned_int_field_at_index, validate_array_unsigned_int_field_at_index },
+ { "seqfield3",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_array_unsigned_int_field,
+ validate_array_unsigned_int_field },
+ { "seqfield4",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_array_unsigned_int_field,
+ validate_array_unsigned_int_field },
+ { "arrfield1[1]",
+ FIELD_TYPE_ARRAY_FIELD,
+ true,
+ true,
+ validate_array_unsigned_int_field_at_index,
+ validate_array_unsigned_int_field_at_index },
{ "stringfield", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
- { "stringfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_escaped, validate_string_escaped },
+ { "stringfield2",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_string_escaped,
+ validate_string_escaped },
{ "floatfield", FIELD_TYPE_PAYLOAD, true, false, validate_floatfield, validate_floatfield },
- { "doublefield", FIELD_TYPE_PAYLOAD, true, false, validate_doublefield, validate_doublefield },
+ { "doublefield",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ false,
+ validate_doublefield,
+ validate_doublefield },
{ "enum0", FIELD_TYPE_PAYLOAD, true, true, validate_enum0, validate_enum0 },
- { "enumnegative", FIELD_TYPE_PAYLOAD, true, true, validate_enumnegative, validate_enumnegative },
- { "$ctx.procname", FIELD_TYPE_CONTEXT, true, true, validate_context_procname_ust, validate_context_procname_kernel },
+ { "enumnegative",
+ FIELD_TYPE_PAYLOAD,
+ true,
+ true,
+ validate_enumnegative,
+ validate_enumnegative },
+ { "$ctx.procname",
+ FIELD_TYPE_CONTEXT,
+ true,
+ true,
+ validate_context_procname_ust,
+ validate_context_procname_kernel },
};
-static const char *get_notification_trigger_name(
- struct lttng_notification *notification)
+static const char *get_notification_trigger_name(struct lttng_notification *notification)
{
const char *trigger_name = NULL;
enum lttng_trigger_status trigger_status;
return trigger_name;
}
-static int validator_notification_trigger_name(
- struct lttng_notification *notification,
- const char *trigger_name)
+static int validator_notification_trigger_name(struct lttng_notification *notification,
+ const char *trigger_name)
{
int ret;
bool name_is_equal;
}
name_is_equal = (strcmp(trigger_name, name) == 0);
- ok(name_is_equal, "Expected trigger name: %s got %s", trigger_name,
- name);
+ ok(name_is_equal, "Expected trigger name: %s got %s", trigger_name, name);
ret = !name_is_equal;
return ret;
}
-static
-void wait_on_file(const char *path, bool file_exist)
+static void wait_on_file(const char *path, bool file_exist)
{
if (!path) {
return;
}
}
-static
-int write_pipe(const char *path, uint8_t data)
+static int write_pipe(const char *path, uint8_t data)
{
int ret = 0;
int fd = 0;
goto end;
}
- ret = write(fd, &data , sizeof(data));
+ ret = write(fd, &data, sizeof(data));
if (ret < 1) {
perror("Named pipe write failed");
if (close(fd)) {
return ret;
}
-static
-int stop_consumer(const char **argv)
+static int stop_consumer(const char **argv)
{
int ret = 0, i;
return ret;
}
-static
-int resume_consumer(const char **argv)
+static int resume_consumer(const char **argv)
{
int ret = 0, i;
return ret;
}
-static
-int suspend_application(void)
+static int suspend_application(void)
{
int ret;
struct stat buf;
error:
return ret;
-
}
-static
-int resume_application(void)
+static int resume_application(void)
{
int ret;
struct stat buf;
error:
return ret;
-
}
-
-static
-void test_triggers_buffer_usage_condition(const char *session_name,
- const char *channel_name,
- enum lttng_condition_type condition_type)
+static void test_triggers_buffer_usage_condition(const char *session_name,
+ const char *channel_name,
+ enum lttng_condition_type condition_type)
{
unsigned int test_vector_size = 5, i;
enum lttng_condition_status condition_status;
}
/* Test lttng_register_trigger with null value */
- ok(lttng_register_trigger(NULL) == -LTTNG_ERR_INVALID, "Registering a NULL trigger fails as expected");
+ ok(lttng_register_trigger(NULL) == -LTTNG_ERR_INVALID,
+ "Registering a NULL trigger fails as expected");
/* Test: register a trigger */
- for (i = 0; i < pow(2,test_vector_size); i++) {
+ for (i = 0; i < pow(2, test_vector_size); i++) {
int loop_ret = 0;
char *test_tuple_string = NULL;
unsigned int mask_position = 0;
if (!condition) {
loop_ret = 1;
goto loop_end;
-
}
/* Prepare the condition for trigger registration test */
/* Set session name */
if ((1 << mask_position) & i) {
condition_status = lttng_condition_buffer_usage_set_session_name(
- condition, session_name);
+ condition, session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
loop_ret = 1;
goto loop_end;
/* Set channel name */
if ((1 << mask_position) & i) {
condition_status = lttng_condition_buffer_usage_set_channel_name(
- condition, channel_name);
+ condition, channel_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
loop_ret = 1;
goto loop_end;
/* Set threshold ratio */
if ((1 << mask_position) & i) {
- condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
- condition, 0.0);
+ condition_status =
+ lttng_condition_buffer_usage_set_threshold_ratio(condition, 0.0);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
loop_ret = 1;
goto loop_end;
/* Set threshold byte */
if ((1 << mask_position) & i) {
- condition_status = lttng_condition_buffer_usage_set_threshold(
- condition, 0);
+ condition_status = lttng_condition_buffer_usage_set_threshold(condition, 0);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
loop_ret = 1;
goto loop_end;
/* Set domain type */
if ((1 << mask_position) & i) {
condition_status = lttng_condition_buffer_usage_set_domain_type(
- condition, LTTNG_DOMAIN_UST);
+ condition, LTTNG_DOMAIN_UST);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
loop_ret = 1;
goto loop_end;
}
/* Safety check */
- if (mask_position != test_vector_size -1) {
+ if (mask_position != test_vector_size - 1) {
LTTNG_ASSERT("Logic error for test vector generation");
}
- loop_ret = asprintf(&test_tuple_string, "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
- session_name_set ? "set" : "unset",
- channel_name_set ? "set" : "unset",
- threshold_ratio_set ? "set" : "unset",
- threshold_byte_set ? "set" : "unset",
- domain_type_set? "set" : "unset");
+ loop_ret = asprintf(
+ &test_tuple_string,
+ "session name %s, channel name %s, threshold ratio %s, threshold byte %s, domain type %s",
+ session_name_set ? "set" : "unset",
+ channel_name_set ? "set" : "unset",
+ threshold_ratio_set ? "set" : "unset",
+ threshold_byte_set ? "set" : "unset",
+ domain_type_set ? "set" : "unset");
if (!test_tuple_string || loop_ret < 0) {
loop_ret = 1;
goto loop_end;
loop_ret = lttng_register_trigger(trigger);
-loop_end:
+ loop_end:
if (loop_ret == 1) {
fail("Setup error occurred for tuple: %s", test_tuple_string);
goto loop_cleanup;
}
/* This combination happens three times */
- if (session_name_set && channel_name_set
- && (threshold_ratio_set || threshold_byte_set)
- && domain_type_set) {
+ if (session_name_set && channel_name_set &&
+ (threshold_ratio_set || threshold_byte_set) && domain_type_set) {
ok(loop_ret == 0, "Trigger is registered: %s", test_tuple_string);
/*
* multiple time.
*/
loop_ret = lttng_register_trigger(trigger);
- ok(loop_ret == -LTTNG_ERR_TRIGGER_EXISTS, "Re-register trigger fails as expected: %s", test_tuple_string);
+ ok(loop_ret == -LTTNG_ERR_TRIGGER_EXISTS,
+ "Re-register trigger fails as expected: %s",
+ test_tuple_string);
/* Test that a trigger can be unregistered */
loop_ret = lttng_unregister_trigger(trigger);
* registered trigger fail.
*/
loop_ret = lttng_unregister_trigger(trigger);
- ok(loop_ret == -LTTNG_ERR_TRIGGER_NOT_FOUND, "Unregister of a non-registered trigger fails as expected: %s", test_tuple_string);
+ ok(loop_ret == -LTTNG_ERR_TRIGGER_NOT_FOUND,
+ "Unregister of a non-registered trigger fails as expected: %s",
+ test_tuple_string);
} else {
- ok(loop_ret == -LTTNG_ERR_INVALID_TRIGGER, "Trigger is invalid as expected and cannot be registered: %s", test_tuple_string);
+ ok(loop_ret == -LTTNG_ERR_INVALID_TRIGGER,
+ "Trigger is invalid as expected and cannot be registered: %s",
+ test_tuple_string);
}
-loop_cleanup:
+ loop_cleanup:
free(test_tuple_string);
lttng_trigger_destroy(trigger);
lttng_condition_destroy(condition);
lttng_action_destroy(action);
}
-static
-void wait_data_pending(const char *session_name)
+static void wait_data_pending(const char *session_name)
{
int ret;
} while (ret != 0);
}
-static
-int setup_buffer_usage_condition(struct lttng_condition *condition,
- const char *condition_name,
- const char *session_name,
- const char *channel_name,
- const enum lttng_domain_type domain_type)
+static int setup_buffer_usage_condition(struct lttng_condition *condition,
+ const char *condition_name,
+ const char *session_name,
+ const char *channel_name,
+ const enum lttng_domain_type domain_type)
{
enum lttng_condition_status condition_status;
int ret = 0;
- condition_status = lttng_condition_buffer_usage_set_session_name(
- condition, session_name);
+ condition_status = lttng_condition_buffer_usage_set_session_name(condition, session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
- fail("Failed to set session name on creation of condition `%s`",
- condition_name);
+ fail("Failed to set session name on creation of condition `%s`", condition_name);
ret = -1;
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_channel_name(
- condition, channel_name);
+ condition_status = lttng_condition_buffer_usage_set_channel_name(condition, channel_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
- fail("Failed to set channel name on creation of condition `%s`",
- condition_name);
+ fail("Failed to set channel name on creation of condition `%s`", condition_name);
ret = -1;
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_domain_type(
- condition, domain_type);
+ condition_status = lttng_condition_buffer_usage_set_domain_type(condition, domain_type);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
- fail("Failed to set domain type on creation of condition `%s`",
- condition_name);
+ fail("Failed to set domain type on creation of condition `%s`", condition_name);
ret = -1;
goto end;
}
return ret;
}
-static
-void test_invalid_channel_subscription(
- const enum lttng_domain_type domain_type)
+static void test_invalid_channel_subscription(const enum lttng_domain_type domain_type)
{
enum lttng_condition_status condition_status;
enum lttng_notification_channel_status nc_status;
struct lttng_notification_channel *notification_channel = NULL;
int ret = 0;
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
if (!notification_channel) {
goto end;
* Test subscription and unsubscription of an invalid condition to/from
* a channel.
*/
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, dummy_invalid_condition);
+ nc_status =
+ lttng_notification_channel_subscribe(notification_channel, dummy_invalid_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
- "Subscribing to an invalid condition");
+ "Subscribing to an invalid condition");
- nc_status = lttng_notification_channel_unsubscribe(
- notification_channel, dummy_invalid_condition);
+ nc_status = lttng_notification_channel_unsubscribe(notification_channel,
+ dummy_invalid_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
- "Unsubscribing from an invalid condition");
+ "Unsubscribing from an invalid condition");
/* Create a valid dummy condition with a ratio of 0.5 */
dummy_condition = lttng_condition_buffer_usage_low_create();
goto end;
}
- condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
- dummy_condition, 0.5);
+ condition_status = lttng_condition_buffer_usage_set_threshold_ratio(dummy_condition, 0.5);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
fail("Setup error on condition creation");
goto end;
}
- ret = setup_buffer_usage_condition(dummy_condition, "dummy_condition",
- "dummy_session", "dummy_channel", domain_type);
+ ret = setup_buffer_usage_condition(
+ dummy_condition, "dummy_condition", "dummy_session", "dummy_channel", domain_type);
if (ret) {
fail("Setup error on dummy condition creation");
goto end;
*/
nc_status = lttng_notification_channel_subscribe(NULL, NULL);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
- "Notification channel subscription is invalid: NULL, NULL");
+ "Notification channel subscription is invalid: NULL, NULL");
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, NULL);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, NULL);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
- "Notification channel subscription is invalid: NON-NULL, NULL");
+ "Notification channel subscription is invalid: NON-NULL, NULL");
nc_status = lttng_notification_channel_subscribe(NULL, dummy_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INVALID,
- "Notification channel subscription is invalid: NULL, NON-NULL");
+ "Notification channel subscription is invalid: NULL, NON-NULL");
- nc_status = lttng_notification_channel_unsubscribe(
- notification_channel, dummy_condition);
+ nc_status = lttng_notification_channel_unsubscribe(notification_channel, dummy_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_UNKNOWN_CONDITION,
- "Unsubscribing from a valid unknown condition");
+ "Unsubscribing from a valid unknown condition");
end:
lttng_notification_channel_destroy(notification_channel);
};
static int register_buffer_usage_notify_trigger(const char *session_name,
- const char *channel_name,
- const enum lttng_domain_type domain_type,
- enum buffer_usage_type buffer_usage_type,
- double ratio,
- struct lttng_condition **condition,
- struct lttng_action **action,
- struct lttng_trigger **trigger)
+ const char *channel_name,
+ const enum lttng_domain_type domain_type,
+ enum buffer_usage_type buffer_usage_type,
+ double ratio,
+ struct lttng_condition **condition,
+ struct lttng_action **action,
+ struct lttng_trigger **trigger)
{
enum lttng_condition_status condition_status;
struct lttng_action *tmp_action = NULL;
}
/* Set the buffer usage threashold */
- condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
- tmp_condition, ratio);
+ condition_status = lttng_condition_buffer_usage_set_threshold_ratio(tmp_condition, ratio);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
fail("Setup error on condition creation");
ret = -1;
goto error;
}
- ret = setup_buffer_usage_condition(tmp_condition, "condition_name",
- session_name, channel_name, domain_type);
+ ret = setup_buffer_usage_condition(
+ tmp_condition, "condition_name", session_name, channel_name, domain_type);
if (ret) {
fail("Setup error on condition creation");
ret = -1;
}
static void test_subscription_twice(const char *session_name,
- const char *channel_name,
- const enum lttng_domain_type domain_type)
+ const char *channel_name,
+ const enum lttng_domain_type domain_type)
{
int ret = 0;
enum lttng_notification_channel_status nc_status;
struct lttng_condition *condition = NULL;
- ret = register_buffer_usage_notify_trigger(session_name, channel_name,
- domain_type, BUFFER_USAGE_TYPE_LOW, 0.99, &condition,
- &action, &trigger);
+ ret = register_buffer_usage_notify_trigger(session_name,
+ channel_name,
+ domain_type,
+ BUFFER_USAGE_TYPE_LOW,
+ 0.99,
+ &condition,
+ &action,
+ &trigger);
if (ret) {
- fail("Setup error on trigger registration in %s()",
- __FUNCTION__);
+ fail("Setup error on trigger registration in %s()", __FUNCTION__);
goto end;
}
/* Begin testing. */
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
if (!notification_channel) {
goto end;
}
/* Subscribe a valid condition. */
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
- ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to condition");
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
+ ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to condition");
/* Subscribing again should fail. */
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_ALREADY_SUBSCRIBED,
- "Subscribe to a condition for which subscription was already done");
+ "Subscribe to a condition for which subscription was already done");
end:
ret = lttng_unregister_trigger(trigger);
}
static void test_buffer_usage_notification_channel(const char *session_name,
- const char *channel_name,
- const enum lttng_domain_type domain_type,
- const char **argv)
+ const char *channel_name,
+ const enum lttng_domain_type domain_type,
+ const char **argv)
{
int ret = 0;
enum lttng_notification_channel_status nc_status;
const double low_ratio = 0.0;
const double high_ratio = 0.90;
- ret = register_buffer_usage_notify_trigger(session_name, channel_name,
- domain_type, BUFFER_USAGE_TYPE_LOW, low_ratio,
- &low_condition, &low_action, &low_trigger);
+ ret = register_buffer_usage_notify_trigger(session_name,
+ channel_name,
+ domain_type,
+ BUFFER_USAGE_TYPE_LOW,
+ low_ratio,
+ &low_condition,
+ &low_action,
+ &low_trigger);
if (ret) {
fail("Setup error on low trigger registration");
goto end;
}
- ret = register_buffer_usage_notify_trigger(session_name, channel_name,
- domain_type, BUFFER_USAGE_TYPE_HIGH, high_ratio,
- &high_condition, &high_action, &high_trigger);
+ ret = register_buffer_usage_notify_trigger(session_name,
+ channel_name,
+ domain_type,
+ BUFFER_USAGE_TYPE_HIGH,
+ high_ratio,
+ &high_condition,
+ &high_action,
+ &high_trigger);
if (ret) {
fail("Setup error on high trigger registration");
goto end;
}
/* Begin testing */
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
if (!notification_channel) {
goto end;
}
/* Subscribe a valid low condition */
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, low_condition);
- ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to low condition");
+ nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
+ ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to low condition");
/* Subscribe a valid high condition */
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, high_condition);
- ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to high condition");
+ nc_status = lttng_notification_channel_subscribe(notification_channel, high_condition);
+ ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK, "Subscribe to high condition");
resume_application();
/* Wait for high notification */
do {
- nc_status = lttng_notification_channel_get_next_notification(
- notification_channel, ¬ification);
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
} while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
- lttng_condition_get_type(lttng_notification_get_condition(
- notification)) ==
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
- "High notification received after intermediary communication");
+ lttng_condition_get_type(lttng_notification_get_condition(notification)) ==
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
+ "High notification received after intermediary communication");
lttng_notification_destroy(notification);
notification = NULL;
* waiting for consumption.
*/
- nc_status = lttng_notification_channel_unsubscribe(
- notification_channel, low_condition);
+ nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Unsubscribe with pending notification");
+ "Unsubscribe with pending notification");
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, low_condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, low_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe with pending notification");
+ "Subscribe with pending notification");
do {
- nc_status = lttng_notification_channel_get_next_notification(
- notification_channel, ¬ification);
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
} while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
- lttng_condition_get_type(lttng_notification_get_condition(
- notification)) ==
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
- "Low notification received after intermediary communication");
+ lttng_condition_get_type(lttng_notification_get_condition(notification)) ==
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
+ "Low notification received after intermediary communication");
lttng_notification_destroy(notification);
notification = NULL;
lttng_start_tracing(session_name);
do {
- nc_status = lttng_notification_channel_get_next_notification(
- notification_channel, ¬ification);
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
} while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
- lttng_condition_get_type(lttng_notification_get_condition(
- notification)) ==
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
- "High notification received after intermediary communication");
+ lttng_condition_get_type(lttng_notification_get_condition(notification)) ==
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
+ "High notification received after intermediary communication");
lttng_notification_destroy(notification);
notification = NULL;
wait_data_pending(session_name);
do {
- nc_status = lttng_notification_channel_get_next_notification(
- notification_channel, ¬ification);
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
} while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
- lttng_condition_get_type(lttng_notification_get_condition(
- notification)) ==
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
- "Low notification received after re-subscription");
+ lttng_condition_get_type(lttng_notification_get_condition(notification)) ==
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
+ "Low notification received after re-subscription");
lttng_notification_destroy(notification);
notification = NULL;
lttng_start_tracing(session_name);
do {
- nc_status = lttng_notification_channel_get_next_notification(
- notification_channel, ¬ification);
+ nc_status = lttng_notification_channel_get_next_notification(notification_channel,
+ ¬ification);
} while (nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_INTERRUPTED);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK && notification &&
- lttng_condition_get_type(lttng_notification_get_condition(
- notification)) ==
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
- "High notification");
+ lttng_condition_get_type(lttng_notification_get_condition(notification)) ==
+ LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
+ "High notification");
lttng_notification_destroy(notification);
notification = NULL;
resume_consumer(argv);
wait_data_pending(session_name);
- nc_status = lttng_notification_channel_unsubscribe(
- notification_channel, low_condition);
+ nc_status = lttng_notification_channel_unsubscribe(notification_channel, low_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Unsubscribe low condition with pending notification");
+ "Unsubscribe low condition with pending notification");
- nc_status = lttng_notification_channel_unsubscribe(
- notification_channel, high_condition);
+ nc_status = lttng_notification_channel_unsubscribe(notification_channel, high_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Unsubscribe high condition with pending notification");
+ "Unsubscribe high condition with pending notification");
end:
lttng_notification_channel_destroy(notification_channel);
}
static void create_tracepoint_event_rule_trigger(const char *event_pattern,
- const char *trigger_name,
- const char *filter,
- unsigned int exclusion_count,
- const char * const *exclusions,
- enum lttng_domain_type domain_type,
- condition_capture_desc_cb capture_desc_cb,
- struct lttng_condition **condition,
- struct lttng_trigger **trigger)
+ const char *trigger_name,
+ const char *filter,
+ unsigned int exclusion_count,
+ const char *const *exclusions,
+ enum lttng_domain_type domain_type,
+ condition_capture_desc_cb capture_desc_cb,
+ struct lttng_condition **condition,
+ struct lttng_trigger **trigger)
{
typedef struct lttng_event_rule *(*event_rule_create)(void);
typedef enum lttng_event_rule_status (
- *event_rule_set_name_pattern)(
- struct lttng_event_rule *rule,
- const char *pattern);
- typedef enum lttng_event_rule_status (*event_rule_set_filter)(
- struct lttng_event_rule *rule,
- const char *expression);
+ *event_rule_set_name_pattern)(struct lttng_event_rule * rule, const char *pattern);
typedef enum lttng_event_rule_status (
- *event_rule_add_name_pattern_exclusion)(
- struct lttng_event_rule * rule, const char *exclusion);
+ *event_rule_set_filter)(struct lttng_event_rule * rule, const char *expression);
+ typedef enum lttng_event_rule_status (*event_rule_add_name_pattern_exclusion)(
+ struct lttng_event_rule * rule, const char *exclusion);
enum lttng_event_rule_status event_rule_status;
struct lttng_action *tmp_action = NULL;
create = lttng_event_rule_user_tracepoint_create;
set_name_pattern = lttng_event_rule_user_tracepoint_set_name_pattern;
set_filter = lttng_event_rule_user_tracepoint_set_filter;
- add_name_pattern_exclusion = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion;
+ add_name_pattern_exclusion =
+ lttng_event_rule_user_tracepoint_add_name_pattern_exclusion;
break;
case LTTNG_DOMAIN_KERNEL:
create = lttng_event_rule_kernel_tracepoint_create;
event_rule_status = set_name_pattern(event_rule, event_pattern);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting tracepoint event rule pattern: '%s'",
- event_pattern);
+ "Setting tracepoint event rule pattern: '%s'",
+ event_pattern);
if (filter) {
event_rule_status = set_filter(event_rule, filter);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting tracepoint event rule filter: '%s'",
- filter);
+ "Setting tracepoint event rule filter: '%s'",
+ filter);
}
if (exclusions) {
LTTNG_ASSERT(exclusion_count > 0);
for (i = 0; i < exclusion_count; i++) {
- event_rule_status = add_name_pattern_exclusion(
- event_rule, exclusions[i]);
+ event_rule_status = add_name_pattern_exclusion(event_rule, exclusions[i]);
if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) {
fail("Setting tracepoint event rule exclusion '%s'.",
- exclusions[i]);
+ exclusions[i]);
success = false;
}
}
return;
}
-static struct lttng_notification *get_next_notification(
- struct lttng_notification_channel *notification_channel)
+static struct lttng_notification *
+get_next_notification(struct lttng_notification_channel *notification_channel)
{
struct lttng_notification *local_notification = NULL;
enum lttng_notification_channel_status status;
/* Receive the next notification. */
- status = lttng_notification_channel_get_next_notification(
- notification_channel, &local_notification);
+ status = lttng_notification_channel_get_next_notification(notification_channel,
+ &local_notification);
switch (status) {
case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK:
default:
/* Unhandled conditions / errors. */
fail("Failed to get next notification (unknown notification channel status): status = %d",
- (int) status);
+ (int) status);
local_notification = NULL;
break;
}
return local_notification;
}
-static void test_tracepoint_event_rule_notification(
- enum lttng_domain_type domain_type)
+static void test_tracepoint_event_rule_notification(enum lttng_domain_type domain_type)
{
int i;
int ret;
struct lttng_condition *condition = NULL;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_trigger *trigger = NULL;
- const char * const trigger_name = "my_precious";
+ const char *const trigger_name = "my_precious";
const char *pattern;
if (domain_type == LTTNG_DOMAIN_UST) {
pattern = "lttng_test_filter_event";
}
- create_tracepoint_event_rule_trigger(pattern, trigger_name, NULL, 0,
- NULL, domain_type, NULL, &condition, &trigger);
+ create_tracepoint_event_rule_trigger(
+ pattern, trigger_name, NULL, 0, NULL, domain_type, NULL, &condition, &trigger);
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
/* Get notifications. */
for (i = 0; i < notification_count; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
return;
}
-static void test_tracepoint_event_rule_notification_filter(
- enum lttng_domain_type domain_type)
+static void test_tracepoint_event_rule_notification_filter(enum lttng_domain_type domain_type)
{
int i;
const int notification_count = 3;
struct lttng_condition *ctrl_condition = NULL, *condition = NULL;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_trigger *ctrl_trigger = NULL, *trigger = NULL;
- const char * const ctrl_trigger_name = "control_trigger";
- const char * const trigger_name = "trigger";
+ const char *const ctrl_trigger_name = "control_trigger";
+ const char *const trigger_name = "trigger";
const char *pattern;
int ctrl_count = 0, count = 0;
pattern = "lttng_test_filter_event";
}
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- create_tracepoint_event_rule_trigger(pattern, ctrl_trigger_name, NULL,
- 0, NULL, domain_type, NULL, &ctrl_condition, &ctrl_trigger);
-
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, ctrl_condition);
+ create_tracepoint_event_rule_trigger(pattern,
+ ctrl_trigger_name,
+ NULL,
+ 0,
+ NULL,
+ domain_type,
+ NULL,
+ &ctrl_condition,
+ &ctrl_trigger);
+
+ nc_status = lttng_notification_channel_subscribe(notification_channel, ctrl_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
/*
* Attach a filter expression to get notification only if the
* `intfield` is even.
*/
- create_tracepoint_event_rule_trigger(pattern, trigger_name,
- "(intfield & 1) == 0", 0, NULL, domain_type, NULL, &condition,
- &trigger);
-
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ create_tracepoint_event_rule_trigger(pattern,
+ trigger_name,
+ "(intfield & 1) == 0",
+ 0,
+ NULL,
+ domain_type,
+ NULL,
+ &condition,
+ &trigger);
+
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
/*
* We registered 2 notifications triggers, one with a filter and one
*/
for (i = 0; i < notification_count; i++) {
const char *name;
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
lttng_notification_destroy(notification);
}
- ok(ctrl_count / 2 == count,
- "Get twice as many control notif as of regular notif");
+ ok(ctrl_count / 2 == count, "Get twice as many control notif as of regular notif");
end:
suspend_application();
lttng_condition_destroy(ctrl_condition);
}
-static void test_tracepoint_event_rule_notification_exclusion(
- enum lttng_domain_type domain_type)
+static void test_tracepoint_event_rule_notification_exclusion(enum lttng_domain_type domain_type)
{
enum lttng_notification_channel_status nc_status;
struct lttng_condition *ctrl_condition = NULL, *condition = NULL;
struct lttng_trigger *ctrl_trigger = NULL, *trigger = NULL;
int ctrl_count = 0, count = 0, i;
const int notification_count = 6;
- const char * const ctrl_trigger_name = "control_exclusion_trigger";
- const char * const trigger_name = "exclusion_trigger";
- const char * const pattern = "tp:tptest*";
- const char * const exclusions[] = {
- "tp:tptest2",
- "tp:tptest3",
- "tp:tptest4",
- "tp:tptest5"
- };
-
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
- ok(notification_channel, "Notification channel object creation");
+ const char *const ctrl_trigger_name = "control_exclusion_trigger";
+ const char *const trigger_name = "exclusion_trigger";
+ const char *const pattern = "tp:tptest*";
+ const char *const exclusions[] = { "tp:tptest2", "tp:tptest3", "tp:tptest4", "tp:tptest5" };
- create_tracepoint_event_rule_trigger(pattern, ctrl_trigger_name, NULL,
- 0, NULL, domain_type, NULL, &ctrl_condition,
- &ctrl_trigger);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
+ ok(notification_channel, "Notification channel object creation");
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, ctrl_condition);
+ create_tracepoint_event_rule_trigger(pattern,
+ ctrl_trigger_name,
+ NULL,
+ 0,
+ NULL,
+ domain_type,
+ NULL,
+ &ctrl_condition,
+ &ctrl_trigger);
+
+ nc_status = lttng_notification_channel_subscribe(notification_channel, ctrl_condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
- create_tracepoint_event_rule_trigger(pattern, trigger_name, NULL, 4,
- exclusions, domain_type, NULL, &condition,
- &trigger);
+ create_tracepoint_event_rule_trigger(
+ pattern, trigger_name, NULL, 4, exclusions, domain_type, NULL, &condition, &trigger);
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
/*
* We registered 2 notifications triggers, one with an exclusion and
*/
for (i = 0; i < notification_count; i++) {
const char *name;
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
lttng_notification_destroy(notification);
}
- ok(ctrl_count / 5 == count,
- "Got 5 times as many control notif as of regular notif");
+ ok(ctrl_count / 5 == count, "Got 5 times as many control notif as of regular notif");
end:
suspend_application();
struct lttng_event_rule *event_rule = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
- const char * const trigger_name = "kprobe_trigger";
- const char * const symbol_name = "lttng_test_filter_event_write";
+ const char *const trigger_name = "kprobe_trigger";
+ const char *const symbol_name = "lttng_test_filter_event_write";
action = lttng_action_notify_create();
if (!action) {
goto end;
}
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
event_rule = lttng_event_rule_kernel_kprobe_create(location);
ok(event_rule, "kprobe event rule object creation");
- event_rule_status = lttng_event_rule_kernel_kprobe_set_event_name(
- event_rule, trigger_name);
+ event_rule_status = lttng_event_rule_kernel_kprobe_set_event_name(event_rule, trigger_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting kprobe event rule name: '%s'", trigger_name);
+ "Setting kprobe event rule name: '%s'",
+ trigger_name);
condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
goto end;
}
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
for (i = 0; i < notification_count; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
return;
}
-static void test_uprobe_event_rule_notification(
- const char *testapp_path,
- const char *test_symbol_name)
+static void test_uprobe_event_rule_notification(const char *testapp_path,
+ const char *test_symbol_name)
{
int i, ret;
enum lttng_error_code ret_code;
enum lttng_event_rule_status event_rule_status;
struct lttng_notification_channel *notification_channel = NULL;
struct lttng_userspace_probe_location *probe_location = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method =
- NULL;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
struct lttng_condition *condition = NULL;
struct lttng_event_rule *event_rule = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
- const char * const trigger_name = "uprobe_trigger";
+ const char *const trigger_name = "uprobe_trigger";
action = lttng_action_notify_create();
if (!action) {
}
probe_location = lttng_userspace_probe_location_function_create(
- testapp_path, test_symbol_name, lookup_method);
+ testapp_path, test_symbol_name, lookup_method);
if (!probe_location) {
fail("Failed to create userspace probe location");
goto end;
}
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
event_rule = lttng_event_rule_kernel_uprobe_create(probe_location);
ok(event_rule, "uprobe event rule object creation");
- event_rule_status = lttng_event_rule_kernel_uprobe_set_event_name(
- event_rule, trigger_name);
+ event_rule_status = lttng_event_rule_kernel_uprobe_set_event_name(event_rule, trigger_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting uprobe event rule name: '%s'", trigger_name);
+ "Setting uprobe event rule name: '%s'",
+ trigger_name);
condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
goto end;
}
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
for (i = 0; i < 3; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
struct lttng_event_rule *event_rule = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
- const char * const trigger_name = "syscall_trigger";
- const char * const syscall_name = "openat";
+ const char *const trigger_name = "syscall_trigger";
+ const char *const syscall_name = "openat";
action = lttng_action_notify_create();
if (!action) {
goto end;
}
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_kernel_syscall_create(LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
+ event_rule = lttng_event_rule_kernel_syscall_create(
+ LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
ok(event_rule, "syscall event rule object creation");
- event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(
- event_rule, syscall_name);
+ event_rule_status =
+ lttng_event_rule_kernel_syscall_set_name_pattern(event_rule, syscall_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting syscall event rule pattern: '%s'", syscall_name);
+ "Setting syscall event rule pattern: '%s'",
+ syscall_name);
condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition syscall event rule object creation");
goto end;
}
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
for (i = 0; i < notification_count; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
struct lttng_event_rule *event_rule = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
- const char * const trigger_name = "syscall_trigger";
- const char * const syscall_name = "openat";
- const char * const filter_pattern = "filename == \"/proc/cpuinfo\"";
+ const char *const trigger_name = "syscall_trigger";
+ const char *const syscall_name = "openat";
+ const char *const filter_pattern = "filename == \"/proc/cpuinfo\"";
action = lttng_action_notify_create();
if (!action) {
goto end;
}
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- event_rule = lttng_event_rule_kernel_syscall_create(LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
+ event_rule = lttng_event_rule_kernel_syscall_create(
+ LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
ok(event_rule, "syscall event rule object creation");
- event_rule_status = lttng_event_rule_kernel_syscall_set_name_pattern(
- event_rule, syscall_name);
+ event_rule_status =
+ lttng_event_rule_kernel_syscall_set_name_pattern(event_rule, syscall_name);
ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting syscall event rule pattern: '%s'", syscall_name);
+ "Setting syscall event rule pattern: '%s'",
+ syscall_name);
- event_rule_status = lttng_event_rule_kernel_syscall_set_filter(
- event_rule, filter_pattern);
- ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting filter: '%s'", filter_pattern);
+ event_rule_status = lttng_event_rule_kernel_syscall_set_filter(event_rule, filter_pattern);
+ ok(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK, "Setting filter: '%s'", filter_pattern);
condition = lttng_condition_event_rule_matches_create(event_rule);
ok(condition, "Condition event rule object creation");
goto end;
}
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
for (i = 0; i < notification_count; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
- ok(notification, "Received notification (%d/%d)", i + 1,
- notification_count);
+ ok(notification, "Received notification (%d/%d)", i + 1, notification_count);
/* Error. */
if (notification == NULL) {
{
int ret, i;
struct lttng_event_expr *expr = NULL;
- const unsigned int basic_field_count = sizeof(test_capture_base_fields) /
- sizeof(*test_capture_base_fields);
+ const unsigned int basic_field_count =
+ sizeof(test_capture_base_fields) / sizeof(*test_capture_base_fields);
enum lttng_condition_status cond_status;
for (i = 0; i < basic_field_count; i++) {
- diag("Adding capture descriptor '%s'",
- test_capture_base_fields[i].field_name);
+ diag("Adding capture descriptor '%s'", test_capture_base_fields[i].field_name);
switch (test_capture_base_fields[i].field_type) {
case FIELD_TYPE_PAYLOAD:
expr = lttng_event_expr_event_payload_field_create(
- test_capture_base_fields[i].field_name);
+ test_capture_base_fields[i].field_name);
break;
case FIELD_TYPE_CONTEXT:
expr = lttng_event_expr_channel_context_field_create(
- test_capture_base_fields[i].field_name);
+ test_capture_base_fields[i].field_name);
break;
case FIELD_TYPE_ARRAY_FIELD:
{
struct lttng_event_expr *array_expr = NULL;
nb_matches = sscanf(test_capture_base_fields[i].field_name,
- "%[^[][%u]", field_name, &index);
+ "%[^[][%u]",
+ field_name,
+ &index);
if (nb_matches != 2) {
fail("Unexpected array field name format: field name = '%s'",
- test_capture_base_fields[i].field_name);
+ test_capture_base_fields[i].field_name);
ret = 1;
goto end;
}
- array_expr = lttng_event_expr_event_payload_field_create(
- field_name);
+ array_expr = lttng_event_expr_event_payload_field_create(field_name);
- expr = lttng_event_expr_array_field_element_create(
- array_expr, index);
+ expr = lttng_event_expr_array_field_element_create(array_expr, index);
break;
}
case FIELD_TYPE_APP_CONTEXT:
}
cond_status = lttng_condition_event_rule_matches_append_capture_descriptor(
- condition, expr);
+ condition, expr);
if (cond_status != LTTNG_CONDITION_STATUS_OK) {
fail("Failed to append capture descriptor");
ret = -1;
return ret;
}
-static int validator_notification_trigger_capture(
- enum lttng_domain_type domain,
- struct lttng_notification *notification,
- const int iteration)
+static int validator_notification_trigger_capture(enum lttng_domain_type domain,
+ struct lttng_notification *notification,
+ const int iteration)
{
int ret;
unsigned int capture_count, i;
- enum lttng_evaluation_event_rule_matches_status
- event_rule_matches_evaluation_status;
+ enum lttng_evaluation_event_rule_matches_status event_rule_matches_evaluation_status;
enum lttng_event_field_value_status event_field_value_status;
const struct lttng_evaluation *evaluation;
const struct lttng_event_field_value *captured_fields;
}
event_rule_matches_evaluation_status =
- lttng_evaluation_event_rule_matches_get_captured_values(
- evaluation, &captured_fields);
- if (event_rule_matches_evaluation_status !=
- LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK) {
+ lttng_evaluation_event_rule_matches_get_captured_values(evaluation,
+ &captured_fields);
+ if (event_rule_matches_evaluation_status != LTTNG_EVALUATION_EVENT_RULE_MATCHES_STATUS_OK) {
diag("Failed to get event rule evaluation captured values: status = %d",
- (int) event_rule_matches_evaluation_status);
+ (int) event_rule_matches_evaluation_status);
ret = 1;
goto end;
}
event_field_value_status =
- lttng_event_field_value_array_get_length(captured_fields,
- &capture_count);
+ lttng_event_field_value_array_get_length(captured_fields, &capture_count);
if (event_field_value_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
fail("Failed to get count of captured value field array");
ret = 1;
validate_cb validate;
bool expected;
- diag("Validating capture of field '%s'",
- test_capture_base_fields[i].field_name);
- event_field_value_status =
- lttng_event_field_value_array_get_element_at_index(
- captured_fields, i,
- &captured_field);
+ diag("Validating capture of field '%s'", test_capture_base_fields[i].field_name);
+ event_field_value_status = lttng_event_field_value_array_get_element_at_index(
+ captured_fields, i, &captured_field);
- switch(domain) {
+ switch (domain) {
case LTTNG_DOMAIN_UST:
expected = test_capture_base_fields[i].expected_ust;
break;
expected = test_capture_base_fields[i].expected_kernel;
break;
default:
- fail("Unexpected domain encountered: domain = %d",
- (int) domain);
+ fail("Unexpected domain encountered: domain = %d", (int) domain);
ret = 1;
goto end;
}
if (!expected) {
ok(event_field_value_status == LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE,
- "No payload captured");
+ "No payload captured");
continue;
}
if (event_field_value_status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
if (event_field_value_status ==
- LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE) {
+ LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE) {
fail("Expected a capture but it is unavailable");
} else {
fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
- (int) event_field_value_status);
+ (int) event_field_value_status);
}
ret = 1;
}
diag("Captured field of type %s",
- field_value_type_to_str(
- lttng_event_field_value_get_type(captured_field)));
+ field_value_type_to_str(lttng_event_field_value_get_type(captured_field)));
LTTNG_ASSERT(validate);
ret = validate(captured_field, iteration);
return ret;
}
-static void test_tracepoint_event_rule_notification_capture(
- enum lttng_domain_type domain_type)
+static void test_tracepoint_event_rule_notification_capture(enum lttng_domain_type domain_type)
{
enum lttng_notification_channel_status nc_status;
pattern = "lttng_test_filter_event";
}
- create_tracepoint_event_rule_trigger(pattern, trigger_name, NULL, 0,
- NULL, domain_type, generate_capture_descr, &condition,
- &trigger);
+ create_tracepoint_event_rule_trigger(pattern,
+ trigger_name,
+ NULL,
+ 0,
+ NULL,
+ domain_type,
+ generate_capture_descr,
+ &condition,
+ &trigger);
- notification_channel = lttng_notification_channel_create(
- lttng_session_daemon_notification_endpoint);
+ notification_channel =
+ lttng_notification_channel_create(lttng_session_daemon_notification_endpoint);
ok(notification_channel, "Notification channel object creation");
- nc_status = lttng_notification_channel_subscribe(
- notification_channel, condition);
+ nc_status = lttng_notification_channel_subscribe(notification_channel, condition);
ok(nc_status == LTTNG_NOTIFICATION_CHANNEL_STATUS_OK,
- "Subscribe to tracepoint event rule condition");
+ "Subscribe to tracepoint event rule condition");
resume_application();
/* Get 3 notifications */
for (i = 0; i < 3; i++) {
- struct lttng_notification *notification = get_next_notification(
- notification_channel);
+ struct lttng_notification *notification =
+ get_next_notification(notification_channel);
ok(notification, "Received notification");
/* Error */
plan_tests(41);
/* Test cases that need gen-ust-event testapp. */
- diag("Test basic notification error paths for %s domain",
- domain_type_string);
+ diag("Test basic notification error paths for %s domain", domain_type_string);
test_invalid_channel_subscription(domain_type);
- diag("Test tracepoint event rule notifications for domain %s",
- domain_type_string);
+ diag("Test tracepoint event rule notifications for domain %s", domain_type_string);
test_tracepoint_event_rule_notification(domain_type);
diag("Test tracepoint event rule notifications with filter for domain %s",
- domain_type_string);
+ domain_type_string);
test_tracepoint_event_rule_notification_filter(domain_type);
break;
}
session_name = argv[5];
channel_name = argv[6];
- test_subscription_twice(session_name, channel_name,
- domain_type);
+ test_subscription_twice(session_name, channel_name, domain_type);
diag("Test trigger for domain %s with buffer_usage_low condition",
- domain_type_string);
- test_triggers_buffer_usage_condition(session_name, channel_name,
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
+ domain_type_string);
+ test_triggers_buffer_usage_condition(
+ session_name, channel_name, LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW);
diag("Test trigger for domain %s with buffer_usage_high condition",
- domain_type_string);
- test_triggers_buffer_usage_condition(session_name, channel_name,
- LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
+ domain_type_string);
+ test_triggers_buffer_usage_condition(
+ session_name, channel_name, LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH);
diag("Test buffer usage notification channel api for domain %s",
- domain_type_string);
- test_buffer_usage_notification_channel(session_name, channel_name,
- domain_type, argv);
+ domain_type_string);
+ test_buffer_usage_notification_channel(
+ session_name, channel_name, domain_type, argv);
break;
}
case 3:
*/
LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_UST);
diag("Test tracepoint event rule notifications with exclusion for domain %s",
- domain_type_string);
+ domain_type_string);
test_tracepoint_event_rule_notification_exclusion(domain_type);
break;
/* Test cases that need the kernel tracer. */
LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
- diag("Test kprobe event rule notifications for domain %s",
- domain_type_string);
+ diag("Test kprobe event rule notifications for domain %s", domain_type_string);
test_kprobe_event_rule_notification();
/* Test cases that need the kernel tracer. */
LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
- diag("Test syscall event rule notifications for domain %s",
- domain_type_string);
+ diag("Test syscall event rule notifications for domain %s", domain_type_string);
test_syscall_event_rule_notification();
diag("Test syscall filtering event rule notifications for domain %s",
- domain_type_string);
+ domain_type_string);
test_syscall_event_rule_notification_filter();
LTTNG_ASSERT(domain_type == LTTNG_DOMAIN_KERNEL);
diag("Test userspace-probe event rule notifications for domain %s",
- domain_type_string);
+ domain_type_string);
- test_uprobe_event_rule_notification(
- testapp_path, test_symbol_name);
+ test_uprobe_event_rule_notification(testapp_path, test_symbol_name);
break;
}
case 7:
{
- switch(domain_type) {
+ switch (domain_type) {
case LTTNG_DOMAIN_UST:
plan_tests(221);
break;
}
diag("Test tracepoint event rule notification captures for domain %s",
- domain_type_string);
+ domain_type_string);
test_tracepoint_event_rule_notification_capture(domain_type);
break;
error:
return exit_status();
}
-
#include <common/compat/getenv.hpp>
#include <common/consumer/consumer.hpp>
-#include <common/pipe.hpp>
#include <common/error.hpp>
-#include <unistd.h>
-#include <stdbool.h>
+#include <common/pipe.hpp>
+
#include <lttng/constant.h>
#include <lttng/lttng-export.h>
-#include <fcntl.h>
+
#include <dlfcn.h>
+#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <unistd.h>
static char *pause_pipe_path;
static struct lttng_pipe *pause_pipe;
-static int *notifier_notif_consumption_state;;
+static int *notifier_notif_consumption_state;
+;
int lttng_opt_verbose;
int lttng_opt_mi;
int lttng_opt_quiet;
-static
-void __attribute__((destructor)) pause_pipe_fini(void)
+static void __attribute__((destructor)) pause_pipe_fini(void)
{
int ret;
if (pause_pipe_path) {
ret = unlink(pause_pipe_path);
if (ret) {
- PERROR("Failed to unlink pause pipe: path = %s",
- pause_pipe_path);
+ PERROR("Failed to unlink pause pipe: path = %s", pause_pipe_path);
}
}
int ret = 0;
const char *pause_pipe_path_prefix;
- pause_pipe_path_prefix = lttng_secure_getenv(
- "NOTIFIER_PAUSE_PIPE_PATH");
+ pause_pipe_path_prefix = lttng_secure_getenv("NOTIFIER_PAUSE_PIPE_PATH");
if (!pause_pipe_path_prefix) {
ret = -1;
goto end;
}
DBG("Creating pause pipe at %s", pause_pipe_path);
- pause_pipe = lttng_pipe_named_open(pause_pipe_path,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, O_NONBLOCK);
+ pause_pipe = lttng_pipe_named_open(
+ pause_pipe_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, O_NONBLOCK);
if (!pause_pipe) {
ERR("Failed to create pause pipe at %s", pause_pipe_path);
ret = -1;
if (value_read) {
*notifier_notif_consumption_state = !!value;
DBG("Message received on pause pipe: %s data consumption",
- *notifier_notif_consumption_state ? "paused" : "resumed");
+ *notifier_notif_consumption_state ? "paused" : "resumed");
}
end:
return ret;
*
*/
+#include <common/macros.hpp>
+
+#include <lttng/lttng.h>
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-
#include <tap/tap.h>
-
-#include <common/macros.hpp>
-#include <lttng/lttng.h>
+#include <unistd.h>
#define TEST_COUNT 1
#define TEST_SESSION_NAME "test_session"
#define TEST_CHANNEL_NAME "test_channel"
-static
-int get_registered_triggers_count(void)
+static int get_registered_triggers_count(void)
{
int ret;
enum lttng_error_code ret_code;
return ret;
}
-static
-int setup_session_with_size_rotation_schedule(const char *session_output_path)
+static int setup_session_with_size_rotation_schedule(const char *session_output_path)
{
int ret;
struct lttng_session_descriptor *session_desriptor = NULL;
enum lttng_error_code ret_code;
- struct lttng_handle ust_channel_handle = {
- TEST_SESSION_NAME,
- {
- .type = LTTNG_DOMAIN_UST,
- .buf_type = LTTNG_BUFFER_PER_UID,
- .padding = {},
- .attr = {},
- },
- {}
- };
-
- lttng_channel channel_cfg {};
+ struct lttng_handle ust_channel_handle = { TEST_SESSION_NAME,
+ {
+ .type = LTTNG_DOMAIN_UST,
+ .buf_type = LTTNG_BUFFER_PER_UID,
+ .padding = {},
+ .attr = {},
+ },
+ {} };
+
+ lttng_channel channel_cfg{};
strcpy(channel_cfg.name, TEST_CHANNEL_NAME);
channel_cfg.enabled = 1;
channel_cfg.attr.overwrite = -1;
enum lttng_rotation_status rotation_status;
struct lttng_rotation_schedule *rotation_schedule = NULL;
- session_desriptor = lttng_session_descriptor_local_create(
- TEST_SESSION_NAME, session_output_path);
+ session_desriptor =
+ lttng_session_descriptor_local_create(TEST_SESSION_NAME, session_output_path);
if (!session_desriptor) {
- fail("Failed to create session descriptor for session `%s`",
- TEST_SESSION_NAME);
+ fail("Failed to create session descriptor for session `%s`", TEST_SESSION_NAME);
ret = -1;
goto end;
}
ret_code = lttng_create_session_ext(session_desriptor);
if (ret_code != LTTNG_OK) {
- fail("Failed to create session `%s`: %s", TEST_SESSION_NAME,
- lttng_strerror(-ret_code));
+ fail("Failed to create session `%s`: %s",
+ TEST_SESSION_NAME,
+ lttng_strerror(-ret_code));
ret = -1;
goto end;
}
ret = lttng_enable_channel(&ust_channel_handle, &channel_cfg);
if (ret) {
- fail("Failed to enable channel `%s`: %s", TEST_CHANNEL_NAME,
- lttng_strerror(ret));
+ fail("Failed to enable channel `%s`: %s", TEST_CHANNEL_NAME, lttng_strerror(ret));
ret = -1;
goto end;
}
ret = lttng_start_tracing(TEST_SESSION_NAME);
if (ret) {
- fail("Failed to start session `%s`: %s", TEST_SESSION_NAME,
- lttng_strerror(ret));
+ fail("Failed to start session `%s`: %s", TEST_SESSION_NAME, lttng_strerror(ret));
ret = -1;
goto end;
}
* time.
*/
rotation_status = lttng_rotation_schedule_size_threshold_set_threshold(
- rotation_schedule, sysconf(_SC_PAGE_SIZE) * 4096);
+ rotation_schedule, sysconf(_SC_PAGE_SIZE) * 4096);
if (rotation_status != LTTNG_ROTATION_STATUS_OK) {
fail("Failed to set size threshold of session rotation schedule");
ret = -1;
goto end;
}
- rotation_status = lttng_session_add_rotation_schedule(
- TEST_SESSION_NAME, rotation_schedule);
+ rotation_status = lttng_session_add_rotation_schedule(TEST_SESSION_NAME, rotation_schedule);
if (rotation_status != LTTNG_ROTATION_STATUS_OK) {
fail("Failed to set size-based rotation schedule on session `%s`",
- TEST_SESSION_NAME);
+ TEST_SESSION_NAME);
ret = -1;
goto end;
}
}
ok(get_registered_triggers_count() == 0,
- "No triggers visible while session has an enabled size-based rotation schedule");
+ "No triggers visible while session has an enabled size-based rotation schedule");
ret = lttng_destroy_session(TEST_SESSION_NAME);
if (ret) {
*
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <tap/tap.h>
+#include <common/macros.hpp>
+
+#include <lttng/lttng.h>
+
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
-#include <lttng/lttng.h>
-#include <common/macros.hpp>
+#include <tap/tap.h>
+#include <unistd.h>
#define TEST_COUNT 70
typedef void (*test_function)(enum unregistration_trigger_instance);
-static
-const char *get_trigger_name(const struct lttng_trigger *trigger)
+static const char *get_trigger_name(const struct lttng_trigger *trigger)
{
const char *trigger_name;
enum lttng_trigger_status trigger_status;
return trigger_name;
}
-static
-const char *unregistration_trigger_instance_name(
- enum unregistration_trigger_instance unregistration_trigger)
+static const char *
+unregistration_trigger_instance_name(enum unregistration_trigger_instance unregistration_trigger)
{
const char *name;
* Returns a negative error code on error, else the number of unregistered
* triggers.
*/
-static
-int unregister_all_triggers(void)
+static int unregister_all_triggers(void)
{
int ret;
enum lttng_error_code ret_code;
return ret;
}
-static
-int get_registered_triggers_count(void)
+static int get_registered_triggers_count(void)
{
int ret;
enum lttng_error_code ret_code;
* Create a generic trigger. The specifics of the condition and action are not
* important for the purposes of this test.
*/
-static
-struct lttng_trigger *create_trigger(uint64_t threshold)
+static struct lttng_trigger *create_trigger(uint64_t threshold)
{
struct lttng_condition *condition = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
enum lttng_condition_status condition_status;
- const char * const session_name = "test session";
+ const char *const session_name = "test session";
condition = lttng_condition_session_consumed_size_create();
if (!condition) {
goto end;
}
- condition_status = lttng_condition_session_consumed_size_set_session_name(condition, session_name);
+ condition_status =
+ lttng_condition_session_consumed_size_set_session_name(condition, session_name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
fail("Failed to set session name on 'session consumed size' condition");
goto end;
}
- condition_status = lttng_condition_session_consumed_size_set_threshold(
- condition, threshold);
+ condition_status =
+ lttng_condition_session_consumed_size_set_threshold(condition, threshold);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
fail("Failed to set threshold on 'session consumed size' condition");
goto end;
return trigger;
}
-static
-void register_anonymous_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void register_anonymous_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
enum lttng_error_code ret_code;
diag("Register an anonymous trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger) {
fail("Failed to create trigger");
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_UNSET,
- "Anonymous trigger name remains unset after registration: trigger name = '%s'",
- get_trigger_name(trigger));
+ "Anonymous trigger name remains unset after registration: trigger name = '%s'",
+ get_trigger_name(trigger));
ret_code = lttng_list_triggers(&triggers);
if (ret_code != LTTNG_OK) {
trigger_status = lttng_trigger_get_name(trigger_from_listing, &trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_UNSET,
- "Anonymous trigger returned by listing has an unset name: trigger name = '%s'",
- get_trigger_name(trigger_from_listing));
+ "Anonymous trigger returned by listing has an unset name: trigger name = '%s'",
+ get_trigger_name(trigger_from_listing));
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_FROM_LISTING) {
ret = lttng_unregister_trigger(trigger_from_listing);
- ok(ret == 0, "Successfully unregistered anonymous trigger using the trigger instance returned by the listing");
+ ok(ret == 0,
+ "Successfully unregistered anonymous trigger using the trigger instance returned by the listing");
}
}
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger);
- ok(ret == 0, "Successfully unregistered anonymous trigger using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered anonymous trigger using the trigger instance used on registration");
}
end:
lttng_trigger_destroy(trigger);
}
-static
-void register_named_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void register_named_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
struct lttng_triggers *triggers = NULL;
unsigned int trigger_count, i;
enum lttng_error_code ret_code;
- const char * const trigger_name = "some name that is hopefully unique";
+ const char *const trigger_name = "some name that is hopefully unique";
diag("Register a named trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger) {
fail("Failed to create trigger");
}
ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
- ok(ret_code == LTTNG_OK, "Registered trigger with name: trigger name = '%s'",
- get_trigger_name(trigger));
+ ok(ret_code == LTTNG_OK,
+ "Registered trigger with name: trigger name = '%s'",
+ get_trigger_name(trigger));
trigger_status = lttng_trigger_get_name(trigger, &returned_trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Trigger name is set after registration: trigger name = '%s'",
- get_trigger_name(trigger));
+ "Trigger name is set after registration: trigger name = '%s'",
+ get_trigger_name(trigger));
ok(!strcmp(get_trigger_name(trigger), trigger_name),
- "Name set on trigger after registration is correct");
+ "Name set on trigger after registration is correct");
ret_code = lttng_list_triggers(&triggers);
if (ret_code != LTTNG_OK) {
trigger_from_listing = lttng_triggers_get_at_index(triggers, i);
LTTNG_ASSERT(trigger_from_listing);
- trigger_status = lttng_trigger_get_name(trigger_from_listing, &returned_trigger_name);
+ trigger_status =
+ lttng_trigger_get_name(trigger_from_listing, &returned_trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Trigger returned by listing has a name: trigger name = '%s'",
- get_trigger_name(trigger_from_listing));
+ "Trigger returned by listing has a name: trigger name = '%s'",
+ get_trigger_name(trigger_from_listing));
- ok(!strcmp(get_trigger_name(trigger_from_listing),
- trigger_name),
- "Name set on trigger returned from listing is correct: name returned from listing = '%s', expected name = '%s'",
- get_trigger_name(trigger_from_listing),
- trigger_name);
+ ok(!strcmp(get_trigger_name(trigger_from_listing), trigger_name),
+ "Name set on trigger returned from listing is correct: name returned from listing = '%s', expected name = '%s'",
+ get_trigger_name(trigger_from_listing),
+ trigger_name);
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_FROM_LISTING) {
ret = lttng_unregister_trigger(trigger_from_listing);
- ok(ret == 0, "Successfully unregistered named trigger using the trigger instance returned by the listing");
+ ok(ret == 0,
+ "Successfully unregistered named trigger using the trigger instance returned by the listing");
}
}
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger);
- ok(ret == 0, "Successfully unregistered named trigger using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered named trigger using the trigger instance used on registration");
}
end:
lttng_trigger_destroy(trigger);
}
-static
-void register_automatic_name_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void
+register_automatic_name_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
enum lttng_error_code ret_code;
diag("Register an automatic name trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger) {
fail("Failed to create trigger");
trigger_status = lttng_trigger_get_name(trigger, &returned_trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Trigger name is set after registration: trigger name = '%s'",
- get_trigger_name(trigger));
+ "Trigger name is set after registration: trigger name = '%s'",
+ get_trigger_name(trigger));
ok(returned_trigger_name && strlen(returned_trigger_name) > 0,
- "Automatic name set on trigger after registration longer is not an empty string");
+ "Automatic name set on trigger after registration longer is not an empty string");
ret_code = lttng_list_triggers(&triggers);
if (ret_code != LTTNG_OK) {
trigger_from_listing = lttng_triggers_get_at_index(triggers, i);
LTTNG_ASSERT(trigger_from_listing);
- trigger_status = lttng_trigger_get_name(trigger_from_listing, &returned_trigger_name);
+ trigger_status =
+ lttng_trigger_get_name(trigger_from_listing, &returned_trigger_name);
ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
- "Trigger returned by listing has a name: trigger name = '%s'",
- get_trigger_name(trigger_from_listing));
+ "Trigger returned by listing has a name: trigger name = '%s'",
+ get_trigger_name(trigger_from_listing));
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_FROM_LISTING) {
ret = lttng_unregister_trigger(trigger_from_listing);
- ok(ret == 0, "Successfully unregistered automatic name trigger using the trigger instance returned by the listing");
+ ok(ret == 0,
+ "Successfully unregistered automatic name trigger using the trigger instance returned by the listing");
}
}
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger);
- ok(ret == 0, "Successfully unregistered automatic trigger using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered automatic trigger using the trigger instance used on registration");
}
end:
lttng_trigger_destroy(trigger);
}
-static
-void double_register_anonymous_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void
+double_register_anonymous_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger = create_trigger(0xbadc0ffee);
struct lttng_triggers *triggers = NULL;
diag("Register duplicate anonymous trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger) {
fail("Failed to create trigger");
ret = lttng_register_trigger(trigger);
ok(ret == -LTTNG_ERR_TRIGGER_EXISTS,
- "Registering identical anonymous trigger fails with `LTTNG_ERR_TRIGGER_EXISTS`");
-
+ "Registering identical anonymous trigger fails with `LTTNG_ERR_TRIGGER_EXISTS`");
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger);
- ok(ret == 0, "Successfully unregistered anonymous trigger using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered anonymous trigger using the trigger instance used on registration");
} else {
- ok(get_registered_triggers_count() == 1,
- "Trigger listing returns 1 trigger");
+ ok(get_registered_triggers_count() == 1, "Trigger listing returns 1 trigger");
ok(unregister_all_triggers() == 1,
- "Successfully unregistered anonymous trigger using the trigger instance returned by the listing");
+ "Successfully unregistered anonymous trigger using the trigger instance returned by the listing");
}
end:
lttng_trigger_destroy(trigger);
}
-static
-void double_register_named_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void
+double_register_named_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
struct lttng_trigger *trigger_b = create_trigger(0xbadc0ffee);
struct lttng_triggers *triggers = NULL;
- const char * const trigger_name = "a unique trigger name";
+ const char *const trigger_name = "a unique trigger name";
enum lttng_error_code ret_code;
diag("Register duplicate named trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger_a || !trigger_b) {
fail("Failed to create triggers");
ret = lttng_register_trigger(trigger_a);
ok(ret == -LTTNG_ERR_INVALID,
- "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (anonymous registration)");
+ "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (anonymous registration)");
ret_code = lttng_register_trigger_with_name(trigger_a, trigger_name);
ok(ret_code == LTTNG_ERR_INVALID,
- "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (register with name)");
+ "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (register with name)");
ret_code = lttng_register_trigger_with_automatic_name(trigger_a);
ok(ret_code == LTTNG_ERR_INVALID,
- "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (register with automatic name)");
+ "Registering a trigger instance already used for registration fails with `LTTNG_ERR_INVALID` (register with automatic name)");
ret_code = lttng_register_trigger_with_name(trigger_b, trigger_name);
- ok(ret_code == LTTNG_ERR_TRIGGER_EXISTS, "Registering trigger with an already used name fails with `LTTNG_ERR_TRIGGER_EXISTS`");
+ ok(ret_code == LTTNG_ERR_TRIGGER_EXISTS,
+ "Registering trigger with an already used name fails with `LTTNG_ERR_TRIGGER_EXISTS`");
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger_a);
- ok(ret == 0, "Successfully unregistered named trigger using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered named trigger using the trigger instance used on registration");
} else {
- ok(get_registered_triggers_count() == 1,
- "Trigger listing returns 1 trigger");
+ ok(get_registered_triggers_count() == 1, "Trigger listing returns 1 trigger");
ok(unregister_all_triggers() == 1,
- "Successfully unregistered named trigger using the trigger instance returned by the listing");
+ "Successfully unregistered named trigger using the trigger instance returned by the listing");
}
end:
lttng_trigger_destroy(trigger_b);
}
-static
-void double_register_automatic_name_trigger(
- enum unregistration_trigger_instance unregistration_trigger)
+static void
+double_register_automatic_name_trigger(enum unregistration_trigger_instance unregistration_trigger)
{
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
enum lttng_error_code ret_code;
diag("Register duplicate automatic name trigger (Unregistration performed with the trigger instance %s)",
- unregistration_trigger_instance_name(
- unregistration_trigger));
+ unregistration_trigger_instance_name(unregistration_trigger));
if (!trigger_a || !trigger_b) {
fail("Failed to create triggers");
}
ret_code = lttng_register_trigger_with_automatic_name(trigger_a);
- ok(ret_code == LTTNG_OK, "Registered automatic name trigger: trigger name = '%s'", get_trigger_name(trigger_a));
+ ok(ret_code == LTTNG_OK,
+ "Registered automatic name trigger: trigger name = '%s'",
+ get_trigger_name(trigger_a));
ret = lttng_register_trigger_with_automatic_name(trigger_b);
- ok(ret_code == LTTNG_OK, "Registering an identical trigger instance with an automatic name succeeds: trigger name = '%s'", get_trigger_name(trigger_b));
+ ok(ret_code == LTTNG_OK,
+ "Registering an identical trigger instance with an automatic name succeeds: trigger name = '%s'",
+ get_trigger_name(trigger_b));
ok(strcmp(get_trigger_name(trigger_a), get_trigger_name(trigger_b)),
- "Two identical triggers registered with an automatic name have different names");
+ "Two identical triggers registered with an automatic name have different names");
if (unregistration_trigger == UNREGISTRATION_TRIGGER_INSTANCE_USED_FOR_REGISTRATION) {
ret = lttng_unregister_trigger(trigger_a);
- ok(ret == 0, "Successfully unregistered automatic trigger A using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered automatic trigger A using the trigger instance used on registration");
ret = lttng_unregister_trigger(trigger_b);
- ok(ret == 0, "Successfully unregistered automatic trigger B using the trigger instance used on registration");
+ ok(ret == 0,
+ "Successfully unregistered automatic trigger B using the trigger instance used on registration");
} else {
- ok(get_registered_triggers_count() == 2,
- "Trigger listing returns 2 trigger");
+ ok(get_registered_triggers_count() == 2, "Trigger listing returns 2 trigger");
ok(unregister_all_triggers() == 2,
- "Successfully unregistered automatic name triggers using the trigger instance returned by the listing");
+ "Successfully unregistered automatic name triggers using the trigger instance returned by the listing");
}
end:
lttng_trigger_destroy(trigger_b);
}
-static
-void register_multiple_anonymous_triggers(void)
+static void register_multiple_anonymous_triggers(void)
{
int ret;
struct lttng_trigger *trigger_a = create_trigger(0xbadc0ffee);
ret = lttng_register_trigger(trigger_b);
ok(ret == 0, "Registered second anonymous trigger");
- ok(get_registered_triggers_count() == 2,
- "Trigger listing returns 2 trigger");
- ok(unregister_all_triggers() == 2,
- "Successfully unregistered two anonymous triggers");
+ ok(get_registered_triggers_count() == 2, "Trigger listing returns 2 trigger");
+ ok(unregister_all_triggers() == 2, "Successfully unregistered two anonymous triggers");
end:
lttng_trigger_destroy(trigger_a);
}
const test_function test_functions[] = {
- register_anonymous_trigger,
- register_named_trigger,
- register_automatic_name_trigger,
- double_register_anonymous_trigger,
- double_register_named_trigger,
- double_register_automatic_name_trigger,
+ register_anonymous_trigger, register_named_trigger,
+ register_automatic_name_trigger, double_register_anonymous_trigger,
+ double_register_named_trigger, double_register_automatic_name_trigger,
};
int main(void)
#include <common/filter/filter-ast.hpp>
#include <common/macros.hpp>
+
#include <lttng/lttng.h>
#include <stdlib.h>
#include <string.h>
static void register_trigger(const char *trigger_name,
- struct lttng_condition *condition,
- struct lttng_action *action)
+ struct lttng_condition *condition,
+ struct lttng_action *action)
{
struct lttng_trigger *trigger;
enum lttng_error_code ret;
* Register a trigger with the given condition and an action list containing a
* single notify action.
*/
-static void register_trigger_action_list_notify(
- const char *trigger_name, struct lttng_condition *condition)
+static void register_trigger_action_list_notify(const char *trigger_name,
+ struct lttng_condition *condition)
{
struct lttng_action *action_notify;
struct lttng_action *action_list;
action_list = lttng_action_list_create();
action_notify = lttng_action_notify_create();
- action_status = lttng_action_list_add_action(
- action_list, action_notify);
+ action_status = lttng_action_list_add_action(action_list, action_notify);
LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
lttng_action_destroy(action_notify);
register_trigger(trigger_name, condition, action_list);
}
-static struct lttng_condition *create_session_consumed_size_condition(
- const char *session_name, uint64_t threshold)
+static struct lttng_condition *create_session_consumed_size_condition(const char *session_name,
+ uint64_t threshold)
{
struct lttng_condition *condition;
enum lttng_condition_status condition_status;
condition = lttng_condition_session_consumed_size_create();
condition_status =
- lttng_condition_session_consumed_size_set_session_name(
- condition, session_name);
+ lttng_condition_session_consumed_size_set_session_name(condition, session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- condition_status = lttng_condition_session_consumed_size_set_threshold(
- condition, threshold);
+ condition_status =
+ lttng_condition_session_consumed_size_set_threshold(condition, threshold);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
return condition;
static void test_session_consumed_size_condition(void)
{
register_trigger_action_list_notify(
- "trigger-with-session-consumed-size-condition",
- create_session_consumed_size_condition(
- "the-session-name", 1234));
+ "trigger-with-session-consumed-size-condition",
+ create_session_consumed_size_condition("the-session-name", 1234));
}
static void fill_buffer_usage_condition(struct lttng_condition *condition,
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type)
+ const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type)
{
enum lttng_condition_status condition_status;
- condition_status = lttng_condition_buffer_usage_set_session_name(
- condition, session_name);
+ condition_status = lttng_condition_buffer_usage_set_session_name(condition, session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- condition_status = lttng_condition_buffer_usage_set_channel_name(
- condition, channel_name);
+ condition_status = lttng_condition_buffer_usage_set_channel_name(condition, channel_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
- condition_status = lttng_condition_buffer_usage_set_domain_type(
- condition, domain_type);
+ condition_status = lttng_condition_buffer_usage_set_domain_type(condition, domain_type);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
}
static void fill_buffer_usage_bytes_condition(struct lttng_condition *condition,
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- uint64_t threshold)
+ const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ uint64_t threshold)
{
enum lttng_condition_status condition_status;
- fill_buffer_usage_condition(
- condition, session_name, channel_name, domain_type);
- condition_status = lttng_condition_buffer_usage_set_threshold(
- condition, threshold);
+ fill_buffer_usage_condition(condition, session_name, channel_name, domain_type);
+ condition_status = lttng_condition_buffer_usage_set_threshold(condition, threshold);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
}
static void fill_buffer_usage_ratio_condition(struct lttng_condition *condition,
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- double ratio)
+ const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ double ratio)
{
enum lttng_condition_status condition_status;
- fill_buffer_usage_condition(
- condition, session_name, channel_name, domain_type);
- condition_status = lttng_condition_buffer_usage_set_threshold_ratio(
- condition, ratio);
+ fill_buffer_usage_condition(condition, session_name, channel_name, domain_type);
+ condition_status = lttng_condition_buffer_usage_set_threshold_ratio(condition, ratio);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
}
-static struct lttng_condition *create_buffer_usage_high_bytes_condition(
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- uint64_t threshold)
+static struct lttng_condition *
+create_buffer_usage_high_bytes_condition(const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ uint64_t threshold)
{
struct lttng_condition *condition;
condition = lttng_condition_buffer_usage_high_create();
- fill_buffer_usage_bytes_condition(condition, session_name, channel_name,
- domain_type, threshold);
+ fill_buffer_usage_bytes_condition(
+ condition, session_name, channel_name, domain_type, threshold);
return condition;
}
-static struct lttng_condition *create_buffer_usage_low_bytes_condition(
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- uint64_t threshold)
+static struct lttng_condition *
+create_buffer_usage_low_bytes_condition(const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ uint64_t threshold)
{
struct lttng_condition *condition;
condition = lttng_condition_buffer_usage_low_create();
- fill_buffer_usage_bytes_condition(condition, session_name, channel_name,
- domain_type, threshold);
+ fill_buffer_usage_bytes_condition(
+ condition, session_name, channel_name, domain_type, threshold);
return condition;
}
-static struct lttng_condition *create_buffer_usage_high_ratio_condition(
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- double ratio)
+static struct lttng_condition *
+create_buffer_usage_high_ratio_condition(const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ double ratio)
{
struct lttng_condition *condition;
condition = lttng_condition_buffer_usage_high_create();
- fill_buffer_usage_ratio_condition(condition, session_name, channel_name,
- domain_type, ratio);
+ fill_buffer_usage_ratio_condition(
+ condition, session_name, channel_name, domain_type, ratio);
return condition;
}
-static struct lttng_condition *create_buffer_usage_low_ratio_condition(
- const char *session_name,
- const char *channel_name,
- enum lttng_domain_type domain_type,
- double ratio)
+static struct lttng_condition *
+create_buffer_usage_low_ratio_condition(const char *session_name,
+ const char *channel_name,
+ enum lttng_domain_type domain_type,
+ double ratio)
{
struct lttng_condition *condition;
condition = lttng_condition_buffer_usage_low_create();
- fill_buffer_usage_ratio_condition(condition, session_name, channel_name,
- domain_type, ratio);
+ fill_buffer_usage_ratio_condition(
+ condition, session_name, channel_name, domain_type, ratio);
return condition;
}
static void test_buffer_usage_conditions(void)
{
register_trigger_action_list_notify(
- "trigger-with-buffer-usage-high-bytes-condition",
- create_buffer_usage_high_bytes_condition(
- "the-session-name", "the-channel-name",
- LTTNG_DOMAIN_UST, 1234));
+ "trigger-with-buffer-usage-high-bytes-condition",
+ create_buffer_usage_high_bytes_condition(
+ "the-session-name", "the-channel-name", LTTNG_DOMAIN_UST, 1234));
register_trigger_action_list_notify(
- "trigger-with-buffer-usage-low-bytes-condition",
- create_buffer_usage_low_bytes_condition(
- "the-session-name", "the-channel-name",
- LTTNG_DOMAIN_UST, 2345));
+ "trigger-with-buffer-usage-low-bytes-condition",
+ create_buffer_usage_low_bytes_condition(
+ "the-session-name", "the-channel-name", LTTNG_DOMAIN_UST, 2345));
register_trigger_action_list_notify(
- "trigger-with-buffer-usage-high-ratio-condition",
- create_buffer_usage_high_ratio_condition(
- "the-session-name", "the-channel-name",
- LTTNG_DOMAIN_UST, 0.25));
+ "trigger-with-buffer-usage-high-ratio-condition",
+ create_buffer_usage_high_ratio_condition(
+ "the-session-name", "the-channel-name", LTTNG_DOMAIN_UST, 0.25));
register_trigger_action_list_notify(
- "trigger-with-buffer-usage-low-ratio-condition",
- create_buffer_usage_low_ratio_condition(
- "the-session-name", "the-channel-name",
- LTTNG_DOMAIN_UST, 0.4));
+ "trigger-with-buffer-usage-low-ratio-condition",
+ create_buffer_usage_low_ratio_condition(
+ "the-session-name", "the-channel-name", LTTNG_DOMAIN_UST, 0.4));
}
-static void fill_session_rotation_condition(
- struct lttng_condition *condition, const char *session_name)
+static void fill_session_rotation_condition(struct lttng_condition *condition,
+ const char *session_name)
{
enum lttng_condition_status condition_status;
- condition_status = lttng_condition_session_rotation_set_session_name(
- condition, session_name);
+ condition_status =
+ lttng_condition_session_rotation_set_session_name(condition, session_name);
LTTNG_ASSERT(condition_status == LTTNG_CONDITION_STATUS_OK);
}
-static struct lttng_condition *create_session_rotation_ongoing_condition(
- const char *session_name)
+static struct lttng_condition *create_session_rotation_ongoing_condition(const char *session_name)
{
struct lttng_condition *condition;
return condition;
}
-static struct lttng_condition *create_session_rotation_completed_condition(
- const char *session_name)
+static struct lttng_condition *create_session_rotation_completed_condition(const char *session_name)
{
struct lttng_condition *condition;
static void test_session_rotation_conditions(void)
{
register_trigger_action_list_notify(
- "trigger-with-session-rotation-ongoing-condition",
- create_session_rotation_ongoing_condition(
- "the-session-name"));
+ "trigger-with-session-rotation-ongoing-condition",
+ create_session_rotation_ongoing_condition("the-session-name"));
register_trigger_action_list_notify(
- "trigger-with-session-rotation-completed-condition",
- create_session_rotation_completed_condition(
- "the-session-name"));
+ "trigger-with-session-rotation-completed-condition",
+ create_session_rotation_completed_condition("the-session-name"));
}
static struct {
const char *name;
void (*callback)(void);
} tests[] = {
- {
- "test_session_consumed_size_condition",
- test_session_consumed_size_condition,
- },
- {"test_buffer_usage_conditions", test_buffer_usage_conditions},
- {"test_session_rotation_conditions",
- test_session_rotation_conditions},
+ {
+ "test_session_consumed_size_condition",
+ test_session_consumed_size_condition,
+ },
+ { "test_buffer_usage_conditions", test_buffer_usage_conditions },
+ { "test_session_rotation_conditions", test_session_rotation_conditions },
};
static void show_known_tests(void)
*
*/
-#include <tap/tap.h>
#include <common/ini-config/ini-config.hpp>
-#include <common/utils.hpp>
#include <common/path.hpp>
-#include <string.h>
+#include <common/utils.hpp>
+
#include <lttng/constant.h>
+#include <string.h>
+#include <tap/tap.h>
+
namespace {
struct state {
int section_1;
if (!strcmp(entry->section, "section1")) {
state->section_1 = 1;
- if (!strcmp(entry->name, "section1_entry") &&
- !strcmp(entry->value, "42")) {
+ if (!strcmp(entry->name, "section1_entry") && !strcmp(entry->value, "42")) {
state->int_entry = 1;
}
}
if (!strcmp(entry->section, "section 3")) {
state->section_3 = 1;
if (!strcmp(entry->name, "name with a space") &&
- !strcmp(entry->value, "another value")) {
+ !strcmp(entry->value, "another value")) {
state->text_entry = 1;
}
}
if (strlen(argv[1]) >= LTTNG_PATH_MAX) {
diag("The provided path exceeds the maximal permitted length of %i bytes",
- LTTNG_PATH_MAX);
+ LTTNG_PATH_MAX);
goto end;
}
path = utils_expand_path(argv[1]);
}
plan_no_plan();
- ret = config_get_section_entries(path, NULL,
- (config_entry_handler_cb)entry_handler, &state);
+ ret = config_get_section_entries(
+ path, NULL, (config_entry_handler_cb) entry_handler, &state);
ok(ret == 0, "Successfully opened a config file, registered to all sections");
- ok(state.section_1 && state.section_2 && state.section_3 &&
- state.section_global, "Processed entries from each sections");
+ ok(state.section_1 && state.section_2 && state.section_3 && state.section_global,
+ "Processed entries from each sections");
ok(state.text_entry, "Text value parsed correctly");
memset(&state, 0, sizeof(struct state));
- ret = config_get_section_entries(path, "section1",
- (config_entry_handler_cb)entry_handler, &state);
+ ret = config_get_section_entries(
+ path, "section1", (config_entry_handler_cb) entry_handler, &state);
ok(ret == 0, "Successfully opened a config file, registered to one section");
- ok(state.section_1 && !state.section_2 && !state.section_3 &&
- !state.section_global, "Processed an entry from section1 only");
+ ok(state.section_1 && !state.section_2 && !state.section_3 && !state.section_global,
+ "Processed an entry from section1 only");
ok(state.int_entry, "Int value parsed correctly");
memset(&state, 0, sizeof(struct state));
- ret = config_get_section_entries(path, "",
- (config_entry_handler_cb)entry_handler, &state);
+ ret = config_get_section_entries(path, "", (config_entry_handler_cb) entry_handler, &state);
ok(ret == 0, "Successfully opened a config file, registered to the global section");
- ok(!state.section_1 && !state.section_2 && !state.section_3 &&
- state.section_global, "Processed an entry from the global section only");
+ ok(!state.section_1 && !state.section_2 && !state.section_3 && state.section_global,
+ "Processed an entry from the global section only");
end:
free(path);
return exit_status();
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
-
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/action/action-internal.hpp>
#include <lttng/action/action.h>
#include <lttng/action/notify.h>
#include <lttng/action/start-session.h>
#include <lttng/action/stop-session.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
+
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
{
int ret;
enum lttng_action_status status;
- struct lttng_action *notify_action = NULL,
- *notify_action_from_buffer = NULL;
+ struct lttng_action *notify_action = NULL, *notify_action_from_buffer = NULL;
struct lttng_rate_policy *policy = NULL, *default_policy;
struct lttng_payload payload;
notify_action = lttng_action_notify_create();
ok(notify_action, "Create notify action");
ok(lttng_action_get_type(notify_action) == LTTNG_ACTION_TYPE_NOTIFY,
- "Action has type LTTNG_ACTION_TYPE_NOTIFY");
+ "Action has type LTTNG_ACTION_TYPE_NOTIFY");
/* Validate the default policy for a notify action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_notify_get_rate_policy(
- notify_action, &cur_policy);
+ status = lttng_action_notify_get_rate_policy(notify_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- default_policy,
- cur_policy),
- "Default policy is every n=1");
+ lttng_rate_policy_is_equal(default_policy, cur_policy),
+ "Default policy is every n=1");
}
/* Set a custom policy. */
/* Validate the custom policy for a notify action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_notify_get_rate_policy(
- notify_action, &cur_policy);
+ status = lttng_action_notify_get_rate_policy(notify_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- policy,
- cur_policy),
- "Notify action policy get");
+ lttng_rate_policy_is_equal(policy, cur_policy),
+ "Notify action policy get");
}
ret = lttng_action_serialize(notify_action, &payload);
ok(ret == 0, "Action notify serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- (void) lttng_action_create_from_payload(
- &view, ¬ify_action_from_buffer);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ (void) lttng_action_create_from_payload(&view, ¬ify_action_from_buffer);
}
- ok(notify_action_from_buffer,
- "Notify action created from payload is non-null");
+ ok(notify_action_from_buffer, "Notify action created from payload is non-null");
ok(lttng_action_is_equal(notify_action, notify_action_from_buffer),
- "Serialized and de-serialized notify action are equal");
+ "Serialized and de-serialized notify action are equal");
lttng_rate_policy_destroy(default_policy);
lttng_rate_policy_destroy(policy);
rotate_session_action = lttng_action_rotate_session_create();
ok(rotate_session_action, "Create rotate_session action");
- ok(lttng_action_get_type(rotate_session_action) ==
- LTTNG_ACTION_TYPE_ROTATE_SESSION,
- "Action has type LTTNG_ACTION_TYPE_ROTATE_SESSION");
+ ok(lttng_action_get_type(rotate_session_action) == LTTNG_ACTION_TYPE_ROTATE_SESSION,
+ "Action has type LTTNG_ACTION_TYPE_ROTATE_SESSION");
/* Session name setter. */
status = lttng_action_rotate_session_set_session_name(NULL, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_rotate_session_set_session_name(
- rotate_session_action, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (object,NULL) expect invalid");
- status = lttng_action_rotate_session_set_session_name(
- NULL, session_name);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,object) expect invalid");
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
+ status = lttng_action_rotate_session_set_session_name(rotate_session_action, NULL);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
+ status = lttng_action_rotate_session_set_session_name(NULL, session_name);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
- status = lttng_action_rotate_session_set_session_name(
- rotate_session_action, session_name);
+ status = lttng_action_rotate_session_set_session_name(rotate_session_action, session_name);
ok(status == LTTNG_ACTION_STATUS_OK, "Set session name");
- status = lttng_action_rotate_session_get_session_name(
- rotate_session_action, &get_session_name);
- ok(status == LTTNG_ACTION_STATUS_OK &&
- !strcmp(session_name, get_session_name),
- "Get session name, expected `%s` got `%s`",
- session_name, get_session_name);
+ status = lttng_action_rotate_session_get_session_name(rotate_session_action,
+ &get_session_name);
+ ok(status == LTTNG_ACTION_STATUS_OK && !strcmp(session_name, get_session_name),
+ "Get session name, expected `%s` got `%s`",
+ session_name,
+ get_session_name);
/* Validate the default policy for a rotate_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_rotate_session_get_rate_policy(
- rotate_session_action, &cur_policy);
+ status = lttng_action_rotate_session_get_rate_policy(rotate_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- default_policy,
- cur_policy),
- "Default policy is every n=1");
+ lttng_rate_policy_is_equal(default_policy, cur_policy),
+ "Default policy is every n=1");
}
/* Set a custom policy. */
- status = lttng_action_rotate_session_set_rate_policy(
- rotate_session_action, policy);
+ status = lttng_action_rotate_session_set_rate_policy(rotate_session_action, policy);
ok(status == LTTNG_ACTION_STATUS_OK, "Set rate policy");
/* Validate the custom policy for a rotate_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_rotate_session_get_rate_policy(
- rotate_session_action, &cur_policy);
+ status = lttng_action_rotate_session_get_rate_policy(rotate_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- policy,
- cur_policy),
- "rotate_session action policy get");
+ lttng_rate_policy_is_equal(policy, cur_policy),
+ "rotate_session action policy get");
}
/* Ser/des tests. */
ok(ret == 0, "Action rotate_session serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- (void) lttng_action_create_from_payload(
- &view, &rotate_session_action_from_buffer);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ (void) lttng_action_create_from_payload(&view, &rotate_session_action_from_buffer);
}
ok(rotate_session_action_from_buffer,
- "rotate_session action created from payload is non-null");
+ "rotate_session action created from payload is non-null");
- ok(lttng_action_is_equal(rotate_session_action,
- rotate_session_action_from_buffer),
- "Serialized and de-serialized rotate_session action are equal");
+ ok(lttng_action_is_equal(rotate_session_action, rotate_session_action_from_buffer),
+ "Serialized and de-serialized rotate_session action are equal");
lttng_rate_policy_destroy(default_policy);
lttng_rate_policy_destroy(policy);
{
int ret;
enum lttng_action_status status;
- struct lttng_action *start_session_action = NULL,
- *start_session_action_from_buffer = NULL;
+ struct lttng_action *start_session_action = NULL, *start_session_action_from_buffer = NULL;
struct lttng_rate_policy *policy = NULL, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
start_session_action = lttng_action_start_session_create();
ok(start_session_action, "Create start_session action");
- ok(lttng_action_get_type(start_session_action) ==
- LTTNG_ACTION_TYPE_START_SESSION,
- "Action has type LTTNG_ACTION_TYPE_START_SESSION");
+ ok(lttng_action_get_type(start_session_action) == LTTNG_ACTION_TYPE_START_SESSION,
+ "Action has type LTTNG_ACTION_TYPE_START_SESSION");
/* Session name setter. */
status = lttng_action_start_session_set_session_name(NULL, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_start_session_set_session_name(
- start_session_action, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (object,NULL) expect invalid");
- status = lttng_action_start_session_set_session_name(
- NULL, session_name);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,object) expect invalid");
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
+ status = lttng_action_start_session_set_session_name(start_session_action, NULL);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
+ status = lttng_action_start_session_set_session_name(NULL, session_name);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
- status = lttng_action_start_session_set_session_name(
- start_session_action, session_name);
+ status = lttng_action_start_session_set_session_name(start_session_action, session_name);
ok(status == LTTNG_ACTION_STATUS_OK, "Set session name");
- status = lttng_action_start_session_get_session_name(
- start_session_action, &get_session_name);
- ok(status == LTTNG_ACTION_STATUS_OK &&
- !strcmp(session_name, get_session_name),
- "Get session name, expected `%s` got `%s`",
- session_name, get_session_name);
+ status = lttng_action_start_session_get_session_name(start_session_action,
+ &get_session_name);
+ ok(status == LTTNG_ACTION_STATUS_OK && !strcmp(session_name, get_session_name),
+ "Get session name, expected `%s` got `%s`",
+ session_name,
+ get_session_name);
/* Validate the default policy for a start_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_start_session_get_rate_policy(
- start_session_action, &cur_policy);
+ status = lttng_action_start_session_get_rate_policy(start_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- default_policy,
- cur_policy),
- "Default policy is every n=1");
+ lttng_rate_policy_is_equal(default_policy, cur_policy),
+ "Default policy is every n=1");
}
/* Set a custom policy. */
- status = lttng_action_start_session_set_rate_policy(
- start_session_action, policy);
+ status = lttng_action_start_session_set_rate_policy(start_session_action, policy);
ok(status == LTTNG_ACTION_STATUS_OK, "Set rate policy");
/* Validate the custom policy for a start_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_start_session_get_rate_policy(
- start_session_action, &cur_policy);
+ status = lttng_action_start_session_get_rate_policy(start_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- policy,
- cur_policy),
- "start_session action policy get");
+ lttng_rate_policy_is_equal(policy, cur_policy),
+ "start_session action policy get");
}
/* Ser/des tests. */
ok(ret == 0, "Action start_session serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- (void) lttng_action_create_from_payload(
- &view, &start_session_action_from_buffer);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ (void) lttng_action_create_from_payload(&view, &start_session_action_from_buffer);
}
ok(start_session_action_from_buffer,
- "start_session action created from payload is non-null");
+ "start_session action created from payload is non-null");
- ok(lttng_action_is_equal(start_session_action,
- start_session_action_from_buffer),
- "Serialized and de-serialized start_session action are equal");
+ ok(lttng_action_is_equal(start_session_action, start_session_action_from_buffer),
+ "Serialized and de-serialized start_session action are equal");
lttng_rate_policy_destroy(default_policy);
lttng_rate_policy_destroy(policy);
{
int ret;
enum lttng_action_status status;
- struct lttng_action *stop_session_action = NULL,
- *stop_session_action_from_buffer = NULL;
+ struct lttng_action *stop_session_action = NULL, *stop_session_action_from_buffer = NULL;
struct lttng_rate_policy *policy = NULL, *default_policy;
struct lttng_payload payload;
const char *session_name = "my_session_name";
stop_session_action = lttng_action_stop_session_create();
ok(stop_session_action, "Create stop_session action");
- ok(lttng_action_get_type(stop_session_action) ==
- LTTNG_ACTION_TYPE_STOP_SESSION,
- "Action has type LTTNG_ACTION_TYPE_STOP_SESSION");
+ ok(lttng_action_get_type(stop_session_action) == LTTNG_ACTION_TYPE_STOP_SESSION,
+ "Action has type LTTNG_ACTION_TYPE_STOP_SESSION");
/* Session name setter. */
status = lttng_action_stop_session_set_session_name(NULL, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_stop_session_set_session_name(
- stop_session_action, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (object,NULL) expect invalid");
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
+ status = lttng_action_stop_session_set_session_name(stop_session_action, NULL);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
status = lttng_action_stop_session_set_session_name(NULL, session_name);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,object) expect invalid");
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
- status = lttng_action_stop_session_set_session_name(
- stop_session_action, session_name);
+ status = lttng_action_stop_session_set_session_name(stop_session_action, session_name);
ok(status == LTTNG_ACTION_STATUS_OK, "Set session name");
- status = lttng_action_stop_session_get_session_name(
- stop_session_action, &get_session_name);
- ok(status == LTTNG_ACTION_STATUS_OK &&
- !strcmp(session_name, get_session_name),
- "Get session name, expected `%s` got `%s`",
- session_name, get_session_name);
+ status = lttng_action_stop_session_get_session_name(stop_session_action, &get_session_name);
+ ok(status == LTTNG_ACTION_STATUS_OK && !strcmp(session_name, get_session_name),
+ "Get session name, expected `%s` got `%s`",
+ session_name,
+ get_session_name);
/* Validate the default policy for a stop_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_stop_session_get_rate_policy(
- stop_session_action, &cur_policy);
+ status =
+ lttng_action_stop_session_get_rate_policy(stop_session_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- default_policy,
- cur_policy),
- "Default policy is every n=1");
+ lttng_rate_policy_is_equal(default_policy, cur_policy),
+ "Default policy is every n=1");
}
/* Set a custom policy. */
- status = lttng_action_stop_session_set_rate_policy(
- stop_session_action, policy);
+ status = lttng_action_stop_session_set_rate_policy(stop_session_action, policy);
ok(status == LTTNG_ACTION_STATUS_OK, "Set rate policy");
/* Validate the custom policy for a stop_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_stop_session_get_rate_policy(
- stop_session_action, &cur_policy);
+ status =
+ lttng_action_stop_session_get_rate_policy(stop_session_action, &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- policy,
- cur_policy),
- "stop_session action policy get");
+ lttng_rate_policy_is_equal(policy, cur_policy),
+ "stop_session action policy get");
}
/* Ser/des tests. */
ok(ret == 0, "Action stop_session serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- (void) lttng_action_create_from_payload(
- &view, &stop_session_action_from_buffer);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ (void) lttng_action_create_from_payload(&view, &stop_session_action_from_buffer);
}
- ok(stop_session_action_from_buffer,
- "stop_session action created from payload is non-null");
+ ok(stop_session_action_from_buffer, "stop_session action created from payload is non-null");
- ok(lttng_action_is_equal(stop_session_action,
- stop_session_action_from_buffer),
- "Serialized and de-serialized stop_session action are equal");
+ ok(lttng_action_is_equal(stop_session_action, stop_session_action_from_buffer),
+ "Serialized and de-serialized stop_session action are equal");
lttng_rate_policy_destroy(default_policy);
lttng_rate_policy_destroy(policy);
snapshot_session_action = lttng_action_snapshot_session_create();
ok(snapshot_session_action, "Create snapshot_session action");
- ok(lttng_action_get_type(snapshot_session_action) ==
- LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
- "Action has type LTTNG_ACTION_TYPE_SNAPSHOT_SESSION");
+ ok(lttng_action_get_type(snapshot_session_action) == LTTNG_ACTION_TYPE_SNAPSHOT_SESSION,
+ "Action has type LTTNG_ACTION_TYPE_SNAPSHOT_SESSION");
/* Session name setter. */
status = lttng_action_snapshot_session_set_session_name(NULL, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,NULL) expect invalid");
- status = lttng_action_snapshot_session_set_session_name(
- snapshot_session_action, NULL);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (object,NULL) expect invalid");
- status = lttng_action_snapshot_session_set_session_name(
- NULL, session_name);
- ok(status == LTTNG_ACTION_STATUS_INVALID,
- "Set session name (NULL,object) expect invalid");
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,NULL) expect invalid");
+ status = lttng_action_snapshot_session_set_session_name(snapshot_session_action, NULL);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (object,NULL) expect invalid");
+ status = lttng_action_snapshot_session_set_session_name(NULL, session_name);
+ ok(status == LTTNG_ACTION_STATUS_INVALID, "Set session name (NULL,object) expect invalid");
/* Set the session name */
- status = lttng_action_snapshot_session_set_session_name(
- snapshot_session_action, session_name);
+ status = lttng_action_snapshot_session_set_session_name(snapshot_session_action,
+ session_name);
ok(status == LTTNG_ACTION_STATUS_OK, "Set session name");
- status = lttng_action_snapshot_session_get_session_name(
- snapshot_session_action, &get_session_name);
- ok(status == LTTNG_ACTION_STATUS_OK &&
- !strcmp(session_name, get_session_name),
- "Get session name, expected `%s` got `%s`",
- session_name, get_session_name);
+ status = lttng_action_snapshot_session_get_session_name(snapshot_session_action,
+ &get_session_name);
+ ok(status == LTTNG_ACTION_STATUS_OK && !strcmp(session_name, get_session_name),
+ "Get session name, expected `%s` got `%s`",
+ session_name,
+ get_session_name);
/* Validate the default policy for a snapshot_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_snapshot_session_get_rate_policy(
- snapshot_session_action, &cur_policy);
+ status = lttng_action_snapshot_session_get_rate_policy(snapshot_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- default_policy,
- cur_policy),
- "Default policy is every n=1");
+ lttng_rate_policy_is_equal(default_policy, cur_policy),
+ "Default policy is every n=1");
}
/* Set a custom policy. */
- status = lttng_action_snapshot_session_set_rate_policy(
- snapshot_session_action, policy);
+ status = lttng_action_snapshot_session_set_rate_policy(snapshot_session_action, policy);
ok(status == LTTNG_ACTION_STATUS_OK, "Set rate policy");
/* Validate the custom policy for a snapshot_session action. */
{
const struct lttng_rate_policy *cur_policy = NULL;
- status = lttng_action_snapshot_session_get_rate_policy(
- snapshot_session_action, &cur_policy);
+ status = lttng_action_snapshot_session_get_rate_policy(snapshot_session_action,
+ &cur_policy);
ok(status == LTTNG_ACTION_STATUS_OK &&
- lttng_rate_policy_is_equal(
- policy,
- cur_policy),
- "snapshot_session action policy get");
+ lttng_rate_policy_is_equal(policy, cur_policy),
+ "snapshot_session action policy get");
}
/* Ser/des tests. */
ok(ret == 0, "Action snapshot_session serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- (void) lttng_action_create_from_payload(
- &view, &snapshot_session_action_from_buffer);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ (void) lttng_action_create_from_payload(&view,
+ &snapshot_session_action_from_buffer);
}
ok(snapshot_session_action_from_buffer,
- "snapshot_session action created from payload is non-null");
+ "snapshot_session action created from payload is non-null");
- ok(lttng_action_is_equal(snapshot_session_action,
- snapshot_session_action_from_buffer),
- "Serialized and de-serialized snapshot_session action are equal");
+ ok(lttng_action_is_equal(snapshot_session_action, snapshot_session_action_from_buffer),
+ "Serialized and de-serialized snapshot_session action are equal");
lttng_rate_policy_destroy(default_policy);
lttng_rate_policy_destroy(policy);
*
*/
-
#include <common/buffer-view.hpp>
+
#include <tap/tap.h>
static const int TEST_COUNT = 5;
static void test_contains_string(void)
{
- const char buf[] = {'A', 'l', 'l', 'o', '\0'};
+ const char buf[] = { 'A', 'l', 'l', 'o', '\0' };
struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5);
- struct lttng_buffer_view view_minus_one =
- lttng_buffer_view_init(buf, 0, 4);
+ struct lttng_buffer_view view_minus_one = lttng_buffer_view_init(buf, 0, 4);
ok1(!lttng_buffer_view_contains_string(&view, buf, 4));
ok1(lttng_buffer_view_contains_string(&view, buf, 5));
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-buffer.hpp>
-#include <lttng/event.h>
-#include <lttng/event-rule/user-tracepoint.h>
#include <lttng/condition/condition-internal.hpp>
-#include <lttng/condition/event-rule-matches.h>
#include <lttng/condition/event-rule-matches-internal.hpp>
+#include <lttng/condition/event-rule-matches.h>
#include <lttng/domain.h>
+#include <lttng/event-rule/user-tracepoint.h>
+#include <lttng/event.h>
#include <lttng/log-level-rule.h>
-#include <common/dynamic-buffer.hpp>
-#include <common/buffer-view.hpp>
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
/* For error.h */
int lttng_opt_quiet = 1;
#define NUM_TESTS 13
-static
-void test_condition_event_rule(void)
+static void test_condition_event_rule(void)
{
int ret, i;
struct lttng_event_rule *tracepoint = NULL;
struct lttng_condition *condition = NULL;
struct lttng_condition *condition_from_buffer = NULL;
enum lttng_condition_status condition_status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *exclusions[] = { "my_event_test1", "my_event_test2", "my_event_test3" };
struct lttng_log_level_rule *log_level_rule_at_least_as_severe = NULL;
struct lttng_payload buffer;
/* Create log level rule. */
log_level_rule_at_least_as_severe =
- lttng_log_level_rule_at_least_as_severe_as_create(
- LTTNG_LOGLEVEL_WARNING);
+ lttng_log_level_rule_at_least_as_severe_as_create(LTTNG_LOGLEVEL_WARNING);
LTTNG_ASSERT(log_level_rule_at_least_as_severe);
tracepoint = lttng_event_rule_user_tracepoint_create();
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Setting filter");
status = lttng_event_rule_user_tracepoint_set_log_level_rule(
- tracepoint, log_level_rule_at_least_as_severe);
+ tracepoint, log_level_rule_at_least_as_severe);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Setting log level range");
for (i = 0; i < 3; i++) {
- status = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(
- tracepoint, exclusions[i]);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting exclusion pattern");
+ status = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(tracepoint,
+ exclusions[i]);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Setting exclusion pattern");
}
condition = lttng_condition_event_rule_matches_create(tracepoint);
ok(condition, "Created condition");
- condition_status = lttng_condition_event_rule_matches_get_rule(
- condition, &tracepoint_tmp);
+ condition_status = lttng_condition_event_rule_matches_get_rule(condition, &tracepoint_tmp);
ok(condition_status == LTTNG_CONDITION_STATUS_OK,
- "Getting event rule from event rule condition");
- ok(tracepoint == tracepoint_tmp, "lttng_condition_event_rule_get_rule provides a reference to the original rule");
+ "Getting event rule from event rule condition");
+ ok(tracepoint == tracepoint_tmp,
+ "lttng_condition_event_rule_get_rule provides a reference to the original rule");
ret = lttng_condition_serialize(condition, &buffer);
ok(ret == 0, "Condition serialized");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(&buffer, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&buffer, 0, -1);
- (void) lttng_condition_create_from_payload(
- &view, &condition_from_buffer);
+ (void) lttng_condition_create_from_payload(&view, &condition_from_buffer);
}
ok(condition_from_buffer, "Condition created from payload is non-null");
ok(lttng_condition_is_equal(condition, condition_from_buffer),
- "Serialized and de-serialized conditions are equal");
+ "Serialized and de-serialized conditions are equal");
lttng_payload_reset(&buffer);
lttng_event_rule_destroy(tracepoint);
*
*/
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
+
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <unistd.h>
-
-#include <common/compat/directory-handle.hpp>
-#include <common/compat/errno.hpp>
-#include <common/error.hpp>
#include <tap/tap.h>
+#include <unistd.h>
#define TEST_COUNT 9
* ├── f
* └── file1
*/
-static int create_non_empty_hierarchy_with_root(
- struct lttng_directory_handle *test_dir_handle,
- const char *test_root_name)
+static int create_non_empty_hierarchy_with_root(struct lttng_directory_handle *test_dir_handle,
+ const char *test_root_name)
{
int ret;
const int file_flags = O_WRONLY | O_CREAT | O_TRUNC;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive(
- test_dir_handle,
- branch_name,
- DIR_CREATION_MODE);
+ test_dir_handle, branch_name, DIR_CREATION_MODE);
if (ret) {
diag("Failed to create test folder hierarchy %s", branch_name);
goto end;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive(
- test_dir_handle,
- branch_name,
- DIR_CREATION_MODE);
+ test_dir_handle, branch_name, DIR_CREATION_MODE);
if (ret) {
diag("Failed to create test folder hierarchy %s", branch_name);
goto end;
diag("Failed to format file path");
goto end;
}
- ret = lttng_directory_handle_open_file(
- test_dir_handle, branch_name, file_flags, file_mode);
+ ret = lttng_directory_handle_open_file(test_dir_handle, branch_name, file_flags, file_mode);
if (ret < 0) {
diag("Failed to create file %s", branch_name);
goto end;
}
ret = close(ret);
if (ret) {
- PERROR("Failed to close fd to newly created file %s",
- branch_name);
+ PERROR("Failed to close fd to newly created file %s", branch_name);
goto end;
}
end:
}
/* Remove "file1" from the test folder hierarchy. */
-static
-int remove_file_from_hierarchy(struct lttng_directory_handle *test_dir_handle,
- const char *test_root_name)
+static int remove_file_from_hierarchy(struct lttng_directory_handle *test_dir_handle,
+ const char *test_root_name)
{
int ret;
char *file_name = NULL;
goto end;
}
- ret = lttng_directory_handle_unlink_file(test_dir_handle,
- file_name);
+ ret = lttng_directory_handle_unlink_file(test_dir_handle, file_name);
if (ret) {
PERROR("Failed to unlink file %s", file_name);
goto end;
}
ret = lttng_directory_handle_remove_subdirectory_recursive(
- test_dir_handle, test_root_name,
- LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG);
- ok(ret == -1, "Error returned when attempting to recursively remove non-empty hierarchy with LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG");
+ test_dir_handle, test_root_name, LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG);
+ ok(ret == -1,
+ "Error returned when attempting to recursively remove non-empty hierarchy with LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG");
tests_ran++;
ret = remove_file_from_hierarchy(test_dir_handle, test_root_name);
}
ret = lttng_directory_handle_remove_subdirectory_recursive(
- test_dir_handle, test_root_name,
- LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG);
- ok(ret == 0, "No error returned when recursively removing empty hierarchy with LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG");
+ test_dir_handle, test_root_name, LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG);
+ ok(ret == 0,
+ "No error returned when recursively removing empty hierarchy with LTTNG_DIRECTORY_HANDLE_FAIL_NON_EMPTY_FLAG");
tests_ran++;
ret = asprintf(&test_dir_path, "%s/%s", test_dir, test_root_name);
goto end;
}
ok(!dir_exists(test_dir_path) && errno == ENOENT,
- "Folder hierarchy %s successfully removed",
- test_dir_path);
+ "Folder hierarchy %s successfully removed",
+ test_dir_path);
tests_ran++;
ret = 0;
end:
}
ret = lttng_directory_handle_remove_subdirectory_recursive(
- test_dir_handle, test_root_name,
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
- ok(ret == 0, "No error returned when attempting to recursively remove non-empty hierarchy with LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG");
+ test_dir_handle, test_root_name, LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ ok(ret == 0,
+ "No error returned when attempting to recursively remove non-empty hierarchy with LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG");
tests_ran++;
ret = asprintf(&test_dir_path, "%s/%s", test_dir, test_root_name);
}
ret = lttng_directory_handle_remove_subdirectory_recursive(
- test_dir_handle, test_root_name,
- LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
- ok(ret == 0, "No error returned when recursively removing empty hierarchy with LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG");
+ test_dir_handle, test_root_name, LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG);
+ ok(ret == 0,
+ "No error returned when recursively removing empty hierarchy with LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG");
tests_ran++;
ok(!dir_exists(test_dir_path) && errno == ENOENT,
- "Folder hierarchy %s successfully removed",
- test_dir_path);
+ "Folder hierarchy %s successfully removed",
+ test_dir_path);
tests_ran++;
ret = 0;
end:
goto end;
}
- for (func_idx = 0; func_idx < sizeof(test_funcs) / sizeof(*test_funcs);
- func_idx++) {
+ for (func_idx = 0; func_idx < sizeof(test_funcs) / sizeof(*test_funcs); func_idx++) {
tests_left -= test_funcs[func_idx](test_dir);
}
if (tests_left) {
diag("Skipping %d tests that could not be executed due to a prior error",
- tests_left);
+ tests_left);
skip(tests_left, "test due to an error");
}
end:
*/
#include <common/bytecode/bytecode.hpp>
+
#include <lttng/event-expr-internal.hpp>
#include <lttng/event-expr.h>
+
#include <tap/tap.h>
#define NR_TESTS 4
-static
-void test_event_payload_field(void)
+static void test_event_payload_field(void)
{
struct lttng_event_expr *event_expr;
struct lttng_bytecode *bytecode = NULL;
free(bytecode);
}
-static
-void test_channel_context_field(void)
+static void test_channel_context_field(void)
{
struct lttng_event_expr *event_expr;
struct lttng_bytecode *bytecode = NULL;
free(bytecode);
}
-static
-void test_app_specific_context_field(void)
+static void test_app_specific_context_field(void)
{
struct lttng_event_expr *event_expr;
struct lttng_bytecode *bytecode = NULL;
free(bytecode);
}
-static
-void test_array_field_element(void)
+static void test_array_field_element(void)
{
struct lttng_event_expr *event_expr;
struct lttng_bytecode *bytecode = NULL;
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+#include "bin/lttng/loglevel.hpp"
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/domain.h>
#include <lttng/event-rule/jul-logging-internal.hpp>
#include <lttng/event-rule/jul-logging.h>
#include <lttng/event-rule/kernel-kprobe.h>
#include <lttng/event-rule/kernel-syscall-internal.hpp>
#include <lttng/event-rule/kernel-syscall.h>
-#include <lttng/event-rule/python-logging-internal.hpp>
-#include <lttng/event-rule/python-logging.h>
#include <lttng/event-rule/kernel-tracepoint-internal.hpp>
#include <lttng/event-rule/kernel-tracepoint.h>
#include <lttng/event-rule/kernel-uprobe-internal.hpp>
#include <lttng/event-rule/kernel-uprobe.h>
+#include <lttng/event-rule/python-logging-internal.hpp>
+#include <lttng/event-rule/python-logging.h>
#include <lttng/event-rule/user-tracepoint-internal.hpp>
#include <lttng/event-rule/user-tracepoint.h>
#include <lttng/event.h>
#include <lttng/kernel-probe.h>
#include <lttng/userspace-probe-internal.hpp>
#include <lttng/userspace-probe.h>
-#include "bin/lttng/loglevel.hpp"
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
#include <tap/tap.h>
+#include <unistd.h>
/* For error.h. */
int lttng_opt_quiet = 1;
typedef struct lttng_event_rule *(*event_rule_create)(void);
typedef enum lttng_event_rule_status (*event_rule_set_log_level)(
- struct lttng_event_rule *rule,
- const struct lttng_log_level_rule *log_level_rule);
+ struct lttng_event_rule *rule, const struct lttng_log_level_rule *log_level_rule);
-static
-void test_event_rule_kernel_tracepoint(void)
+static void test_event_rule_kernel_tracepoint(void)
{
struct lttng_event_rule *tracepoint = NULL;
struct lttng_event_rule *tracepoint_from_buffer = NULL;
enum lttng_event_rule_status status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
struct lttng_payload payload;
ok(lttng_event_rule_serialize(tracepoint, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &tracepoint_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &tracepoint_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_event_rule_is_equal(tracepoint, tracepoint_from_buffer), "serialized and from buffer are equal.");
+ ok(lttng_event_rule_is_equal(tracepoint, tracepoint_from_buffer),
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(tracepoint);
lttng_event_rule_destroy(tracepoint_from_buffer);
}
-static
-void test_event_rule_user_tracepoint(void)
+static void test_event_rule_user_tracepoint(void)
{
int i;
unsigned int count;
struct lttng_event_rule *tracepoint = NULL;
struct lttng_event_rule *tracepoint_from_buffer = NULL;
enum lttng_event_rule_status status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
- const char *name_pattern_exclusions[] = {"my_event_test1", "my_event_test2" ,"my_event_test3"};
+ const char *name_pattern_exclusions[] = { "my_event_test1",
+ "my_event_test2",
+ "my_event_test3" };
struct lttng_log_level_rule *log_level_rule = NULL;
const struct lttng_log_level_rule *log_level_rule_return = NULL;
struct lttng_payload payload;
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting filter.");
ok(!strncmp(filter, tmp, strlen(filter)), "filter is equal.");
- status = lttng_event_rule_user_tracepoint_get_log_level_rule(tracepoint, &log_level_rule_return);
+ status = lttng_event_rule_user_tracepoint_get_log_level_rule(tracepoint,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_UNSET, "get unset log level rule.");
- status = lttng_event_rule_user_tracepoint_set_log_level_rule(
- tracepoint, log_level_rule);
+ status = lttng_event_rule_user_tracepoint_set_log_level_rule(tracepoint, log_level_rule);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting log level rule.");
- status = lttng_event_rule_user_tracepoint_get_log_level_rule(
- tracepoint, &log_level_rule_return);
+ status = lttng_event_rule_user_tracepoint_get_log_level_rule(tracepoint,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "get log level rule.");
/* Name pattern exclusions */
for (i = 0; i < 3; i++) {
status = lttng_event_rule_user_tracepoint_add_name_pattern_exclusion(
- tracepoint, name_pattern_exclusions[i]);
+ tracepoint, name_pattern_exclusions[i]);
ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "setting name pattern exclusions \"%s\"",
- name_pattern_exclusions[i]);
+ "setting name pattern exclusions \"%s\"",
+ name_pattern_exclusions[i]);
}
- status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
- tracepoint, &count);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "getting name pattern exclusion count.");
+ status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(tracepoint,
+ &count);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting name pattern exclusion count.");
ok(count == 3, "count is %d/3", count);
for (i = 0; i < count; i++) {
status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
- tracepoint, i, &tmp);
+ tracepoint, i, &tmp);
ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "getting name pattern exclusion at index %d.",
- i);
- ok(!strncmp(name_pattern_exclusions[i], tmp,
- strlen(name_pattern_exclusions[i])),
- "%s == %s.", tmp, name_pattern_exclusions[i]);
+ "getting name pattern exclusion at index %d.",
+ i);
+ ok(!strncmp(name_pattern_exclusions[i], tmp, strlen(name_pattern_exclusions[i])),
+ "%s == %s.",
+ tmp,
+ name_pattern_exclusions[i]);
}
ok(lttng_event_rule_serialize(tracepoint, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &tracepoint_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &tracepoint_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_event_rule_is_equal(tracepoint, tracepoint_from_buffer), "serialized and from buffer are equal.");
+ ok(lttng_event_rule_is_equal(tracepoint, tracepoint_from_buffer),
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(tracepoint);
lttng_payload_init(&payload);
- syscall = lttng_event_rule_kernel_syscall_create(LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
+ syscall = lttng_event_rule_kernel_syscall_create(
+ LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY);
ok(syscall, "syscall object.");
status = lttng_event_rule_kernel_syscall_set_name_pattern(syscall, pattern);
ok(lttng_event_rule_serialize(syscall, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &syscall_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &syscall_from_buffer) > 0,
+ "Deserializing.");
}
ok(lttng_event_rule_is_equal(syscall, syscall_from_buffer),
- "serialized and from buffer are equal.");
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(syscall);
lttng_event_rule_destroy(syscall_from_buffer);
}
-static
-void test_event_rule_jul_logging(void)
+static void test_event_rule_jul_logging(void)
{
struct lttng_event_rule *jul_logging = NULL;
struct lttng_event_rule *jul_logging_from_buffer = NULL;
enum lttng_event_rule_status status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
struct lttng_log_level_rule *log_level_rule = NULL;
const struct lttng_log_level_rule *log_level_rule_return = NULL;
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting filter.");
ok(!strncmp(filter, tmp, strlen(filter)), "filter is equal.");
- status = lttng_event_rule_jul_logging_get_log_level_rule(jul_logging, &log_level_rule_return);
+ status = lttng_event_rule_jul_logging_get_log_level_rule(jul_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_UNSET, "get unset log level rule.");
- status = lttng_event_rule_jul_logging_set_log_level_rule(
- jul_logging, log_level_rule);
+ status = lttng_event_rule_jul_logging_set_log_level_rule(jul_logging, log_level_rule);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting log level rule.");
- status = lttng_event_rule_jul_logging_get_log_level_rule(
- jul_logging, &log_level_rule_return);
+ status = lttng_event_rule_jul_logging_get_log_level_rule(jul_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "get log level rule.");
ok(lttng_event_rule_serialize(jul_logging, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &jul_logging_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &jul_logging_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_event_rule_is_equal(jul_logging, jul_logging_from_buffer), "serialized and from buffer are equal.");
+ ok(lttng_event_rule_is_equal(jul_logging, jul_logging_from_buffer),
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(jul_logging);
lttng_log_level_rule_destroy(log_level_rule);
}
-static
-void test_event_rule_log4j_logging(void)
+static void test_event_rule_log4j_logging(void)
{
struct lttng_event_rule *log4j_logging = NULL;
struct lttng_event_rule *log4j_logging_from_buffer = NULL;
enum lttng_event_rule_status status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
struct lttng_log_level_rule *log_level_rule = NULL;
const struct lttng_log_level_rule *log_level_rule_return = NULL;
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting filter.");
ok(!strncmp(filter, tmp, strlen(filter)), "filter is equal.");
- status = lttng_event_rule_log4j_logging_get_log_level_rule(log4j_logging, &log_level_rule_return);
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(log4j_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_UNSET, "get unset log level rule.");
- status = lttng_event_rule_log4j_logging_set_log_level_rule(
- log4j_logging, log_level_rule);
+ status = lttng_event_rule_log4j_logging_set_log_level_rule(log4j_logging, log_level_rule);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting log level rule.");
- status = lttng_event_rule_log4j_logging_get_log_level_rule(
- log4j_logging, &log_level_rule_return);
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(log4j_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "get log level rule.");
ok(lttng_event_rule_serialize(log4j_logging, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &log4j_logging_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &log4j_logging_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_event_rule_is_equal(log4j_logging, log4j_logging_from_buffer), "serialized and from buffer are equal.");
+ ok(lttng_event_rule_is_equal(log4j_logging, log4j_logging_from_buffer),
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(log4j_logging);
lttng_log_level_rule_destroy(log_level_rule);
}
-static
-void test_event_rule_python_logging(void)
+static void test_event_rule_python_logging(void)
{
struct lttng_event_rule *python_logging = NULL;
struct lttng_event_rule *python_logging_from_buffer = NULL;
enum lttng_event_rule_status status;
- const char *pattern="my_event_*";
- const char *filter="msg_id == 23 && size >= 2048";
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
const char *tmp;
struct lttng_log_level_rule *log_level_rule = NULL;
const struct lttng_log_level_rule *log_level_rule_return = NULL;
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting filter.");
ok(!strncmp(filter, tmp, strlen(filter)), "filter is equal.");
- status = lttng_event_rule_python_logging_get_log_level_rule(python_logging, &log_level_rule_return);
+ status = lttng_event_rule_python_logging_get_log_level_rule(python_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_UNSET, "get unset log level rule.");
- status = lttng_event_rule_python_logging_set_log_level_rule(
- python_logging, log_level_rule);
+ status = lttng_event_rule_python_logging_set_log_level_rule(python_logging, log_level_rule);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting log level rule.");
- status = lttng_event_rule_python_logging_get_log_level_rule(
- python_logging, &log_level_rule_return);
+ status = lttng_event_rule_python_logging_get_log_level_rule(python_logging,
+ &log_level_rule_return);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "get log level rule.");
ok(lttng_event_rule_serialize(python_logging, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &python_logging_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &python_logging_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_event_rule_is_equal(python_logging, python_logging_from_buffer), "serialized and from buffer are equal.");
+ ok(lttng_event_rule_is_equal(python_logging, python_logging_from_buffer),
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(python_logging);
{
struct lttng_event_rule *uprobe = NULL;
struct lttng_event_rule *uprobe_from_buffer = NULL;
- struct lttng_userspace_probe_location_lookup_method *lookup_method =
- NULL;
+ struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL;
struct lttng_userspace_probe_location *probe_location = NULL;
const struct lttng_userspace_probe_location *probe_location_tmp = NULL;
enum lttng_event_rule_status status;
}
probe_location = lttng_userspace_probe_location_function_create(
- "/proc/self/exe",
- "lttng_userspace_probe_location_tracepoint_create",
- lookup_method);
+ "/proc/self/exe",
+ "lttng_userspace_probe_location_tracepoint_create",
+ lookup_method);
if (!probe_location) {
fail("Setup error on userspace probe location creation.");
goto end;
uprobe = lttng_event_rule_kernel_uprobe_create(probe_location);
ok(uprobe, "uprobe event rule object creation.");
- status = lttng_event_rule_kernel_uprobe_get_location(
- uprobe, &probe_location_tmp);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "Getting uprobe event rule location.");
- ok(lttng_userspace_probe_location_is_equal(
- probe_location, probe_location_tmp),
- "Location is equal.");
+ status = lttng_event_rule_kernel_uprobe_get_location(uprobe, &probe_location_tmp);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting uprobe event rule location.");
+ ok(lttng_userspace_probe_location_is_equal(probe_location, probe_location_tmp),
+ "Location is equal.");
status = lttng_event_rule_kernel_uprobe_set_event_name(uprobe, probe_name);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting uprobe event rule name: %s.", probe_name);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Setting uprobe event rule name: %s.", probe_name);
status = lttng_event_rule_kernel_uprobe_get_event_name(uprobe, &tmp);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting uprobe name.");
ok(!strcmp(probe_name, tmp), "Uprobe name are equal.");
ok(lttng_event_rule_serialize(uprobe, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &uprobe_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &uprobe_from_buffer) > 0,
+ "Deserializing.");
}
ok(lttng_event_rule_is_equal(uprobe, uprobe_from_buffer),
- "serialized and from buffer are equal.");
+ "serialized and from buffer are equal.");
end:
lttng_payload_reset(&payload);
lttng_userspace_probe_location_lookup_method_destroy(lookup_method);
}
#else
-static void test_event_rule_userspace_probe(void) {}
+static void test_event_rule_userspace_probe(void)
+{
+}
#endif
-static void test_event_rule_kernel_probe_by_location(
- const struct lttng_kernel_probe_location *location)
+static void
+test_event_rule_kernel_probe_by_location(const struct lttng_kernel_probe_location *location)
{
struct lttng_event_rule *kprobe = NULL;
struct lttng_event_rule *kprobe_from_buffer = NULL;
struct lttng_payload payload;
diag("Event rule kprobe for location type %d.",
- lttng_kernel_probe_location_get_type(location));
+ lttng_kernel_probe_location_get_type(location));
lttng_payload_init(&payload);
ok(kprobe, "kprobe event rule object creation.");
status = lttng_event_rule_kernel_kprobe_get_location(kprobe, &_location);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "Getting kprobe event rule location.");
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting kprobe event rule location.");
ok(lttng_kernel_probe_location_is_equal(location, _location), "Locations are equal.");
status = lttng_event_rule_kernel_kprobe_set_event_name(kprobe, probe_name);
- ok(status == LTTNG_EVENT_RULE_STATUS_OK,
- "Setting kprobe event rule name: %s.", probe_name);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Setting kprobe event rule name: %s.", probe_name);
status = lttng_event_rule_kernel_kprobe_get_event_name(kprobe, &tmp);
ok(status == LTTNG_EVENT_RULE_STATUS_OK, "Getting kprobe name.");
ok(!strcmp(probe_name, tmp), "kprobe name are equal.");
ok(lttng_event_rule_serialize(kprobe, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_event_rule_create_from_payload(
- &view, &kprobe_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_event_rule_create_from_payload(&view, &kprobe_from_buffer) > 0,
+ "Deserializing.");
}
ok(lttng_event_rule_is_equal(kprobe, kprobe_from_buffer),
- "serialized and from buffer are equal.");
+ "serialized and from buffer are equal.");
lttng_payload_reset(&payload);
lttng_event_rule_destroy(kprobe);
lttng_kernel_probe_location_destroy(symbol_location);
}
-static void test_set_event_rule_log_level_rules(
- struct lttng_event_rule *event_rule,
- event_rule_set_log_level set_log_level,
- int log_level,
- enum lttng_event_rule_status *exactly_status,
- enum lttng_event_rule_status *as_severe_status)
+static void test_set_event_rule_log_level_rules(struct lttng_event_rule *event_rule,
+ event_rule_set_log_level set_log_level,
+ int log_level,
+ enum lttng_event_rule_status *exactly_status,
+ enum lttng_event_rule_status *as_severe_status)
{
struct lttng_log_level_rule *log_level_rule;
- log_level_rule = lttng_log_level_rule_at_least_as_severe_as_create(
- log_level);
+ log_level_rule = lttng_log_level_rule_at_least_as_severe_as_create(log_level);
LTTNG_ASSERT(log_level_rule);
- *as_severe_status = set_log_level(
- event_rule, log_level_rule);
+ *as_severe_status = set_log_level(event_rule, log_level_rule);
lttng_log_level_rule_destroy(log_level_rule);
log_level_rule = lttng_log_level_rule_exactly_create(log_level);
LTTNG_ASSERT(log_level_rule);
- *exactly_status = set_log_level(
- event_rule, log_level_rule);
+ *exactly_status = set_log_level(event_rule, log_level_rule);
lttng_log_level_rule_destroy(log_level_rule);
}
static void test_event_rule_log_level_generic(enum lttng_event_rule_type event_rule_type,
- log_level_name_getter get_log_level_name,
- event_rule_create create_event_rule,
- event_rule_set_log_level set_log_level,
- const int tagged_log_level_values[],
- size_t tagged_log_level_values_count,
- const int valid_log_level_values[],
- size_t valid_log_level_values_count,
- const int invalid_log_level_values[],
- size_t invalid_log_level_values_count)
+ log_level_name_getter get_log_level_name,
+ event_rule_create create_event_rule,
+ event_rule_set_log_level set_log_level,
+ const int tagged_log_level_values[],
+ size_t tagged_log_level_values_count,
+ const int valid_log_level_values[],
+ size_t valid_log_level_values_count,
+ const int invalid_log_level_values[],
+ size_t invalid_log_level_values_count)
{
size_t i;
struct lttng_event_rule *rule;
enum lttng_event_rule_status er_exactly_status, er_as_severe_status;
const char *event_rule_type_str = lttng_event_rule_type_str(event_rule_type);
-
diag("Test %s event rule + log level rule", event_rule_type_str);
rule = create_event_rule();
for (i = 0; i < tagged_log_level_values_count; i++) {
const int tagged_log_level_value = tagged_log_level_values[i];
- test_set_event_rule_log_level_rules(rule, set_log_level,
- tagged_log_level_value,
- &er_exactly_status, &er_as_severe_status);
+ test_set_event_rule_log_level_rules(rule,
+ set_log_level,
+ tagged_log_level_value,
+ &er_exactly_status,
+ &er_as_severe_status);
ok(er_exactly_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Log level rule \"exactly\" accepted by %s event rule: level = %s",
- event_rule_type_str,
- get_log_level_name(
- tagged_log_level_value));
+ "Log level rule \"exactly\" accepted by %s event rule: level = %s",
+ event_rule_type_str,
+ get_log_level_name(tagged_log_level_value));
ok(er_as_severe_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Log level rule \"as least as severe as\" accepted by %s event rule: level = %s",
- event_rule_type_str,
- get_log_level_name(
- tagged_log_level_value));
+ "Log level rule \"as least as severe as\" accepted by %s event rule: level = %s",
+ event_rule_type_str,
+ get_log_level_name(tagged_log_level_value));
}
for (i = 0; i < valid_log_level_values_count; i++) {
const int valid_log_level_value = valid_log_level_values[i];
- test_set_event_rule_log_level_rules(rule, set_log_level,
- valid_log_level_value,
- &er_exactly_status, &er_as_severe_status);
+ test_set_event_rule_log_level_rules(rule,
+ set_log_level,
+ valid_log_level_value,
+ &er_exactly_status,
+ &er_as_severe_status);
ok(er_exactly_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Log level rule \"exactly\" accepted by %s event rule: level = %d",
- event_rule_type_str,
- valid_log_level_value);
+ "Log level rule \"exactly\" accepted by %s event rule: level = %d",
+ event_rule_type_str,
+ valid_log_level_value);
ok(er_as_severe_status == LTTNG_EVENT_RULE_STATUS_OK,
- "Log level rule \"as least as severe as\" accepted by %s event rule: level = %d",
- event_rule_type_str,
- valid_log_level_value);
+ "Log level rule \"as least as severe as\" accepted by %s event rule: level = %d",
+ event_rule_type_str,
+ valid_log_level_value);
}
for (i = 0; i < invalid_log_level_values_count; i++) {
const int invalid_log_level_value = invalid_log_level_values[i];
- test_set_event_rule_log_level_rules(rule, set_log_level,
- invalid_log_level_value,
- &er_exactly_status, &er_as_severe_status);
+ test_set_event_rule_log_level_rules(rule,
+ set_log_level,
+ invalid_log_level_value,
+ &er_exactly_status,
+ &er_as_severe_status);
ok(er_exactly_status == LTTNG_EVENT_RULE_STATUS_INVALID,
- "Log level rule \"exactly\" rejected by %s event rule: level = %d",
- event_rule_type_str,
- invalid_log_level_value);
+ "Log level rule \"exactly\" rejected by %s event rule: level = %d",
+ event_rule_type_str,
+ invalid_log_level_value);
ok(er_as_severe_status == LTTNG_EVENT_RULE_STATUS_INVALID,
- "Log level rule \"as least as severe as\" rejected by %s event rule: level = %d",
- event_rule_type_str,
- invalid_log_level_value);
+ "Log level rule \"as least as severe as\" rejected by %s event rule: level = %d",
+ event_rule_type_str,
+ invalid_log_level_value);
}
lttng_event_rule_destroy(rule);
static void test_event_rule_log_level_ust(void)
{
const int tagged_log_level_values[] = {
- LTTNG_LOGLEVEL_EMERG,
- LTTNG_LOGLEVEL_ALERT,
- LTTNG_LOGLEVEL_CRIT,
- LTTNG_LOGLEVEL_ERR,
- LTTNG_LOGLEVEL_WARNING,
- LTTNG_LOGLEVEL_NOTICE,
- LTTNG_LOGLEVEL_INFO,
- LTTNG_LOGLEVEL_DEBUG_SYSTEM,
- LTTNG_LOGLEVEL_DEBUG_PROGRAM,
- LTTNG_LOGLEVEL_DEBUG_PROCESS,
- LTTNG_LOGLEVEL_DEBUG_MODULE,
- LTTNG_LOGLEVEL_DEBUG_UNIT,
- LTTNG_LOGLEVEL_DEBUG_FUNCTION,
- LTTNG_LOGLEVEL_DEBUG_LINE,
+ LTTNG_LOGLEVEL_EMERG, LTTNG_LOGLEVEL_ALERT,
+ LTTNG_LOGLEVEL_CRIT, LTTNG_LOGLEVEL_ERR,
+ LTTNG_LOGLEVEL_WARNING, LTTNG_LOGLEVEL_NOTICE,
+ LTTNG_LOGLEVEL_INFO, LTTNG_LOGLEVEL_DEBUG_SYSTEM,
+ LTTNG_LOGLEVEL_DEBUG_PROGRAM, LTTNG_LOGLEVEL_DEBUG_PROCESS,
+ LTTNG_LOGLEVEL_DEBUG_MODULE, LTTNG_LOGLEVEL_DEBUG_UNIT,
+ LTTNG_LOGLEVEL_DEBUG_FUNCTION, LTTNG_LOGLEVEL_DEBUG_LINE,
LTTNG_LOGLEVEL_DEBUG,
};
const int invalid_log_level_values[] = {
};
test_event_rule_log_level_generic(LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT,
- loglevel_value_to_name,
- lttng_event_rule_user_tracepoint_create,
- lttng_event_rule_user_tracepoint_set_log_level_rule,
- tagged_log_level_values,
- ARRAY_SIZE(tagged_log_level_values), NULL, 0,
- invalid_log_level_values,
- ARRAY_SIZE(invalid_log_level_values));
+ loglevel_value_to_name,
+ lttng_event_rule_user_tracepoint_create,
+ lttng_event_rule_user_tracepoint_set_log_level_rule,
+ tagged_log_level_values,
+ ARRAY_SIZE(tagged_log_level_values),
+ NULL,
+ 0,
+ invalid_log_level_values,
+ ARRAY_SIZE(invalid_log_level_values));
}
static void test_event_rule_log_level_jul(void)
{
const int tagged_log_level_values[] = {
- LTTNG_LOGLEVEL_JUL_OFF,
- LTTNG_LOGLEVEL_JUL_SEVERE,
- LTTNG_LOGLEVEL_JUL_WARNING,
- LTTNG_LOGLEVEL_JUL_INFO,
- LTTNG_LOGLEVEL_JUL_CONFIG,
- LTTNG_LOGLEVEL_JUL_FINE,
- LTTNG_LOGLEVEL_JUL_FINER,
- LTTNG_LOGLEVEL_JUL_FINEST,
- LTTNG_LOGLEVEL_JUL_ALL,
- };
- const int valid_log_level_values[] = {
- 0,
- -1980,
- 1995
+ LTTNG_LOGLEVEL_JUL_OFF, LTTNG_LOGLEVEL_JUL_SEVERE, LTTNG_LOGLEVEL_JUL_WARNING,
+ LTTNG_LOGLEVEL_JUL_INFO, LTTNG_LOGLEVEL_JUL_CONFIG, LTTNG_LOGLEVEL_JUL_FINE,
+ LTTNG_LOGLEVEL_JUL_FINER, LTTNG_LOGLEVEL_JUL_FINEST, LTTNG_LOGLEVEL_JUL_ALL,
};
+ const int valid_log_level_values[] = { 0, -1980, 1995 };
test_event_rule_log_level_generic(LTTNG_EVENT_RULE_TYPE_JUL_LOGGING,
- loglevel_jul_value_to_name,
- lttng_event_rule_jul_logging_create,
- lttng_event_rule_jul_logging_set_log_level_rule,
- tagged_log_level_values,
- ARRAY_SIZE(tagged_log_level_values),
- valid_log_level_values,
- ARRAY_SIZE(valid_log_level_values), NULL, 0);
+ loglevel_jul_value_to_name,
+ lttng_event_rule_jul_logging_create,
+ lttng_event_rule_jul_logging_set_log_level_rule,
+ tagged_log_level_values,
+ ARRAY_SIZE(tagged_log_level_values),
+ valid_log_level_values,
+ ARRAY_SIZE(valid_log_level_values),
+ NULL,
+ 0);
}
static void test_event_rule_log_level_log4j(void)
{
const int tagged_log_level_values[] = {
- LTTNG_LOGLEVEL_LOG4J_OFF,
- LTTNG_LOGLEVEL_LOG4J_FATAL,
- LTTNG_LOGLEVEL_LOG4J_ERROR,
- LTTNG_LOGLEVEL_LOG4J_WARN,
- LTTNG_LOGLEVEL_LOG4J_INFO,
- LTTNG_LOGLEVEL_LOG4J_DEBUG,
- LTTNG_LOGLEVEL_LOG4J_TRACE,
- LTTNG_LOGLEVEL_LOG4J_ALL,
- };
- const int valid_log_level_values[] = {
- 0
- -1980,
- 1995
+ LTTNG_LOGLEVEL_LOG4J_OFF, LTTNG_LOGLEVEL_LOG4J_FATAL, LTTNG_LOGLEVEL_LOG4J_ERROR,
+ LTTNG_LOGLEVEL_LOG4J_WARN, LTTNG_LOGLEVEL_LOG4J_INFO, LTTNG_LOGLEVEL_LOG4J_DEBUG,
+ LTTNG_LOGLEVEL_LOG4J_TRACE, LTTNG_LOGLEVEL_LOG4J_ALL,
};
+ const int valid_log_level_values[] = { 0 - 1980, 1995 };
test_event_rule_log_level_generic(LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING,
- loglevel_log4j_value_to_name,
- lttng_event_rule_log4j_logging_create,
- lttng_event_rule_log4j_logging_set_log_level_rule,
- tagged_log_level_values,
- ARRAY_SIZE(tagged_log_level_values),
- valid_log_level_values,
- ARRAY_SIZE(valid_log_level_values), NULL, 0);
+ loglevel_log4j_value_to_name,
+ lttng_event_rule_log4j_logging_create,
+ lttng_event_rule_log4j_logging_set_log_level_rule,
+ tagged_log_level_values,
+ ARRAY_SIZE(tagged_log_level_values),
+ valid_log_level_values,
+ ARRAY_SIZE(valid_log_level_values),
+ NULL,
+ 0);
}
static void test_event_rule_log_level_python(void)
{
const int tagged_log_level_values[] = {
- LTTNG_LOGLEVEL_PYTHON_CRITICAL,
- LTTNG_LOGLEVEL_PYTHON_ERROR,
- LTTNG_LOGLEVEL_PYTHON_WARNING,
- LTTNG_LOGLEVEL_PYTHON_INFO,
- LTTNG_LOGLEVEL_PYTHON_DEBUG,
- LTTNG_LOGLEVEL_PYTHON_NOTSET,
+ LTTNG_LOGLEVEL_PYTHON_CRITICAL, LTTNG_LOGLEVEL_PYTHON_ERROR,
+ LTTNG_LOGLEVEL_PYTHON_WARNING, LTTNG_LOGLEVEL_PYTHON_INFO,
+ LTTNG_LOGLEVEL_PYTHON_DEBUG, LTTNG_LOGLEVEL_PYTHON_NOTSET,
};
const int valid_log_level_values[] = {
45,
};
test_event_rule_log_level_generic(LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING,
- loglevel_python_value_to_name,
- lttng_event_rule_python_logging_create,
- lttng_event_rule_python_logging_set_log_level_rule,
- tagged_log_level_values,
- ARRAY_SIZE(tagged_log_level_values),
- valid_log_level_values,
- ARRAY_SIZE(valid_log_level_values),
- NULL, 0);
+ loglevel_python_value_to_name,
+ lttng_event_rule_python_logging_create,
+ lttng_event_rule_python_logging_set_log_level_rule,
+ tagged_log_level_values,
+ ARRAY_SIZE(tagged_log_level_values),
+ valid_log_level_values,
+ ARRAY_SIZE(valid_log_level_values),
+ NULL,
+ 0);
}
int main(void)
*
*/
-#include <stdlib.h>
+#include <common/compat/directory-handle.hpp>
+#include <common/compat/errno.hpp>
+#include <common/error.hpp>
+#include <common/fd-tracker/fd-tracker.hpp>
+#include <common/fs-handle.hpp>
+
+#include <dirent.h>
+#include <fcntl.h>
#include <inttypes.h>
-#include <stdbool.h>
-#include <string.h>
#include <stdarg.h>
-#include <tap/tap.h>
-#include <sys/types.h>
-#include <dirent.h>
+#include <stdbool.h>
#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-
+#include <tap/tap.h>
+#include <unistd.h>
#include <urcu.h>
-#include <common/compat/directory-handle.hpp>
-#include <common/compat/errno.hpp>
-#include <common/error.hpp>
-#include <common/fs-handle.hpp>
-#include <common/fd-tracker/fd-tracker.hpp>
-
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
/* Number of TAP tests in this file */
#define NUM_TESTS 61
/* 3 for stdin, stdout, and stderr */
-#define STDIO_FD_COUNT 3
-#define TRACKER_FD_LIMIT 50
-#define TMP_DIR_PATTERN "/tmp/fd-tracker-XXXXXX"
+#define STDIO_FD_COUNT 3
+#define TRACKER_FD_LIMIT 50
+#define TMP_DIR_PATTERN "/tmp/fd-tracker-XXXXXX"
#define TEST_UNLINK_DIRECTORY_NAME "unlinked_files"
#ifdef __linux__
int unknown_fds_count;
const char file_contents[] = "Bacon ipsum dolor amet jerky drumstick sirloin "
- "strip steak venison boudin filet mignon picanha doner shoulder. "
- "Strip steak brisket alcatra, venison beef chuck cupim pastrami. "
- "Landjaeger tri-tip salami leberkas ball tip, ham hock chuck sausage "
- "flank jerky cupim. Pig bacon chuck pancetta andouille.";
+ "strip steak venison boudin filet mignon picanha doner shoulder. "
+ "Strip steak brisket alcatra, venison beef chuck cupim pastrami. "
+ "Landjaeger tri-tip salami leberkas ball tip, ham hock chuck sausage "
+ "flank jerky cupim. Pig bacon chuck pancetta andouille.";
-static
-void get_temporary_directories(char **_test_directory, char **_unlink_directory)
+static void get_temporary_directories(char **_test_directory, char **_unlink_directory)
{
int ret;
char tmp_path_pattern[] = TMP_DIR_PATTERN;
output_dir = mkdtemp(tmp_path_pattern);
if (!output_dir) {
- diag("Failed to create temporary path of the form %s",
- TMP_DIR_PATTERN);
+ diag("Failed to create temporary path of the form %s", TMP_DIR_PATTERN);
abort();
}
*_test_directory = strdup(output_dir);
LTTNG_ASSERT(*_test_directory);
- ret = asprintf(_unlink_directory, "%s/%s", output_dir,
- TEST_UNLINK_DIRECTORY_NAME);
+ ret = asprintf(_unlink_directory, "%s/%s", output_dir, TEST_UNLINK_DIRECTORY_NAME);
if (ret < 0) {
abort();
}
}
-static
-int fd_count(void)
+static int fd_count(void)
{
DIR *dir;
struct dirent *entry;
dir = opendir(SELF_FD_DIR);
if (!dir) {
- perror("# Failed to enumerate " SELF_FD_DIR " to count the number of used file descriptors");
+ perror("# Failed to enumerate " SELF_FD_DIR
+ " to count the number of used file descriptors");
count = -1;
goto end;
}
/* Don't account for the file descriptor opened by opendir(). */
count--;
if (closedir(dir)) {
- perror("# Failed to close test program's " SELF_FD_DIR " directory file descriptor");
+ perror("# Failed to close test program's " SELF_FD_DIR
+ " directory file descriptor");
}
end:
return count;
}
-static
-void check_fd_count(int expected_count)
+static void check_fd_count(int expected_count)
{
int count = 0;
count = fd_count();
- ok(count == expected_count, "Expected %d open file descriptors (%d are open)",
- expected_count, count);
+ ok(count == expected_count,
+ "Expected %d open file descriptors (%d are open)",
+ expected_count,
+ count);
}
-static
-int noop_open(void *data, int *fds)
+static int noop_open(void *data, int *fds)
{
*fds = *((int *) data);
return 0;
}
-static
-int noop_close(void *data __attribute__((unused)),
- int *fds __attribute__((unused)))
+static int noop_close(void *data __attribute__((unused)), int *fds __attribute__((unused)))
{
return 0;
}
-static
-void track_std_fds(struct fd_tracker *tracker)
+static void track_std_fds(struct fd_tracker *tracker)
{
int i;
- struct { int fd; const char *name; } files[] = {
+ struct {
+ int fd;
+ const char *name;
+ } files[] = {
{ .fd = fileno(stdin), .name = "stdin" },
{ .fd = fileno(stdout), .name = "stdout" },
{ .fd = fileno(stderr), .name = "stderr" },
for (i = 0; i < sizeof(files) / sizeof(*files); i++) {
int out_fd, ret;
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- &files[i].name, 1, noop_open, &files[i].fd);
+ ret = fd_tracker_open_unsuspendable_fd(
+ tracker, &out_fd, &files[i].name, 1, noop_open, &files[i].fd);
LTTNG_ASSERT(out_fd == files[i].fd);
- ok(ret == 0, "Track unsuspendable fd %d (%s)", files[i].fd,
- files[i].name);
+ ok(ret == 0, "Track unsuspendable fd %d (%s)", files[i].fd, files[i].name);
}
}
-static
-void untrack_std_fds(struct fd_tracker *tracker)
+static void untrack_std_fds(struct fd_tracker *tracker)
{
int i;
- struct { int fd; const char *name; } files[] = {
+ struct {
+ int fd;
+ const char *name;
+ } files[] = {
{ .fd = fileno(stdin), .name = "stdin" },
{ .fd = fileno(stdout), .name = "stdout" },
{ .fd = fileno(stderr), .name = "stderr" },
for (i = 0; i < sizeof(files) / sizeof(*files); i++) {
int fd = files[i].fd;
- int ret = fd_tracker_close_unsuspendable_fd(tracker,
- &files[i].fd, 1, noop_close, NULL);
+ int ret = fd_tracker_close_unsuspendable_fd(
+ tracker, &files[i].fd, 1, noop_close, NULL);
- ok(ret == 0, "Untrack unsuspendable fd %d (%s)", fd,
- files[i].name);
+ ok(ret == 0, "Untrack unsuspendable fd %d (%s)", fd, files[i].name);
}
}
/*
- * Basic test opening and closing three unsuspendable fds.
+ * Basic test opening and closing three unsuspendable fds.
*/
-static
-void test_unsuspendable_basic(void)
+static void test_unsuspendable_basic(void)
{
int ret;
struct fd_tracker *tracker;
get_temporary_directories(&test_directory, &unlinked_files_directory);
tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT);
- ok(tracker, "Created an fd tracker with a limit of %d simulateously opened file descriptors",
- TRACKER_FD_LIMIT);
+ ok(tracker,
+ "Created an fd tracker with a limit of %d simulateously opened file descriptors",
+ TRACKER_FD_LIMIT);
if (!tracker) {
goto end;
}
free(unlinked_files_directory);
}
-static
-int error_open(void *data, int *fds __attribute__((unused)))
+static int error_open(void *data, int *fds __attribute__((unused)))
{
return *((int *) data);
}
-static
-int error_close(void *data, int *fds __attribute__((unused)))
+static int error_close(void *data, int *fds __attribute__((unused)))
{
return *((int *) data);
}
* Validate that user callback return values are returned to the
* caller of the fd tracker.
*/
-static
-void test_unsuspendable_cb_return(void)
+static void test_unsuspendable_cb_return(void)
{
int ret, stdout_fd = fileno(stdout), out_fd = 42;
struct fd_tracker *tracker;
LTTNG_ASSERT(tracker);
/* The error_open callback should fail and return 'expected_error'. */
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, error_open, &expected_error);
- ok(ret == expected_error, "fd_tracker_open_unsuspendable_fd() forwards the user callback's error code");
- ok(out_fd == 42, "Output fd parameter is unaffected on error of fd_tracker_open_unsuspendable_fd()");
+ ret = fd_tracker_open_unsuspendable_fd(
+ tracker, &out_fd, NULL, 1, error_open, &expected_error);
+ ok(ret == expected_error,
+ "fd_tracker_open_unsuspendable_fd() forwards the user callback's error code");
+ ok(out_fd == 42,
+ "Output fd parameter is unaffected on error of fd_tracker_open_unsuspendable_fd()");
/*
* Track a valid fd since we don't want the tracker to fail with an
* invalid fd error for this test.
*/
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, noop_open, &stdout_fd);
- ok(out_fd == stdout_fd, "fd_tracker_open_unsuspendable_fd() sets the output fd parameter to the newly-tracked fd's value");
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ok(out_fd == stdout_fd,
+ "fd_tracker_open_unsuspendable_fd() sets the output fd parameter to the newly-tracked fd's value");
LTTNG_ASSERT(!ret);
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- &stdout_fd, 1, error_close, &expected_error);
- ok(ret == expected_error, "fd_tracker_close_unsuspendable_fd() forwards the user callback's error code");
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- &stdout_fd, 1, noop_close, &expected_error);
+ ret = fd_tracker_close_unsuspendable_fd(
+ tracker, &stdout_fd, 1, error_close, &expected_error);
+ ok(ret == expected_error,
+ "fd_tracker_close_unsuspendable_fd() forwards the user callback's error code");
+ ret = fd_tracker_close_unsuspendable_fd(
+ tracker, &stdout_fd, 1, noop_close, &expected_error);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
* Validate that the tracker refuses to track two identical unsuspendable
* file descriptors.
*/
-static
-void test_unsuspendable_duplicate(void)
+static void test_unsuspendable_duplicate(void)
{
int ret, stdout_fd = fileno(stdout), out_fd;
struct fd_tracker *tracker;
tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT);
LTTNG_ASSERT(tracker);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
LTTNG_ASSERT(!ret);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
ok(ret == -EEXIST, "EEXIST reported on open of an already tracked file descriptor");
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- &stdout_fd, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, NULL);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
free(unlinked_files_directory);
}
-static
-int open_pipes(void *data __attribute__((unused)), int *out_fds)
+static int open_pipes(void *data __attribute__((unused)), int *out_fds)
{
unsigned int i;
const unsigned int pipe_count = TRACKER_FD_LIMIT / 2;
return 0;
}
-static
-int close_pipes(void *data __attribute__((unused)), int *fds)
+static int close_pipes(void *data __attribute__((unused)), int *fds)
{
int i;
int *pipes = fds;
* Validate that the tracker enforces the open file descriptor limit
* when unsuspendable file descriptors are being opened.
*/
-static
-void test_unsuspendable_limit(void)
+static void test_unsuspendable_limit(void)
{
struct fd_tracker *tracker;
int ret, stdout_fd = fileno(stdout), out_fd;
tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT);
LTTNG_ASSERT(tracker);
- ret = fd_tracker_open_unsuspendable_fd(tracker, fds,
- NULL, TRACKER_FD_LIMIT, open_pipes, NULL);
- ok(ret == 0, "File descriptor tracker allowed the user to meet its limit with unsuspendable file descriptors (%d)",
- TRACKER_FD_LIMIT);
+ ret = fd_tracker_open_unsuspendable_fd(
+ tracker, fds, NULL, TRACKER_FD_LIMIT, open_pipes, NULL);
+ ok(ret == 0,
+ "File descriptor tracker allowed the user to meet its limit with unsuspendable file descriptors (%d)",
+ TRACKER_FD_LIMIT);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, noop_open, &stdout_fd);
- ok(ret == -EMFILE, "EMFILE reported when exceeding the file descriptor limit while opening an unsuspendable fd");
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
+ ok(ret == -EMFILE,
+ "EMFILE reported when exceeding the file descriptor limit while opening an unsuspendable fd");
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- fds, TRACKER_FD_LIMIT, close_pipes, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, fds, TRACKER_FD_LIMIT, close_pipes, NULL);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
* Validate that the tracker refuses to track two identical unsuspendable
* file descriptors.
*/
-static
-void test_unsuspendable_close_untracked(void)
+static void test_unsuspendable_close_untracked(void)
{
int ret, stdout_fd = fileno(stdout), unknown_fds[2], out_fd;
struct fd_tracker *tracker;
tracker = fd_tracker_create(unlinked_files_directory, TRACKER_FD_LIMIT);
if (!tracker) {
- goto end;;
+ goto end;
+ ;
}
ret = pipe(unknown_fds);
ret = close(unknown_fds[1]);
LTTNG_ASSERT(ret == 0);
- ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd,
- NULL, 1, noop_open, &stdout_fd);
+ ret = fd_tracker_open_unsuspendable_fd(tracker, &out_fd, NULL, 1, noop_open, &stdout_fd);
LTTNG_ASSERT(!ret);
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- unknown_fds, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, unknown_fds, 1, noop_close, NULL);
ok(ret == -EINVAL, "EINVAL reported on close of an untracked file descriptor");
- ret = fd_tracker_close_unsuspendable_fd(tracker,
- &stdout_fd, 1, noop_close, NULL);
+ ret = fd_tracker_close_unsuspendable_fd(tracker, &stdout_fd, 1, noop_close, NULL);
LTTNG_ASSERT(!ret);
fd_tracker_destroy(tracker);
}
static int open_files(struct fd_tracker *tracker,
- struct lttng_directory_handle *directory,
- unsigned int count,
- struct fs_handle **handles,
- char **file_paths)
+ struct lttng_directory_handle *directory,
+ unsigned int count,
+ struct fs_handle **handles,
+ char **file_paths)
{
int ret = 0;
unsigned int i;
LTTNG_ASSERT(p_ret >= 0);
file_paths[i] = file_path;
- handle = fd_tracker_open_fs_handle(tracker, directory, file_path,
- O_RDWR | O_CREAT, &mode);
+ handle = fd_tracker_open_fs_handle(
+ tracker, directory, file_path, O_RDWR | O_CREAT, &mode);
if (!handle) {
ret = -1;
break;
}
static int open_same_file(struct fd_tracker *tracker,
- struct lttng_directory_handle *directory,
- const char *file,
- unsigned int count,
- struct fs_handle **handles)
+ struct lttng_directory_handle *directory,
+ const char *file,
+ unsigned int count,
+ struct fs_handle **handles)
{
int ret = 0;
unsigned int i;
struct fs_handle *handle;
mode_t mode = S_IWUSR | S_IRUSR;
- handle = fd_tracker_open_fs_handle(tracker, directory, file,
- O_RDWR | O_CREAT, &mode);
+ handle = fd_tracker_open_fs_handle(
+ tracker, directory, file, O_RDWR | O_CREAT, &mode);
if (!handle) {
ret = -1;
break;
return ret;
}
-static
-int cleanup_files(struct fd_tracker *tracker __attribute__((unused)),
- const char *dir __attribute__((unused)),
- unsigned int count, struct fs_handle **handles,
- char **file_paths)
+static int cleanup_files(struct fd_tracker *tracker __attribute__((unused)),
+ const char *dir __attribute__((unused)),
+ unsigned int count,
+ struct fs_handle **handles,
+ char **file_paths)
{
int ret = 0;
unsigned int i;
return ret;
}
-static
-void test_suspendable_limit(void)
+static void test_suspendable_limit(void)
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT * 10;
LTTNG_ASSERT(dir_handle);
dir_handle_fd_count = !!lttng_directory_handle_uses_fd(dir_handle);
- ret = open_files(tracker, dir_handle, files_to_create, handles,
- output_files);
- ok(!ret, "Created %d files with a limit of %d simultaneously-opened file descriptor",
- files_to_create, TRACKER_FD_LIMIT);
- check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count +
- dir_handle_fd_count);
+ ret = open_files(tracker, dir_handle, files_to_create, handles, output_files);
+ ok(!ret,
+ "Created %d files with a limit of %d simultaneously-opened file descriptor",
+ files_to_create,
+ TRACKER_FD_LIMIT);
+ check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count + dir_handle_fd_count);
- ret = cleanup_files(tracker, test_directory, files_to_create, handles,
- output_files);
+ ret = cleanup_files(tracker, test_directory, files_to_create, handles, output_files);
ok(!ret, "Close all opened filesystem handles");
ret = rmdir(test_directory);
ok(ret == 0, "Test directory is empty");
free(unlinked_files_directory);
}
-static
-void test_mixed_limit(void)
+static void test_mixed_limit(void)
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT;
LTTNG_ASSERT(dir_handle);
dir_handle_fd_count = !!lttng_directory_handle_uses_fd(dir_handle);
- ret = open_files(tracker, dir_handle, files_to_create, handles,
- output_files);
- ok(!ret, "Created %d files with a limit of %d simultaneously-opened file descriptor",
- files_to_create, TRACKER_FD_LIMIT);
+ ret = open_files(tracker, dir_handle, files_to_create, handles, output_files);
+ ok(!ret,
+ "Created %d files with a limit of %d simultaneously-opened file descriptor",
+ files_to_create,
+ TRACKER_FD_LIMIT);
diag("Check file descriptor count after opening %u files", files_to_create);
- check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count +
- dir_handle_fd_count);
+ check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count + dir_handle_fd_count);
/*
* Open unsuspendable fds (stdin, stdout, stderr) and verify that the fd
* cap is still respected.
*/
- diag("Check file descriptor count after adding %d unsuspendable fds",
- STDIO_FD_COUNT);
+ diag("Check file descriptor count after adding %d unsuspendable fds", STDIO_FD_COUNT);
track_std_fds(tracker);
- check_fd_count(TRACKER_FD_LIMIT + unknown_fds_count +
- dir_handle_fd_count);
+ check_fd_count(TRACKER_FD_LIMIT + unknown_fds_count + dir_handle_fd_count);
diag("Untrack unsuspendable file descriptors");
untrack_std_fds(tracker);
- check_fd_count(TRACKER_FD_LIMIT + unknown_fds_count +
- dir_handle_fd_count);
+ check_fd_count(TRACKER_FD_LIMIT + unknown_fds_count + dir_handle_fd_count);
- ret = cleanup_files(tracker, test_directory, files_to_create, handles,
- output_files);
+ ret = cleanup_files(tracker, test_directory, files_to_create, handles, output_files);
ok(!ret, "Close all opened filesystem handles");
ret = rmdir(test_directory);
ok(ret == 0, "Test directory is empty");
*
* The content of the files is also verified at the end.
*/
-static
-void test_suspendable_restore(void)
+static void test_suspendable_restore(void)
{
int ret;
const int files_to_create = TRACKER_FD_LIMIT * 10;
LTTNG_ASSERT(dir_handle);
dir_handle_fd_count = !!lttng_directory_handle_uses_fd(dir_handle);
- ret = open_files(tracker, dir_handle, files_to_create, handles,
- output_files);
- ok(!ret, "Created %d files with a limit of %d simultaneously-opened file descriptor",
- files_to_create, TRACKER_FD_LIMIT);
+ ret = open_files(tracker, dir_handle, files_to_create, handles, output_files);
+ ok(!ret,
+ "Created %d files with a limit of %d simultaneously-opened file descriptor",
+ files_to_create,
+ TRACKER_FD_LIMIT);
diag("Check file descriptor count after opening %u files", files_to_create);
- check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count +
- dir_handle_fd_count);
+ check_fd_count(TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count + dir_handle_fd_count);
for (content_index = 0; content_index < sizeof(file_contents); content_index++) {
for (handle_index = 0; handle_index < files_to_create; handle_index++) {
fd = fs_handle_get_fd(handle);
if (fd < 0) {
write_success = false;
- diag("Failed to restore fs_handle to %s",
- path);
+ diag("Failed to restore fs_handle to %s", path);
goto skip_write;
}
goto skip_write;
}
- if (fd_count() > (TRACKER_FD_LIMIT + STDIO_FD_COUNT +
- unknown_fds_count +
- dir_handle_fd_count)) {
+ if (fd_count() > (TRACKER_FD_LIMIT + STDIO_FD_COUNT + unknown_fds_count +
+ dir_handle_fd_count)) {
fd_cap_respected = false;
}
}
}
skip_write:
- ok(write_success, "Wrote reference string to %d files",
- files_to_create);
+ ok(write_success, "Wrote reference string to %d files", files_to_create);
ok(fd_cap_respected, "FD tracker enforced the file descriptor cap");
/* Validate the contents of the files. */
size_t to_read = sizeof(read_buf);
int fd;
- fd = lttng_directory_handle_open_file(
- dir_handle, path, O_RDONLY, 0);
+ fd = lttng_directory_handle_open_file(dir_handle, path, O_RDONLY, 0);
LTTNG_ASSERT(fd >= 0);
ret = fstat(fd, &fd_stat);
LTTNG_ASSERT(!ret);
if (fd_stat.st_size != sizeof(file_contents)) {
diag("Content size of file %s doesn't match, got %" PRId64 ", expected %zu",
- path, (int64_t) fd_stat.st_size,
- sizeof(file_contents));
+ path,
+ (int64_t) fd_stat.st_size,
+ sizeof(file_contents));
content_ok = false;
(void) close(fd);
break;
(void) close(fd);
}
ok(content_ok, "Files contain the expected content");
- ret = cleanup_files(tracker, test_directory, files_to_create, handles,
- output_files);
+ ret = cleanup_files(tracker, test_directory, files_to_create, handles, output_files);
ok(!ret, "Close all opened filesystem handles");
ret = rmdir(test_directory);
ok(ret == 0, "Test directory is empty");
free(unlinked_files_directory);
}
-static
-void test_unlink(void)
+static void test_unlink(void)
{
int ret;
struct fd_tracker *tracker;
int fd;
get_temporary_directories(&test_directory, &unlinked_files_directory);
- ret = asprintf(&unlinked_file_zero, "%s/%u", unlinked_files_directory,
- 0);
+ ret = asprintf(&unlinked_file_zero, "%s/%u", unlinked_files_directory, 0);
LTTNG_ASSERT(ret > 0);
- ret = asprintf(&unlinked_file_one, "%s/%u", unlinked_files_directory,
- 1);
+ ret = asprintf(&unlinked_file_one, "%s/%u", unlinked_files_directory, 1);
LTTNG_ASSERT(ret > 0);
tracker = fd_tracker_create(unlinked_files_directory, 1);
LTTNG_ASSERT(dir_handle);
/* Open two handles to the same file. */
- ret = open_same_file(tracker, dir_handle, file_name, handles_to_open,
- handles);
- ok(!ret, "Successfully opened %i handles to %s/%s", handles_to_open,
- test_directory, file_name);
+ ret = open_same_file(tracker, dir_handle, file_name, handles_to_open, handles);
+ ok(!ret,
+ "Successfully opened %i handles to %s/%s",
+ handles_to_open,
+ test_directory,
+ file_name);
if (ret) {
goto end;
}
* to '0'.
*/
ret = fs_handle_unlink(handles[0]);
- ok(!ret, "Successfully unlinked the first handle to %s/%s",
- test_directory, file_name);
+ ok(!ret, "Successfully unlinked the first handle to %s/%s", test_directory, file_name);
/*
* The original file should no longer exist on the file system, and a
* new file named '0' should exist.
*/
- ok(lttng_directory_handle_stat(dir_handle, file_name, &statbuf) == -1 &&
- errno == ENOENT,
- "%s no longer present on file system after unlink",
- file_name);
- ok(lttng_directory_handle_stat(
- dir_handle, unlinked_file_zero, &statbuf) == 0,
- "%s exists on file system after unlink",
- unlinked_file_zero);
+ ok(lttng_directory_handle_stat(dir_handle, file_name, &statbuf) == -1 && errno == ENOENT,
+ "%s no longer present on file system after unlink",
+ file_name);
+ ok(lttng_directory_handle_stat(dir_handle, unlinked_file_zero, &statbuf) == 0,
+ "%s exists on file system after unlink",
+ unlinked_file_zero);
/*
* It should be possible to use the file descriptors of both handles.
ok(fd >= 0, "Got fd from first handle");
fd = fs_handle_get_fd(handles[1]);
- ok (fd < 0, "fd tracker does not allow two fds to be used at once");
+ ok(fd < 0, "fd tracker does not allow two fds to be used at once");
fs_handle_put_fd(handles[0]);
fd = fs_handle_get_fd(handles[1]);
/* The second unlink should fail with -ENOENT. */
ret = fs_handle_unlink(handles[1]);
ok(ret == -ENOENT,
- "ENOENT is reported when attempting to unlink the second handle to %s/%s",
- test_directory, file_name);
+ "ENOENT is reported when attempting to unlink the second handle to %s/%s",
+ test_directory,
+ file_name);
/*
* Opening a new handle to 'my_file' should succeed.
*/
ret = open_same_file(tracker, dir_handle, file_name, 1, &new_handle);
- ok(!ret, "Successfully opened a new handle to previously unlinked file %s/%s",
- test_directory, file_name);
+ ok(!ret,
+ "Successfully opened a new handle to previously unlinked file %s/%s",
+ test_directory,
+ file_name);
LTTNG_ASSERT(new_handle);
/*
* to '1' since '0' already exists.
*/
ret = fs_handle_unlink(new_handle);
- ok(!ret, "Successfully unlinked the new handle handle to %s/%s",
- test_directory, file_name);
+ ok(!ret, "Successfully unlinked the new handle handle to %s/%s", test_directory, file_name);
ok(stat(unlinked_file_one, &statbuf) == 0,
- "%s exists on file system after unlink",
- unlinked_file_one);
+ "%s exists on file system after unlink",
+ unlinked_file_one);
ret = fs_handle_close(handles[0]);
ok(!ret, "Successfully closed the first handle");
ret = fs_handle_close(new_handle);
ok(!ret, "Successfully closed the third handle");
- ok(lttng_directory_handle_stat(dir_handle, file_name, &statbuf) == -1 &&
- errno == ENOENT,
- "%s no longer present on file system after handle close",
- file_name);
- ok(lttng_directory_handle_stat(
- dir_handle, unlinked_file_zero, &statbuf) == -1 &&
- errno == ENOENT,
- "%s no longer present on file system after handle close",
- unlinked_file_zero);
- ok(lttng_directory_handle_stat(dir_handle, unlinked_file_one,
- &statbuf) == -1 &&
- errno == ENOENT,
- "%s no longer present on file system after handle close",
- unlinked_file_one);
+ ok(lttng_directory_handle_stat(dir_handle, file_name, &statbuf) == -1 && errno == ENOENT,
+ "%s no longer present on file system after handle close",
+ file_name);
+ ok(lttng_directory_handle_stat(dir_handle, unlinked_file_zero, &statbuf) == -1 &&
+ errno == ENOENT,
+ "%s no longer present on file system after handle close",
+ unlinked_file_zero);
+ ok(lttng_directory_handle_stat(dir_handle, unlinked_file_one, &statbuf) == -1 &&
+ errno == ENOENT,
+ "%s no longer present on file system after handle close",
+ unlinked_file_one);
ret = rmdir(test_directory);
ok(ret == 0, "Test directory is empty");
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-
#include <common/compat/errno.hpp>
-#include <bin/lttng-sessiond/trace-kernel.hpp>
#include <common/defaults.hpp>
+#include <bin/lttng-sessiond/trace-kernel.hpp>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <tap/tap.h>
+#include <time.h>
+#include <unistd.h>
-#define RANDOM_STRING_LEN 11
+#define RANDOM_STRING_LEN 11
/* Number of TAP tests in this file */
#define NUM_TESTS 11
LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
#endif
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
+static const char alphanum[] = "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
static struct ltt_kernel_session *kern;
static char random_string[RANDOM_STRING_LEN];
skip(1, "Kernel session is null");
return;
}
- ok(kern->fd == -1 &&
- kern->metadata_stream_fd == -1 &&
- kern->consumer_fds_sent == 0 &&
- kern->channel_count == 0 &&
- kern->stream_count_global == 0 &&
- kern->metadata == NULL,
+ ok(kern->fd == -1 && kern->metadata_stream_fd == -1 && kern->consumer_fds_sent == 0 &&
+ kern->channel_count == 0 && kern->stream_count_global == 0 &&
+ kern->metadata == NULL,
"Validate kernel session");
}
kern->metadata = trace_kernel_create_metadata();
ok(kern->metadata != NULL, "Create kernel metadata");
- ok(kern->metadata->fd == -1 &&
- kern->metadata->conf != NULL &&
- kern->metadata->conf->attr.overwrite
- == DEFAULT_METADATA_OVERWRITE &&
- kern->metadata->conf->attr.subbuf_size
- == default_get_metadata_subbuf_size() &&
- kern->metadata->conf->attr.num_subbuf
- == DEFAULT_METADATA_SUBBUF_NUM &&
- kern->metadata->conf->attr.switch_timer_interval
- == DEFAULT_METADATA_SWITCH_TIMER &&
- kern->metadata->conf->attr.read_timer_interval
- == DEFAULT_METADATA_READ_TIMER &&
- kern->metadata->conf->attr.output
- == LTTNG_EVENT_MMAP,
+ ok(kern->metadata->fd == -1 && kern->metadata->conf != NULL &&
+ kern->metadata->conf->attr.overwrite == DEFAULT_METADATA_OVERWRITE &&
+ kern->metadata->conf->attr.subbuf_size == default_get_metadata_subbuf_size() &&
+ kern->metadata->conf->attr.num_subbuf == DEFAULT_METADATA_SUBBUF_NUM &&
+ kern->metadata->conf->attr.switch_timer_interval ==
+ DEFAULT_METADATA_SWITCH_TIMER &&
+ kern->metadata->conf->attr.read_timer_interval == DEFAULT_METADATA_READ_TIMER &&
+ kern->metadata->conf->attr.output == LTTNG_EVENT_MMAP,
"Validate kernel session metadata");
trace_kernel_destroy_metadata(kern->metadata);
return;
}
- ok(chan->fd == -1 &&
- chan->enabled == 1 &&
- chan->stream_count == 0 &&
- chan->channel->attr.overwrite == attr.attr.overwrite,
+ ok(chan->fd == -1 && chan->enabled == 1 && chan->stream_count == 0 &&
+ chan->channel->attr.overwrite == attr.attr.overwrite,
"Validate kernel channel");
/* Init list in order to avoid sefaults from cds_list_del */
struct lttng_event ev;
memset(&ev, 0, sizeof(ev));
- ok(!lttng_strncpy(ev.name, get_random_string(),
- RANDOM_STRING_LEN),
- "Validate string length");
+ ok(!lttng_strncpy(ev.name, get_random_string(), RANDOM_STRING_LEN),
+ "Validate string length");
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
return;
}
- ok(event->fd == -1 &&
- event->enabled == 1 &&
- event->event->instrumentation == LTTNG_KERNEL_ABI_TRACEPOINT &&
- strlen(event->event->name),
+ ok(event->fd == -1 && event->enabled == 1 &&
+ event->event->instrumentation == LTTNG_KERNEL_ABI_TRACEPOINT &&
+ strlen(event->event->name),
"Validate kernel event");
/* Init list in order to avoid sefaults from cds_list_del */
return;
}
- ok(stream->fd == -1 &&
- stream->state == 0,
- "Validate kernel stream");
+ ok(stream->fd == -1 && stream->state == 0, "Validate kernel stream");
/* Init list in order to avoid sefaults from cds_list_del */
CDS_INIT_LIST_HEAD(&stream->list);
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
-
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/kernel-probe-internal.hpp>
#include <lttng/kernel-probe.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
+
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
type = lttng_kernel_probe_location_get_type(location);
ok(LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS == type,
- "Location type got %d expected %d", type,
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
+ "Location type got %d expected %d",
+ type,
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
- status = lttng_kernel_probe_location_address_get_address(
- location, &_address);
+ status = lttng_kernel_probe_location_address_get_address(location, &_address);
ok(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK, "Getting address");
ok(address == _address,
- "Address is equal. Got %" PRIu64 " expected %" PRIu64,
- _address, address);
+ "Address is equal. Got %" PRIu64 " expected %" PRIu64,
+ _address,
+ address);
- ok(lttng_kernel_probe_location_serialize(location, &payload) > 0,
- "Serializing");
+ ok(lttng_kernel_probe_location_serialize(location, &payload) > 0, "Serializing");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- ok(lttng_kernel_probe_location_create_from_payload(
- &view, &location_from_buffer) > 0,
- "Deserializing");
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ ok(lttng_kernel_probe_location_create_from_payload(&view, &location_from_buffer) >
+ 0,
+ "Deserializing");
}
type = lttng_kernel_probe_location_get_type(location_from_buffer);
ok(LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS == type,
- "Location from buffer type got %d expected %d", type,
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
+ "Location from buffer type got %d expected %d",
+ type,
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
- status = lttng_kernel_probe_location_address_get_address(
- location_from_buffer, &_address);
+ status = lttng_kernel_probe_location_address_get_address(location_from_buffer, &_address);
ok(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK, "Getting address");
ok(address == _address,
- "Address from buffer is equal. Got %" PRIu64
- " expected %" PRIu64,
- _address, address);
+ "Address from buffer is equal. Got %" PRIu64 " expected %" PRIu64,
+ _address,
+ address);
ok(lttng_kernel_probe_location_is_equal(location, location_from_buffer),
- "serialized and from buffer are equal");
+ "serialized and from buffer are equal");
lttng_payload_reset(&payload);
lttng_kernel_probe_location_destroy(location);
type = lttng_kernel_probe_location_get_type(location);
ok(LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET == type,
- "Location type got %d expected %d", type,
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
+ "Location type got %d expected %d",
+ type,
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
_symbol = lttng_kernel_probe_location_symbol_get_name(location);
ok(_symbol, "Getting symbol name");
ok(!strncmp(symbol, _symbol, strlen(symbol)),
- "Symbol name is equal. Got %s, expected %s", _symbol,
- symbol);
+ "Symbol name is equal. Got %s, expected %s",
+ _symbol,
+ symbol);
- status = lttng_kernel_probe_location_symbol_get_offset(
- location, &_offset);
+ status = lttng_kernel_probe_location_symbol_get_offset(location, &_offset);
ok(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK, "Getting offset");
- ok(offset == _offset,
- "Offset is equal. Got %" PRIu64 " expected %" PRIu64,
- _offset, offset);
+ ok(offset == _offset, "Offset is equal. Got %" PRIu64 " expected %" PRIu64, _offset, offset);
- ok(lttng_kernel_probe_location_serialize(location, &payload) > 0,
- "Serializing");
+ ok(lttng_kernel_probe_location_serialize(location, &payload) > 0, "Serializing");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- ok(lttng_kernel_probe_location_create_from_payload(
- &view, &location_from_buffer) > 0,
- "Deserializing");
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+ ok(lttng_kernel_probe_location_create_from_payload(&view, &location_from_buffer) >
+ 0,
+ "Deserializing");
}
type = lttng_kernel_probe_location_get_type(location_from_buffer);
ok(LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET == type,
- "Location from buffer type got %d expected %d", type,
- LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
+ "Location from buffer type got %d expected %d",
+ type,
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
- _symbol = lttng_kernel_probe_location_symbol_get_name(
- location_from_buffer);
+ _symbol = lttng_kernel_probe_location_symbol_get_name(location_from_buffer);
ok(_symbol, "Getting symbol name");
ok(!strncmp(symbol, _symbol, strlen(symbol)),
- "Symbol name is equal. Got %s, expected %s", _symbol,
- symbol);
+ "Symbol name is equal. Got %s, expected %s",
+ _symbol,
+ symbol);
- status = lttng_kernel_probe_location_symbol_get_offset(
- location_from_buffer, &_offset);
+ status = lttng_kernel_probe_location_symbol_get_offset(location_from_buffer, &_offset);
ok(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK, "Getting offset");
- ok(offset == _offset,
- "Offset is equal. Got %" PRIu64 " expected %" PRIu64,
- _offset, offset);
+ ok(offset == _offset, "Offset is equal. Got %" PRIu64 " expected %" PRIu64, _offset, offset);
ok(lttng_kernel_probe_location_is_equal(location, location_from_buffer),
- "serialized and from buffer are equal");
+ "serialized and from buffer are equal");
lttng_payload_reset(&payload);
lttng_kernel_probe_location_destroy(location);
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
-
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/log-level-rule-internal.hpp>
#include <lttng/log-level-rule.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
+
/* For error.h. */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
static void test_log_level_rule_error(void)
{
int level = 9000;
- struct lttng_log_level_rule *exactly =
- lttng_log_level_rule_exactly_create(level);
+ struct lttng_log_level_rule *exactly = lttng_log_level_rule_exactly_create(level);
struct lttng_log_level_rule *at_least_as_severe =
- lttng_log_level_rule_at_least_as_severe_as_create(
- level);
-
- ok(lttng_log_level_rule_get_type(NULL) == LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN, "Get type on invalid pointer");
-
- ok(lttng_log_level_rule_exactly_get_level(NULL, NULL) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_exactly_get_level (NULL, NULL) returns invalid");
- ok(lttng_log_level_rule_exactly_get_level(exactly, NULL) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_exactly_get_level (valid, NULL) returns invalid");
- ok(lttng_log_level_rule_exactly_get_level(NULL, &level) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_exactly_get_level (NULL, valid) returns invalid");
-
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, NULL) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, NULL) returns invalid");
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(exactly, NULL) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_at_least_as_severe_as_get_level (valid, NULL) returns invalid");
- ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, &level) == LTTNG_LOG_LEVEL_RULE_STATUS_INVALID, "lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, valid) returns invalid");
+ lttng_log_level_rule_at_least_as_severe_as_create(level);
+
+ ok(lttng_log_level_rule_get_type(NULL) == LTTNG_LOG_LEVEL_RULE_TYPE_UNKNOWN,
+ "Get type on invalid pointer");
+
+ ok(lttng_log_level_rule_exactly_get_level(NULL, NULL) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_exactly_get_level (NULL, NULL) returns invalid");
+ ok(lttng_log_level_rule_exactly_get_level(exactly, NULL) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_exactly_get_level (valid, NULL) returns invalid");
+ ok(lttng_log_level_rule_exactly_get_level(NULL, &level) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_exactly_get_level (NULL, valid) returns invalid");
+
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, NULL) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, NULL) returns invalid");
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(exactly, NULL) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_at_least_as_severe_as_get_level (valid, NULL) returns invalid");
+ ok(lttng_log_level_rule_at_least_as_severe_as_get_level(NULL, &level) ==
+ LTTNG_LOG_LEVEL_RULE_STATUS_INVALID,
+ "lttng_log_level_rule_at_least_as_severe_as_get_level (NULL, valid) returns invalid");
lttng_log_level_rule_destroy(exactly);
lttng_log_level_rule_destroy(at_least_as_severe);
}
-static
-void test_log_level_rule_serialize_deserialize(const struct lttng_log_level_rule *rule)
+static void test_log_level_rule_serialize_deserialize(const struct lttng_log_level_rule *rule)
{
struct lttng_log_level_rule *log_level_rule_from_buffer = NULL;
struct lttng_payload payload;
ok(lttng_log_level_rule_serialize(rule, &payload) == 0, "Serializing.");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
- ok(lttng_log_level_rule_create_from_payload(
- &view, &log_level_rule_from_buffer) > 0,
- "Deserializing.");
+ ok(lttng_log_level_rule_create_from_payload(&view, &log_level_rule_from_buffer) > 0,
+ "Deserializing.");
}
- ok(lttng_log_level_rule_is_equal(rule, log_level_rule_from_buffer), "Serialized and from buffer are equal");
+ ok(lttng_log_level_rule_is_equal(rule, log_level_rule_from_buffer),
+ "Serialized and from buffer are equal");
lttng_log_level_rule_destroy(log_level_rule_from_buffer);
lttng_payload_reset(&payload);
}
-static
-void test_log_level_rule_is_equal_exactly(void)
+static void test_log_level_rule_is_equal_exactly(void)
{
int level = 9000, no_eq_level = 420;
struct lttng_log_level_rule *a, *b, *different_level, *different_type;
ok(lttng_log_level_rule_is_equal(a, a), "Same object is equal");
ok(lttng_log_level_rule_is_equal(a, b), "Object a and b are equal");
- ok(!lttng_log_level_rule_is_equal(a, different_level), " Object of different levels are not equal");
- ok(!lttng_log_level_rule_is_equal(a, different_type), " Object of different types are not equal");
+ ok(!lttng_log_level_rule_is_equal(a, different_level),
+ " Object of different levels are not equal");
+ ok(!lttng_log_level_rule_is_equal(a, different_type),
+ " Object of different types are not equal");
lttng_log_level_rule_destroy(a);
lttng_log_level_rule_destroy(b);
lttng_log_level_rule_destroy(different_type);
}
-static
-void test_log_level_rule_is_equal_at_least_as_severe_as(void)
+static void test_log_level_rule_is_equal_at_least_as_severe_as(void)
{
int level = 9000, no_eq_level = 420;
struct lttng_log_level_rule *a, *b, *different_level, *different_type;
ok(lttng_log_level_rule_is_equal(a, a), "Same object is equal");
ok(lttng_log_level_rule_is_equal(a, b), "Object a and b are equal");
- ok(!lttng_log_level_rule_is_equal(a, different_level), " Object of different levels are not equal");
- ok(!lttng_log_level_rule_is_equal(a, different_type), " Object of different types are not equal");
+ ok(!lttng_log_level_rule_is_equal(a, different_level),
+ " Object of different levels are not equal");
+ ok(!lttng_log_level_rule_is_equal(a, different_type),
+ " Object of different types are not equal");
lttng_log_level_rule_destroy(a);
lttng_log_level_rule_destroy(b);
exactly = lttng_log_level_rule_exactly_create(level);
ok(exactly, "Log level exactly allocated");
- ok(lttng_log_level_rule_get_type(exactly) ==
- LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY,
- "Log level rule exactly type");
+ ok(lttng_log_level_rule_get_type(exactly) == LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY,
+ "Log level rule exactly type");
status = lttng_log_level_rule_exactly_get_level(exactly, &_level);
ok(status == LTTNG_LOG_LEVEL_RULE_STATUS_OK, "Get the level");
ok(at_least_as_severe_as, "Log level at_least_as_severe_as allocated");
ok(lttng_log_level_rule_get_type(at_least_as_severe_as) ==
- LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS,
- "Log level rule at_least_as_severe_as type");
+ LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS,
+ "Log level rule at_least_as_severe_as type");
- status = lttng_log_level_rule_at_least_as_severe_as_get_level(at_least_as_severe_as, &_level);
+ status = lttng_log_level_rule_at_least_as_severe_as_get_level(at_least_as_severe_as,
+ &_level);
ok(status == LTTNG_LOG_LEVEL_RULE_STATUS_OK, "Get the level");
ok(_level == level, "Level property is valid");
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
+#include <common/macros.hpp>
#include <lttng/action/action.h>
#include <lttng/action/notify.h>
#include <lttng/notification/notification.h>
#include <lttng/trigger/trigger.h>
-#include <common/macros.hpp>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
/* For error.h */
int lttng_opt_quiet = 1;
#define NUM_TESTS 180
-static void test_condition_buffer_usage(
- struct lttng_condition *buffer_usage_condition)
+static void test_condition_buffer_usage(struct lttng_condition *buffer_usage_condition)
{
enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
const char *session_name = NULL;
LTTNG_ASSERT(buffer_usage_condition);
diag("Validating initialization");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold ratio is unset");
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold byte is unset");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Session name is unset");
ok(!session_name, "Session name is null");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Channel name is unset");
ok(!session_name, "Channel name is null");
status = lttng_condition_buffer_usage_get_session_name(NULL, &session_name);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get session name with null condition");
ok(!session_name, "Session name is null");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Session name is unset");
ok(!session_name, "Session name is null");
status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, NULL);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null session name");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Session name is unset");
ok(!session_name, "Session name is null");
status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, "");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set empty session name");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Session name is unset");
ok(!session_name, "Session name is null");
- status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, "session420");
+ status =
+ lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, "session420");
ok(status == LTTNG_CONDITION_STATUS_OK, "Set session name session420");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_OK, "Session name is set");
ok(session_name, "Session name has a value");
ok(strcmp("session420", session_name) == 0, "Session name is %s", "session420");
status = lttng_condition_buffer_usage_set_session_name(buffer_usage_condition, "");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set session name to empty");
- status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition, &session_name);
+ status = lttng_condition_buffer_usage_get_session_name(buffer_usage_condition,
+ &session_name);
ok(status == LTTNG_CONDITION_STATUS_OK, "Session name is still set");
ok(session_name, "Session name has a value");
ok(strcmp("session420", session_name) == 0, "Session is still name is %s", "session420");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null condition on set channel name");
status = lttng_condition_buffer_usage_get_channel_name(NULL, &channel_name);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get channel name with null condition");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Channel name is unset");
ok(!channel_name, "Channel name is null");
status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, NULL);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set null channel name");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Channel name is unset");
ok(!channel_name, "Channel name is null");
status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, "");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set empty channel name");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Channel name is unset");
ok(!channel_name, "Channel name is null");
- status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, "channel420");
+ status =
+ lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, "channel420");
ok(status == LTTNG_CONDITION_STATUS_OK, "Set channel name channel420");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_OK, "Channel name is set");
ok(channel_name, "Channel name has a value");
ok(strcmp("channel420", channel_name) == 0, "Channel name is %s", "channel420");
status = lttng_condition_buffer_usage_set_channel_name(buffer_usage_condition, "");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set channel name to empty");
- status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition, &channel_name);
+ status = lttng_condition_buffer_usage_get_channel_name(buffer_usage_condition,
+ &channel_name);
ok(status == LTTNG_CONDITION_STATUS_OK, "Channel name is still set");
ok(channel_name, "Channel name has a value");
ok(strcmp("channel420", channel_name) == 0, "Channel is still name is %s", "channel420");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set threshold ratio with null condition");
status = lttng_condition_buffer_usage_get_threshold_ratio(NULL, &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get threshold ratio with null condition");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold ratio is unset");
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, -100.0);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set threshold ratio < 0");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold ratio is unset");
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, 200.0);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set Threshold ratio > 1");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold ratio is unset");
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, 1.0);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold ratio == 1.0");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold ratio is set");
ok(threshold_ratio == 1.0, "Threshold ratio is 1.0");
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, 0.0);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold ratio == 0.0");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold ratio is set");
ok(threshold_ratio == 0.0, "Threshold ratio is 0.0");
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, 0.420);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold ratio == 0.420");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold ratio is set");
ok(threshold_ratio == 0.420, "Threshold ratio is 0.420");
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set threshold with null condition");
status = lttng_condition_buffer_usage_get_threshold(NULL, &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get threshold value with null condition ");
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold is unset");
status = lttng_condition_buffer_usage_set_threshold(buffer_usage_condition, 100000);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold > 0");
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold is set");
ok(threshold_bytes == 100000, "Threshold is 100000");
status = lttng_condition_buffer_usage_set_threshold(buffer_usage_condition, UINT64_MAX);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold UINT64_MAX");
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold is set");
ok(threshold_bytes == UINT64_MAX, "Threshold is UINT64_MAX");
status = lttng_condition_buffer_usage_set_threshold(buffer_usage_condition, 0);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold == 0");
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold is set");
ok(threshold_bytes == 0, "Threshold is %d", 0);
diag("Testing interaction between byte and ratio thresholds");
threshold_ratio = -1.0;
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold ratio is unset");
ok(threshold_ratio == -1.0, "Threshold ratio is untouched");
/* Set a ratio to validate that the byte threshold is now unset */
status = lttng_condition_buffer_usage_set_threshold_ratio(buffer_usage_condition, 0.420);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set threshold ratio == 0.420");
- status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition, &threshold_ratio);
+ status = lttng_condition_buffer_usage_get_threshold_ratio(buffer_usage_condition,
+ &threshold_ratio);
ok(status == LTTNG_CONDITION_STATUS_OK, "Threshold ratio is set");
ok(threshold_ratio == 0.420, "Threshold ratio is 0.420");
threshold_bytes = 420;
- status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition, &threshold_bytes);
+ status = lttng_condition_buffer_usage_get_threshold(buffer_usage_condition,
+ &threshold_bytes);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Threshold is unset");
ok(threshold_bytes == 420, "Threshold is untouched");
status = lttng_condition_buffer_usage_get_domain_type(NULL, &domain_type);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Get domain type with null condition");
- status = lttng_condition_buffer_usage_set_domain_type(buffer_usage_condition, LTTNG_DOMAIN_NONE);
+ status = lttng_condition_buffer_usage_set_domain_type(buffer_usage_condition,
+ LTTNG_DOMAIN_NONE);
ok(status == LTTNG_CONDITION_STATUS_INVALID, "Set domain type as LTTNG_DOMAIN_NONE");
status = lttng_condition_buffer_usage_get_domain_type(buffer_usage_condition, &domain_type);
ok(status == LTTNG_CONDITION_STATUS_UNSET, "Domain type is unset");
- status = lttng_condition_buffer_usage_set_domain_type(buffer_usage_condition, LTTNG_DOMAIN_UST);
+ status = lttng_condition_buffer_usage_set_domain_type(buffer_usage_condition,
+ LTTNG_DOMAIN_UST);
ok(status == LTTNG_CONDITION_STATUS_OK, "Set domain type as LTTNG_DOMAIN_UST");
status = lttng_condition_buffer_usage_get_domain_type(buffer_usage_condition, &domain_type);
ok(status == LTTNG_CONDITION_STATUS_OK, "Domain type is set");
buffer_usage_low = lttng_condition_buffer_usage_low_create();
ok(buffer_usage_low, "Condition allocated");
- ok(lttng_condition_get_type(buffer_usage_low) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW, "Condition is of type \"low buffer usage\"");
+ ok(lttng_condition_get_type(buffer_usage_low) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW,
+ "Condition is of type \"low buffer usage\"");
test_condition_buffer_usage(buffer_usage_low);
buffer_usage_high = lttng_condition_buffer_usage_high_create();
ok(buffer_usage_high, "High buffer usage condition allocated");
- ok(lttng_condition_get_type(buffer_usage_high) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH, "Condition is of type \"high buffer usage\"");
+ ok(lttng_condition_get_type(buffer_usage_high) == LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH,
+ "Condition is of type \"high buffer usage\"");
test_condition_buffer_usage(buffer_usage_high);
lttng_trigger_destroy(trigger);
}
-
int main(void)
{
plan_tests(NUM_TESTS);
*
*/
-#include <unistd.h>
-
#include <common/compat/fcntl.hpp>
-#include <common/payload.hpp>
#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+
#include <tap/tap.h>
+#include <unistd.h>
static const int TEST_COUNT = 5;
{
bool fail_pop = false;
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
for (i = 0; i < 3; i++) {
- struct fd_handle *handle =
- lttng_payload_view_pop_fd_handle(&view);
+ struct fd_handle *handle = lttng_payload_view_pop_fd_handle(&view);
fail_pop |= fd_handle_get_fd(handle) != fds[i];
fd_handle_put(handle);
}
- ok(!fail_pop, "File descriptors are popped from a payload view in the order of insertion");
+ ok(!fail_pop,
+ "File descriptors are popped from a payload view in the order of insertion");
}
lttng_payload_reset(&payload);
{
int ret, i;
struct lttng_payload payload;
- const char * const test_description = "Error reported when popping more file descriptors than were pushed";
+ const char *const test_description =
+ "Error reported when popping more file descriptors than were pushed";
lttng_payload_init(&payload);
{
struct fd_handle *handle;
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
for (i = 0; i < 10; i++) {
handle = lttng_payload_view_pop_fd_handle(&view);
int fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
struct fd_handle *handle;
struct lttng_payload payload;
- const char * const test_description = "Same file descriptor returned when popping from different top-level views";
+ const char *const test_description =
+ "Same file descriptor returned when popping from different top-level views";
LTTNG_ASSERT(fd >= 0);
handle = fd_handle_create(fd);
for (i = 0; i < 5; i++) {
int view_fd;
struct fd_handle *view_handle;
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
view_handle = lttng_payload_view_pop_fd_handle(&view);
if (!view_handle) {
struct fd_handle *handle2 = fd_handle_create(fd2);
struct fd_handle *view_handle1 = NULL, *view_handle2 = NULL;
struct lttng_payload payload;
- const char * const test_description = "Different file descriptors returned when popping from descendant views";
+ const char *const test_description =
+ "Different file descriptors returned when popping from descendant views";
lttng_payload_init(&payload);
LTTNG_ASSERT(handle1);
}
{
- struct lttng_payload_view view1 =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
- struct lttng_payload_view view2 =
- lttng_payload_view_from_view(
- &view1, 0, -1);
+ struct lttng_payload_view view1 = lttng_payload_view_from_payload(&payload, 0, -1);
+ struct lttng_payload_view view2 = lttng_payload_view_from_view(&view1, 0, -1);
view_handle1 = lttng_payload_view_pop_fd_handle(&view1);
if (!view_handle1 || fd_handle_get_fd(view_handle1) != fd1) {
*
*/
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <tap/tap.h>
-
#include <common/payload-view.hpp>
#include <common/payload.hpp>
+
#include <lttng/action/rate-policy-internal.hpp>
#include <lttng/action/rate-policy.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <tap/tap.h>
+#include <unistd.h>
+
/* For error.h. */
int lttng_opt_quiet = 1;
int lttng_opt_verbose;
policy_a = lttng_rate_policy_every_n_create(interval_a_b);
policy_b = lttng_rate_policy_every_n_create(interval_a_b);
policy_c = lttng_rate_policy_every_n_create(interval_c);
- ok(policy_a != NULL,
- "Rate policy every n A created: interval: %" PRIu64,
- interval_a_b);
- ok(policy_b != NULL,
- "Rate policy every n B created: interval: %" PRIu64,
- interval_a_b);
- ok(policy_c != NULL,
- "Rate policy every n C created: interval: %" PRIu64,
- interval_c);
-
- ok(LTTNG_RATE_POLICY_TYPE_EVERY_N ==
- lttng_rate_policy_get_type(policy_a),
- "Type is LTTNG_RATE_POLICY_TYPE_EVERY_N");
+ ok(policy_a != NULL, "Rate policy every n A created: interval: %" PRIu64, interval_a_b);
+ ok(policy_b != NULL, "Rate policy every n B created: interval: %" PRIu64, interval_a_b);
+ ok(policy_c != NULL, "Rate policy every n C created: interval: %" PRIu64, interval_c);
+
+ ok(LTTNG_RATE_POLICY_TYPE_EVERY_N == lttng_rate_policy_get_type(policy_a),
+ "Type is LTTNG_RATE_POLICY_TYPE_EVERY_N");
/* Getter tests */
status = lttng_rate_policy_every_n_get_interval(NULL, NULL);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get interval returns INVALID");
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
status = lttng_rate_policy_every_n_get_interval(NULL, &interval_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get interval returns INVALID");
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
status = lttng_rate_policy_every_n_get_interval(policy_a, NULL);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get interval returns INVALID");
-
- status = lttng_rate_policy_every_n_get_interval(
- policy_a, &interval_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- interval_query == interval_a_b,
- " Getting interval A");
-
- status = lttng_rate_policy_every_n_get_interval(
- policy_b, &interval_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- interval_query == interval_a_b,
- " Getting interval B");
-
- status = lttng_rate_policy_every_n_get_interval(
- policy_c, &interval_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- interval_query == interval_c,
- " Getting interval C");
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get interval returns INVALID");
+
+ status = lttng_rate_policy_every_n_get_interval(policy_a, &interval_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && interval_query == interval_a_b,
+ " Getting interval A");
+
+ status = lttng_rate_policy_every_n_get_interval(policy_b, &interval_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && interval_query == interval_a_b,
+ " Getting interval B");
+
+ status = lttng_rate_policy_every_n_get_interval(policy_c, &interval_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && interval_query == interval_c,
+ " Getting interval C");
/* is_equal tests */
/* TODO: this is the behaviour introduced by the
* lttng_condition_is_equal back in 2017 do we want to fix this and
* return true if both are NULL?
*/
- ok(false == lttng_rate_policy_is_equal(NULL, NULL),
- "is equal (NULL,NULL)");
- ok(false == lttng_rate_policy_is_equal(policy_a, NULL),
- "is equal (object, NULL)");
- ok(false == lttng_rate_policy_is_equal(NULL, policy_a),
- " is equal (NULL, object)");
- ok(true == lttng_rate_policy_is_equal(policy_a, policy_a),
- "is equal (object A, object A)");
-
- ok(true == lttng_rate_policy_is_equal(policy_a, policy_b),
- "is equal (object A, object B");
- ok(true == lttng_rate_policy_is_equal(policy_b, policy_a),
- "is equal (object B, object A");
+ ok(false == lttng_rate_policy_is_equal(NULL, NULL), "is equal (NULL,NULL)");
+ ok(false == lttng_rate_policy_is_equal(policy_a, NULL), "is equal (object, NULL)");
+ ok(false == lttng_rate_policy_is_equal(NULL, policy_a), " is equal (NULL, object)");
+ ok(true == lttng_rate_policy_is_equal(policy_a, policy_a), "is equal (object A, object A)");
+
+ ok(true == lttng_rate_policy_is_equal(policy_a, policy_b), "is equal (object A, object B");
+ ok(true == lttng_rate_policy_is_equal(policy_b, policy_a), "is equal (object B, object A");
ok(false == lttng_rate_policy_is_equal(policy_a, policy_c),
- "is equal (object A, object C)");
+ "is equal (object A, object C)");
ok(false == lttng_rate_policy_is_equal(policy_c, policy_a),
- "is equal (object C, object A)");
+ "is equal (object C, object A)");
/* Serialization and create_from buffer. */
ok(lttng_rate_policy_serialize(policy_a, &payload) == 0, "Serializing");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
-
- ok(lttng_rate_policy_create_from_payload(
- &view, &policy_from_buffer) > 0 &&
- policy_from_buffer != NULL,
- "Deserializing");
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+
+ ok(lttng_rate_policy_create_from_payload(&view, &policy_from_buffer) > 0 &&
+ policy_from_buffer != NULL,
+ "Deserializing");
}
ok(lttng_rate_policy_is_equal(policy_a, policy_from_buffer),
- "serialized and from buffer are equal");
+ "serialized and from buffer are equal");
lttng_rate_policy_destroy(policy_a);
lttng_rate_policy_destroy(policy_b);
policy_a = lttng_rate_policy_once_after_n_create(threshold_a_b);
policy_b = lttng_rate_policy_once_after_n_create(threshold_a_b);
policy_c = lttng_rate_policy_once_after_n_create(threshold_c);
- ok(policy_a != NULL,
- "Rate policy every n A created: threshold: %" PRIu64,
- threshold_a_b);
- ok(policy_b != NULL,
- "Rate policy every n B created: threshold: %" PRIu64,
- threshold_a_b);
- ok(policy_c != NULL,
- "Rate policy every n C created: threshold: %" PRIu64,
- threshold_c);
-
- ok(LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N ==
- lttng_rate_policy_get_type(policy_a),
- "Type is LTTNG_RATE_POLICY_TYPE_once_after_n");
+ ok(policy_a != NULL, "Rate policy every n A created: threshold: %" PRIu64, threshold_a_b);
+ ok(policy_b != NULL, "Rate policy every n B created: threshold: %" PRIu64, threshold_a_b);
+ ok(policy_c != NULL, "Rate policy every n C created: threshold: %" PRIu64, threshold_c);
+
+ ok(LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N == lttng_rate_policy_get_type(policy_a),
+ "Type is LTTNG_RATE_POLICY_TYPE_once_after_n");
/* Getter tests */
status = lttng_rate_policy_once_after_n_get_threshold(NULL, NULL);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get threshold returns INVALID");
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
- status = lttng_rate_policy_once_after_n_get_threshold(
- NULL, &threshold_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get threshold returns INVALID");
+ status = lttng_rate_policy_once_after_n_get_threshold(NULL, &threshold_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
status = lttng_rate_policy_once_after_n_get_threshold(policy_a, NULL);
- ok(status == LTTNG_RATE_POLICY_STATUS_INVALID,
- "Get threshold returns INVALID");
-
- status = lttng_rate_policy_once_after_n_get_threshold(
- policy_a, &threshold_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- threshold_query == threshold_a_b,
- " Getting threshold A");
-
- status = lttng_rate_policy_once_after_n_get_threshold(
- policy_b, &threshold_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- threshold_query == threshold_a_b,
- " Getting threshold B");
-
- status = lttng_rate_policy_once_after_n_get_threshold(
- policy_c, &threshold_query);
- ok(status == LTTNG_RATE_POLICY_STATUS_OK &&
- threshold_query == threshold_c,
- " Getting threshold C");
+ ok(status == LTTNG_RATE_POLICY_STATUS_INVALID, "Get threshold returns INVALID");
+
+ status = lttng_rate_policy_once_after_n_get_threshold(policy_a, &threshold_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && threshold_query == threshold_a_b,
+ " Getting threshold A");
+
+ status = lttng_rate_policy_once_after_n_get_threshold(policy_b, &threshold_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && threshold_query == threshold_a_b,
+ " Getting threshold B");
+
+ status = lttng_rate_policy_once_after_n_get_threshold(policy_c, &threshold_query);
+ ok(status == LTTNG_RATE_POLICY_STATUS_OK && threshold_query == threshold_c,
+ " Getting threshold C");
/* is_equal tests */
- ok(false == lttng_rate_policy_is_equal(NULL, NULL),
- "is equal (NULL,NULL)");
- ok(false == lttng_rate_policy_is_equal(policy_a, NULL),
- "is equal (object, NULL)");
- ok(false == lttng_rate_policy_is_equal(NULL, policy_a),
- " is equal (NULL, object)");
- ok(true == lttng_rate_policy_is_equal(policy_a, policy_a),
- "is equal (object A, object A)");
-
- ok(true == lttng_rate_policy_is_equal(policy_a, policy_b),
- "is equal (object A, object B");
- ok(true == lttng_rate_policy_is_equal(policy_b, policy_a),
- "is equal (object B, object A");
+ ok(false == lttng_rate_policy_is_equal(NULL, NULL), "is equal (NULL,NULL)");
+ ok(false == lttng_rate_policy_is_equal(policy_a, NULL), "is equal (object, NULL)");
+ ok(false == lttng_rate_policy_is_equal(NULL, policy_a), " is equal (NULL, object)");
+ ok(true == lttng_rate_policy_is_equal(policy_a, policy_a), "is equal (object A, object A)");
+
+ ok(true == lttng_rate_policy_is_equal(policy_a, policy_b), "is equal (object A, object B");
+ ok(true == lttng_rate_policy_is_equal(policy_b, policy_a), "is equal (object B, object A");
ok(false == lttng_rate_policy_is_equal(policy_a, policy_c),
- "is equal (object A, object C)");
+ "is equal (object A, object C)");
ok(false == lttng_rate_policy_is_equal(policy_c, policy_a),
- "is equal (object C, object A)");
+ "is equal (object C, object A)");
/* Serialization and create_from buffer. */
ok(lttng_rate_policy_serialize(policy_a, &payload) == 0, "Serializing");
{
- struct lttng_payload_view view =
- lttng_payload_view_from_payload(
- &payload, 0, -1);
-
- ok(lttng_rate_policy_create_from_payload(
- &view, &policy_from_buffer) > 0 &&
- policy_from_buffer != NULL,
- "Deserializing");
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+
+ ok(lttng_rate_policy_create_from_payload(&view, &policy_from_buffer) > 0 &&
+ policy_from_buffer != NULL,
+ "Deserializing");
}
ok(lttng_rate_policy_is_equal(policy_a, policy_from_buffer),
- "serialized and from buffer are equal");
+ "serialized and from buffer are equal");
lttng_rate_policy_destroy(policy_a);
lttng_rate_policy_destroy(policy_b);
*
*/
+#include "backward-compatibility-group-by.hpp"
+
+#include <common/time.hpp>
+
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#include <common/time.hpp>
-
-#include "backward-compatibility-group-by.hpp"
-
#include <tap/tap.h>
/* Number of TAP tests in this file */
int lttng_opt_verbose;
struct test tests[] = {
- /* Default name session streaming. */
- {"hostname/auto-20190918-164429/ust/uid/1000/64-bit",
- "auto-20190918-164429", "hostname",
- "20190918-164429", "", "ust/uid/1000/64-bit",
- true},
- /* Custom default name session */
- {"hostname/custom_auto-20190319-120000/ust/uid/1000/64-bit",
- "custom_auto-20190319-120000", "hostname",
- "20190319-120000", "", "ust/uid/1000/64-bit",
- true},
- /* Named session streaming */
- {"hostname/test-20190918-164709/ust/uid/1000/64-bit", "test",
- "hostname", "20190918-164709", "",
- "ust/uid/1000/64-bit", true},
- /* Default session snapshot streaming */
- {"hostname//snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
- "my_session", "hostname", "", "",
- "snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
- true},
- /* Named session snapshot streaming */
- {"hostname//snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
- "my_session", "hostname", "", "",
- "snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
- true},
- /* Default name session, live */
- {"hostname//auto-20190918-171641/ust/uid/1000/64-bit",
- "auto-20190918-171641", "hostname",
- "20190918-171641", "", "ust/uid/1000/64-bit",
- true},
- /* Named session, live */
- {"hostname//test-20190918-180333//ust/uid/1000/64-bit",
- "test-20190918-180333", "hostname",
- "20190918-180333", "", "/ust/uid/1000/64-bit",
- true},
- /* Default name session, streaming & live , extra path */
- {"hostname/extra/path/ust/uid/1000/64-bit",
- "auto-20190919-122110", "hostname",
- "20190919-122110", "extra",
- "path/ust/uid/1000/64-bit", true},
- /* Named session, live, extra path */
- {"hostname/extra/path/ust/uid/1000/64-bit", "test", "hostname",
- "", "extra", "path/ust/uid/1000/64-bit", true},
- /* Named session, snapshot, extra path */
- {"hostname/extra/path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
- "test", "hostname", "", "extra",
- "path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
- true},
- /* Corner cases*/
- /* Named session with valid datetime in it */
- /* Default name session, extra path with session name in it*/
- {"hostname/test-20190319-120000-20190918-180921/ust/uid/1000/64-bit",
- "test-20190319-120000", "hostname",
- "20190918-180921", "", "ust/uid/1000/64-bit",
- true},
- /* Empty path */
- {"", "test", "", "", "", "", false},
- /* Path without second token */
- {"hostname", "test", "hostname", "", "", "", false},
- /* No leftover */
- {"hostname/test", "test", "hostname", "", "", "", true},
- /* Path with ession name but no datetime */
- {"hostname/test/ust/uid/1000/64-bit", "test", "hostname", "",
- "", "ust/uid/1000/64-bit", true},
+ /* Default name session streaming. */
+ { "hostname/auto-20190918-164429/ust/uid/1000/64-bit",
+ "auto-20190918-164429",
+ "hostname",
+ "20190918-164429",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
+ /* Custom default name session */
+ { "hostname/custom_auto-20190319-120000/ust/uid/1000/64-bit",
+ "custom_auto-20190319-120000",
+ "hostname",
+ "20190319-120000",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
+ /* Named session streaming */
+ { "hostname/test-20190918-164709/ust/uid/1000/64-bit",
+ "test",
+ "hostname",
+ "20190918-164709",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
+ /* Default session snapshot streaming */
+ { "hostname//snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
+ "my_session",
+ "hostname",
+ "",
+ "",
+ "snapshot-1-20190918-164829-0/ust//uid/1000/64-bit",
+ true },
+ /* Named session snapshot streaming */
+ { "hostname//snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
+ "my_session",
+ "hostname",
+ "",
+ "",
+ "snapshot-1-20190918-175919-0/ust//uid/1000/64-bit",
+ true },
+ /* Default name session, live */
+ { "hostname//auto-20190918-171641/ust/uid/1000/64-bit",
+ "auto-20190918-171641",
+ "hostname",
+ "20190918-171641",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
+ /* Named session, live */
+ { "hostname//test-20190918-180333//ust/uid/1000/64-bit",
+ "test-20190918-180333",
+ "hostname",
+ "20190918-180333",
+ "",
+ "/ust/uid/1000/64-bit",
+ true },
+ /* Default name session, streaming & live , extra path */
+ { "hostname/extra/path/ust/uid/1000/64-bit",
+ "auto-20190919-122110",
+ "hostname",
+ "20190919-122110",
+ "extra",
+ "path/ust/uid/1000/64-bit",
+ true },
+ /* Named session, live, extra path */
+ { "hostname/extra/path/ust/uid/1000/64-bit",
+ "test",
+ "hostname",
+ "",
+ "extra",
+ "path/ust/uid/1000/64-bit",
+ true },
+ /* Named session, snapshot, extra path */
+ { "hostname/extra/path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
+ "test",
+ "hostname",
+ "",
+ "extra",
+ "path/snapshot-1-20190919-140702-0/ust//uid/1000/64-bit",
+ true },
+ /* Corner cases*/
+ /* Named session with valid datetime in it */
+ /* Default name session, extra path with session name in it*/
+ { "hostname/test-20190319-120000-20190918-180921/ust/uid/1000/64-bit",
+ "test-20190319-120000",
+ "hostname",
+ "20190918-180921",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
+ /* Empty path */
+ { "", "test", "", "", "", "", false },
+ /* Path without second token */
+ { "hostname", "test", "hostname", "", "", "", false },
+ /* No leftover */
+ { "hostname/test", "test", "hostname", "", "", "", true },
+ /* Path with ession name but no datetime */
+ { "hostname/test/ust/uid/1000/64-bit",
+ "test",
+ "hostname",
+ "",
+ "",
+ "ust/uid/1000/64-bit",
+ true },
};
static char *craft_expected(struct test *test, time_t relay_session_creation_time)
char relay_session_creation_datetime[DATETIME_STR_LEN];
ret = time_to_datetime_str(relay_session_creation_time,
- relay_session_creation_datetime,
- sizeof(relay_session_creation_datetime));
+ relay_session_creation_datetime,
+ sizeof(relay_session_creation_datetime));
if (ret < 0) {
result = NULL;
goto end;
}
- ret = asprintf(&result, "%s/%s-%s/%s%s%s", test->session_name,
- test->hostname,
- test->creation_time[0] == '\0' ?
- relay_session_creation_datetime :
- test->creation_time,
- test->extra_path,
- test->extra_path[0] != '\0' ? "/" : "", test->leftover);
+ ret = asprintf(&result,
+ "%s/%s-%s/%s%s%s",
+ test->session_name,
+ test->hostname,
+ test->creation_time[0] == '\0' ? relay_session_creation_datetime :
+ test->creation_time,
+ test->extra_path,
+ test->extra_path[0] != '\0' ? "/" : "",
+ test->leftover);
if (ret < 0) {
result = NULL;
goto end;
goto loop;
}
- result = backward_compat_group_by_session(tests[i].stream_path,
- tests[i].session_name, test_time);
+ result = backward_compat_group_by_session(
+ tests[i].stream_path, tests[i].session_name, test_time);
if (!result && tests[i].is_valid) {
fprintf(stderr, "Failed to get result\n");
goto loop;
}
ok(strncmp(expected, result, strlen(expected)) == 0,
- "In: %s, out: %s, expected: %s",
- tests[i].stream_path, result, expected);
+ "In: %s, out: %s, expected: %s",
+ tests[i].stream_path,
+ result,
+ expected);
loop:
free(expected);
free(result);
*
*/
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#include <bin/lttng-sessiond/health-sessiond.hpp>
+#include <bin/lttng-sessiond/session.hpp>
+#include <bin/lttng-sessiond/thread.hpp>
+#include <bin/lttng-sessiond/ust-app.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <tap/tap.h>
#include <time.h>
#include <unistd.h>
#include <urcu.h>
-#include <bin/lttng-sessiond/health-sessiond.hpp>
-#include <bin/lttng-sessiond/session.hpp>
-#include <bin/lttng-sessiond/thread.hpp>
-#include <bin/lttng-sessiond/ust-app.hpp>
-#include <common/common.hpp>
-#include <common/compat/errno.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-
-#include <tap/tap.h>
-
#define SESSION1 "test1"
-#define MAX_SESSIONS 10000
-#define RANDOM_STRING_LEN 11
+#define MAX_SESSIONS 10000
+#define RANDOM_STRING_LEN 11
/* Number of TAP tests in this file */
#define NUM_TESTS 11
static struct ltt_session_list *session_list;
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
+static const char alphanum[] = "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
static char random_string[RANDOM_STRING_LEN];
/*
{
struct ltt_session *iter;
- cds_list_for_each_entry(iter, &session_list->head, list) {
+ cds_list_for_each_entry (iter, &session_list->head, list) {
if (strcmp(iter->name, name) == 0) {
return 0;
}
int count = 0;
struct ltt_session *iter;
- cds_list_for_each_entry(iter, &session_list->head, list) {
+ cds_list_for_each_entry (iter, &session_list->head, list) {
count++;
}
return count;
struct ltt_session *iter, *tmp;
session_lock_list();
- cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+ cds_list_for_each_entry_safe (iter, tmp, &session_list->head, list) {
session_destroy(iter);
}
session_unlock_list();
static void test_create_one_session(void)
{
- ok(create_one_session(SESSION1) == 0,
- "Create session: %s",
- SESSION1);
+ ok(create_one_session(SESSION1) == 0, "Create session: %s", SESSION1);
}
static void test_validate_session(void)
session_lock_list();
tmp = session_find_by_name(SESSION1);
- ok(tmp != NULL,
- "Validating session: session found");
+ ok(tmp != NULL, "Validating session: session found");
if (tmp) {
- ok(tmp->kernel_session == NULL &&
- strlen(tmp->name),
+ ok(tmp->kernel_session == NULL && strlen(tmp->name),
"Validating session: basic sanity check");
} else {
skip(1, "Skipping session validation check as session was not found");
session_lock_list();
tmp = session_find_by_name(SESSION1);
- ok(tmp != NULL,
- "Destroying session: session found");
+ ok(tmp != NULL, "Destroying session: session found");
if (tmp) {
- ok(destroy_one_session(tmp) == 0,
- "Destroying session: %s destroyed",
- SESSION1);
+ ok(destroy_one_session(tmp) == 0, "Destroying session: %s destroyed", SESSION1);
} else {
skip(1, "Skipping session destruction as it was not found");
}
static void test_duplicate_session(void)
{
- ok(two_session_same_name() == 0,
- "Duplicate session creation");
+ ok(two_session_same_name() == 0, "Duplicate session creation");
}
static void test_session_name_generation(void)
session_lock_list();
ret_code = session_create(NULL, geteuid(), getegid(), &session);
- ok(ret_code == LTTNG_OK,
- "Create session with a NULL name (auto-generate a name)");
+ ok(ret_code == LTTNG_OK, "Create session with a NULL name (auto-generate a name)");
if (!session) {
skip(1, "Skipping session name generation tests as session_create() failed.");
goto end;
}
- diag("Automatically-generated session name: %s", *session->name ?
- session->name : "ERROR");
- ok(*session->name && !strncmp(expected_session_name_prefix, session->name,
- sizeof(DEFAULT_SESSION_NAME) - 1),
- "Auto-generated session name starts with %s",
- DEFAULT_SESSION_NAME);
+ diag("Automatically-generated session name: %s", *session->name ? session->name : "ERROR");
+ ok(*session->name &&
+ !strncmp(expected_session_name_prefix,
+ session->name,
+ sizeof(DEFAULT_SESSION_NAME) - 1),
+ "Auto-generated session name starts with %s",
+ DEFAULT_SESSION_NAME);
end:
session_put(session);
session_unlock_list();
}
}
- ok(failed == 0,
- "Large sessions number: created %u sessions",
- MAX_SESSIONS);
+ ok(failed == 0, "Large sessions number: created %u sessions", MAX_SESSIONS);
failed = 0;
session_lock_list();
for (i = 0; i < MAX_SESSIONS; i++) {
- cds_list_for_each_entry_safe(iter, tmp, &session_list->head, list) {
+ cds_list_for_each_entry_safe (iter, tmp, &session_list->head, list) {
LTTNG_ASSERT(session_get(iter));
ret = destroy_one_session(iter);
if (ret < 0) {
int main(void)
{
-
plan_tests(NUM_TESTS);
the_health_sessiond = health_app_create(NR_HEALTH_SESSIOND_TYPES);
*
*/
-#include <stdlib.h>
+#include <common/string-utils/string-utils.hpp>
+
+#include <stdarg.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
-#include <common/string-utils/string-utils.hpp>
#include <tap/tap.h>
/* Number of TAP tests in this file */
int lttng_opt_verbose;
int lttng_opt_mi;
-static void test_one_split(const char *input, char delim, int escape_delim,
- ...)
+static void test_one_split(const char *input, char delim, int escape_delim, ...)
{
va_list vl;
bool all_ok = true;
for (i = 0; i < string_count; i++) {
const char *expected_substring = va_arg(vl, const char *);
const char *substring =
- (const char *) lttng_dynamic_pointer_array_get_pointer(
- &strings, i);
+ (const char *) lttng_dynamic_pointer_array_get_pointer(&strings, i);
diag(" got `%s`, expecting `%s`", substring, expected_substring);
lttng_dynamic_pointer_array_reset(&strings);
va_end(vl);
- ok(all_ok, "strutils_split() produces the expected substrings: `%s` (delim. `%c`, escape `%d`)",
- input, delim, escape_delim);
+ ok(all_ok,
+ "strutils_split() produces the expected substrings: `%s` (delim. `%c`, escape `%d`)",
+ input,
+ delim,
+ escape_delim);
}
static void test_split(void)
static void test_one_is_star_at_the_end_only_glob_pattern(const char *pattern, bool expected)
{
ok(strutils_is_star_at_the_end_only_glob_pattern(pattern) == expected,
- "strutils_is_star_at_the_end_only_glob_pattern() returns the expected result: `%s` -> %d",
- pattern, expected);
+ "strutils_is_star_at_the_end_only_glob_pattern() returns the expected result: `%s` -> %d",
+ pattern,
+ expected);
}
static void test_is_star_at_the_end_only_glob_pattern(void)
static void test_one_is_star_glob_pattern(const char *pattern, bool expected)
{
ok(strutils_is_star_glob_pattern(pattern) == expected,
- "strutils_is_star_glob_pattern() returns the expected result: `%s` -> %d",
- pattern, expected);
+ "strutils_is_star_glob_pattern() returns the expected result: `%s` -> %d",
+ pattern,
+ expected);
}
static void test_is_star_glob_pattern(void)
test_one_is_star_glob_pattern("allo\\", false);
}
-static void test_one_normalize_star_glob_pattern(const char *pattern,
- const char *expected)
+static void test_one_normalize_star_glob_pattern(const char *pattern, const char *expected)
{
char *rw_pattern = strdup(pattern);
LTTNG_ASSERT(rw_pattern);
strutils_normalize_star_glob_pattern(rw_pattern);
ok(strcmp(rw_pattern, expected) == 0,
- "strutils_normalize_star_glob_pattern() produces the expected result: `%s` -> `%s`",
- pattern, expected);
+ "strutils_normalize_star_glob_pattern() produces the expected result: `%s` -> `%s`",
+ pattern,
+ expected);
free(rw_pattern);
}
*
*/
-#include <algorithm>
#include <common/compat/fcntl.hpp>
-#include <common/sessiond-comm/sessiond-comm.hpp>
-#include <common/payload.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
#include <common/payload-view.hpp>
+#include <common/payload.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
#include <common/unix.hpp>
#include <common/utils.hpp>
-#include <common/defaults.hpp>
-#include <tap/tap.h>
-#include <stdbool.h>
-#include <common/error.hpp>
+
#include <lttng/constant.h>
-#include <stdio.h>
+
+#include <algorithm>
#include <pthread.h>
-#include <unistd.h>
-#include <sys/wait.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <sys/wait.h>
+#include <tap/tap.h>
+#include <unistd.h>
-#define HIGH_FD_COUNT LTTCOMM_MAX_SEND_FDS
-#define MESSAGE_COUNT 4
-#define LARGE_PAYLOAD_SIZE 4 * 1024
-#define LARGE_PAYLOAD_RECV_SIZE 100
+#define HIGH_FD_COUNT LTTCOMM_MAX_SEND_FDS
+#define MESSAGE_COUNT 4
+#define LARGE_PAYLOAD_SIZE 4 * 1024
+#define LARGE_PAYLOAD_RECV_SIZE 100
static const int TEST_COUNT = 37;
*/
static void test_high_fd_count(unsigned int fd_count)
{
- int sockets[2] = {-1, -1};
+ int sockets[2] = { -1, -1 };
int ret;
unsigned int i;
const unsigned int payload_content = 42;
}
/* Add dummy content to payload. */
- ret = lttng_dynamic_buffer_append(&sent_payload.buffer,
- &payload_content, sizeof(payload_content));
+ ret = lttng_dynamic_buffer_append(
+ &sent_payload.buffer, &payload_content, sizeof(payload_content));
if (ret) {
PERROR("Failed to initialize test payload");
goto error;
/* Send payload. */
{
ssize_t sock_ret;
- struct lttng_payload_view pv = lttng_payload_view_from_payload(
- &sent_payload, 0, -1);
+ struct lttng_payload_view pv =
+ lttng_payload_view_from_payload(&sent_payload, 0, -1);
/* Not expected to block considering the size of the payload. */
- sock_ret = lttcomm_send_unix_sock(
- sockets[0], pv.buffer.data, pv.buffer.size);
+ sock_ret = lttcomm_send_unix_sock(sockets[0], pv.buffer.data, pv.buffer.size);
ok(sock_ret == pv.buffer.size, "Sent complete test payload");
if (sock_ret != pv.buffer.size) {
ERR("Failed to send test payload bytes: ret = %zd, expected = %zu",
- sock_ret, pv.buffer.size);
+ sock_ret,
+ pv.buffer.size);
goto error;
}
- sock_ret = lttcomm_send_payload_view_fds_unix_sock(
- sockets[0], &pv);
+ sock_ret = lttcomm_send_payload_view_fds_unix_sock(sockets[0], &pv);
ok(sock_ret == 1, "Sent test payload file descriptors");
if (sock_ret != 1) {
if (sock_ret < 0) {
PERROR("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
} else {
diag("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
}
goto error;
ssize_t sock_ret;
ret = lttng_dynamic_buffer_set_size(&received_payload.buffer,
- sent_payload.buffer.size);
+ sent_payload.buffer.size);
if (ret) {
PERROR("Failed to pre-allocate reception buffer");
goto error;
}
- sock_ret = lttcomm_recv_unix_sock(sockets[1],
- received_payload.buffer.data,
- received_payload.buffer.size);
- ok(sock_ret == received_payload.buffer.size,
- "Received payload bytes");
+ sock_ret = lttcomm_recv_unix_sock(
+ sockets[1], received_payload.buffer.data, received_payload.buffer.size);
+ ok(sock_ret == received_payload.buffer.size, "Received payload bytes");
if (sock_ret != received_payload.buffer.size) {
ERR("Failed to receive payload bytes: ret = %zd, expected = %zu",
- sock_ret, received_payload.buffer.size);
+ sock_ret,
+ received_payload.buffer.size);
goto error;
}
- sock_ret = lttcomm_recv_payload_fds_unix_sock(
- sockets[1], fd_count, &received_payload);
+ sock_ret =
+ lttcomm_recv_payload_fds_unix_sock(sockets[1], fd_count, &received_payload);
ok(sock_ret == (int) (sizeof(int) * fd_count),
- "FD reception return value is number of fd * sizeof(int)");
+ "FD reception return value is number of fd * sizeof(int)");
if (sock_ret != (int) (sizeof(int) * fd_count)) {
ERR("Failed to receive test payload file descriptors: ret = %zd, expected = %d",
- sock_ret,
- (int) (fd_count * sizeof(int)));
+ sock_ret,
+ (int) (fd_count * sizeof(int)));
goto error;
}
{
const struct lttng_payload_view pv =
- lttng_payload_view_from_payload(
- &received_payload, 0,
- -1);
- const int fd_handle_count =
- lttng_payload_view_get_fd_handle_count(
- &pv);
+ lttng_payload_view_from_payload(&received_payload, 0, -1);
+ const int fd_handle_count = lttng_payload_view_get_fd_handle_count(&pv);
ok(fd_handle_count == fd_count,
- "Received all test payload file descriptors in one invocation");
+ "Received all test payload file descriptors in one invocation");
}
}
static void test_one_fd_per_message(unsigned int message_count)
{
const unsigned int payload_content = 42;
- int sockets[2] = {-1, -1};
+ int sockets[2] = { -1, -1 };
int ret;
unsigned int i;
struct lttng_payload sent_payload;
struct lttng_payload received_payload;
- diag("Send and receive small messages with one FD each (%u messages)",
- message_count);
+ diag("Send and receive small messages with one FD each (%u messages)", message_count);
lttng_payload_init(&sent_payload);
lttng_payload_init(&received_payload);
int fd;
/* Add dummy content to payload. */
- ret = lttng_dynamic_buffer_append(&sent_payload.buffer,
- &payload_content, sizeof(payload_content));
+ ret = lttng_dynamic_buffer_append(
+ &sent_payload.buffer, &payload_content, sizeof(payload_content));
if (ret) {
PERROR("Failed to initialize test payload");
goto error;
{
ssize_t sock_ret;
struct lttng_payload_view pv =
- lttng_payload_view_from_payload(
- &sent_payload, 0, -1);
+ lttng_payload_view_from_payload(&sent_payload, 0, -1);
/* Not expected to block considering the size of the
* payload. */
- sock_ret = lttcomm_send_unix_sock(sockets[0],
- pv.buffer.data, pv.buffer.size);
- ok(sock_ret == pv.buffer.size,
- "Sent binary payload for message %u",
- i);
+ sock_ret =
+ lttcomm_send_unix_sock(sockets[0], pv.buffer.data, pv.buffer.size);
+ ok(sock_ret == pv.buffer.size, "Sent binary payload for message %u", i);
if (sock_ret != pv.buffer.size) {
ERR("Failed to send test payload bytes: ret = %zd, expected = %zu",
- sock_ret, pv.buffer.size);
+ sock_ret,
+ pv.buffer.size);
goto error;
}
- sock_ret = lttcomm_send_payload_view_fds_unix_sock(
- sockets[0], &pv);
- ok(sock_ret == 1,
- "Sent file descriptors payload for message %u",
- i);
+ sock_ret = lttcomm_send_payload_view_fds_unix_sock(sockets[0], &pv);
+ ok(sock_ret == 1, "Sent file descriptors payload for message %u", i);
if (sock_ret != 1) {
if (sock_ret < 0) {
PERROR("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
} else {
diag("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
}
goto error;
ssize_t sock_ret;
ret = lttng_dynamic_buffer_set_size(&received_payload.buffer,
- sizeof(payload_content));
+ sizeof(payload_content));
if (ret) {
PERROR("Failed to pre-allocate reception buffer");
goto error;
}
- sock_ret = lttcomm_recv_unix_sock(sockets[1],
- received_payload.buffer.data,
- received_payload.buffer.size);
+ sock_ret = lttcomm_recv_unix_sock(
+ sockets[1], received_payload.buffer.data, received_payload.buffer.size);
ok(sock_ret == received_payload.buffer.size,
- "Received payload bytes for message %u", i);
+ "Received payload bytes for message %u",
+ i);
if (sock_ret != received_payload.buffer.size) {
ERR("Failed to receive payload bytes: ret = %zd, expected = %zu",
- sock_ret, received_payload.buffer.size);
+ sock_ret,
+ received_payload.buffer.size);
goto error;
}
- sock_ret = lttcomm_recv_payload_fds_unix_sock(
- sockets[1], 1, &received_payload);
- ok(sock_ret == (int) sizeof(int), "Received fd for message %u",
- i);
+ sock_ret = lttcomm_recv_payload_fds_unix_sock(sockets[1], 1, &received_payload);
+ ok(sock_ret == (int) sizeof(int), "Received fd for message %u", i);
if (sock_ret != (int) sizeof(int)) {
ERR("Failed to receive test payload file descriptors: ret = %zd, expected = %u",
- sock_ret, (int) sizeof(int));
+ sock_ret,
+ (int) sizeof(int));
goto error;
}
{
const struct lttng_payload_view pv =
- lttng_payload_view_from_payload(
- &received_payload, 0,
- -1);
- const int fd_handle_count =
- lttng_payload_view_get_fd_handle_count(
- &pv);
+ lttng_payload_view_from_payload(&received_payload, 0, -1);
+ const int fd_handle_count = lttng_payload_view_get_fd_handle_count(&pv);
- ok(fd_handle_count == 1,
- "Payload contains 1 fd for message %u",
- i);
+ ok(fd_handle_count == 1, "Payload contains 1 fd for message %u", i);
}
lttng_payload_clear(&received_payload);
/*
* Validate that a large message can be received in multiple chunks.
*/
-static void test_receive_in_chunks(
- unsigned int payload_size, unsigned int max_recv_size)
+static void test_receive_in_chunks(unsigned int payload_size, unsigned int max_recv_size)
{
- int sockets[2] = {-1, -1};
+ int sockets[2] = { -1, -1 };
int ret;
unsigned int i;
struct lttng_payload sent_payload;
/* Send payload. */
{
- struct lttng_payload_view pv = lttng_payload_view_from_payload(
- &sent_payload, 0, -1);
+ struct lttng_payload_view pv =
+ lttng_payload_view_from_payload(&sent_payload, 0, -1);
/* Not expected to block considering the size of the payload. */
- sock_ret = lttcomm_send_unix_sock(
- sockets[0], pv.buffer.data, pv.buffer.size);
+ sock_ret = lttcomm_send_unix_sock(sockets[0], pv.buffer.data, pv.buffer.size);
ok(sock_ret == pv.buffer.size, "Sent complete test payload");
if (sock_ret != pv.buffer.size) {
ERR("Failed to send test payload bytes: ret = %zd, expected = %zu",
- sock_ret, pv.buffer.size);
+ sock_ret,
+ pv.buffer.size);
goto error;
}
- sock_ret = lttcomm_send_payload_view_fds_unix_sock(
- sockets[0], &pv);
+ sock_ret = lttcomm_send_payload_view_fds_unix_sock(sockets[0], &pv);
ok(sock_ret == 1, "Sent test payload file descriptors");
if (sock_ret != 1) {
if (sock_ret < 0) {
PERROR("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
} else {
diag("Failed to send test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, 1);
+ sock_ret,
+ 1);
}
goto error;
}
/* Receive payload */
- ret = lttng_dynamic_buffer_set_size(
- &received_payload.buffer, sent_payload.buffer.size);
+ ret = lttng_dynamic_buffer_set_size(&received_payload.buffer, sent_payload.buffer.size);
if (ret) {
PERROR("Failed to pre-allocate reception buffer");
goto error;
do {
const ssize_t to_receive_this_pass =
- std::min<ssize_t>(max_recv_size,
- sent_payload.buffer.size - received);
+ std::min<ssize_t>(max_recv_size, sent_payload.buffer.size - received);
- sock_ret = lttcomm_recv_unix_sock(sockets[1],
- received_payload.buffer.data + received,
- to_receive_this_pass);
+ sock_ret = lttcomm_recv_unix_sock(
+ sockets[1], received_payload.buffer.data + received, to_receive_this_pass);
if (sock_ret != to_receive_this_pass) {
ERR("Failed to receive payload bytes: ret = %zd, expected = %zu",
- sock_ret, to_receive_this_pass);
+ sock_ret,
+ to_receive_this_pass);
break;
}
} while (received < sent_payload.buffer.size);
ok(received == sent_payload.buffer.size,
- "Received complete payload in chunks of %u bytes",
- max_recv_size);
+ "Received complete payload in chunks of %u bytes",
+ max_recv_size);
if (received != sent_payload.buffer.size) {
goto error;
}
- sock_ret = lttcomm_recv_payload_fds_unix_sock(
- sockets[1], 1, &received_payload);
+ sock_ret = lttcomm_recv_payload_fds_unix_sock(sockets[1], 1, &received_payload);
ok(sock_ret == (int) sizeof(int),
- "Received file descriptor after receiving payload in chunks");
+ "Received file descriptor after receiving payload in chunks");
if (sock_ret != (int) sizeof(int)) {
ERR("Failed to receive test payload file descriptors: ret = %zd, expected = %d",
- sock_ret, (int) sizeof(int));
+ sock_ret,
+ (int) sizeof(int));
goto error;
}
{
const struct lttng_payload_view pv =
- lttng_payload_view_from_payload(
- &received_payload, 0, -1);
- const int fd_handle_count =
- lttng_payload_view_get_fd_handle_count(&pv);
+ lttng_payload_view_from_payload(&received_payload, 0, -1);
+ const int fd_handle_count = lttng_payload_view_get_fd_handle_count(&pv);
- ok(fd_handle_count == 1,
- "Payload contains 1 fd after receiving payload in chunks");
+ ok(fd_handle_count == 1, "Payload contains 1 fd after receiving payload in chunks");
}
error:
lttng_payload_reset(&received_payload);
}
-static
-void test_creds_passing(void)
+static void test_creds_passing(void)
{
pid_t fork_ret = -1;
int ret, parent_socket = -1, child_connection_socket = -1;
goto error;
}
- strncat(socket_path, socket_dir_path,
- sizeof(socket_path) - strlen(socket_path) - 1);
- strncat(socket_path, "/test_unix_socket",
- sizeof(socket_path) - strlen(socket_path) - 1);
+ strncat(socket_path, socket_dir_path, sizeof(socket_path) - strlen(socket_path) - 1);
+ strncat(socket_path, "/test_unix_socket", sizeof(socket_path) - strlen(socket_path) - 1);
parent_socket = lttcomm_create_unix_sock(socket_path);
ok(parent_socket >= 0, "Created unix socket at path `%s`", socket_path);
PERROR("Failed to set SO_PASSCRED on child socket");
}
- sock_ret = lttcomm_send_creds_unix_sock(child_socket, &expected_creds,
- sizeof(expected_creds));
+ sock_ret = lttcomm_send_creds_unix_sock(
+ child_socket, &expected_creds, sizeof(expected_creds));
if (sock_ret < 0) {
PERROR("Failed to send expected credentials");
}
pid_t wait_pid_ret;
lttng_sock_cred received_creds = {};
- child_connection_socket =
- lttcomm_accept_unix_sock(parent_socket);
+ child_connection_socket = lttcomm_accept_unix_sock(parent_socket);
if (child_connection_socket < 0) {
PERROR();
goto error;
}
- ret = lttcomm_setsockopt_creds_unix_sock(
- child_connection_socket);
+ ret = lttcomm_setsockopt_creds_unix_sock(child_connection_socket);
if (ret) {
PERROR("Failed to set SO_PASSCRED on child connection socket");
goto error;
}
sock_ret = lttcomm_recv_creds_unix_sock(child_connection_socket,
- &expected_creds, sizeof(expected_creds),
- &received_creds);
+ &expected_creds,
+ sizeof(expected_creds),
+ &received_creds);
if (sock_ret < 0) {
PERROR("Failed to receive credentials");
goto error;
}
ok(expected_creds.euid == received_creds.uid,
- "Received the expected effective uid (%d == %d)",
- expected_creds.euid, received_creds.uid);
+ "Received the expected effective uid (%d == %d)",
+ expected_creds.euid,
+ received_creds.uid);
ok(expected_creds.egid == received_creds.gid,
- "Received the expected effective gid (%d == %d)",
- expected_creds.egid, received_creds.gid);
+ "Received the expected effective gid (%d == %d)",
+ expected_creds.egid,
+ received_creds.gid);
ok(expected_creds.pid == received_creds.pid,
- "Received the expected pid (%d == %d)",
- expected_creds.pid, received_creds.pid);
+ "Received the expected pid (%d == %d)",
+ expected_creds.pid,
+ received_creds.pid);
}
error:
ret = unlink(socket_path);
if (ret) {
- PERROR("Failed to unlink socket at path `%s`",
- socket_path);
+ PERROR("Failed to unlink socket at path `%s`", socket_path);
}
ret = rmdir(socket_dir_path);
if (ret) {
- PERROR("Failed to remove test directory at `%s`",
- socket_dir_path);
+ PERROR("Failed to remove test directory at `%s`", socket_dir_path);
}
}
}
*
*/
-#include <string.h>
+#include <common/uri.hpp>
+#include <string.h>
#include <tap/tap.h>
-#include <common/uri.hpp>
-
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
size = uri_parse(s_uri1, &uri);
- ok(size == 2 &&
- uri[0].dtype == LTTNG_DST_IPV4 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 0 &&
- strlen(uri[0].subdir) == 0 &&
- strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
- uri[1].dtype == LTTNG_DST_IPV4 &&
- uri[1].utype == LTTNG_URI_DST &&
- uri[1].stype == 0 &&
- uri[1].port == 0 &&
- strlen(uri[1].subdir) == 0 &&
- strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+ ok(size == 2 && uri[0].dtype == LTTNG_DST_IPV4 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 0 && strlen(uri[0].subdir) == 0 &&
+ strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 && uri[1].dtype == LTTNG_DST_IPV4 &&
+ uri[1].utype == LTTNG_URI_DST && uri[1].stype == 0 && uri[1].port == 0 &&
+ strlen(uri[1].subdir) == 0 && strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
"URI set to net://localhost");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 2 &&
- uri[0].dtype == LTTNG_DST_IPV4 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 8989 &&
- strcmp(uri[0].subdir, "my/test/path") == 0 &&
- strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
- uri[1].dtype == LTTNG_DST_IPV4 &&
- uri[1].utype == LTTNG_URI_DST &&
- uri[1].stype == 0 &&
- uri[1].port == 4242 &&
- strlen(uri[1].subdir) == 0 &&
- strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+ ok(size == 2 && uri[0].dtype == LTTNG_DST_IPV4 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 8989 &&
+ strcmp(uri[0].subdir, "my/test/path") == 0 &&
+ strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 && uri[1].dtype == LTTNG_DST_IPV4 &&
+ uri[1].utype == LTTNG_URI_DST && uri[1].stype == 0 && uri[1].port == 4242 &&
+ strlen(uri[1].subdir) == 0 && strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
"URI set to net://localhost:8989:4242/my/test/path");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 2 &&
- uri[0].dtype == LTTNG_DST_IPV4 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 8989 &&
- strlen(uri[0].subdir) == 0 &&
- strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 &&
- uri[1].dtype == LTTNG_DST_IPV4 &&
- uri[1].utype == LTTNG_URI_DST &&
- uri[1].stype == 0 &&
- uri[1].port == 4242 &&
- strlen(uri[1].subdir) == 0 &&
- strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
+ ok(size == 2 && uri[0].dtype == LTTNG_DST_IPV4 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 8989 && strlen(uri[0].subdir) == 0 &&
+ strcmp(uri[0].dst.ipv4, "127.0.0.1") == 0 && uri[1].dtype == LTTNG_DST_IPV4 &&
+ uri[1].utype == LTTNG_URI_DST && uri[1].stype == 0 && uri[1].port == 4242 &&
+ strlen(uri[1].subdir) == 0 && strcmp(uri[1].dst.ipv4, "127.0.0.1") == 0,
"URI set to net://localhost:8989:4242");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 2 &&
- uri[0].dtype == LTTNG_DST_IPV6 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 8989 &&
- strlen(uri[0].subdir) == 0 &&
- strcmp(uri[0].dst.ipv6, "::1") == 0 &&
- uri[1].dtype == LTTNG_DST_IPV6 &&
- uri[1].utype == LTTNG_URI_DST &&
- uri[1].stype == 0 &&
- uri[1].port == 0 &&
- strlen(uri[1].subdir) == 0 &&
- strcmp(uri[1].dst.ipv6, "::1") == 0,
+ ok(size == 2 && uri[0].dtype == LTTNG_DST_IPV6 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 8989 && strlen(uri[0].subdir) == 0 &&
+ strcmp(uri[0].dst.ipv6, "::1") == 0 && uri[1].dtype == LTTNG_DST_IPV6 &&
+ uri[1].utype == LTTNG_URI_DST && uri[1].stype == 0 && uri[1].port == 0 &&
+ strlen(uri[1].subdir) == 0 && strcmp(uri[1].dst.ipv6, "::1") == 0,
"URI set to net6://[::1]:8989");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 1 &&
- uri[0].dtype == LTTNG_DST_IPV4 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 0 &&
- strcmp(uri[0].subdir, "my/test/path") == 0 &&
- strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0,
+ ok(size == 1 && uri[0].dtype == LTTNG_DST_IPV4 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 0 &&
+ strcmp(uri[0].subdir, "my/test/path") == 0 &&
+ strcmp(uri[0].dst.ipv4, "42.42.42.42") == 0,
"URI set to tcp://42.42.42.42/my/test/path");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 1 &&
- uri[0].dtype == LTTNG_DST_IPV6 &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 0 &&
- strcmp(uri[0].subdir, "my/test/path") == 0 &&
- strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0,
+ ok(size == 1 && uri[0].dtype == LTTNG_DST_IPV6 && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 0 &&
+ strcmp(uri[0].subdir, "my/test/path") == 0 &&
+ strcmp(uri[0].dst.ipv6, "fe80::f66d:4ff:fe53:d220") == 0,
"URI set to tcp6://[fe80::f66d:4ff:fe53:d220]/my/test/path");
if (uri) {
size = uri_parse(s_uri1, &uri);
- ok(size == 1 &&
- uri[0].dtype == LTTNG_DST_PATH &&
- uri[0].utype == LTTNG_URI_DST &&
- uri[0].stype == 0 &&
- uri[0].port == 0 &&
- strlen(uri[0].subdir) == 0 &&
- strcmp(uri[0].dst.path, "/my/test/path") == 0,
+ ok(size == 1 && uri[0].dtype == LTTNG_DST_PATH && uri[0].utype == LTTNG_URI_DST &&
+ uri[0].stype == 0 && uri[0].port == 0 && strlen(uri[0].subdir) == 0 &&
+ strcmp(uri[0].dst.path, "/my/test/path") == 0,
"URI set to file:///my/test/path");
if (uri) {
res = uri_compare(uri1, uri1);
- ok(res == 0,
- "URI compare net://localhost == net://localhost");
+ ok(res == 0, "URI compare net://localhost == net://localhost");
res = uri_compare(uri1, uri2);
- ok(res != 0,
- "URI compare net://localhost != net://localhost:8989:4242");
+ ok(res != 0, "URI compare net://localhost != net://localhost:8989:4242");
uri_free(uri1);
uri_free(uri2);
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <time.h>
-#include <urcu.h>
+#include <common/compat/errno.hpp>
+#include <common/defaults.hpp>
#include <lttng/lttng.h>
+#include <lttng/ust-sigbus.h>
+
#include <bin/lttng-sessiond/lttng-ust-abi.hpp>
-#include <common/defaults.hpp>
-#include <common/compat/errno.hpp>
+#include <bin/lttng-sessiond/notification-thread.hpp>
#include <bin/lttng-sessiond/trace-ust.hpp>
#include <bin/lttng-sessiond/ust-app.hpp>
-#include <bin/lttng-sessiond/notification-thread.hpp>
-
-#include <lttng/ust-sigbus.h>
-
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <tap/tap.h>
+#include <time.h>
+#include <unistd.h>
+#include <urcu.h>
/* This path will NEVER be created in this test */
#define PATH1 "/tmp/.test-junk-lttng"
-#define RANDOM_STRING_LEN 11
+#define RANDOM_STRING_LEN 11
/* Number of TAP tests in this file */
#define NUM_TESTS 16
LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
-static const char alphanum[] =
- "0123456789"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz";
+static const char alphanum[] = "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
static char random_string[RANDOM_STRING_LEN];
/*
static void test_create_one_ust_session(void)
{
- struct ltt_ust_session *usess =
- trace_ust_create_session(42);
+ struct ltt_ust_session *usess = trace_ust_create_session(42);
ok(usess != NULL, "Create UST session");
return;
}
- ok(usess->id == 42 &&
- usess->active == 0 &&
- usess->domain_global.channels != NULL &&
- usess->uid == 0 &&
- usess->gid == 0,
+ ok(usess->id == 42 && usess->active == 0 && usess->domain_global.channels != NULL &&
+ usess->uid == 0 && usess->gid == 0,
"Validate UST session");
trace_ust_destroy_session(usess);
attr.attr.extended.ptr = &extended;
ok(lttng_strncpy(attr.name, "channel0", sizeof(attr.name)) == 0,
- "Validate channel name length");
+ "Validate channel name length");
uchan = trace_ust_create_channel(&attr, LTTNG_DOMAIN_UST);
ok(uchan != NULL, "Create UST channel");
return;
}
- ok(uchan->enabled == 0 &&
- strncmp(uchan->name, "channel0", 8) == 0 &&
- uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' &&
- uchan->ctx != NULL &&
- uchan->events != NULL &&
- uchan->attr.overwrite == attr.attr.overwrite,
+ ok(uchan->enabled == 0 && strncmp(uchan->name, "channel0", 8) == 0 &&
+ uchan->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0' && uchan->ctx != NULL &&
+ uchan->events != NULL && uchan->attr.overwrite == attr.attr.overwrite,
"Validate UST channel");
trace_ust_destroy_channel(uchan);
enum lttng_error_code ret;
memset(&ev, 0, sizeof(ev));
- ok(lttng_strncpy(ev.name, get_random_string(),
- LTTNG_SYMBOL_NAME_LEN) == 0,
- "Validate string length");
+ ok(lttng_strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN) == 0,
+ "Validate string length");
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
return;
}
- ok(event->enabled == 0 &&
- 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',
+ ok(event->enabled == 0 && 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");
trace_ust_destroy_event(event);
/* make a wildcarded event name */
name = get_random_string();
name[strlen(name) - 1] = '*';
- ok(lttng_strncpy(ev.name, name, LTTNG_SYMBOL_NAME_LEN) == 0,
- "Validate string length");
+ ok(lttng_strncpy(ev.name, name, LTTNG_SYMBOL_NAME_LEN) == 0, "Validate string length");
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
/* set up an exclusion set */
exclusion = zmalloc<lttng_event_exclusion>(sizeof(*exclusion) +
- LTTNG_SYMBOL_NAME_LEN * exclusion_count);
+ LTTNG_SYMBOL_NAME_LEN * exclusion_count);
ok(exclusion != NULL, "Create UST exclusion");
if (!exclusion) {
skip(4, "zmalloc failed");
exclusion->count = exclusion_count;
random_name = get_random_string();
- strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0), random_name,
+ strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0),
+ random_name,
LTTNG_SYMBOL_NAME_LEN - 1);
- strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1), random_name,
+ strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1),
+ random_name,
LTTNG_SYMBOL_NAME_LEN - 1);
ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event);
ok(ret != LTTNG_OK, "Create UST event with identical exclusion names fails");
exclusion = zmalloc<lttng_event_exclusion>(sizeof(*exclusion) +
- LTTNG_SYMBOL_NAME_LEN * exclusion_count);
+ LTTNG_SYMBOL_NAME_LEN * exclusion_count);
ok(exclusion != NULL, "Create UST exclusion");
if (!exclusion) {
skip(2, "zmalloc failed");
}
exclusion_copy = zmalloc<lttng_event_exclusion>(sizeof(*exclusion) +
- LTTNG_SYMBOL_NAME_LEN * exclusion_count);
+ LTTNG_SYMBOL_NAME_LEN * exclusion_count);
if (!exclusion_copy) {
skip(2, "zmalloc failed");
goto end;
exclusion->count = exclusion_count;
copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0),
- get_random_string(),
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0)));
+ get_random_string(),
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0)));
LTTNG_ASSERT(copy_ret == 0);
copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1),
- get_random_string(),
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1)));
+ get_random_string(),
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1)));
LTTNG_ASSERT(copy_ret == 0);
exclusion_copy->count = exclusion_count;
copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0),
- LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0),
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0)));
+ LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 0),
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 0)));
LTTNG_ASSERT(copy_ret == 0);
copy_ret = lttng_strncpy(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1),
- LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1),
- sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1)));
+ LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion, 1),
+ sizeof(LTTNG_EVENT_EXCLUSION_NAME_AT(exclusion_copy, 1)));
LTTNG_ASSERT(copy_ret == 0);
ret = trace_ust_create_event(&ev, NULL, NULL, exclusion, false, &event);
goto end;
}
- ok(event->enabled == 0 &&
- event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
- strcmp(event->attr.name, ev.name) == 0 &&
- event->exclusion != NULL &&
- event->exclusion->count == exclusion_count &&
- !memcmp(event->exclusion->names, exclusion_copy->names,
- LTTNG_SYMBOL_NAME_LEN * exclusion_count) &&
- event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0',
- "Validate UST event and exclusion");
+ ok(event->enabled == 0 && event->attr.instrumentation == LTTNG_UST_ABI_TRACEPOINT &&
+ strcmp(event->attr.name, ev.name) == 0 && event->exclusion != NULL &&
+ event->exclusion->count == exclusion_count &&
+ !memcmp(event->exclusion->names,
+ exclusion_copy->names,
+ LTTNG_SYMBOL_NAME_LEN * exclusion_count) &&
+ event->attr.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] == '\0',
+ "Validate UST event and exclusion");
trace_ust_destroy_event(event);
end:
return;
}
-
static void test_create_ust_context(void)
{
struct lttng_event_context ectx;
ok(uctx != NULL, "Create UST context");
if (uctx) {
- ok((int) uctx->ctx.ctx == LTTNG_UST_ABI_CONTEXT_VTID,
- "Validate UST context");
+ ok((int) uctx->ctx.ctx == LTTNG_UST_ABI_CONTEXT_VTID, "Validate UST context");
} else {
skip(1, "Skipping UST context validation as creation failed");
}
*
*/
+#include <common/compat/poll.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/pipe.hpp>
+#include <common/readwrite.hpp>
+
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
-
-#include <common/compat/poll.hpp>
-#include <common/readwrite.hpp>
-#include <common/pipe.hpp>
-#include <common/dynamic-array.hpp>
-
#include <tap/tap.h>
+#include <unistd.h>
/* Verification without trashing test order in the child process */
-#define childok(e, test, ...) do { \
- if (!(e)) { \
- diag(test, ## __VA_ARGS__); \
- _exit(EXIT_FAILURE); \
- } \
-} while(0)
+#define childok(e, test, ...) \
+ do { \
+ if (!(e)) { \
+ diag(test, ##__VA_ARGS__); \
+ _exit(EXIT_FAILURE); \
+ } \
+ } while (0)
/* For error.h */
int lttng_opt_quiet = 1;
#define CLOE_VALUE FD_CLOEXEC
#endif
-static
-void test_epoll_compat(void)
+static void test_epoll_compat(void)
{
/*
* Type conversion present to disable warning of anonymous enum from
lttng_poll_init(&poll_events);
ok(lttng_poll_add(NULL, 1, LPOLLIN) != 0, "Adding to NULL set fails");
- ok(lttng_poll_add(&poll_events, 1, LPOLLIN) != 0, "Adding to uninitialized structure fails");
+ ok(lttng_poll_add(&poll_events, 1, LPOLLIN) != 0,
+ "Adding to uninitialized structure fails");
ok(lttng_poll_add(&poll_events, -1, LPOLLIN) != 0, "Adding invalid FD fails");
ok(lttng_poll_create(&poll_events, 1, 0) == 0, "Create a poll set succeeds");
cpid = fork();
if (cpid == 0) {
- childok(lttng_poll_create(&cpoll_events, 1, 0) == 0, "Create valid poll set succeeds");
- childok(lttng_poll_mod(NULL, infd[0], LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
- childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
- childok(lttng_poll_add(&cpoll_events, infd[0], LPOLLIN) == 0, "Add valid FD succeeds");
- childok(lttng_poll_mod(&cpoll_events, -1, LPOLLIN) == -1, "lttng_poll_mod with invalid input returns an error");
- childok(lttng_poll_mod(&cpoll_events, hupfd[0], LPOLLIN) == 0, "lttng_poll_mod on unincluded FD goes on");
- childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == 0, "Modify event type succeeds");
+ childok(lttng_poll_create(&cpoll_events, 1, 0) == 0,
+ "Create valid poll set succeeds");
+ childok(lttng_poll_mod(NULL, infd[0], LPOLLIN) == -1,
+ "lttng_poll_mod with invalid input returns an error");
+ childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == -1,
+ "lttng_poll_mod with invalid input returns an error");
+ childok(lttng_poll_add(&cpoll_events, infd[0], LPOLLIN) == 0,
+ "Add valid FD succeeds");
+ childok(lttng_poll_mod(&cpoll_events, -1, LPOLLIN) == -1,
+ "lttng_poll_mod with invalid input returns an error");
+ childok(lttng_poll_mod(&cpoll_events, hupfd[0], LPOLLIN) == 0,
+ "lttng_poll_mod on unincluded FD goes on");
+ childok(lttng_poll_mod(&cpoll_events, infd[0], LPOLLIN) == 0,
+ "Modify event type succeeds");
childok(close(infd[1]) == 0, "Close valid FD succeeds");
childok(lttng_poll_wait(&cpoll_events, -1) == 1, "Wait on close times out");
childok(lttng_read(infd[0], &rbuf, 1) == 1, "Data is present in the pipe");
ok(close(hupfd[1]) == 0, "Close valid FD succeeds");
ok(close(infd[0]) == 0, "Close valid FD succeeds");
- ok(lttng_poll_wait(NULL, -1) == -1, "lttng_poll_wait call with invalid input returns error");
+ ok(lttng_poll_wait(NULL, -1) == -1,
+ "lttng_poll_wait call with invalid input returns error");
ok(lttng_poll_create(&poll_events, 1, 0) == 0, "Create valid poll set succeeds");
- ok(lttng_poll_wait(&poll_events, -1) == -1, "lttng_poll_wait call with invalid input returns error");
+ ok(lttng_poll_wait(&poll_events, -1) == -1,
+ "lttng_poll_wait call with invalid input returns error");
ok(lttng_poll_add(&poll_events, hupfd[0], LPOLLIN) == 0, "Add valid FD succeeds");
ok(lttng_write(infd[1], &tbuf, 1) == 1, "Write to pipe succeeds");
ok(lttng_poll_wait(&poll_events, -1) == 1, "Wakes up on one event");
lttng_pipe_destroy((lttng_pipe *) pipe);
}
-static int run_active_set_combination(unsigned int fd_count,
- unsigned int active_fds_mask)
+static int run_active_set_combination(unsigned int fd_count, unsigned int active_fds_mask)
{
int ret = 0;
unsigned int i;
ret = lttng_poll_create(&poll_events, fd_count, 0);
if (ret) {
- diag("Failed to create poll set for %u file descriptors",
- fd_count);
+ diag("Failed to create poll set for %u file descriptors", fd_count);
goto end;
}
goto end;
}
- ret = lttng_poll_add(&poll_events, lttng_pipe_get_readfd(pipe),
- LPOLLIN);
+ ret = lttng_poll_add(&poll_events, lttng_pipe_get_readfd(pipe), LPOLLIN);
if (ret) {
diag("Failed to add file descriptor to poll set");
ret = -1;
continue;
}
- borrowed_pipe =
- (lttng_pipe *) lttng_dynamic_pointer_array_get_pointer(
- &pipes, i);
+ borrowed_pipe = (lttng_pipe *) lttng_dynamic_pointer_array_get_pointer(&pipes, i);
char c = 'a';
- ret = lttng_pipe_write(
- borrowed_pipe, &c, sizeof(char));
+ ret = lttng_pipe_write(borrowed_pipe, &c, sizeof(char));
if (ret != sizeof(char)) {
diag("Failed to write to pipe");
ret = -1;
ret = lttng_poll_wait(&poll_events, 0);
if (ret != active_fds_count) {
diag("lttng_poll_wait returned %d, expected %u active file descriptors",
- ret, active_fds_count);
+ ret,
+ active_fds_count);
ret = -1;
goto end;
} else {
#endif
ok(lttng_poll_reset == lttng_poll_reset, "lttng_poll_reset is defined");
- ok(lttng_poll_init == lttng_poll_init , "lttng_poll_init is defined");
+ ok(lttng_poll_init == lttng_poll_init, "lttng_poll_init is defined");
ok(PASS_GETFD, "GETFD is defined");
ok(PASS_GETEV, "GETEV is defined");
ok(PASS_GETSZ, "GETSZ is defined");
*
*/
-#include <stdio.h>
-#include <string.h>
#include "common/compat/pthread.hpp"
+#include <stdio.h>
+#include <string.h>
#include <tap/tap.h>
#define TEST_NAME_PROPER_LEN 16
/* Get the thread name again, should be the one we set */
ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
ok(ret == 0, "Get a short thread name: '%s'", name1);
- ok(strcmp(short_name, name1) == 0, "Compare the short thread name: '%s' == '%s'", short_name, name1);
-
+ ok(strcmp(short_name, name1) == 0,
+ "Compare the short thread name: '%s' == '%s'",
+ short_name,
+ name1);
/* Set a thread name of 16 bytes */
ret = lttng_pthread_setname_np(long_name);
/* Get the thread name again, should be the one we set */
ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
ok(ret == 0, "Get a long thread name: '%s'", name1);
- ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name, name1);
+ ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0,
+ "Compare the long thread name: '%s' == '%s'",
+ long_name,
+ name1);
return exit_status();
}
*
*/
-#include <string.h>
+#include <common/common.hpp>
+#include <common/path.hpp>
+#include <common/utils.hpp>
+
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <limits.h>
-
+#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-
-#include <common/utils.hpp>
-#include <common/path.hpp>
-#include <common/common.hpp>
-
#include <tap/tap.h>
/* For error.h */
/* Valid test cases */
struct valid_test_input valid_tests_inputs[] = {
- { "/a/b/c/d/e", "", "/a/b/c/d/e" },
- { "/a//b//c/d/e", "", "/a/b/c/d/e" },
- { "./a/b/c/d/e", ".", "/a/b/c/d/e" },
- { "../a/b/c/d/../e", "..", "/a/b/c/e" },
- { ".././a/b/c/d/./e", "..", "/a/b/c/d/e" },
- { "../../a/b/c/d/e", "../..", "/a/b/c/d/e" },
- { "./a/b/../c/d/../e", ".", "/a/c/e" },
- { "../a/b/../../c/./d/./e", "..", "/c/d/e" },
- { "../../a/b/../c/d/../../e", "../..", "/a/e" },
- { "./a/b/c/d/../../../../e", ".", "/e" },
- { ".././a/b/c/d/./e", "..", "/a/b/c/d/e" },
- { "a/", ".", "/a/" },
- { "a", ".", "/a" },
- { "../../", "../..", "/" },
- { "../..", "../..", "" },
- { "../", "..", "/" },
- { "..", "..", "" },
- { "./", ".", "/" },
- { ".", ".", "" },
- { "/../a/b/c/d/e", "", "/a/b/c/d/e" },
- { "/a/b/c/d/../../../../../e", "", "/e" },
- { "/..", "", "/" },
- { "/a/..", "", "/" },
+ { "/a/b/c/d/e", "", "/a/b/c/d/e" },
+ { "/a//b//c/d/e", "", "/a/b/c/d/e" },
+ { "./a/b/c/d/e", ".", "/a/b/c/d/e" },
+ { "../a/b/c/d/../e", "..", "/a/b/c/e" },
+ { ".././a/b/c/d/./e", "..", "/a/b/c/d/e" },
+ { "../../a/b/c/d/e", "../..", "/a/b/c/d/e" },
+ { "./a/b/../c/d/../e", ".", "/a/c/e" },
+ { "../a/b/../../c/./d/./e", "..", "/c/d/e" },
+ { "../../a/b/../c/d/../../e", "../..", "/a/e" },
+ { "./a/b/c/d/../../../../e", ".", "/e" },
+ { ".././a/b/c/d/./e", "..", "/a/b/c/d/e" },
+ { "a/", ".", "/a/" },
+ { "a", ".", "/a" },
+ { "../../", "../..", "/" },
+ { "../..", "../..", "" },
+ { "../", "..", "/" },
+ { "..", "..", "" },
+ { "./", ".", "/" },
+ { ".", ".", "" },
+ { "/../a/b/c/d/e", "", "/a/b/c/d/e" },
+ { "/a/b/c/d/../../../../../e", "", "/e" },
+ { "/..", "", "/" },
+ { "/a/..", "", "/" },
};
char **valid_tests_expected_results;
-const int num_valid_tests =
- sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
+const int num_valid_tests = sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
/* Symlinks test cases */
char tree_origin[] = "/tmp/test_utils_expand_path.XXXXXX";
-const char * const tree_dirs[] = {
+const char *const tree_dirs[] = {
"a",
"a/b",
"a/b/c",
"a/e",
};
-const int num_tree_dirs =
- sizeof(tree_dirs) / sizeof(tree_dirs[0]);
+const int num_tree_dirs = sizeof(tree_dirs) / sizeof(tree_dirs[0]);
struct tree_symlink tree_symlinks[] = {
- { "a/d", "b/c/" },
- { "a/g", "d/" },
- { "a/b/f", "../e/" },
- { "a/b/h", "../g/" },
- { "a/b/k", "c/g/" },
- { "a/b/c/g", "../../../" },
+ { "a/d", "b/c/" }, { "a/g", "d/" }, { "a/b/f", "../e/" },
+ { "a/b/h", "../g/" }, { "a/b/k", "c/g/" }, { "a/b/c/g", "../../../" },
};
-const int num_tree_symlinks =
- sizeof(tree_symlinks) / sizeof(tree_symlinks[0]);
+const int num_tree_symlinks = sizeof(tree_symlinks) / sizeof(tree_symlinks[0]);
static struct symlink_test_input symlink_tests_inputs[] = {
- { "a/g/../l/.", "a/b/l" },
- { "a/g/../l/./", "a/b/l/" },
- { "a/g/../l/..", "a/b" },
- { "a/g/../l/../", "a/b/" },
- { "a/b/h/g/", "" },
+ { "a/g/../l/.", "a/b/l" }, { "a/g/../l/./", "a/b/l/" }, { "a/g/../l/..", "a/b" },
+ { "a/g/../l/../", "a/b/" }, { "a/b/h/g/", "" },
};
-const int num_symlink_tests =
- sizeof(symlink_tests_inputs) / sizeof(symlink_tests_inputs[0]);
+const int num_symlink_tests = sizeof(symlink_tests_inputs) / sizeof(symlink_tests_inputs[0]);
/* Invalid test cases */
char *invalid_tests_inputs[] = {
NULL,
};
-const int num_invalid_tests =
- sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
+const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
} /* namespace */
-#define PRINT_ERR(fmt, args...) \
- fprintf(stderr, "test_utils_expand_path: error: " fmt "\n", ## args)
+#define PRINT_ERR(fmt, args...) fprintf(stderr, "test_utils_expand_path: error: " fmt "\n", ##args)
static int prepare_valid_results(void)
{
int i;
- char *relative, *cur_path = NULL, *prev_path = NULL,
- *pprev_path = NULL, *empty = NULL;
+ char *relative, *cur_path = NULL, *prev_path = NULL, *pprev_path = NULL, *empty = NULL;
int ret = 0;
/* Prepare the relative paths */
relative = empty;
}
- snprintf(valid_tests_expected_results[i], PATH_MAX,
- "%s%s", relative, valid_tests_inputs[i].absolute_part);
+ snprintf(valid_tests_expected_results[i],
+ PATH_MAX,
+ "%s%s",
+ relative,
+ valid_tests_inputs[i].absolute_part);
}
end:
/* Create the directories of the test tree */
for (i = 0; i < num_tree_dirs; i++) {
- snprintf(tmppath, sizeof(tmppath), "%s/%s", tree_origin,
- tree_dirs[i]);
+ snprintf(tmppath, sizeof(tmppath), "%s/%s", tree_origin, tree_dirs[i]);
if (mkdir(tmppath, 0755) != 0) {
PRINT_ERR("mkdir failed with path \"%s\"", tmppath);
/* Create the symlinks of the test tree */
for (i = 0; i < num_tree_symlinks; i++) {
- snprintf(tmppath, sizeof(tmppath), "%s/%s",
- tree_origin, tree_symlinks[i].orig);
+ snprintf(tmppath, sizeof(tmppath), "%s/%s", tree_origin, tree_symlinks[i].orig);
if (symlink(tree_symlinks[i].dest, tmppath) != 0) {
- PRINT_ERR("failed to symlink \"%s\" to \"%s\"", tmppath,
- tree_symlinks[i].dest);
+ PRINT_ERR("failed to symlink \"%s\" to \"%s\"",
+ tmppath,
+ tree_symlinks[i].dest);
goto error;
}
}
char tmppath[PATH_MAX];
/* Remove the symlinks from the test tree */
- for (i = num_tree_symlinks - 1; i > -1; i--) {
- snprintf(tmppath, PATH_MAX, "%s/%s",
- tree_origin, tree_symlinks[i].orig);
+ for (i = num_tree_symlinks - 1; i > -1; i--) {
+ snprintf(tmppath, PATH_MAX, "%s/%s", tree_origin, tree_symlinks[i].orig);
if (unlink(tmppath) != 0) {
PRINT_ERR("failed to unlink \"%s\"", tmppath);
sprintf(name, "valid test case: %s", valid_tests_inputs[i].input);
result = utils_expand_path(valid_tests_inputs[i].input);
- ok(result != NULL &&
- strcmp(result, valid_tests_expected_results[i]) == 0, "%s", name);
+ ok(result != NULL && strcmp(result, valid_tests_expected_results[i]) == 0,
+ "%s",
+ name);
free(result);
}
for (i = 0; i < num_symlink_tests; i++) {
int ret;
- sprintf(name, "symlink tree test case: [tmppath/]%s",
- symlink_tests_inputs[i].input);
+ sprintf(name,
+ "symlink tree test case: [tmppath/]%s",
+ symlink_tests_inputs[i].input);
- ret = snprintf(tmppath, PATH_MAX, "%s/%s",
- real_tree_origin,
- symlink_tests_inputs[i].input);
+ ret = snprintf(tmppath,
+ PATH_MAX,
+ "%s/%s",
+ real_tree_origin,
+ symlink_tests_inputs[i].input);
if (ret == -1 || ret >= PATH_MAX) {
PRINT_ERR("truncation occurred while concatenating paths \"%s\" and \"%s\"",
- real_tree_origin,
- symlink_tests_inputs[i].input);
+ real_tree_origin,
+ symlink_tests_inputs[i].input);
fail("%s", name);
continue;
}
result = utils_expand_path(tmppath);
- ok(result != NULL && strcmp(result + treelen,
- symlink_tests_inputs[i].expected_result) == 0, "%s", name);
+ ok(result != NULL &&
+ strcmp(result + treelen, symlink_tests_inputs[i].expected_result) == 0,
+ "%s",
+ name);
free(result);
}
for (i = 0; i < num_invalid_tests; i++) {
const char *test_input = invalid_tests_inputs[i];
- sprintf(name, "invalid test case: %s", test_input ?
- test_input : "NULL");
+ sprintf(name, "invalid test case: %s", test_input ? test_input : "NULL");
result = utils_expand_path(test_input);
if (result != NULL) {
*
*/
-#include <string.h>
-#include <stdio.h>
+#include <common/utils.hpp>
+#include <stdio.h>
+#include <string.h>
#include <tap/tap.h>
-#include <common/utils.hpp>
-
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
/* Valid test cases */
struct valid_test_input valid_tests_inputs[] = {
- { "0", 0 },
- { "1234", 1234 },
- { "0x400", 1024 },
- { "0300", 192 },
- { "16k", 16384 },
- { "128K", 131072 },
- { "0x1234k", 4771840 },
- { "32M", 33554432 },
- { "1024G", 1099511627776ULL },
- { "0X400", 1024 },
- { "0x40a", 1034 },
- { "0X40b", 1035 },
- { "0x40C", 1036 },
- { "0X40D", 1037 },
- { "0x40e", 1038 },
- { "0X40f", 1039 },
- { "00", 0 },
- { "0k", 0 },
- { "0K", 0 },
- { "0M", 0 },
- { "0G", 0 },
- { "00k", 0 },
- { "00K", 0 },
- { "00M", 0 },
- { "00G", 0 },
- { "0x0", 0 },
- { "0X0", 0 },
- { "0x0k", 0 },
- { "0X0K", 0 },
- { "0x0M", 0 },
- { "0X0G", 0 },
- { "0X40G", 68719476736ULL },
- { "0300k", 196608 },
- { "0300K", 196608 },
- { "030M", 25165824 },
- { "020G", 17179869184ULL },
- { "0xa0k", 163840 },
- { "0xa0K", 163840 },
- { "0XA0M", 167772160 },
- { "0xA0G", 171798691840ULL },
+ { "0", 0 },
+ { "1234", 1234 },
+ { "0x400", 1024 },
+ { "0300", 192 },
+ { "16k", 16384 },
+ { "128K", 131072 },
+ { "0x1234k", 4771840 },
+ { "32M", 33554432 },
+ { "1024G", 1099511627776ULL },
+ { "0X400", 1024 },
+ { "0x40a", 1034 },
+ { "0X40b", 1035 },
+ { "0x40C", 1036 },
+ { "0X40D", 1037 },
+ { "0x40e", 1038 },
+ { "0X40f", 1039 },
+ { "00", 0 },
+ { "0k", 0 },
+ { "0K", 0 },
+ { "0M", 0 },
+ { "0G", 0 },
+ { "00k", 0 },
+ { "00K", 0 },
+ { "00M", 0 },
+ { "00G", 0 },
+ { "0x0", 0 },
+ { "0X0", 0 },
+ { "0x0k", 0 },
+ { "0X0K", 0 },
+ { "0x0M", 0 },
+ { "0X0G", 0 },
+ { "0X40G", 68719476736ULL },
+ { "0300k", 196608 },
+ { "0300K", 196608 },
+ { "030M", 25165824 },
+ { "020G", 17179869184ULL },
+ { "0xa0k", 163840 },
+ { "0xa0K", 163840 },
+ { "0XA0M", 167772160 },
+ { "0xA0G", 171798691840ULL },
};
const int num_valid_tests = sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
/* Invalid test cases */
const char *invalid_tests_inputs[] = {
- "",
- " ",
- "-1",
- "k",
- "4611686018427387904G",
- "0x40g",
- "08",
- "09",
- "0x",
- "x0",
- "0xx0",
- "07kK",
- "0xk",
- "0XM",
- "0xG",
- "0x0MM",
- "0X0GG",
- "0a",
- "0B",
+ "", " ", "-1", "k", "4611686018427387904G",
+ "0x40g", "08", "09", "0x", "x0",
+ "0xx0", "07kK", "0xk", "0XM", "0xG",
+ "0x0MM", "0X0GG", "0a", "0B",
};
const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
*
*/
-#include <string.h>
-#include <stdio.h>
-#include <inttypes.h>
+#include <common/utils.hpp>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
#include <tap/tap.h>
-#include <common/utils.hpp>
-
/* For error.h */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 3;
/* Valid test cases */
struct valid_test_input valid_tests_inputs[] = {
- { "0", 0 },
- { "1234", 1234 },
- { "1234us", 1234 },
- { "16ms", 16000 },
- { "128ms", 128000 },
- { "32s", 32000000 },
- { "1m", 60000000 },
- { "20m", 1200000000 },
- { "1h", 3600000000 },
- { "5h", 18000000000 },
- { "00", 0 },
- { "0us", 0 },
- { "0ms", 0 },
- { "0s", 0 },
- { "0m", 0 },
- { "0h", 0 },
- { "00us", 0 },
- { "00ms", 0 },
- { "00s", 0 },
- { "00m", 0 },
- { "00h", 0 },
- { "12ms", 12000 },
- { "3597us", 3597 },
- { "+5", 5 },
- { "08", 8 },
- { "0145us", 145 },
+ { "0", 0 }, { "1234", 1234 }, { "1234us", 1234 }, { "16ms", 16000 },
+ { "128ms", 128000 }, { "32s", 32000000 }, { "1m", 60000000 }, { "20m", 1200000000 },
+ { "1h", 3600000000 }, { "5h", 18000000000 }, { "00", 0 }, { "0us", 0 },
+ { "0ms", 0 }, { "0s", 0 }, { "0m", 0 }, { "0h", 0 },
+ { "00us", 0 }, { "00ms", 0 }, { "00s", 0 }, { "00m", 0 },
+ { "00h", 0 }, { "12ms", 12000 }, { "3597us", 3597 }, { "+5", 5 },
+ { "08", 8 }, { "0145us", 145 },
};
const int num_valid_tests = sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]);
/* Invalid test cases */
const char *invalid_tests_inputs[] = {
- "",
- " ",
- "-1",
- "m",
- "4611686018427387904s",
- "0x40M",
- "0x",
- "x0",
- "0xx0",
- "07mm",
- "0xm",
- "0Xs",
- "0x0ss",
- "0a",
- "0B",
- "0x3 s",
- "0xbs ",
- "14ns",
- "0xbs",
- "14ns",
- "14ms garbage after value",
- "0x14s",
- "0u",
- "5mS",
- "5Ms",
- "12ussr",
- "67msrp",
- "14si",
- "12mo",
- "53hi",
+ "",
+ " ",
+ "-1",
+ "m",
+ "4611686018427387904s",
+ "0x40M",
+ "0x",
+ "x0",
+ "0xx0",
+ "07mm",
+ "0xm",
+ "0Xs",
+ "0x0ss",
+ "0a",
+ "0B",
+ "0x3 s",
+ "0xbs ",
+ "14ns",
+ "0xbs",
+ "14ns",
+ "14ms garbage after value",
+ "0x14s",
+ "0u",
+ "5mS",
+ "5Ms",
+ "12ussr",
+ "67msrp",
+ "14si",
+ "12mo",
+ "53hi",
};
const int num_invalid_tests = sizeof(invalid_tests_inputs) / sizeof(invalid_tests_inputs[0]);
} /* namespace */
char name[256];
ret = utils_parse_time_suffix(valid_tests_inputs[i].input, &result);
- sprintf(name, "valid test case: %s expected %" PRIu64, valid_tests_inputs[i].input, result);
+ sprintf(name,
+ "valid test case: %s expected %" PRIu64,
+ valid_tests_inputs[i].input,
+ result);
ok(ret == 0 && result == valid_tests_inputs[i].expected_result, "%s", name);
}
*
*/
-#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
-
#include "common/uuid.hpp"
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
#include <tap/tap.h>
#define NR_TESTS 21
static const char valid_str_4[] = "8ADED5B9-ACD2-439F-A60C-897403AA2AB4";
static const char valid_str_5[] = "f109e0a2-C619-4d18-b760-20EA20E0F69A";
-static lttng_uuid valid_uuid_1 = {
- 0x3d, 0x26, 0x0c, 0x88, 0x75, 0xea, 0x47, 0xb8,
- 0xa7, 0xe2, 0xd6, 0x07, 0x7c, 0x03, 0x78, 0xd9
-};
-static lttng_uuid valid_uuid_2 = {
- 0x61, 0x1c, 0xf3, 0xa6, 0xa6, 0x8b, 0x45, 0x15,
- 0x83, 0x4f, 0x20, 0x8b, 0xc2, 0x76, 0x25, 0x92
-};
-static lttng_uuid valid_uuid_3 = {
- 0x1b, 0x48, 0x55, 0xcc, 0x96, 0xde, 0x4a, 0xe8,
- 0xab, 0xe3, 0x86, 0x44, 0x9c, 0x2a, 0x43, 0xc4
-};
+static lttng_uuid valid_uuid_1 = { 0x3d, 0x26, 0x0c, 0x88, 0x75, 0xea, 0x47, 0xb8,
+ 0xa7, 0xe2, 0xd6, 0x07, 0x7c, 0x03, 0x78, 0xd9 };
+static lttng_uuid valid_uuid_2 = { 0x61, 0x1c, 0xf3, 0xa6, 0xa6, 0x8b, 0x45, 0x15,
+ 0x83, 0x4f, 0x20, 0x8b, 0xc2, 0x76, 0x25, 0x92 };
+static lttng_uuid valid_uuid_3 = { 0x1b, 0x48, 0x55, 0xcc, 0x96, 0xde, 0x4a, 0xe8,
+ 0xab, 0xe3, 0x86, 0x44, 0x9c, 0x2a, 0x43, 0xc4 };
static const char invalid_str_1[] = "1b485!cc-96de-4XX8-abe3-86449c2a43?4";
static const char invalid_str_2[] = "c2e6eddb&3955&4006&be3a&70bb63bd5f25";
int lttng_opt_verbose = 0;
int lttng_opt_mi;
-static
-void run_test_lttng_uuid_from_str(void)
+static void run_test_lttng_uuid_from_str(void)
{
int ret;
lttng_uuid uuid1;
* Parse invalid UUID strings, expect failure.
*/
ret = lttng_uuid_from_str(invalid_str_1, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_1);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_1);
ret = lttng_uuid_from_str(invalid_str_2, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_2);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_2);
ret = lttng_uuid_from_str(invalid_str_3, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_3);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_3);
ret = lttng_uuid_from_str(invalid_str_4, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_4);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_4);
ret = lttng_uuid_from_str(invalid_str_5, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_5);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_5);
ret = lttng_uuid_from_str(invalid_str_6, uuid1);
- ok(ret != 0, "lttng_uuid_from_str - Parse invalid string '%s', expect failure", invalid_str_6);
+ ok(ret != 0,
+ "lttng_uuid_from_str - Parse invalid string '%s', expect failure",
+ invalid_str_6);
}
-static
-void run_test_lttng_uuid_to_str(void)
+static void run_test_lttng_uuid_to_str(void)
{
char uuid_str[LTTNG_UUID_STR_LEN];
lttng_uuid_to_str(valid_uuid_1, uuid_str);
- ok(strcmp(uuid_str, valid_str_1) == 0, "lttng_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_1);
+ ok(strcmp(uuid_str, valid_str_1) == 0,
+ "lttng_uuid_to_str - Convert UUID '%s' to string, expect success",
+ valid_str_1);
lttng_uuid_to_str(valid_uuid_2, uuid_str);
- ok(strcmp(uuid_str, valid_str_2) == 0, "lttng_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_2);
+ ok(strcmp(uuid_str, valid_str_2) == 0,
+ "lttng_uuid_to_str - Convert UUID '%s' to string, expect success",
+ valid_str_2);
lttng_uuid_to_str(valid_uuid_3, uuid_str);
- ok(strcmp(uuid_str, valid_str_3) == 0, "lttng_uuid_to_str - Convert UUID '%s' to string, expect success", valid_str_3);
+ ok(strcmp(uuid_str, valid_str_3) == 0,
+ "lttng_uuid_to_str - Convert UUID '%s' to string, expect success",
+ valid_str_3);
}
-static
-void run_test_lttng_uuid_is_equal(void)
+static void run_test_lttng_uuid_is_equal(void)
{
int ret;
lttng_uuid uuid1, uuid2;
ok(ret == false, "lttng_uuid_is_equal - Compare different UUID, expect failure");
}
-static
-void run_test_lttng_uuid_copy(void)
+static void run_test_lttng_uuid_copy(void)
{
bool ret;
lttng_uuid uuid1;
ok(ret == true, "lttng_uuid_copy - Compare copied UUID with source, expect success");
}
-static
-void run_test_lttng_uuid_generate(void)
+static void run_test_lttng_uuid_generate(void)
{
int ret;
lttng_uuid uuid1, uuid2;
ok(ret == LTTNG_UUID_VER, "lttng_uuid_generate - Generated UUID version check");
}
-static
-void run_test(void)
+static void run_test(void)
{
plan_tests(NR_TESTS);
#define _GNU_SOURCE
#endif
+#include "signal-helper.hpp"
+#include "utils.h"
+
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
+
+#include <inttypes.h>
#include <popt.h>
#include <sched.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-
-#include <common/compat/tid.hpp>
-#include <common/macros.hpp>
-
-#include "signal-helper.hpp"
-#include "utils.h"
#define LTTNG_PROC_NS_PATH_MAX 40
* but that use a libc that doesn't define its associated clone flag.
*/
#ifndef CLONE_NEWNS
-#define CLONE_NEWNS 0x00020000
+#define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
#endif
#ifndef CLONE_NEWUTS
-#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWIPC
-#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWUSER
-#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWPID
-#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWNET
-#define CLONE_NEWNET 0x40000000
+#define CLONE_NEWNET 0x40000000
#endif
#ifndef CLONE_NEWTIME
-#define CLONE_NEWTIME 0x00000080
+#define CLONE_NEWTIME 0x00000080
#endif
static int debug = 0;
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{ "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", NULL },
{ "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", NULL },
- { "before", 'b', POPT_ARG_STRING, &before_unshare_wait_file_path, 0, "Wait for file before unshare", NULL },
- { "after", 'a', POPT_ARG_STRING, &after_unshare_wait_file_path, 0, "Wait for file after unshare", NULL },
- { "signal", 's', POPT_ARG_STRING, &after_unshare_signal_file_path, 0, "Create signal file after unshare", NULL },
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0, NULL, NULL }
+ { "before",
+ 'b',
+ POPT_ARG_STRING,
+ &before_unshare_wait_file_path,
+ 0,
+ "Wait for file before unshare",
+ NULL },
+ { "after",
+ 'a',
+ POPT_ARG_STRING,
+ &after_unshare_wait_file_path,
+ 0,
+ "Wait for file after unshare",
+ NULL },
+ { "signal",
+ 's',
+ POPT_ARG_STRING,
+ &after_unshare_signal_file_path,
+ 0,
+ "Create signal file after unshare",
+ NULL },
+ POPT_AUTOHELP{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
-static ATTR_FORMAT_PRINTF(1, 2)
-void debug_printf(const char *format, ...)
+static ATTR_FORMAT_PRINTF(1, 2) void debug_printf(const char *format, ...)
{
va_list args;
va_start(args, format);
/*
* /proc/thread-self was introduced in kernel v3.17
*/
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/thread-self/ns/%s", ns) >= 0) {
+ if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX, "/proc/thread-self/ns/%s", ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
} else {
goto end;
}
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/self/task/%d/%s/net", lttng_gettid(), ns) >= 0) {
+ if (snprintf(proc_ns_path,
+ LTTNG_PROC_NS_PATH_MAX,
+ "/proc/self/task/%d/%s/net",
+ lttng_gettid(),
+ ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
} else {
ret = get_ns_inum(ns_str, &ns1);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
ret = get_ns_inum(ns_str, &ns2);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
if (opt < -1) {
/* an error occurred during option processing */
poptPrintUsage(pc, stderr, 0);
- fprintf(stderr, "%s: %s\n",
+ fprintf(stderr,
+ "%s: %s\n",
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
poptStrerror(opt));
ret = EXIT_FAILURE;
*
*/
+#include "utils.h"
+
+#include <common/align.hpp>
+#include <common/error.hpp>
+
#include <fcntl.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
-#include <common/error.hpp>
-#include <common/align.hpp>
-
-#include "utils.h"
#define MAX_LEN 16
* This isn't a proper fix; it is simply the best we can do for now.
* See bug #1261 for more context.
*/
-static
-void prefault_string(const char *p)
+static void prefault_string(const char *p)
{
- const char * const end = p + strlen(p) + 1;
+ const char *const end = p + strlen(p) + 1;
while (p < end) {
/*
}
}
-static
-int open_read_close(const char *path)
+static int open_read_close(const char *path)
{
int fd, ret;
char buf[MAX_LEN];
ret = syscall(SYS_read, fd, buf, MAX_LEN);
if (ret < 0) {
PERROR_NO_LOGGER("Failed to read file: path = '%s', fd = %d, length = %d",
- path, fd, MAX_LEN);
+ path,
+ fd,
+ MAX_LEN);
ret = -1;
goto error;
}
#define _GNU_SOURCE
#endif
+#include "signal-helper.hpp"
+#include "utils.h"
+
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
+
+#include <inttypes.h>
#include <popt.h>
#include <sched.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <inttypes.h>
-
-#include <common/compat/tid.hpp>
-#include <common/macros.hpp>
-
-#include "signal-helper.hpp"
-#include "utils.h"
#define TRACEPOINT_DEFINE
#include "tp.h"
* but that use a libc that doesn't define its associated clone flag.
*/
#ifndef CLONE_NEWNS
-#define CLONE_NEWNS 0x00020000
+#define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
#endif
#ifndef CLONE_NEWUTS
-#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWIPC
-#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWUSER
-#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWPID
-#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWNET
-#define CLONE_NEWNET 0x40000000
+#define CLONE_NEWNET 0x40000000
#endif
#ifndef CLONE_NEWTIME
-#define CLONE_NEWTIME 0x00000080
+#define CLONE_NEWTIME 0x00000080
#endif
static int nr_iter = 100;
static char *after_unshare_file_path = NULL;
static char *before_second_event_file_path = NULL;
-static
-struct poptOption opts[] = {
+static struct poptOption opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{ "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", NULL },
{ "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", NULL },
{ "iter", 'i', POPT_ARG_INT, &nr_iter, 0, "Number of tracepoint iterations", NULL },
- { "after", 'a', POPT_ARG_STRING, &after_unshare_file_path, 0, "after_unshare_file_path,", NULL },
- { "before", 'b', POPT_ARG_STRING, &before_second_event_file_path, 0, "before_second_event_file_path,", NULL },
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { "after",
+ 'a',
+ POPT_ARG_STRING,
+ &after_unshare_file_path,
+ 0,
+ "after_unshare_file_path,",
+ NULL },
+ { "before",
+ 'b',
+ POPT_ARG_STRING,
+ &before_second_event_file_path,
+ 0,
+ "before_second_event_file_path,",
+ NULL },
+ POPT_AUTOHELP{ NULL, 0, 0, NULL, 0 }
};
-static ATTR_FORMAT_PRINTF(1, 2)
-void debug_printf(const char *format, ...)
+static ATTR_FORMAT_PRINTF(1, 2) void debug_printf(const char *format, ...)
{
va_list args;
va_start(args, format);
/*
* /proc/thread-self was introduced in kernel v3.17
*/
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/thread-self/ns/%s", ns) >= 0) {
+ if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX, "/proc/thread-self/ns/%s", ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
ret = 0;
goto end;
}
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/self/task/%d/%s/net", lttng_gettid(), ns) >= 0) {
+ if (snprintf(proc_ns_path,
+ LTTNG_PROC_NS_PATH_MAX,
+ "/proc/self/task/%d/%s/net",
+ lttng_gettid(),
+ ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
ret = 0;
ret = get_ns_inum(ns_str, &ns1);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
ret = get_ns_inum(ns_str, &ns2);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
if (opt < -1) {
/* An error occurred during option processing. */
poptPrintUsage(pc, stderr, 0);
- fprintf(stderr, "%s: %s\n",
- poptBadOption(pc, POPT_BADOPTION_NOALIAS),
- poptStrerror(opt));
+ fprintf(stderr,
+ "%s: %s\n",
+ poptBadOption(pc, POPT_BADOPTION_NOALIAS),
+ poptStrerror(opt));
ret = EXIT_FAILURE;
goto end;
}
*/
#define _LGPL_SOURCE
-#include <getopt.h>
+#include "signal-helper.hpp"
+#include "utils.h"
+
#include <arpa/inet.h>
+#include <errno.h>
#include <fcntl.h>
+#include <getopt.h>
+#include <poll.h>
+#include <signal.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <stdbool.h>
-#include <signal.h>
-#include <poll.h>
-#include <errno.h>
-#include "utils.h"
-#include "signal-helper.hpp"
#define TRACEPOINT_DEFINE
#include "tp.h"
-static struct option long_options[] =
-{
+static struct option long_options[] = {
/* These options set a flag. */
- {"iter", required_argument, 0, 'i'},
- {"wait", required_argument, 0, 'w'},
- {"sync-after-first-event", required_argument, 0, 'a'},
- {"sync-before-last-event", required_argument, 0, 'b'},
- {"sync-before-last-event-touch", required_argument, 0, 'c'},
- {"sync-before-exit", required_argument, 0, 'd'},
- {"sync-before-exit-touch", required_argument, 0, 'e'},
- {"emit-end-event", no_argument, 0, 'f'},
- {0, 0, 0, 0}
+ { "iter", required_argument, 0, 'i' },
+ { "wait", required_argument, 0, 'w' },
+ { "sync-after-first-event", required_argument, 0, 'a' },
+ { "sync-before-last-event", required_argument, 0, 'b' },
+ { "sync-before-last-event-touch", required_argument, 0, 'c' },
+ { "sync-before-exit", required_argument, 0, 'd' },
+ { "sync-before-exit-touch", required_argument, 0, 'e' },
+ { "emit-end-event", no_argument, 0, 'f' },
+ { 0, 0, 0, 0 }
};
int main(int argc, char **argv)
net_values[i] = htonl(net_values[i]);
}
- while ((option = getopt_long(argc, argv, "i:w:a:b:c:d:e:f",
- long_options, &option_index)) != -1) {
+ while ((option = getopt_long(argc, argv, "i:w:a:b:c:d:e:f", long_options, &option_index)) !=
+ -1) {
switch (option) {
case 'a':
after_first_event_file_path = strdup(optarg);
goto end;
}
-
if (set_signal_handler()) {
ret = -1;
goto end;
}
}
netint = htonl(i);
- tracepoint(tp, tptest, i, netint, values, text,
- strlen(text), escape, net_values, dbl, flt);
+ tracepoint(tp,
+ tptest,
+ i,
+ netint,
+ values,
+ text,
+ strlen(text),
+ escape,
+ net_values,
+ dbl,
+ flt);
/*
* First loop we create the file if asked to indicate
}
if (nr_usec) {
- if (usleep_safe(nr_usec)) {
+ if (usleep_safe(nr_usec)) {
ret = -1;
goto end;
}
*/
#define _LGPL_SOURCE
-#include <stdio.h>
#include "signal-helper.hpp"
+#include <stdio.h>
+
#define TRACEPOINT_DEFINE
#include "tp.h"
}
if (argc <= 3) {
- fprintf(stderr, "Usage: %s COUNT STRING [STRING]...\n",
- argv[0]);
+ fprintf(stderr, "Usage: %s COUNT STRING [STRING]...\n", argv[0]);
return 1;
}
*/
#define _LGPL_SOURCE
+#include "signal-helper.hpp"
+#include "utils.h"
+
#include <arpa/inet.h>
#include <getopt.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include "utils.h"
-#include "signal-helper.hpp"
#define TRACEPOINT_DEFINE
#include "tp.h"
-static struct option long_options[] =
-{
+static struct option long_options[] = {
/* These options set a flag. */
- {"iter", required_argument, 0, 'i'},
- {"wait", required_argument, 0, 'w'},
- {"create-in-main", required_argument, 0, 'm'},
- {"wait-before-first-event", required_argument, 0, 'b'},
- {0, 0, 0, 0}
+ { "iter", required_argument, 0, 'i' },
+ { "wait", required_argument, 0, 'w' },
+ { "create-in-main", required_argument, 0, 'm' },
+ { "wait-before-first-event", required_argument, 0, 'b' },
+ { 0, 0, 0, 0 }
};
int main(int argc, char **argv)
char *wait_before_first_event_file_path = NULL;
char *create_in_main_file_path = NULL;
- while ((option = getopt_long(argc, argv, "i:w:b:m:",
- long_options, &option_index)) != -1) {
+ while ((option = getopt_long(argc, argv, "i:w:b:m:", long_options, &option_index)) != -1) {
switch (option) {
case 'b':
wait_before_first_event_file_path = strdup(optarg);
for (i = 0; i < nr_iter; i++) {
netint = htonl(i);
- tracepoint(tp, tptest1, i, netint, values, text, strlen(text),
- dbl, flt);
- tracepoint(tp, tptest2, i, netint, values, text, strlen(text),
- dbl, flt);
- tracepoint(tp, tptest3, i, netint, values, text, strlen(text),
- dbl, flt);
- tracepoint(tp, tptest4, i, netint, values, text, strlen(text),
- dbl, flt);
- tracepoint(tp, tptest5, i, netint, values, text, strlen(text),
- dbl, flt);
+ tracepoint(tp, tptest1, i, netint, values, text, strlen(text), dbl, flt);
+ tracepoint(tp, tptest2, i, netint, values, text, strlen(text), dbl, flt);
+ tracepoint(tp, tptest3, i, netint, values, text, strlen(text), dbl, flt);
+ tracepoint(tp, tptest4, i, netint, values, text, strlen(text), dbl, flt);
+ tracepoint(tp, tptest5, i, netint, values, text, strlen(text), dbl, flt);
if (nr_usec) {
- if (usleep_safe(nr_usec)) {
+ if (usleep_safe(nr_usec)) {
ret = -1;
goto end;
}
*/
#define _LGPL_SOURCE
+#include "signal-helper.hpp"
+
+#include <common/macros.hpp>
+
+#include <lttng/tracef.h>
+
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/macros.hpp>
-#include <lttng/tracef.h>
-#include "signal-helper.hpp"
-
const char *str = "test string";
-static
-void create_file(const char *path)
+static void create_file(const char *path)
{
int ret;
*/
#include "test_class.hpp"
-test_class::test_class() {
+test_class::test_class()
+{
test_member = 1;
}
-void test_class::test_method() {
+void test_class::test_method()
+{
test_member += 1;
}
volatile int not_a_function = 0;
-void test_cxx_function() __attribute__ ((noinline));
+void test_cxx_function() __attribute__((noinline));
void test_cxx_function()
{
not_a_function += 1;
*
*/
+#include "utils.h"
+
+#include <common/compat/errno.hpp>
#include <common/compat/time.hpp>
+#include <common/macros.hpp>
#include <common/time.hpp>
+
#include <fcntl.h>
#include <poll.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/errno.hpp>
-#include <common/macros.hpp>
-
-#include "utils.h"
-
-static inline
-int64_t elapsed_time_ns(struct timespec *t1, struct timespec *t2)
+static inline int64_t elapsed_time_ns(struct timespec *t1, struct timespec *t2)
{
struct timespec delta;
LTTNG_ASSERT(t1 && t2);
delta.tv_sec = t2->tv_sec - t1->tv_sec;
delta.tv_nsec = t2->tv_nsec - t1->tv_nsec;
- return ((int64_t) NSEC_PER_SEC * (int64_t) delta.tv_sec) +
- (int64_t) delta.tv_nsec;
+ return ((int64_t) NSEC_PER_SEC * (int64_t) delta.tv_sec) + (int64_t) delta.tv_nsec;
}
int usleep_safe(useconds_t usec)
for (;;) {
ret = stat(path, &buf);
if (ret == -1 && errno == ENOENT) {
- ret = poll(NULL, 0, 10); /* 10 ms delay */
+ ret = poll(NULL, 0, 10); /* 10 ms delay */
/* Should return 0 everytime */
if (ret) {
if (ret < 0) {
perror("perror");
} else {
- fprintf(stderr,
- "poll return value is larger than zero\n");
+ fprintf(stderr, "poll return value is larger than zero\n");
}
return -1;
}
- continue; /* retry */
+ continue; /* retry */
}
if (ret) {
perror("stat");
return -1;
}
- break; /* found */
+ break; /* found */
}
return 0;
* node;b;
* node;c;
*/
+#include <common/defaults.hpp>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-#include <common/defaults.hpp>
-
#if defined(LIBXML_XPATH_ENABLED)
static int opt_verbose;
LTTNG_ASSERT(nodes->nodeTab[i]);
if (nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
- fprintf(stderr, "ERR:%s\n",
- "This executable does not support xml namespacing\n");
+ fprintf(stderr,
+ "ERR:%s\n",
+ "This executable does not support xml namespacing\n");
ret = -1;
goto end;
} else if (nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
if (xmlChildElementCount(cur) == 0) {
if (xmlNodeIsText(cur->children)) {
- node_child_value_string = xmlNodeListGetString(doc,
- cur->children, 1);
+ node_child_value_string =
+ xmlNodeListGetString(doc, cur->children, 1);
if (node_exist) {
result = true;
} else if (opt_verbose) {
- fprintf(output, "%s;%s;\n", cur->name,
- node_child_value_string);
+ fprintf(output,
+ "%s;%s;\n",
+ cur->name,
+ node_child_value_string);
} else {
- fprintf(output, "%s\n",
- node_child_value_string);
+ fprintf(output, "%s\n", node_child_value_string);
}
xmlFree(node_child_value_string);
} else {
if (node_exist) {
result = true;
} else {
- fprintf(stderr, "ERR:%s\n",
- "Xpath expression return non-final xml element");
+ fprintf(stderr,
+ "ERR:%s\n",
+ "Xpath expression return non-final xml element");
ret = -1;
goto end;
}
result = true;
} else {
/* We don't want to print non-final element */
- fprintf(stderr, "ERR:%s\n",
- "Xpath expression return non-final xml element");
+ fprintf(stderr,
+ "ERR:%s\n",
+ "Xpath expression return non-final xml element");
ret = -1;
goto end;
}
return -1;
}
/* Do the main job */
- if (extract_xpath(argv[optind], (xmlChar *)argv[optind+1])) {
+ if (extract_xpath(argv[optind], (xmlChar *) argv[optind + 1])) {
return -1;
}
*
*/
- /*
- * This script validate and xml from an xsd.
- * argv[1] Path of the xsd
- * argv[2] Path to the XML to be validated
- */
+/*
+ * This script validate and xml from an xsd.
+ * argv[1] Path of the xsd
+ * argv[2] Path to the XML to be validated
+ */
+
+#include <common/macros.hpp>
+
+#include <lttng/lttng-error.h>
#include <ctype.h>
+#include <dirent.h>
+#include <inttypes.h>
+#include <libxml/parser.h>
+#include <libxml/xmlschemas.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <inttypes.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/types.h>
#include <sys/stat.h>
-
-#include <libxml/xmlschemas.h>
-#include <libxml/parser.h>
-
-#include <lttng/lttng-error.h>
-#include <common/macros.hpp>
+#include <sys/types.h>
+#include <unistd.h>
namespace {
struct validation_ctx {
};
} /* namespace */
-enum command_err_code {
- CMD_SUCCESS = 0,
- CMD_ERROR
-};
+enum command_err_code { CMD_SUCCESS = 0, CMD_ERROR };
-static ATTR_FORMAT_PRINTF(2, 3)
-void xml_error_handler(void *ctx __attribute__((unused)),
- const char *format, ...)
+static ATTR_FORMAT_PRINTF(2, 3) void xml_error_handler(void *ctx __attribute__((unused)),
+ const char *format,
+ ...)
{
char *err_msg;
va_list args;
ret = vasprintf(&err_msg, format, args);
va_end(args);
if (ret == -1) {
- fprintf(stderr, "ERR: %s\n",
- "String allocation failed in xml error handle");
+ fprintf(stderr, "ERR: %s\n", "String allocation failed in xml error handle");
return;
}
free(err_msg);
}
-static
-void fini_validation_ctx(
- struct validation_ctx *ctx)
+static void fini_validation_ctx(struct validation_ctx *ctx)
{
if (ctx->parser_ctx) {
xmlSchemaFreeParserCtxt(ctx->parser_ctx);
memset(ctx, 0, sizeof(struct validation_ctx));
}
-static
-int init_validation_ctx(
- struct validation_ctx *ctx, char *xsd_path)
+static int init_validation_ctx(struct validation_ctx *ctx, char *xsd_path)
{
int ret;
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
goto end;
}
- xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler,
- xml_error_handler, NULL);
+ xmlSchemaSetParserErrors(ctx->parser_ctx, xml_error_handler, xml_error_handler, NULL);
ctx->schema = xmlSchemaParse(ctx->parser_ctx);
if (!ctx->schema) {
goto end;
}
- xmlSchemaSetValidErrors(ctx->schema_validation_ctx, xml_error_handler,
- xml_error_handler, NULL);
+ xmlSchemaSetValidErrors(
+ ctx->schema_validation_ctx, xml_error_handler, xml_error_handler, NULL);
ret = 0;
end: