int ret;
struct ltt_kernel_channel *kchan;
+ assert(ksession);
+ assert(channel_name);
+
kchan = trace_kernel_get_channel_by_name(channel_name, ksession);
if (kchan == NULL) {
ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
goto error;
- } else if (kchan->enabled == 1) {
+ }
+
+ /* Only if channel is enabled disable it. */
+ if (kchan->enabled == 1) {
ret = kernel_disable_channel(kchan);
if (ret < 0 && ret != -EEXIST) {
ret = LTTNG_ERR_KERN_CHAN_DISABLE_FAIL;
{
int ret;
+ assert(ksession);
+ assert(kchan);
+
if (kchan->enabled == 0) {
ret = kernel_enable_channel(kchan);
if (ret < 0) {
int ret;
struct lttng_channel *defattr = NULL;
+ assert(ksession);
+
/* Creating channel attributes if needed */
if (attr == NULL) {
defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL);
{
int ret = LTTNG_OK;
+ assert(usess);
+ assert(uchan);
+
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
struct ltt_ust_channel *uchan = NULL;
struct lttng_channel *defattr = NULL;
+ assert(usess);
+
/* Creating channel attributes if needed */
if (attr == NULL) {
defattr = channel_new_default_attr(domain);
}
/*
- * Validate UST buffer size and number of buffers: must both be
- * power of 2 and nonzero. We validate right here for UST,
- * because applications will not report the error to the user
- * (unlike kernel tracing).
+ * Validate UST buffer size and number of buffers: must both be power of 2
+ * 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 = LTTNG_ERR_INVALID;
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 = LTTNG_ERR_INVALID;
goto error;
}
{
int ret = LTTNG_OK;
+ assert(usess);
+ assert(uchan);
+
/* Already disabled */
if (uchan->enabled == 0) {
DBG2("Channel UST %s already disabled", uchan->name);
int ret;
struct ltt_kernel_channel *kchan;
+ assert(ksession);
+ assert(kctx);
+
DBG("Adding kernel context to all channels");
/* Go over all channels */
{
int ret;
+ assert(kchan);
+ assert(kctx);
+
DBG("Add kernel context to channel '%s'", kchan->channel->name);
ret = kernel_add_channel_context(kchan, kctx);
struct lttng_ht_iter iter;
struct lttng_ht_node_ulong *uctx_node;
+ assert(usess);
+ assert(uchan);
+ assert(ctx);
+
/* Create ltt UST context */
uctx = trace_ust_create_context(ctx);
if (uctx == NULL) {
struct ltt_kernel_channel *kchan;
struct lttng_kernel_context kctx;
+ assert(ksession);
+ assert(ctx);
+ assert(channel_name);
+
/* Setup kernel context structure */
switch (ctx->ctx) {
case LTTNG_EVENT_CONTEXT_PID:
struct lttng_ht *chan_ht;
struct ltt_ust_channel *uchan = NULL;
+ assert(usess);
+ assert(ctx);
+ assert(channel_name);
+
/*
* Define which channel's hashtable to use from the domain or quit if
* unknown domain.
*/
static void init_syscalls_kernel_event(struct lttng_event *event)
{
+ assert(event);
+
event->name[0] = '\0';
/*
* We use LTTNG_EVENT* here since the trace kernel creation will make the
int ret;
struct ltt_kernel_event *kevent;
+ assert(kchan);
+
kevent = trace_kernel_get_event_by_name(event_name, kchan);
if (kevent == NULL) {
ret = LTTNG_ERR_NO_EVENT;
int ret;
struct ltt_kernel_event *kevent;
+ assert(kchan);
+
/* For each event in the kernel session */
cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
ret = kernel_disable_event(kevent);
{
int ret;
+ assert(ksession);
+ assert(kchan);
+
ret = event_kernel_disable_all_tracepoints(ksession, kchan);
if (ret != LTTNG_OK)
return ret;
int ret;
struct ltt_kernel_event *kevent;
+ assert(kchan);
+ assert(event);
+
kevent = trace_kernel_get_event_by_name(event->name, kchan);
if (kevent == NULL) {
ret = kernel_create_event(event, kchan);
struct ltt_kernel_event *kevent;
struct lttng_event *event_list = NULL;
+ assert(kchan);
+
/* For each event in the kernel session */
cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
if (kevent->enabled == 0) {
ret = LTTNG_OK;
end:
return ret;
-
}
/*
int ret;
struct lttng_event event;
+ assert(kchan);
+
init_syscalls_kernel_event(&event);
DBG("Enabling all syscall tracing");
{
int tp_ret;
- tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+ assert(ksession);
+ assert(kchan);
+
+ tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan,
+ kernel_tracer_fd);
if (tp_ret != LTTNG_OK) {
goto end;
}
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;
+ assert(usess);
+ assert(uchan);
+
rcu_read_lock();
switch (domain) {
int ret = LTTNG_OK, to_create = 0;
struct ltt_ust_event *uevent;
+ assert(usess);
+ assert(uchan);
+ assert(event);
+
rcu_read_lock();
uevent = trace_ust_find_event(uchan->events, event->name, filter,
struct lttng_ht_iter iter;
struct lttng_ht *ht;
+ assert(usess);
+ assert(uchan);
+ assert(event_name);
+
ht = uchan->events;
rcu_read_lock();
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;
+ assert(usess);
+ assert(uchan);
+
rcu_read_lock();
switch (domain) {
{
int ret;
+ assert(chan);
+ assert(ctx);
+
DBG("Adding context to channel %s", chan->channel->name);
ret = kernctl_add_context(chan->fd, ctx);
if (ret < 0) {
int ret;
struct ltt_kernel_session *lks;
+ assert(session);
+
/* Allocate data structure */
lks = trace_kernel_create_session(session->path);
if (lks == NULL) {
int ret;
struct ltt_kernel_channel *lkc;
+ assert(session);
+ assert(chan);
+ assert(path);
+
/* Allocate kernel channel */
lkc = trace_kernel_create_channel(chan, path);
if (lkc == NULL) {
int ret;
struct ltt_kernel_event *event;
+ assert(ev);
+ assert(channel);
+
event = trace_kernel_create_event(ev);
if (event == NULL) {
ret = -1;
{
int ret;
+ assert(chan);
+
ret = kernctl_disable(chan->fd);
if (ret < 0) {
PERROR("disable chan ioctl");
{
int ret;
+ assert(chan);
+
ret = kernctl_enable(chan->fd);
if (ret < 0 && errno != EEXIST) {
PERROR("Enable kernel chan");
{
int ret;
+ assert(event);
+
ret = kernctl_enable(event->fd);
if (ret < 0) {
switch (errno) {
{
int ret;
+ assert(event);
+
ret = kernctl_disable(event->fd);
if (ret < 0) {
switch (errno) {
int ret;
struct ltt_kernel_metadata *lkm;
+ assert(session);
+
/* Allocate kernel metadata */
lkm = trace_kernel_create_metadata();
if (lkm == NULL) {
{
int ret;
+ assert(session);
+
ret = kernctl_start_session(session->fd);
if (ret < 0) {
PERROR("ioctl start session");
{
int ret;
+ assert(calibrate);
+
ret = kernctl_calibrate(fd, calibrate);
if (ret < 0) {
PERROR("calibrate ioctl");
int ret;
struct ltt_kernel_stream *stream;
+ assert(channel);
+
DBG("Flush buffer for channel %s", channel->channel->name);
cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
{
int ret;
+ assert(session);
+
ret = kernctl_stop_session(session->fd);
if (ret < 0) {
goto error;
int ret, count = 0;
struct ltt_kernel_stream *lks;
+ assert(channel);
+
while ((ret = kernctl_create_stream(channel->fd)) >= 0) {
lks = trace_kernel_create_stream(channel->channel->name, count);
if (lks == NULL) {
{
int ret;
+ assert(session);
+
ret = kernctl_create_stream(session->metadata->fd);
if (ret < 0) {
PERROR("kernel create metadata stream");
FILE *fp;
struct lttng_event *elist;
+ assert(events);
+
fd = kernctl_tracepoint_list(tracer_fd);
if (fd < 0) {
PERROR("kernel tracepoint list");
*/
static unsigned int add_session_list(struct ltt_session *ls)
{
+ assert(ls);
+
cds_list_add(&ls->list, <t_session_list.head);
return ltt_session_list.next_uuid++;
}
*/
static void del_session_list(struct ltt_session *ls)
{
+ assert(ls);
+
cds_list_del(&ls->list);
}
*/
void session_lock(struct ltt_session *session)
{
+ assert(session);
+
pthread_mutex_lock(&session->lock);
}
*/
void session_unlock(struct ltt_session *session)
{
+ assert(session);
+
pthread_mutex_unlock(&session->lock);
}
{
struct ltt_session *iter;
+ assert(name);
+
DBG2("Trying to find session by name %s", name);
cds_list_for_each_entry(iter, <t_session_list.head, list) {
int session_destroy(struct ltt_session *session)
{
/* Safety check */
- if (session == NULL) {
- ERR("Session pointer was null on session destroy");
- return LTTNG_OK;
- }
+ assert(session);
DBG("Destroying session %s", session->name);
del_session_list(session);
int wait_shm_fd, ret;
mode_t mode;
+ assert(shm_path);
+
/* Default permissions */
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
int wait_shm_fd, ret;
char *wait_shm_mmap;
+ assert(shm_path);
+
wait_shm_fd = get_wait_shm(shm_path, mmap_size, global);
if (wait_shm_fd < 0) {
goto error;
{
struct ltt_kernel_channel *chan;
- if (session == NULL) {
- ERR("Undefine session");
- goto error;
- }
+ assert(session);
+ assert(name);
DBG("Trying to find channel %s", name);
}
}
-error:
return NULL;
}
{
struct ltt_kernel_event *ev;
- if (channel == NULL) {
- ERR("Undefine channel");
- goto error;
- }
+ assert(name);
+ assert(channel);
cds_list_for_each_entry(ev, &channel->events_list.head, list) {
if (strcmp(name, ev->event->name) == 0) {
}
}
-error:
return NULL;
}
{
struct ltt_kernel_channel *lkc;
+ assert(chan);
+
lkc = zmalloc(sizeof(struct ltt_kernel_channel));
if (lkc == NULL) {
PERROR("ltt_kernel_channel zmalloc");
struct ltt_kernel_event *lke;
struct lttng_kernel_event *attr;
+ assert(ev);
+
lke = zmalloc(sizeof(struct ltt_kernel_event));
attr = zmalloc(sizeof(struct lttng_kernel_event));
if (lke == NULL || attr == NULL) {
int ret;
struct ltt_kernel_stream *lks;
+ assert(name);
+
lks = zmalloc(sizeof(struct ltt_kernel_stream));
if (lks == NULL) {
PERROR("kernel stream zmalloc");
*/
void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream)
{
+ assert(stream);
+
DBG("[trace] Closing stream fd %d", stream->fd);
/* Close kernel fd */
if (stream->fd >= 0) {
*/
void trace_kernel_destroy_event(struct ltt_kernel_event *event)
{
+ assert(event);
+
if (event->fd >= 0) {
int ret;
struct ltt_kernel_event *event, *etmp;
int ret;
+ assert(channel);
+
DBG("[trace] Closing channel fd %d", channel->fd);
/* Close kernel fd */
if (channel->fd >= 0) {
*/
void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata)
{
+ assert(metadata);
+
DBG("[trace] Closing metadata fd %d", metadata->fd);
/* Close kernel fd */
if (metadata->fd >= 0) {
struct ltt_kernel_channel *channel, *ctmp;
int ret;
+ assert(session);
+
DBG("[trace] Closing session fd %d", session->fd);
/* Close kernel fds */
if (session->fd >= 0) {
int ret;
struct ltt_ust_channel *luc;
+ assert(chan);
+ assert(path);
+
luc = zmalloc(sizeof(struct ltt_ust_channel));
if (luc == NULL) {
PERROR("ltt_ust_channel zmalloc");
{
struct ltt_ust_event *lue;
+ assert(ev);
+
lue = zmalloc(sizeof(struct ltt_ust_event));
if (lue == NULL) {
PERROR("ust event zmalloc");
int ret;
struct ltt_ust_metadata *lum;
+ assert(path);
+
lum = zmalloc(sizeof(struct ltt_ust_metadata));
if (lum == NULL) {
PERROR("ust metadata zmalloc");
struct ltt_ust_context *uctx;
enum lttng_ust_context_type utype;
+ assert(ctx);
+
switch (ctx->ctx) {
case LTTNG_EVENT_CONTEXT_VTID:
utype = LTTNG_UST_CONTEXT_VTID;
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
+ assert(ht);
+
cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
ret = lttng_ht_del(ht, &iter);
if (!ret) {
*/
void trace_ust_destroy_event(struct ltt_ust_event *event)
{
+ assert(event);
+
DBG2("Trace destroy UST event %s", event->attr.name);
free(event->filter);
free(event);
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
+ assert(events);
+
cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
ret = lttng_ht_del(events, &iter);
assert(!ret);
*/
void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
{
+ assert(channel);
+
DBG2("Trace destroy UST channel %s", channel->name);
rcu_read_lock();
*/
void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
{
+ assert(metadata);
+
if (!metadata->handle) {
return;
}
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
+ assert(channels);
+
rcu_read_lock();
cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
struct lttng_ht_iter iter;
struct ltt_ust_domain_pid *dpid;
+ assert(ht);
+
cds_lfht_for_each_entry(ht->ht, &iter.iter, dpid, node.node) {
ret = lttng_ht_del(ht , &iter);
assert(!ret);
struct lttng_ht_iter iter;
struct ltt_ust_domain_exec *dexec;
+ assert(ht);
+
cds_lfht_for_each_entry(ht->ht, &iter.iter, dexec, node.node) {
ret = lttng_ht_del(ht , &iter);
assert(!ret);
*/
static void destroy_domain_global(struct ltt_ust_domain_global *dom)
{
+ assert(dom);
+
destroy_channels(dom->channels);
}
*/
void trace_ust_destroy_session(struct ltt_ust_session *session)
{
- /* Extra protection */
- if (session == NULL) {
- return;
- }
+ assert(session);
rcu_read_lock();
return 0;
}
-static int fuzzing_destroy_args(void)
-{
- int ret;
-
- ret = destroy_one_session(NULL);
- if (ret > 0) {
- printf("Session destroyed with (null)\n");
- return -1;
- }
-
- /* Session list must be 0 */
- assert(!session_list_count());
-
- return 0;
-}
-
/*
* This test is supposed to fail at the second create call. If so, return 0 for
* test success, else -1.
}
PRINT_OK();
- printf("Fuzzing destroy_session argument: ");
- fflush(stdout);
- ret = fuzzing_destroy_args();
- if (ret < 0) {
- return -1;
- }
- PRINT_OK();
-
printf("Creating %d sessions: ", MAX_SESSIONS);
fflush(stdout);
for (i = 0; i < MAX_SESSIONS; i++) {