2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef _LTT_TRACE_KERNEL_H
9 #define _LTT_TRACE_KERNEL_H
11 #include <urcu/list.h>
13 #include <lttng/lttng.h>
14 #include <common/lttng-kernel.h>
15 #include <common/lttng-kernel-old.h>
16 #include <common/defaults.h>
21 /* Kernel event list */
22 struct ltt_kernel_event_list
{
23 struct cds_list_head head
;
26 /* Channel stream list */
27 struct ltt_kernel_stream_list
{
28 struct cds_list_head head
;
32 struct ltt_kernel_channel_list
{
33 struct cds_list_head head
;
36 struct ltt_kernel_context
{
37 struct lttng_kernel_context ctx
;
38 struct cds_list_head list
;
39 /* Indicates whether or not the context is in a list. */
44 struct ltt_kernel_event
{
47 enum lttng_event_type type
;
48 struct lttng_kernel_event
*event
;
49 struct cds_list_head list
;
50 char *filter_expression
;
51 struct lttng_filter_bytecode
*filter
;
52 struct lttng_userspace_probe_location
*userspace_probe_location
;
56 struct ltt_kernel_channel
{
58 uint64_t key
; /* Key to reference this channel with the consumer. */
60 unsigned int stream_count
;
61 unsigned int event_count
;
62 bool published_to_notification_thread
;
63 struct cds_list_head ctx_list
;
64 struct lttng_channel
*channel
;
65 struct ltt_kernel_event_list events_list
;
66 struct ltt_kernel_stream_list stream_list
;
67 struct cds_list_head list
;
68 /* Session pointer which has a reference to this object. */
69 struct ltt_kernel_session
*session
;
70 bool sent_to_consumer
;
74 struct ltt_kernel_metadata
{
76 uint64_t key
; /* Key to reference this channel with the consumer. */
77 struct lttng_channel
*conf
;
81 struct ltt_kernel_stream
{
85 bool sent_to_consumer
;
86 /* Format is %s_%d respectively channel name and CPU number. */
87 char name
[DEFAULT_STREAM_NAME_LEN
];
88 uint64_t tracefile_size
;
89 uint64_t tracefile_count
;
90 struct cds_list_head list
;
94 struct ltt_kernel_session
{
96 int metadata_stream_fd
;
97 int consumer_fds_sent
;
98 unsigned int channel_count
;
99 unsigned int stream_count_global
;
100 struct ltt_kernel_metadata
*metadata
;
101 struct ltt_kernel_channel_list channel_list
;
102 /* UID/GID of the user owning the session */
105 struct consumer_output
*consumer
;
106 /* Tracing session id */
108 /* Session is active or not meaning it has been started or stopped. */
109 unsigned int active
:1;
110 /* Tell or not if the session has to output the traces. */
111 unsigned int output_traces
;
112 unsigned int snapshot_mode
;
113 unsigned int has_non_default_channel
;
114 bool is_live_session
;
115 /* Current trace chunk of the ltt_session. */
116 struct lttng_trace_chunk
*current_trace_chunk
;
118 struct process_attr_tracker
*tracker_pid
;
119 struct process_attr_tracker
*tracker_vpid
;
120 struct process_attr_tracker
*tracker_uid
;
121 struct process_attr_tracker
*tracker_vuid
;
122 struct process_attr_tracker
*tracker_gid
;
123 struct process_attr_tracker
*tracker_vgid
;
127 * Lookup functions. NULL is returned if not found.
129 struct ltt_kernel_event
*trace_kernel_get_event_by_name(
130 char *name
, struct ltt_kernel_channel
*channel
,
131 enum lttng_event_type type
);
132 struct ltt_kernel_event
*trace_kernel_find_event(
133 char *name
, struct ltt_kernel_channel
*channel
,
134 enum lttng_event_type type
,
135 struct lttng_filter_bytecode
*filter
);
136 struct ltt_kernel_channel
*trace_kernel_get_channel_by_name(
137 const char *name
, struct ltt_kernel_session
*session
);
140 * Create functions malloc() the data structure.
142 struct ltt_kernel_session
*trace_kernel_create_session(void);
143 struct ltt_kernel_channel
*trace_kernel_create_channel(
144 struct lttng_channel
*chan
);
145 enum lttng_error_code
trace_kernel_create_event(struct lttng_event
*ev
,
146 char *filter_expression
, struct lttng_filter_bytecode
*filter
,
147 struct ltt_kernel_event
**kernel_event
);
148 struct ltt_kernel_metadata
*trace_kernel_create_metadata(void);
149 struct ltt_kernel_stream
*trace_kernel_create_stream(const char *name
,
151 struct ltt_kernel_context
*trace_kernel_create_context(
152 struct lttng_kernel_context
*ctx
);
153 struct ltt_kernel_context
*trace_kernel_copy_context(
154 struct ltt_kernel_context
*ctx
);
157 * Destroy functions free() the data structure and remove from linked list if
160 void trace_kernel_destroy_session(struct ltt_kernel_session
*session
);
161 void trace_kernel_destroy_metadata(struct ltt_kernel_metadata
*metadata
);
162 void trace_kernel_destroy_channel(struct ltt_kernel_channel
*channel
);
163 void trace_kernel_destroy_event(struct ltt_kernel_event
*event
);
164 void trace_kernel_destroy_stream(struct ltt_kernel_stream
*stream
);
165 void trace_kernel_destroy_context(struct ltt_kernel_context
*ctx
);
166 void trace_kernel_free_session(struct ltt_kernel_session
*session
);
168 #endif /* _LTT_TRACE_KERNEL_H */