X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.c;h=b70d63673fd8ed9d275d39066a39be3dc2c04380;hp=e74ed62ba894862394576d9991ba93e41ede9489;hb=627cbbe733b1d69d381c536243fac777ba04780f;hpb=a9ad0c8fb50ac8cf9e9812dd9c9b4f949bac19a8 diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index e74ed62ba..b70d63673 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -30,6 +30,7 @@ #include "trace-ust.h" #include "utils.h" #include "ust-app.h" +#include "agent.h" /* * Match function for the events hash table lookup. @@ -283,14 +284,6 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id) goto error_consumer; } - /* - * The tmp_consumer stays NULL until a set_consumer_uri command is - * executed. At this point, the consumer should be nullify until an - * enable_consumer command. This assignment is symbolic since we've zmalloc - * the struct. - */ - lus->tmp_consumer = NULL; - DBG2("UST trace session create successful"); return lus; @@ -308,7 +301,8 @@ error: * * Return pointer to structure or NULL. */ -struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan) +struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, + enum lttng_domain_type domain) { struct ltt_ust_channel *luc; @@ -320,6 +314,8 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan) goto error; } + luc->domain = domain; + /* Copy UST channel attributes */ luc->attr.overwrite = chan->attr.overwrite; luc->attr.subbuf_size = chan->attr.subbuf_size; @@ -374,7 +370,8 @@ error: struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, char *filter_expression, struct lttng_filter_bytecode *filter, - struct lttng_event_exclusion *exclusion) + struct lttng_event_exclusion *exclusion, + bool internal_event) { struct ltt_ust_event *lue; @@ -386,6 +383,8 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, goto error; } + lue->internal = internal_event; + switch (ev->type) { case LTTNG_EVENT_PROBE: lue->attr.instrumentation = LTTNG_UST_PROBE; @@ -428,8 +427,8 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, /* Same layout. */ lue->filter_expression = filter_expression; - lue->filter = (struct lttng_ust_filter_bytecode *) filter; - lue->exclusion = (struct lttng_event_exclusion *) exclusion; + lue->filter = filter; + lue->exclusion = exclusion; /* Init node */ lttng_ht_node_init_str(&lue->node, lue->attr.name); @@ -655,7 +654,7 @@ int pid_tracker_add_pid(struct ust_pid_tracker *pid_tracker, int pid) tracker_node = pid_tracker_lookup(pid_tracker, pid, &iter); if (tracker_node) { /* Already exists. */ - retval = LTTNG_ERR_INVALID; + retval = LTTNG_ERR_PID_TRACKED; goto end; } tracker_node = zmalloc(sizeof(*tracker_node)); @@ -683,7 +682,7 @@ int pid_tracker_del_pid(struct ust_pid_tracker *pid_tracker, int pid) tracker_node = pid_tracker_lookup(pid_tracker, pid, &iter); if (!tracker_node) { /* Not found */ - retval = LTTNG_ERR_INVALID; + retval = LTTNG_ERR_PID_NOT_TRACKED; goto end; } ret = lttng_ht_del(pid_tracker->ht, &iter); @@ -808,6 +807,50 @@ end: return retval; } +/* + * Called with session lock held. + */ +ssize_t trace_ust_list_tracker_pids(struct ltt_ust_session *session, + int32_t **_pids) +{ + struct ust_pid_tracker_node *tracker_node; + struct lttng_ht_iter iter; + unsigned long count, i = 0; + long approx[2]; + int32_t *pids; + int ret = 0; + + if (!session->pid_tracker.ht) { + /* Tracker disabled. Set first entry to -1. */ + pids = zmalloc(sizeof(*pids)); + if (!pids) { + ret = -1; + goto end; + } + pids[0] = -1; + *_pids = pids; + return 1; + } + + rcu_read_lock(); + cds_lfht_count_nodes(session->pid_tracker.ht->ht, + &approx[0], &count, &approx[1]); + pids = zmalloc(sizeof(*pids) * count); + if (!pids) { + ret = -1; + goto end; + } + cds_lfht_for_each_entry(session->pid_tracker.ht->ht, + &iter.iter, tracker_node, node.node) { + pids[i++] = tracker_node->node.key; + } + *_pids = pids; + ret = count; +end: + rcu_read_unlock(); + return ret; +} + /* * RCU safe free context structure. */ @@ -909,11 +952,6 @@ static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel) DBG2("Trace destroy UST channel %s", channel->name); - /* Destroying all events of the channel */ - destroy_events(channel->events); - /* Destroying all context of the channel */ - destroy_contexts(channel->ctx); - free(channel); } @@ -932,6 +970,11 @@ static void destroy_channel_rcu(struct rcu_head *head) void trace_ust_destroy_channel(struct ltt_ust_channel *channel) { + /* Destroying all events of the channel */ + destroy_events(channel->events); + /* Destroying all context of the channel */ + destroy_contexts(channel->ctx); + call_rcu(&channel->node.head, destroy_channel_rcu); } @@ -957,18 +1000,18 @@ void trace_ust_delete_channel(struct lttng_ht *ht, */ static void destroy_channels(struct lttng_ht *channels) { - int ret; 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) { - ret = lttng_ht_del(channels, &iter); - assert(!ret); - call_rcu(&node->head, destroy_channel_rcu); + struct ltt_ust_channel *chan = + caa_container_of(node, struct ltt_ust_channel, node); + + trace_ust_delete_channel(channels, chan); + trace_ust_destroy_channel(chan); } rcu_read_unlock(); @@ -1022,8 +1065,7 @@ void trace_ust_destroy_session(struct ltt_ust_session *session) buffer_reg_uid_destroy(reg, session->consumer); } - consumer_destroy_output(session->consumer); - consumer_destroy_output(session->tmp_consumer); + consumer_output_put(session->consumer); fini_pid_tracker(&session->pid_tracker);