4 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * Holds LTTng probes registry.
8 * Dual LGPL v2.1/GPL v2 license.
13 #include <urcu/list.h>
14 #include <lttng/core.h>
15 #include <lttng/ust-events.h>
17 #include "ltt-tracer-core.h"
20 * probe list is protected by ust_lock()/ust_unlock().
22 static CDS_LIST_HEAD(probe_list
);
25 const struct lttng_event_desc
*find_event(const char *name
)
27 struct lttng_probe_desc
*probe_desc
;
30 cds_list_for_each_entry(probe_desc
, &probe_list
, head
) {
31 for (i
= 0; i
< probe_desc
->nr_events
; i
++) {
32 if (!strcmp(probe_desc
->event_desc
[i
].name
, name
))
33 return &probe_desc
->event_desc
[i
];
39 int ltt_probe_register(struct lttng_probe_desc
*desc
)
46 * TODO: This is O(N^2). Turn into a hash table when probe registration
47 * overhead becomes an issue.
49 for (i
= 0; i
< desc
->nr_events
; i
++) {
50 if (find_event(desc
->event_desc
[i
].name
)) {
55 cds_list_add(&desc
->head
, &probe_list
);
58 * fix the events awaiting probe load.
60 for (i
= 0; i
< desc
->nr_events
; i
++) {
61 ret
= pending_probe_fix_events(&desc
->event_desc
[i
]);
69 void ltt_probe_unregister(struct lttng_probe_desc
*desc
)
72 cds_list_del(&desc
->head
);
77 * called with UST lock held.
79 const struct lttng_event_desc
*ltt_event_get(const char *name
)
81 const struct lttng_event_desc
*event
;
83 event
= find_event(name
);
89 void ltt_event_put(const struct lttng_event_desc
*event
)
95 void *tp_list_start(struct seq_file
*m
, loff_t
*pos
)
97 struct lttng_probe_desc
*probe_desc
;
100 pthread_mutex_lock(&probe_mutex
);
101 cds_list_for_each_entry(probe_desc
, &probe_list
, head
) {
102 for (i
= 0; i
< probe_desc
->nr_events
; i
++) {
104 return (void *) &probe_desc
->event_desc
[i
];
112 void *tp_list_next(struct seq_file
*m
, void *p
, loff_t
*ppos
)
114 struct lttng_probe_desc
*probe_desc
;
118 cds_list_for_each_entry(probe_desc
, &probe_list
, head
) {
119 for (i
= 0; i
< probe_desc
->nr_events
; i
++) {
121 return (void *) &probe_desc
->event_desc
[i
];
129 void tp_list_stop(struct seq_file
*m
, void *p
)
131 pthread_mutex_unlock(&probe_mutex
);
135 int tp_list_show(struct seq_file
*m
, void *p
)
137 const struct lttng_event_desc
*probe_desc
= p
;
140 * Don't export lttng internal events (metadata).
142 if (!strncmp(probe_desc
->name
, "lttng_", sizeof("lttng_") - 1))
144 seq_printf(m
, "event { name = %s; };\n",
150 const struct seq_operations lttng_tracepoint_list_seq_ops
= {
151 .start
= tp_list_start
,
152 .next
= tp_list_next
,
153 .stop
= tp_list_stop
,
154 .show
= tp_list_show
,
158 int lttng_tracepoint_list_open(struct inode
*inode
, struct file
*file
)
160 return seq_open(file
, <tng_tracepoint_list_seq_ops
);
163 const struct file_operations lttng_tracepoint_list_fops
= {
164 .open
= lttng_tracepoint_list_open
,
167 .release
= seq_release
,