4 * Copyright 2010-2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Mimic system calls for:
9 * - session creation, returns an object descriptor or failure.
10 * - channel creation, returns an object descriptor or failure.
11 * - Operates on a session object descriptor
12 * - Takes all channel options as parameters.
13 * - stream get, returns an object descriptor or failure.
14 * - Operates on a channel object descriptor.
15 * - stream notifier get, returns an object descriptor or failure.
16 * - Operates on a channel object descriptor.
17 * - event creation, returns an object descriptor or failure.
18 * - Operates on a channel object descriptor
19 * - Takes an event name as parameter
20 * - Takes an instrumentation source as parameter
21 * - e.g. tracepoints, dynamic_probes...
22 * - Takes instrumentation source specific arguments.
24 * Dual LGPL v2.1/GPL v2 license.
27 #include <lttng/ust-abi.h>
28 #include <urcu/compiler.h>
29 #include <urcu/list.h>
30 #include <lttng/ust-events.h>
31 #include <lttng/ust-version.h>
32 #include <usterr-signal-safe.h>
34 #include "ltt-tracer.h"
35 #include "tracepoint-internal.h"
37 static int lttng_ust_abi_close_in_progress
;
40 int lttng_abi_tracepoint_list(void);
43 * Object descriptor table. Should be protected from concurrent access
47 struct lttng_ust_obj
{
51 const struct lttng_ust_objd_ops
*ops
;
54 int freelist_next
; /* offset freelist. end is -1. */
58 struct lttng_ust_objd_table
{
59 struct lttng_ust_obj
*array
;
60 unsigned int len
, allocated_len
;
61 int freelist_head
; /* offset freelist head. end is -1 */
64 static struct lttng_ust_objd_table objd_table
= {
69 int objd_alloc(void *private_data
, const struct lttng_ust_objd_ops
*ops
)
71 struct lttng_ust_obj
*obj
;
73 if (objd_table
.freelist_head
!= -1) {
74 obj
= &objd_table
.array
[objd_table
.freelist_head
];
75 objd_table
.freelist_head
= obj
->u
.freelist_next
;
79 if (objd_table
.len
>= objd_table
.allocated_len
) {
80 unsigned int new_allocated_len
, old_allocated_len
;
81 struct lttng_ust_obj
*new_table
, *old_table
;
83 old_allocated_len
= objd_table
.allocated_len
;
84 old_table
= objd_table
.array
;
85 if (!old_allocated_len
)
86 new_allocated_len
= 1;
88 new_allocated_len
= old_allocated_len
<< 1;
89 new_table
= zmalloc(sizeof(struct lttng_ust_obj
) * new_allocated_len
);
92 memcpy(new_table
, old_table
,
93 sizeof(struct lttng_ust_obj
) * old_allocated_len
);
95 objd_table
.array
= new_table
;
96 objd_table
.allocated_len
= new_allocated_len
;
98 obj
= &objd_table
.array
[objd_table
.len
];
101 obj
->u
.s
.private_data
= private_data
;
103 obj
->u
.s
.f_count
= 2; /* count == 1 : object is allocated */
104 /* count == 2 : allocated + hold ref */
105 return obj
- objd_table
.array
;
109 struct lttng_ust_obj
*_objd_get(int id
)
111 if (id
>= objd_table
.len
)
113 if (!objd_table
.array
[id
].u
.s
.f_count
)
115 return &objd_table
.array
[id
];
119 void *objd_private(int id
)
121 struct lttng_ust_obj
*obj
= _objd_get(id
);
123 return obj
->u
.s
.private_data
;
127 void objd_set_private(int id
, void *private_data
)
129 struct lttng_ust_obj
*obj
= _objd_get(id
);
131 obj
->u
.s
.private_data
= private_data
;
134 const struct lttng_ust_objd_ops
*objd_ops(int id
)
136 struct lttng_ust_obj
*obj
= _objd_get(id
);
144 void objd_free(int id
)
146 struct lttng_ust_obj
*obj
= _objd_get(id
);
149 obj
->u
.freelist_next
= objd_table
.freelist_head
;
150 objd_table
.freelist_head
= obj
- objd_table
.array
;
151 assert(obj
->u
.s
.f_count
== 1);
152 obj
->u
.s
.f_count
= 0; /* deallocated */
156 void objd_ref(int id
)
158 struct lttng_ust_obj
*obj
= _objd_get(id
);
162 int lttng_ust_objd_unref(int id
)
164 struct lttng_ust_obj
*obj
= _objd_get(id
);
168 if (obj
->u
.s
.f_count
== 1) {
169 ERR("Reference counting error\n");
172 if ((--obj
->u
.s
.f_count
) == 1) {
173 const struct lttng_ust_objd_ops
*ops
= objd_ops(id
);
183 void objd_table_destroy(void)
187 for (i
= 0; i
< objd_table
.allocated_len
; i
++)
188 (void) lttng_ust_objd_unref(i
);
189 free(objd_table
.array
);
190 objd_table
.array
= NULL
;
192 objd_table
.allocated_len
= 0;
193 objd_table
.freelist_head
= -1;
197 * This is LTTng's own personal way to create an ABI for sessiond.
198 * We send commands over a socket.
201 static const struct lttng_ust_objd_ops lttng_ops
;
202 static const struct lttng_ust_objd_ops lttng_session_ops
;
203 static const struct lttng_ust_objd_ops lttng_channel_ops
;
204 static const struct lttng_ust_objd_ops lttng_metadata_ops
;
205 static const struct lttng_ust_objd_ops lttng_event_ops
;
206 static const struct lttng_ust_objd_ops lttng_loglevel_ops
;
207 static const struct lttng_ust_objd_ops lttng_wildcard_ops
;
208 static const struct lttng_ust_objd_ops lib_ring_buffer_objd_ops
;
209 static const struct lttng_ust_objd_ops lttng_tracepoint_list_ops
;
216 int lttng_abi_create_root_handle(void)
220 root_handle
= objd_alloc(NULL
, <tng_ops
);
225 int lttng_abi_create_session(void)
227 struct ltt_session
*session
;
228 int session_objd
, ret
;
230 session
= ltt_session_create();
233 session_objd
= objd_alloc(session
, <tng_session_ops
);
234 if (session_objd
< 0) {
238 session
->objd
= session_objd
;
242 ltt_session_destroy(session
);
247 long lttng_abi_tracer_version(int objd
,
248 struct lttng_ust_tracer_version
*v
)
250 v
->major
= LTTNG_UST_MAJOR_VERSION
;
251 v
->minor
= LTTNG_UST_MINOR_VERSION
;
252 v
->patchlevel
= LTTNG_UST_PATCHLEVEL_VERSION
;
257 long lttng_abi_add_context(int objd
,
258 struct lttng_ust_context
*context_param
,
259 struct lttng_ctx
**ctx
, struct ltt_session
*session
)
261 if (session
->been_active
)
264 switch (context_param
->ctx
) {
265 case LTTNG_UST_CONTEXT_PTHREAD_ID
:
266 return lttng_add_pthread_id_to_ctx(ctx
);
267 case LTTNG_UST_CONTEXT_VTID
:
268 return lttng_add_vtid_to_ctx(ctx
);
269 case LTTNG_UST_CONTEXT_VPID
:
270 return lttng_add_vpid_to_ctx(ctx
);
271 case LTTNG_UST_CONTEXT_PROCNAME
:
272 return lttng_add_procname_to_ctx(ctx
);
279 * lttng_cmd - lttng control through socket commands
281 * @objd: the object descriptor
284 * @uargs: UST arguments (internal)
286 * This descriptor implements lttng commands:
288 * Returns a LTTng trace session object descriptor
289 * LTTNG_UST_TRACER_VERSION
290 * Returns the LTTng kernel tracer version
291 * LTTNG_UST_TRACEPOINT_LIST
292 * Returns a file descriptor listing available tracepoints
293 * LTTNG_UST_WAIT_QUIESCENT
294 * Returns after all previously running probes have completed
296 * The returned session will be deleted when its file descriptor is closed.
299 long lttng_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
300 union ust_args
*uargs
)
303 case LTTNG_UST_SESSION
:
304 return lttng_abi_create_session();
305 case LTTNG_UST_TRACER_VERSION
:
306 return lttng_abi_tracer_version(objd
,
307 (struct lttng_ust_tracer_version
*) arg
);
308 case LTTNG_UST_TRACEPOINT_LIST
:
309 return lttng_abi_tracepoint_list();
310 case LTTNG_UST_WAIT_QUIESCENT
:
318 static const struct lttng_ust_objd_ops lttng_ops
= {
323 * We tolerate no failure in this function (if one happens, we print a dmesg
324 * error, but cannot return any error, because the channel information is
328 void lttng_metadata_create_events(int channel_objd
)
330 struct ltt_channel
*channel
= objd_private(channel_objd
);
331 static struct lttng_ust_event metadata_params
= {
332 .instrumentation
= LTTNG_UST_TRACEPOINT
,
333 .name
= "lttng_ust:metadata",
335 struct ltt_event
*event
;
339 * We tolerate no failure path after event creation. It will stay
340 * invariant for the rest of the session.
342 ret
= ltt_event_create(channel
, &metadata_params
, NULL
, &event
);
350 return; /* not allowed to return error */
353 int lttng_abi_create_channel(int session_objd
,
354 struct lttng_ust_channel
*chan_param
,
355 enum channel_type channel_type
,
356 union ust_args
*uargs
)
358 struct ltt_session
*session
= objd_private(session_objd
);
359 const struct lttng_ust_objd_ops
*ops
;
360 const char *transport_name
;
361 struct ltt_channel
*chan
;
364 struct ltt_channel chan_priv_init
;
366 switch (channel_type
) {
367 case PER_CPU_CHANNEL
:
368 if (chan_param
->output
== LTTNG_UST_MMAP
) {
369 transport_name
= chan_param
->overwrite
?
370 "relay-overwrite-mmap" : "relay-discard-mmap";
374 ops
= <tng_channel_ops
;
376 case METADATA_CHANNEL
:
377 if (chan_param
->output
== LTTNG_UST_MMAP
)
378 transport_name
= "relay-metadata-mmap";
381 ops
= <tng_metadata_ops
;
384 transport_name
= "<unknown>";
387 chan_objd
= objd_alloc(NULL
, ops
);
392 memset(&chan_priv_init
, 0, sizeof(chan_priv_init
));
393 /* Copy of session UUID for consumer (availability through shm) */
394 memcpy(chan_priv_init
.uuid
, session
->uuid
, sizeof(session
->uuid
));
397 * We tolerate no failure path after channel creation. It will stay
398 * invariant for the rest of the session.
400 chan
= ltt_channel_create(session
, transport_name
, NULL
,
401 chan_param
->subbuf_size
,
402 chan_param
->num_subbuf
,
403 chan_param
->switch_timer_interval
,
404 chan_param
->read_timer_interval
,
405 &uargs
->channel
.shm_fd
,
406 &uargs
->channel
.wait_fd
,
407 &uargs
->channel
.memory_map_size
,
413 objd_set_private(chan_objd
, chan
);
414 chan
->objd
= chan_objd
;
415 if (channel_type
== METADATA_CHANNEL
) {
416 session
->metadata
= chan
;
417 lttng_metadata_create_events(chan_objd
);
419 /* The channel created holds a reference on the session */
420 objd_ref(session_objd
);
428 err
= lttng_ust_objd_unref(chan_objd
);
436 * lttng_session_cmd - lttng session object command
441 * @uargs: UST arguments (internal)
443 * This descriptor implements lttng commands:
445 * Returns a LTTng channel object descriptor
447 * Enables tracing for a session (weak enable)
449 * Disables tracing for a session (strong disable)
451 * Returns a LTTng metadata object descriptor
453 * The returned channel will be deleted when its file descriptor is closed.
456 long lttng_session_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
457 union ust_args
*uargs
)
459 struct ltt_session
*session
= objd_private(objd
);
462 case LTTNG_UST_CHANNEL
:
463 return lttng_abi_create_channel(objd
,
464 (struct lttng_ust_channel
*) arg
,
465 PER_CPU_CHANNEL
, uargs
);
466 case LTTNG_UST_SESSION_START
:
467 case LTTNG_UST_ENABLE
:
468 return ltt_session_enable(session
);
469 case LTTNG_UST_SESSION_STOP
:
470 case LTTNG_UST_DISABLE
:
471 return ltt_session_disable(session
);
472 case LTTNG_UST_METADATA
:
473 return lttng_abi_create_channel(objd
,
474 (struct lttng_ust_channel
*) arg
,
475 METADATA_CHANNEL
, uargs
);
482 * Called when the last file reference is dropped.
484 * Big fat note: channels and events are invariant for the whole session after
485 * their creation. So this session destruction also destroys all channel and
486 * event structures specific to this session (they are not destroyed when their
487 * individual file is released).
490 int lttng_release_session(int objd
)
492 struct ltt_session
*session
= objd_private(objd
);
495 ltt_session_destroy(session
);
502 static const struct lttng_ust_objd_ops lttng_session_ops
= {
503 .release
= lttng_release_session
,
504 .cmd
= lttng_session_cmd
,
508 long lttng_tracepoint_list_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
509 union ust_args
*uargs
)
511 struct lttng_ust_tracepoint_list
*list
= objd_private(objd
);
512 struct lttng_ust_tracepoint_iter
*tp
=
513 (struct lttng_ust_tracepoint_iter
*) arg
;
514 struct lttng_ust_tracepoint_iter
*iter
;
517 case LTTNG_UST_TRACEPOINT_LIST_GET
:
520 iter
= lttng_ust_tracepoint_list_get_iter_next(list
);
523 if (!strcmp(iter
->name
, "lttng_ust:metadata"))
525 memcpy(tp
, iter
, sizeof(*tp
));
534 int lttng_abi_tracepoint_list(void)
537 struct lttng_ust_tracepoint_list
*list
;
539 list_objd
= objd_alloc(NULL
, <tng_tracepoint_list_ops
);
544 list
= zmalloc(sizeof(*list
));
549 objd_set_private(list_objd
, list
);
551 /* populate list by walking on all registered probes. */
552 ret
= ltt_probes_get_event_list(list
);
564 err
= lttng_ust_objd_unref(list_objd
);
572 int lttng_release_tracepoint_list(int objd
)
574 struct lttng_ust_tracepoint_list
*list
= objd_private(objd
);
577 ltt_probes_prune_event_list(list
);
585 static const struct lttng_ust_objd_ops lttng_tracepoint_list_ops
= {
586 .release
= lttng_release_tracepoint_list
,
587 .cmd
= lttng_tracepoint_list_cmd
,
590 struct stream_priv_data
{
591 struct lttng_ust_lib_ring_buffer
*buf
;
592 struct ltt_channel
*ltt_chan
;
596 int lttng_abi_open_stream(int channel_objd
, struct lttng_ust_stream
*info
,
597 union ust_args
*uargs
)
599 struct ltt_channel
*channel
= objd_private(channel_objd
);
600 struct lttng_ust_lib_ring_buffer
*buf
;
601 struct stream_priv_data
*priv
;
602 int stream_objd
, ret
;
604 buf
= channel
->ops
->buffer_read_open(channel
->chan
, channel
->handle
,
605 &uargs
->stream
.shm_fd
,
606 &uargs
->stream
.wait_fd
,
607 &uargs
->stream
.memory_map_size
);
611 priv
= zmalloc(sizeof(*priv
));
617 priv
->ltt_chan
= channel
;
618 stream_objd
= objd_alloc(priv
, &lib_ring_buffer_objd_ops
);
619 if (stream_objd
< 0) {
623 /* Hold a reference on the channel object descriptor */
624 objd_ref(channel_objd
);
630 channel
->ops
->buffer_read_close(buf
, channel
->handle
);
635 int lttng_abi_create_event(int channel_objd
,
636 struct lttng_ust_event
*event_param
)
638 struct ltt_channel
*channel
= objd_private(channel_objd
);
639 struct ltt_event
*event
;
642 event_param
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
643 event_objd
= objd_alloc(NULL
, <tng_event_ops
);
644 if (event_objd
< 0) {
649 * We tolerate no failure path after event creation. It will stay
650 * invariant for the rest of the session.
652 ret
= ltt_event_create(channel
, event_param
, NULL
, &event
);
656 objd_set_private(event_objd
, event
);
657 /* The event holds a reference on the channel */
658 objd_ref(channel_objd
);
665 err
= lttng_ust_objd_unref(event_objd
);
673 int lttng_abi_create_loglevel(int channel_objd
,
674 struct lttng_ust_event
*event_param
)
676 struct ltt_channel
*channel
= objd_private(channel_objd
);
677 struct session_loglevel
*loglevel
;
678 int loglevel_objd
, ret
;
680 event_param
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
681 loglevel_objd
= objd_alloc(NULL
, <tng_loglevel_ops
);
682 if (loglevel_objd
< 0) {
687 * We tolerate no failure path after loglevel creation. It will
688 * stay invariant for the rest of the session.
690 ret
= ltt_loglevel_create(channel
, event_param
, &loglevel
);
694 objd_set_private(loglevel_objd
, loglevel
);
695 /* The loglevel holds a reference on the channel */
696 objd_ref(channel_objd
);
697 return loglevel_objd
;
703 err
= lttng_ust_objd_unref(loglevel_objd
);
711 int lttng_abi_create_wildcard(int channel_objd
,
712 struct lttng_ust_event
*event_param
)
714 struct ltt_channel
*channel
= objd_private(channel_objd
);
715 struct session_wildcard
*wildcard
;
716 int wildcard_objd
, ret
;
718 event_param
->name
[LTTNG_UST_SYM_NAME_LEN
- 1] = '\0';
719 wildcard_objd
= objd_alloc(NULL
, <tng_wildcard_ops
);
720 if (wildcard_objd
< 0) {
725 * We tolerate no failure path after wildcard creation. It will
726 * stay invariant for the rest of the session.
728 ret
= ltt_wildcard_create(channel
, event_param
, &wildcard
);
732 objd_set_private(wildcard_objd
, wildcard
);
733 /* The wildcard holds a reference on the channel */
734 objd_ref(channel_objd
);
735 return wildcard_objd
;
741 err
= lttng_ust_objd_unref(wildcard_objd
);
749 * lttng_channel_cmd - lttng control through object descriptors
751 * @objd: the object descriptor
754 * @uargs: UST arguments (internal)
756 * This object descriptor implements lttng commands:
758 * Returns an event stream object descriptor or failure.
759 * (typically, one event stream records events from one CPU)
761 * Returns an event object descriptor or failure.
763 * Prepend a context field to each event in the channel
765 * Enable recording for events in this channel (weak enable)
767 * Disable recording for events in this channel (strong disable)
769 * Channel and event file descriptors also hold a reference on the session.
772 long lttng_channel_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
773 union ust_args
*uargs
)
775 struct ltt_channel
*channel
= objd_private(objd
);
778 case LTTNG_UST_STREAM
:
780 struct lttng_ust_stream
*stream
;
782 stream
= (struct lttng_ust_stream
*) arg
;
783 /* stream used as output */
784 return lttng_abi_open_stream(objd
, stream
, uargs
);
786 case LTTNG_UST_EVENT
:
788 struct lttng_ust_event
*event_param
=
789 (struct lttng_ust_event
*) arg
;
790 if (event_param
->instrumentation
== LTTNG_UST_TRACEPOINT_LOGLEVEL
) {
791 return lttng_abi_create_loglevel(objd
, event_param
);
793 if (event_param
->name
[strlen(event_param
->name
) - 1] == '*') {
794 /* If ends with wildcard, create wildcard. */
795 return lttng_abi_create_wildcard(objd
, event_param
);
797 return lttng_abi_create_event(objd
, event_param
);
801 case LTTNG_UST_CONTEXT
:
802 return lttng_abi_add_context(objd
,
803 (struct lttng_ust_context
*) arg
,
804 &channel
->ctx
, channel
->session
);
805 case LTTNG_UST_ENABLE
:
806 return ltt_channel_enable(channel
);
807 case LTTNG_UST_DISABLE
:
808 return ltt_channel_disable(channel
);
809 case LTTNG_UST_FLUSH_BUFFER
:
810 return channel
->ops
->flush_buffer(channel
->chan
, channel
->handle
);
817 * lttng_metadata_cmd - lttng control through object descriptors
819 * @objd: the object descriptor
822 * @uargs: UST arguments (internal)
824 * This object descriptor implements lttng commands:
826 * Returns an event stream file descriptor or failure.
828 * Channel and event file descriptors also hold a reference on the session.
831 long lttng_metadata_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
832 union ust_args
*uargs
)
834 struct ltt_channel
*channel
= objd_private(objd
);
837 case LTTNG_UST_STREAM
:
839 struct lttng_ust_stream
*stream
;
841 stream
= (struct lttng_ust_stream
*) arg
;
842 /* stream used as output */
843 return lttng_abi_open_stream(objd
, stream
, uargs
);
845 case LTTNG_UST_FLUSH_BUFFER
:
846 return channel
->ops
->flush_buffer(channel
->chan
, channel
->handle
);
854 * lttng_channel_poll - lttng stream addition/removal monitoring
859 unsigned int lttng_channel_poll(struct file
*file
, poll_table
*wait
)
861 struct ltt_channel
*channel
= file
->private_data
;
862 unsigned int mask
= 0;
864 if (file
->f_mode
& FMODE_READ
) {
865 poll_wait_set_exclusive(wait
);
866 poll_wait(file
, channel
->ops
->get_hp_wait_queue(channel
->chan
),
869 if (channel
->ops
->is_disabled(channel
->chan
))
871 if (channel
->ops
->is_finalized(channel
->chan
))
873 if (channel
->ops
->buffer_has_read_closed_stream(channel
->chan
))
874 return POLLIN
| POLLRDNORM
;
883 int lttng_channel_release(int objd
)
885 struct ltt_channel
*channel
= objd_private(objd
);
888 return lttng_ust_objd_unref(channel
->session
->objd
);
892 static const struct lttng_ust_objd_ops lttng_channel_ops
= {
893 .release
= lttng_channel_release
,
894 //.poll = lttng_channel_poll,
895 .cmd
= lttng_channel_cmd
,
898 static const struct lttng_ust_objd_ops lttng_metadata_ops
= {
899 .release
= lttng_channel_release
,
900 .cmd
= lttng_metadata_cmd
,
904 * lttng_rb_cmd - lttng ring buffer control through object descriptors
906 * @objd: the object descriptor
909 * @uargs: UST arguments (internal)
911 * This object descriptor implements lttng commands:
912 * (None for now. Access is done directly though shm.)
915 long lttng_rb_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
916 union ust_args
*uargs
)
925 int lttng_rb_release(int objd
)
927 struct stream_priv_data
*priv
= objd_private(objd
);
928 struct lttng_ust_lib_ring_buffer
*buf
;
929 struct ltt_channel
*channel
;
933 channel
= priv
->ltt_chan
;
936 * If we are at ABI exit, we don't want to close the
937 * buffer opened for read: it is being shared between
938 * the parent and child (right after fork), and we don't
939 * want the child to close it for the parent. For a real
940 * exit, we don't care about marking it as closed, as
941 * the consumer daemon (if there is one) will do fine
942 * even if we don't mark it as "closed" for reading on
944 * We only mark it as closed if it is being explicitely
945 * released by the session daemon with an explicit
948 if (!lttng_ust_abi_close_in_progress
)
949 channel
->ops
->buffer_read_close(buf
, channel
->handle
);
951 return lttng_ust_objd_unref(channel
->objd
);
956 static const struct lttng_ust_objd_ops lib_ring_buffer_objd_ops
= {
957 .release
= lttng_rb_release
,
962 * lttng_event_cmd - lttng control through object descriptors
964 * @objd: the object descriptor
967 * @uargs: UST arguments (internal)
969 * This object descriptor implements lttng commands:
971 * Prepend a context field to each record of this event
973 * Enable recording for this event (weak enable)
975 * Disable recording for this event (strong disable)
978 long lttng_event_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
979 union ust_args
*uargs
)
981 struct ltt_event
*event
= objd_private(objd
);
984 case LTTNG_UST_CONTEXT
:
985 return lttng_abi_add_context(objd
,
986 (struct lttng_ust_context
*) arg
,
987 &event
->ctx
, event
->chan
->session
);
988 case LTTNG_UST_ENABLE
:
989 return ltt_event_enable(event
);
990 case LTTNG_UST_DISABLE
:
991 return ltt_event_disable(event
);
998 int lttng_event_release(int objd
)
1000 struct ltt_event
*event
= objd_private(objd
);
1003 return lttng_ust_objd_unref(event
->chan
->objd
);
1007 /* TODO: filter control ioctl */
1008 static const struct lttng_ust_objd_ops lttng_event_ops
= {
1009 .release
= lttng_event_release
,
1010 .cmd
= lttng_event_cmd
,
1014 * lttng_loglevel_cmd - lttng control through object descriptors
1016 * @objd: the object descriptor
1019 * @uargs: UST arguments (internal)
1021 * This object descriptor implements lttng commands:
1023 * Prepend a context field to each record of events of this
1026 * Enable recording for these loglevel events (weak enable)
1028 * Disable recording for these loglevel events (strong disable)
1031 long lttng_loglevel_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
1032 union ust_args
*uargs
)
1034 struct session_loglevel
*loglevel
= objd_private(objd
);
1037 case LTTNG_UST_CONTEXT
:
1038 return -ENOSYS
; /* not implemented yet */
1040 return lttng_abi_add_context(objd
,
1041 (struct lttng_ust_context
*) arg
,
1042 &loglevel
->ctx
, loglevel
->chan
->session
);
1044 case LTTNG_UST_ENABLE
:
1045 return ltt_loglevel_enable(loglevel
);
1046 case LTTNG_UST_DISABLE
:
1047 return ltt_loglevel_disable(loglevel
);
1054 int lttng_loglevel_release(int objd
)
1056 struct session_loglevel
*loglevel
= objd_private(objd
);
1059 return lttng_ust_objd_unref(loglevel
->chan
->objd
);
1063 /* TODO: filter control ioctl */
1064 static const struct lttng_ust_objd_ops lttng_loglevel_ops
= {
1065 .release
= lttng_loglevel_release
,
1066 .cmd
= lttng_loglevel_cmd
,
1070 * lttng_wildcard_cmd - lttng control through object descriptors
1072 * @objd: the object descriptor
1075 * @uargs: UST arguments (internal)
1077 * This object descriptor implements lttng commands:
1079 * Prepend a context field to each record of events of this
1082 * Enable recording for these wildcard events (weak enable)
1084 * Disable recording for these wildcard events (strong disable)
1087 long lttng_wildcard_cmd(int objd
, unsigned int cmd
, unsigned long arg
,
1088 union ust_args
*uargs
)
1090 struct session_wildcard
*wildcard
= objd_private(objd
);
1093 case LTTNG_UST_CONTEXT
:
1094 return -ENOSYS
; /* not implemented yet */
1096 return lttng_abi_add_context(objd
,
1097 (struct lttng_ust_context
*) arg
,
1098 &wildcard
->ctx
, wildcard
->chan
->session
);
1100 case LTTNG_UST_ENABLE
:
1101 return ltt_wildcard_enable(wildcard
);
1102 case LTTNG_UST_DISABLE
:
1103 return ltt_wildcard_disable(wildcard
);
1110 int lttng_wildcard_release(int objd
)
1112 struct session_wildcard
*wildcard
= objd_private(objd
);
1115 return lttng_ust_objd_unref(wildcard
->chan
->objd
);
1119 /* TODO: filter control ioctl */
1120 static const struct lttng_ust_objd_ops lttng_wildcard_ops
= {
1121 .release
= lttng_wildcard_release
,
1122 .cmd
= lttng_wildcard_cmd
,
1125 void lttng_ust_abi_exit(void)
1127 lttng_ust_abi_close_in_progress
= 1;
1128 objd_table_destroy();
1129 lttng_ust_abi_close_in_progress
= 0;