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 */
uint64_t num_subbuf; /* Number of sub-buffers for writer */
uint32_t mode; /* Buffer mode: 0: overwrite, 1: discard */
};
+} /* namespace */
/* Variables */
static const char *progname;
struct cds_lfht *ht;
};
+namespace {
struct trace_chunk_registry_ht_key {
lttng_uuid sessiond_uuid;
};
struct lttng_trace_chunk_registry *trace_chunk_registry;
struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
};
+} /* namespace */
static
unsigned long trace_chunk_registry_ht_key_hash(
#endif /* ! defined (__linux__) && ! defined (__sun__) */
+namespace {
struct tcp_keep_alive_support {
/* TCP keep-alive is supported by this platform. */
bool supported;
int abort_threshold;
};
-static struct tcp_keep_alive_config the_config = {.enabled = false,
+struct tcp_keep_alive_config the_config = {.enabled = false,
.idle_time = -1,
.probe_interval = -1,
.max_probe_count = -1,
.abort_threshold = -1};
-static struct tcp_keep_alive_support the_support = {.supported = false,
+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 */
/*
* Common parser for string to positive int conversion where the value must be
#define THREAD_NAME "Action Executor"
#define MAX_QUEUED_WORK_COUNT 8192
+struct action_executor {
+ struct lttng_thread *thread;
+ struct notification_thread_handle *notification_thread_handle;
+ struct {
+ uint64_t pending_count;
+ struct cds_list_head list;
+ pthread_cond_t cond;
+ pthread_mutex_t lock;
+ } work;
+ bool should_quit;
+ uint64_t next_work_item_id;
+};
+
+namespace {
/*
* A work item is composed of a dynamic array of sub-items which
* represent a flattened, and augmented, version of a trigger's actions.
* trigger object at the moment of execution, if the trigger is found to be
* unregistered, the execution is skipped.
*/
-
struct action_work_item {
uint64_t id;
LTTNG_OPTIONAL(uint64_t) session_id;
} context;
};
+} /* namespace */
-struct action_executor {
- struct lttng_thread *thread;
- struct notification_thread_handle *notification_thread_handle;
- struct {
- uint64_t pending_count;
- struct cds_list_head list;
- pthread_cond_t cond;
- pthread_mutex_t lock;
- } work;
- bool should_quit;
- uint64_t next_work_item_id;
-};
/*
* Only return non-zero on a fatal error that should shut down the action
#include "utils.hpp"
#include "thread.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
sem_t ready;
unsigned int major, minor;
};
-static int agent_tracing_enabled = -1;
+int agent_tracing_enabled = -1;
/*
* Note that there is not port here. It's set after this URI is parsed so we
* can let the user define a custom one. However, localhost is ALWAYS the
* default listening address.
*/
-static const char *default_reg_uri =
- "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS;
+const char *default_reg_uri = "tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS;
+} /* namespace */
/*
* Update agent application using the given socket. This is done just after
/*
* Agent application context representation.
*/
+namespace {
struct agent_app_ctx {
char *provider_name;
char *ctx_name;
/* For call_rcu teardown. */
struct rcu_head rcu_node;
};
+} /* namespace */
/*
* Human readable agent return code.
#include "kernel.hpp"
#include "cmd.hpp"
+namespace {
struct cmd_clear_session_reply_context {
int reply_sock_fd;
};
+} /* namespace */
static
void cmd_clear_session_reply(const struct ltt_session *session,
#include "testpoint.hpp"
#include "utils.hpp"
-static bool is_root;
+namespace {
+bool is_root;
-static struct thread_state {
+struct thread_state {
sem_t ready;
bool running;
int client_sock;
} thread_state;
+} /* namespace */
static void set_thread_status(bool running)
{
/* Sleep for 100ms between each check for the shm path's deletion. */
#define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000
+static enum lttng_error_code wait_on_path(void *path);
+
+namespace {
struct cmd_destroy_session_reply_context {
int reply_sock_fd;
bool implicit_rotation_on_destroy;
enum lttng_error_code destruction_status;
};
-static enum lttng_error_code wait_on_path(void *path);
-
/*
* Command completion handler that is used by the destroy command
* when a session that has a non-default shm_path is being destroyed.
*
* See comment in cmd_destroy_session() for the rationale.
*/
-static struct destroy_completion_handler {
+struct destroy_completion_handler {
struct cmd_completion_handler handler;
char shm_path[member_sizeof(struct ltt_session, shm_path)];
} destroy_completion_handler = {
.shm_path = { 0 },
};
-static struct cmd_completion_handler *current_completion_handler;
-
/*
* Used to keep a unique index for each relayd socket created where this value
* is associated with streams on the consumer so it can match the right relayd
* to send to. It must be accessed with the relayd_net_seq_idx_lock
* held.
*/
-static pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER;
-static uint64_t relayd_net_seq_idx;
+pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER;
+uint64_t relayd_net_seq_idx;
+} /* namespace */
+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,
#include "lttng-sessiond.hpp"
#include "thread.hpp"
+namespace {
struct thread_notifiers {
struct ust_cmd_queue *ust_cmd_queue;
int apps_cmd_pipe_write_fd;
int apps_cmd_notify_pipe_write_fd;
int dispatch_thread_exit;
};
+} /* namespace */
/*
* For each tracing session, update newly registered apps. The session list
#define ERROR_COUNTER_INDEX_HT_INITIAL_SIZE 16
+namespace {
struct index_ht_entry {
struct lttng_ht_node_u64 node;
uint64_t error_counter_index;
int error_counter_fd;
};
-static struct kernel_error_accounting_entry kernel_error_accounting_entry;
+struct kernel_error_accounting_entry kernel_error_accounting_entry;
/* Hashtable mapping uid to error_account_entry. */
-static struct lttng_ht *error_counter_uid_ht;
+struct lttng_ht *error_counter_uid_ht;
struct error_accounting_state {
struct lttng_index_allocator *index_allocator;
uint64_t number_indices;
};
-static struct error_accounting_state ust_state;
-static struct error_accounting_state kernel_state;
+struct error_accounting_state ust_state;
+struct error_accounting_state kernel_state;
+} /* namespace */
static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
const char **trigger_name,
}
#ifdef HAVE_LIBLTTNG_UST_CTL
+namespace {
struct event_notifier_counter {
pthread_mutex_t lock;
long count;
};
-static struct event_notifier_counter the_event_notifier_counter;
+struct event_notifier_counter the_event_notifier_counter;
+} /* namespace */
static void free_ust_error_accounting_entry(struct rcu_head *head)
{
#include "utils.hpp"
#include "thread.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
sem_t ready;
};
+} /* namespace */
static
void mark_thread_as_ready(struct thread_notifiers *notifiers)
#include "utils.hpp"
#include "thread.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
int apps_cmd_pipe_read_fd;
};
+} /* namespace */
static void cleanup_application_management_thread(void *data)
{
#include "thread.hpp"
#include "ust-consumer.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
struct consumer_data *consumer_data;
sem_t ready;
int initialization_result;
};
+} /* namespace */
static void mark_thread_as_ready(struct thread_notifiers *notifiers)
{
#include "kernel.hpp"
#include "kernel-consumer.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
int kernel_poll_pipe_read_fd;
};
+} /* namespace */
/*
* Update the kernel poll set of all channel fd available over all tracing
LTTNG_OBJECT_TYPE_SESSION,
};
-struct lttng_trigger_list_element {
- /* No ownership of the trigger object is assumed. */
- struct lttng_trigger *trigger;
- struct cds_list_head node;
-};
-
struct lttng_channel_trigger_list {
struct channel_key channel_key;
/* List of struct lttng_trigger_list_element. */
struct rcu_head rcu_node;
};
+namespace {
+struct lttng_trigger_list_element {
+ /* No ownership of the trigger object is assumed. */
+ struct lttng_trigger *trigger;
+ struct cds_list_head node;
+};
+
struct lttng_trigger_ht_element {
struct lttng_trigger *trigger;
struct cds_lfht_node node;
/* call_rcu delayed reclaim. */
struct rcu_head rcu_node;
};
+} /* namespace */
static unsigned long hash_channel_key(struct channel_key *key);
static int evaluate_buffer_condition(const struct lttng_condition *condition,
#include "utils.hpp"
#include "thread.hpp"
+namespace {
struct thread_notifiers {
struct lttng_pipe *quit_pipe;
int apps_cmd_notify_pipe_read_fd;
};
+} /* namespace */
/*
* This thread manage application notify communication.
#include "utils.hpp"
#include "thread.hpp"
+namespace {
struct thread_state {
struct lttng_pipe *quit_pipe;
struct ust_cmd_queue *ust_cmd_queue;
bool running;
int application_socket;
};
+} /* namespace */
/*
* Creates the application socket.
struct lttng_poll_event events;
};
-struct rotation_thread_job {
- enum rotation_thread_job_type type;
- struct ltt_session *session;
- /* List member in struct rotation_thread_timer_queue. */
- struct cds_list_head head;
-};
-
/*
* The timer thread enqueues jobs and wakes up the rotation thread.
* When the rotation thread wakes up, it empties the queue.
struct lttng_pipe *quit_pipe;
};
+namespace {
+struct rotation_thread_job {
+ enum rotation_thread_job_type type;
+ struct ltt_session *session;
+ /* List member in struct rotation_thread_timer_queue. */
+ struct cds_list_head head;
+};
+} /* namespace */
+
static
const char *get_job_type_str(enum rotation_thread_job_type job_type)
{
#include "timer.hpp"
#include "cmd.hpp"
+namespace {
struct ltt_session_destroy_notifier_element {
ltt_session_destroy_notifier notifier;
void *user_data;
* using session_lock() and session_unlock().
*/
+/* These characters are forbidden in a session name. Used by validate_name. */
+const char *forbidden_name_chars = "/";
+
+/* Global hash table to keep the sessions, indexed by id. */
+struct lttng_ht *ltt_sessions_ht_by_id = NULL;
+/* Global hash table to keep the sessions, indexed by name. */
+struct lttng_ht *ltt_sessions_ht_by_name = NULL;
+
/*
* Init tracing session list.
*
* Please see session.h for more explanation and correct usage of the list.
*/
-static struct ltt_session_list ltt_session_list = {
+struct ltt_session_list the_session_list = {
.lock = PTHREAD_MUTEX_INITIALIZER,
.removal_cond = PTHREAD_COND_INITIALIZER,
.next_uuid = 0,
- .head = CDS_LIST_HEAD_INIT(ltt_session_list.head),
+ .head = CDS_LIST_HEAD_INIT(the_session_list.head),
};
-
-/* These characters are forbidden in a session name. Used by validate_name. */
-static const char *forbidden_name_chars = "/";
-
-/* Global hash table to keep the sessions, indexed by id. */
-static struct lttng_ht *ltt_sessions_ht_by_id = NULL;
-/* Global hash table to keep the sessions, indexed by name. */
-static struct lttng_ht *ltt_sessions_ht_by_name = NULL;
+} /* namespace */
/*
* Validate the session name for forbidden characters.
{
LTTNG_ASSERT(ls);
- cds_list_add(&ls->list, <t_session_list.head);
- return ltt_session_list.next_uuid++;
+ cds_list_add(&ls->list, &the_session_list.head);
+ return the_session_list.next_uuid++;
}
/*
*/
struct ltt_session_list *session_get_list(void)
{
- return <t_session_list;
+ return &the_session_list;
}
/*
*/
void session_list_wait_empty(void)
{
- pthread_mutex_lock(<t_session_list.lock);
- while (!cds_list_empty(<t_session_list.head)) {
- pthread_cond_wait(<t_session_list.removal_cond,
- <t_session_list.lock);
+ 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_mutex_unlock(<t_session_list.lock);
+ pthread_mutex_unlock(&the_session_list.lock);
}
/*
*/
void session_lock_list(void)
{
- pthread_mutex_lock(<t_session_list.lock);
+ pthread_mutex_lock(&the_session_list.lock);
}
/*
*/
int session_trylock_list(void)
{
- return pthread_mutex_trylock(<t_session_list.lock);
+ return pthread_mutex_trylock(&the_session_list.lock);
}
/*
*/
void session_unlock_list(void)
{
- pthread_mutex_unlock(<t_session_list.lock);
+ pthread_mutex_unlock(&the_session_list.lock);
}
/*
pthread_mutex_destroy(&session->lock);
if (session_published) {
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
del_session_list(session);
del_session_ht(session);
}
* Broadcast after free-ing to ensure the memory is
* reclaimed before the main thread exits.
*/
- ASSERT_LOCKED(ltt_session_list.lock);
- pthread_cond_broadcast(<t_session_list.removal_cond);
+ ASSERT_LOCKED(the_session_list.lock);
+ pthread_cond_broadcast(&the_session_list.removal_cond);
}
}
* The session list lock must be held as any session_put()
* may cause the removal of the session from the session_list.
*/
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
LTTNG_ASSERT(session->ref.refcount);
urcu_ref_put(&session->ref, session_release);
}
struct ltt_session *iter;
LTTNG_ASSERT(name);
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
DBG2("Trying to find session by name %s", name);
- cds_list_for_each_entry(iter, <t_session_list.head, list) {
+ cds_list_for_each_entry(iter, &the_session_list.head, list) {
if (!strncmp(iter->name, name, NAME_MAX) &&
!iter->destroyed) {
goto found;
struct ltt_session *ls;
ASSERT_RCU_READ_LOCKED();
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
if (!ltt_sessions_ht_by_id) {
goto end;
enum lttng_error_code ret_code;
struct ltt_session *new_session = NULL;
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
if (name) {
struct ltt_session *clashing_session;
{
int ret = 0;
- ASSERT_LOCKED(ltt_session_list.lock);
+ ASSERT_LOCKED(the_session_list.lock);
ASSERT_LOCKED(session->lock);
session->rotation_state = result;
#include <common/error.hpp>
#include <common/defaults.hpp>
-static struct thread_list {
+namespace {
+struct thread_list {
struct cds_list_head head;
pthread_mutex_t lock;
} thread_list = {
.head = CDS_LIST_HEAD_INIT(thread_list.head),
.lock = PTHREAD_MUTEX_INITIALIZER,
};
+} /* namespace */
struct lttng_thread {
struct urcu_ref ref;
})
#define PTR_TO_UINT(ptr) ((uintptr_t) ptr)
+namespace {
/*
* Handle timer teardown race wrt memory free of private data by sessiond
* signals are handled by a single thread, which permits a synchronization
* point between handling of each signal. Internal lock ensures mutual
* exclusion.
*/
-static
struct timer_signal_data {
/* Thread managing signals. */
pthread_t tid;
.qs_done = 0,
.lock = PTHREAD_MUTEX_INITIALIZER,
};
+} /* namespace */
/*
* Set custom signal mask to current thread.
#include <common/tracker.hpp>
#include <lttng/lttng-error.h>
+struct process_attr_tracker {
+ enum lttng_tracking_policy policy;
+ struct cds_lfht *inclusion_set_ht;
+};
+
+namespace {
struct process_attr_tracker_value_node {
struct process_attr_value *value;
struct cds_lfht_node inclusion_set_ht_node;
struct rcu_head rcu_head;
};
-
-struct process_attr_tracker {
- enum lttng_tracking_policy policy;
- struct cds_lfht *inclusion_set_ht;
-};
+} /* namespace */
static void process_attr_tracker_value_node_rcu_free(struct rcu_head *rcu_head)
{
#define NR_CLOCK_OFFSET_SAMPLES 10
+namespace {
struct offset_sample {
- int64_t offset; /* correlation offset */
- uint64_t measure_delta; /* lower is better */
+ /* correlation offset */
+ int64_t offset;
+ /* lower is better */
+ uint64_t measure_delta;
};
+} /* namespace */
static
int _lttng_field_statedump(struct ust_registry_session *session,
_PERF_HW_CACHE(optstr "-prefetch-misses", name, type, \
PREFETCH, MISS, hide)
-static
+namespace {
const struct ctx_opts {
/* Needed for end-of-list item. */
ctx_opts()
} ctx_type_list = {
.head = CDS_LIST_HEAD_INIT(ctx_type_list.head),
};
-
-
+} /* namespace */
/*
* Find context numerical value from string.
lttng_event_expr_destroy((lttng_event_expr *) ptr);
}
+namespace {
struct parse_event_rule_res {
/* Owned by this. */
struct lttng_event_rule *er;
/* Array of `struct lttng_event_expr *` */
struct lttng_dynamic_pointer_array capture_descriptors;
};
+} /* namespace */
static
struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv,
return c;
}
+namespace {
struct condition_descr {
const char *name;
struct lttng_condition *(*handler) (int *argc, const char ***argv,
int argc_offset);
};
+} /* namespace */
static const
struct condition_descr condition_descrs[] = {
return action;
}
+namespace {
struct action_descr {
const char *name;
struct lttng_action *(*handler) (int *argc, const char ***argv,
int argc_offset);
};
+} /* namespace */
static const
struct action_descr action_descrs[] = {
#include "../command.hpp"
+namespace {
struct process_attr_command_args {
enum lttng_process_attr process_attr;
/* Present in the user's command. */
bool all;
struct lttng_dynamic_pointer_array string_args;
};
+} /* namespace */
enum cmd_type {
CMD_TRACK,
#include <strings.h>
#include <ctype.h>
+namespace {
struct loglevel_name_value {
const char *name;
int value;
};
+} /* namespace */
static
const struct loglevel_name_value loglevel_values[] = {
#define IS_LIST_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_LIST)
+namespace {
struct lttng_action_list {
struct lttng_action parent;
*/
char data[];
} LTTNG_PACKED;
+} /* namespace */
static void destroy_lttng_action_list_element(void *ptr)
{
#include <lttng/action/path-internal.hpp>
+namespace {
struct lttng_action_path_comm {
uint32_t index_count;
uint64_t indexes[];
} LTTNG_PACKED;
+} /* namespace */
struct lttng_action_path *lttng_action_path_create(
const uint64_t *indexes, size_t index_count)
rate_policy_mi_serialize_cb mi_serialize;
};
+namespace {
struct lttng_rate_policy_every_n {
struct lttng_rate_policy parent;
uint64_t interval;
struct lttng_rate_policy_every_n_comm {
uint64_t interval;
} LTTNG_PACKED;
+} /* namespace */
/* Forward declaration. */
static void lttng_rate_policy_init(struct lttng_rate_policy *rate_policy,
#define IS_ROTATE_SESSION_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_ROTATE_SESSION)
+namespace {
struct lttng_action_rotate_session {
struct lttng_action parent;
*/
char data[];
} LTTNG_PACKED;
+} /* namespace */
static const struct lttng_rate_policy *
lttng_action_rotate_session_internal_get_rate_policy(
#define IS_SNAPSHOT_SESSION_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_SNAPSHOT_SESSION)
+namespace {
struct lttng_action_snapshot_session {
struct lttng_action parent;
*/
char data[];
} LTTNG_PACKED;
+} /* namespace */
static const struct lttng_rate_policy *
lttng_action_snapshot_session_internal_get_rate_policy(
#define IS_START_SESSION_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_START_SESSION)
+namespace {
struct lttng_action_start_session {
struct lttng_action parent;
*/
char data[];
} LTTNG_PACKED;
+} /* namespace */
static const struct lttng_rate_policy *
lttng_action_start_session_internal_get_rate_policy(
#define IS_STOP_SESSION_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_STOP_SESSION)
+namespace {
struct lttng_action_stop_session {
struct lttng_action parent;
*/
char data[];
} LTTNG_PACKED;
+} /* namespace */
static const struct lttng_rate_policy *
lttng_action_stop_session_internal_get_rate_policy(
return ret;
}
+namespace {
struct rmdir_frame {
ssize_t parent_frame_idx;
DIR *dir;
/* Size including '\0'. */
size_t path_size;
};
+} /* namespace */
static
void rmdir_frame_fini(void *data)
#define CONFIG_USERSPACE_PROBE_LOOKUP_METHOD_NAME_MAX_LEN 7
+namespace {
struct session_config_validation_ctx {
xmlSchemaParserCtxtPtr parser_ctx;
xmlSchemaPtr schema;
xmlSchemaValidCtxtPtr schema_validation_ctx;
};
+} /* namespace */
const char * const config_element_all = "all";
LTTNG_EXPORT const char *config_xml_encoding = "UTF-8";
ENABLE = 1,
};
+namespace {
struct consumer_output {
int enabled;
char *path;
char *control_uri;
char *data_uri;
};
+} /* namespace */
/*
* Returns a xmlChar string which must be released using xmlFree().
CONSUMER_CHANNEL_QUIT,
};
+namespace {
struct consumer_channel_msg {
enum consumer_channel_action action;
struct lttng_consumer_channel *chan; /* add */
uint64_t key; /* del */
};
+/*
+ * Global hash table containing respectively metadata and data streams. The
+ * stream element in this ht should only be updated by the metadata poll thread
+ * for the metadata and the data poll thread for the data.
+ */
+struct lttng_ht *metadata_ht;
+struct lttng_ht *data_ht;
+} /* namespace */
+
/* Flag used to temporarily pause data consumption from testpoints. */
int data_consumption_paused;
*/
int consumer_quit;
-/*
- * Global hash table containing respectively metadata and data streams. The
- * stream element in this ht should only be updated by the metadata poll thread
- * for the metadata and the data poll thread for the data.
- */
-static struct lttng_ht *metadata_ht;
-static struct lttng_ht *data_ht;
-
static const char *get_consumer_domain(void)
{
switch (the_consumer_data.type) {
enum lttng_error_query_target_type target_type;
};
+struct lttng_error_query_result {
+ enum lttng_error_query_result_type type;
+ char *name;
+ char *description;
+};
+
+struct lttng_error_query_results {
+ struct lttng_dynamic_pointer_array results;
+};
+
+namespace {
struct lttng_error_query_comm {
/* enum lttng_error_query_target_type */
int8_t target_type;
struct lttng_action_path action_path;
};
-struct lttng_error_query_result {
- enum lttng_error_query_result_type type;
- char *name;
- char *description;
-};
-
struct lttng_error_query_result_comm {
/* enum lttng_error_query_result_type */
uint8_t type;
/* `count` instances of `struct lttng_error_query_result` follow. */
char payload[];
} LTTNG_PACKED;
-
-struct lttng_error_query_results {
- struct lttng_dynamic_pointer_array results;
-};
+} /* namespace */
static
enum lttng_error_code lttng_error_query_result_mi_serialize(
#include <lttng/lttng-error.h>
#include <lttng/userspace-probe-internal.hpp>
+namespace {
struct event_list_element {
struct lttng_event *event;
struct lttng_event_exclusion *exclusions;
char *filter_expression;
};
+} /* namespace */
static void event_list_destructor(void *ptr)
{
struct lttng_unlinked_file_pool *unlinked_file_pool;
};
+namespace {
struct open_properties {
int flags;
LTTNG_OPTIONAL(mode_t) mode;
struct rcu_head rcu_head;
};
-static struct {
+struct {
pthread_mutex_t lock;
bool initialized;
unsigned long value;
.initialized = false,
.value = 0,
};
+} /* namespace */
static int match_fd(struct cds_lfht_node *node, const void *key);
static void unsuspendable_fd_destroy(struct unsuspendable_fd *entry);
#include "inode.hpp"
+namespace {
struct inode_id {
dev_t device;
ino_t inode;
};
+} /* namespace */
struct lttng_inode_registry {
/* Hashtable of inode_id to lttng_inode. */
unsigned int next_id;
};
-static struct {
+namespace {
+struct {
pthread_mutex_t lock;
bool initialized;
unsigned long value;
.initialized = false,
.value = 0,
};
+} /* namespace */
static unsigned long lttng_inode_id_hash(const struct inode_id *id)
{
#ifdef HAVE_EPOLL
+namespace {
struct create_args {
struct lttng_poll_event *events;
int size;
int flags;
};
+} /* namespace */
static int open_epoll(void *data, int *out_fd)
{
tracker, pipe, 2, close_pipe, NULL);
}
+namespace {
struct open_directory_handle_args {
const struct lttng_directory_handle *in_handle;
struct lttng_directory_handle *ret_handle;
const char *path;
};
+} /* namespace */
static
int open_directory_handle(void *_args, int *out_fds)
uint64_t nb_allocated_indexes;
};
+namespace {
struct lttng_index {
uint64_t index;
struct cds_list_head head;
};
+} /* namespace */
struct lttng_index_allocator *lttng_index_allocator_create(
uint64_t index_count)
LTTNG_EXPORT const char *config_str_false = "false";
LTTNG_EXPORT const char *config_str_off = "off";
+namespace {
struct handler_filter_args {
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)
#define EV_NUM 2
#endif
+namespace {
struct lttng_elf_ehdr {
uint16_t e_type;
uint16_t e_machine;
uint64_t st_value;
uint64_t st_size;
};
+} /* namespace */
struct lttng_elf {
int fd;
#define GETPW_BUFFER_FALLBACK_SIZE 4096
-struct run_as_data;
-struct run_as_ret;
-typedef int (*run_as_fct)(struct run_as_data *data, struct run_as_ret *ret_value);
-
enum run_as_cmd {
RUN_AS_MKDIR,
RUN_AS_MKDIRAT,
RUN_AS_GENERATE_FILTER_BYTECODE,
};
+namespace {
+struct run_as_data;
+struct run_as_ret;
+typedef int (*run_as_fct)(struct run_as_data *data, struct run_as_ret *ret_value);
+
struct run_as_mkdir_data {
int dirfd;
char path[LTTNG_PATH_MAX];
bool use_cwd_fd;
};
-static const struct run_as_command_properties command_properties[] = {
+const struct run_as_command_properties command_properties[] = {
{
.in_fds_offset = offsetof(struct run_as_data, u.mkdir.dirfd),
.out_fds_offset = -1,
};
/* Single global worker per process (for now). */
-static run_as_worker_data *global_worker;
+run_as_worker_data *global_worker;
/* Lock protecting the worker. */
-static pthread_mutex_t worker_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t worker_lock = PTHREAD_MUTEX_INITIALIZER;
+} /* namespace */
#ifdef VALGRIND
static
#include <time.h>
#include <stdio.h>
+namespace {
struct lttng_session_descriptor_network_location {
struct lttng_uri *control;
struct lttng_uri *data;
};
+} /* namespace */
struct lttng_session_descriptor {
enum lttng_session_descriptor_type type;
} output;
};
+namespace {
struct lttng_session_descriptor_snapshot {
struct lttng_session_descriptor base;
/*
/* Live-specific parameters. */
uint64_t live_timer_us;
} LTTNG_PACKED;
+} /* namespace */
static
struct lttng_uri *uri_copy(const struct lttng_uri *uri)
return equal;
}
+namespace {
/*
* This is essentially the same as `struct lttng_snapshot_output`, but packed.
*/
char ctrl_url[PATH_MAX];
char data_url[PATH_MAX];
} LTTNG_PACKED;
+} /* namespace */
int lttng_snapshot_output_serialize(
const struct lttng_snapshot_output *output,
#include "macros.hpp"
#include "spawn-viewer.hpp"
-
-static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
-static const char *babeltrace2_bin = CONFIG_BABELTRACE2_BIN;
-
-/*
- * This is needed for each viewer since we are using execvp().
- */
-static const char *babeltrace_opts[] = { "babeltrace" };
-static const char *babeltrace2_opts[] = { "babeltrace2" };
-
/*
* 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.
VIEWER_USER_DEFINED = 2,
};
-static const struct viewer {
+namespace {
+const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
+const char *babeltrace2_bin = CONFIG_BABELTRACE2_BIN;
+
+/*
+ * This is needed for each viewer since we are using execvp().
+ */
+const char *babeltrace_opts[] = { "babeltrace" };
+const char *babeltrace2_opts[] = { "babeltrace2" };
+
+const struct viewer {
const char *exec_name;
enum viewer_type type;
} viewers[] = {
{ "babeltrace2", VIEWER_BABELTRACE2 },
{ NULL, VIEWER_USER_DEFINED },
};
+} /* namespace */
static const struct viewer *parse_viewer_option(const char *opt_viewer)
{
enum lttng_trace_chunk_status lttng_trace_chunk_rename_path_no_lock(
struct lttng_trace_chunk *chunk, const char *path);
+namespace {
struct chunk_credentials {
bool use_current_user;
struct lttng_credentials user;
};
+} /* namespace */
/*
* NOTE: Make sure to update:
struct fd_tracker *fd_tracker;
};
+namespace {
/* A trace chunk is uniquely identified by its (session id, chunk id) tuple. */
struct lttng_trace_chunk_registry_element {
struct lttng_trace_chunk chunk;
/* call_rcu delayed reclaim. */
struct rcu_head rcu_node;
};
+} /* namespace */
struct lttng_trace_chunk_registry {
struct cds_lfht *ht;
};
+namespace {
struct fs_handle_untracked {
struct fs_handle parent;
int fd;
char *path;
} location;
};
+} /* namespace */
static
int fs_handle_untracked_get_fd(struct fs_handle *handle);
#include <type_traits>
+namespace {
struct process_attr_tracker_values_comm_header {
uint32_t count;
} LTTNG_PACKED;
uint32_t name_len;
} value;
} LTTNG_PACKED;
+} /* namespace */
#define GET_INTEGRAL_COMM_VALUE(value_ptr, as_type) \
((as_type)(std::is_signed<as_type>::value ? (value_ptr)->u._signed : \
P_NET, P_NET6, P_FILE, P_TCP, P_TCP6,
};
+namespace {
struct uri_proto {
const char *name;
const char *leading_string;
};
/* Supported protocols */
-static const struct uri_proto proto_uri[] = {
+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 },
/* Invalid proto marking the end of the array. */
{}
};
+} /* namespace */
/*
* Return pointer to the character in s matching one of the characters in
typedef void (*test_case_cb)(FILE *output_file);
-static const struct test_case {
+namespace {
+const struct test_case {
test_case_cb run;
bool produces_validation_info;
int timeout;
struct pollfd *ufds;
int value;
};
+} /* namespace */
static
void test_select_big(void)
LTTNG_EXPORT DEFINE_LTTNG_UST_SIGBUS_STATE();
#endif
-static int control_sock;
+namespace {
struct live_session *session;
+int control_sock;
-static int first_packet_offset;
-static int first_packet_len;
-static int first_packet_stream_id = -1;
+int first_packet_offset;
+int first_packet_len;
+int first_packet_stream_id = -1;
struct viewer_stream {
uint64_t id;
uint64_t live_timer_interval;
uint64_t stream_count;
};
+} /* namespace */
static
ssize_t lttng_live_recv(int fd, void *buf, size_t len)
FIELD_TYPE_ARRAY_FIELD,
};
+namespace {
struct capture_base_field_tuple {
const char *field_name;
enum field_type field_type;
validate_cb validate_ust;
validate_cb validate_kernel;
};
+} /* namespace */
static
const char *field_value_type_to_str(enum lttng_event_field_value_type type)
#include <string.h>
#include <lttng/constant.h>
+namespace {
struct state {
int section_1;
int section_2;
int text_entry;
int int_entry;
};
+} /* namespace */
int lttng_opt_quiet = 1;
int lttng_opt_verbose = 0;
#define NUM_TESTS 212
+namespace {
struct tracepoint_test {
enum lttng_domain_type type;
bool support_name_pattern_exclusion;
};
+} /* namespace */
typedef const char *(*log_level_name_getter)(int log_level);
/* Number of TAP tests in this file */
#define NUM_TESTS_PER_TEST 1
+namespace {
struct test {
const char *stream_path;
const char *session_name;
const char *leftover;
bool is_valid;
};
+} /* namespace */
int lttng_opt_quiet;
int lttng_opt_mi;
int lttng_opt_verbose = 3;
int lttng_opt_mi;
+namespace {
struct valid_test_input {
const char *input;
const char *relative_part;
};
/* Valid test cases */
-static struct valid_test_input valid_tests_inputs[] = {
+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/..", "", "/" },
};
char **valid_tests_expected_results;
-static const int num_valid_tests =
+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";
-static const char * const tree_dirs[] = {
+const char * const tree_dirs[] = {
"a",
"a/b",
"a/b/c",
"a/e",
};
-static const int num_tree_dirs =
+const int num_tree_dirs =
sizeof(tree_dirs) / sizeof(tree_dirs[0]);
-static struct tree_symlink tree_symlinks[] = {
+struct tree_symlink tree_symlinks[] = {
{ "a/d", "b/c/" },
{ "a/g", "d/" },
{ "a/b/f", "../e/" },
{ "a/b/k", "c/g/" },
{ "a/b/c/g", "../../../" },
};
-static const int num_tree_symlinks =
+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/" },
{ "a/b/h/g/", "" },
};
-static const int num_symlink_tests =
+const int num_symlink_tests =
sizeof(symlink_tests_inputs) / sizeof(symlink_tests_inputs[0]);
/* Invalid test cases */
-static char *invalid_tests_inputs[] = {
+char *invalid_tests_inputs[] = {
NULL,
};
-static const int num_invalid_tests =
+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)
int lttng_opt_verbose = 3;
int lttng_opt_mi;
+namespace {
struct valid_test_input {
const char *input;
uint64_t expected_result;
};
/* Valid test cases */
-static struct valid_test_input valid_tests_inputs[] = {
+struct valid_test_input valid_tests_inputs[] = {
{ "0", 0 },
{ "1234", 1234 },
{ "0x400", 1024 },
{ "0XA0M", 167772160 },
{ "0xA0G", 171798691840ULL },
};
-static 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]);
/* Invalid test cases */
-static const char *invalid_tests_inputs[] = {
+const char *invalid_tests_inputs[] = {
"",
" ",
"-1",
"0B",
};
-static 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 */
static void test_utils_parse_size_suffix(void)
{
int lttng_opt_verbose = 3;
int lttng_opt_mi;
+namespace {
struct valid_test_input {
const char *input;
uint64_t expected_result;
};
/* Valid test cases */
-static struct valid_test_input valid_tests_inputs[] = {
+struct valid_test_input valid_tests_inputs[] = {
{ "0", 0 },
{ "1234", 1234 },
{ "1234us", 1234 },
{ "08", 8 },
{ "0145us", 145 },
};
-static 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]);
/* Invalid test cases */
-static const char *invalid_tests_inputs[] = {
+const char *invalid_tests_inputs[] = {
"",
" ",
"-1",
"12mo",
"53hi",
};
-static 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 */
static void test_utils_parse_time_suffix(void)
{
#include <lttng/lttng-error.h>
#include <common/macros.hpp>
+namespace {
struct validation_ctx {
xmlSchemaParserCtxtPtr parser_ctx;
xmlSchemaPtr schema;
xmlSchemaValidCtxtPtr schema_validation_ctx;
};
+} /* namespace */
enum command_err_code {
CMD_SUCCESS = 0,