#include "trace-ust.h"
#include "utils.h"
#include "ust-app.h"
+#include "agent.h"
/*
* Match function for the events hash table lookup.
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;
goto error;
}
+ lue->internal = internal_event;
+
switch (ev->type) {
case LTTNG_EVENT_PROBE:
lue->attr.instrumentation = LTTNG_UST_PROBE;
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));
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);
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.
*/