ust-abi: add missing lttng_ust_abi prefixes
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.h
1 /*
2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef _LTT_TRACE_KERNEL_H
9 #define _LTT_TRACE_KERNEL_H
10
11 #include <urcu/list.h>
12
13 #include <lttng/lttng.h>
14 #include <common/lttng-kernel.h>
15 #include <common/lttng-kernel-old.h>
16 #include <common/defaults.h>
17
18 #include "consumer.h"
19 #include "tracker.h"
20
21 /* Kernel event list */
22 struct ltt_kernel_event_list {
23 struct cds_list_head head;
24 };
25
26 /* Channel stream list */
27 struct ltt_kernel_stream_list {
28 struct cds_list_head head;
29 };
30
31 /* Channel list */
32 struct ltt_kernel_channel_list {
33 struct cds_list_head head;
34 };
35
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. */
40 bool in_list;
41 };
42
43 /* Kernel event */
44 struct ltt_kernel_event {
45 int fd;
46 int enabled;
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_bytecode *filter;
52 struct lttng_userspace_probe_location *userspace_probe_location;
53 };
54
55 /* Kernel event */
56 struct ltt_kernel_event_notifier_rule {
57 int fd;
58 int enabled;
59 enum lttng_event_type type;
60 struct lttng_trigger *trigger;
61 uint64_t token;
62 const struct lttng_bytecode *filter;
63 struct lttng_userspace_probe_location *userspace_probe_location;
64 struct cds_lfht_node ht_node;
65 /* call_rcu delayed reclaim. */
66 struct rcu_head rcu_node;
67 };
68
69 /* Kernel channel */
70 struct ltt_kernel_channel {
71 int fd;
72 uint64_t key; /* Key to reference this channel with the consumer. */
73 int enabled;
74 unsigned int stream_count;
75 unsigned int event_count;
76 bool published_to_notification_thread;
77 struct cds_list_head ctx_list;
78 struct lttng_channel *channel;
79 struct ltt_kernel_event_list events_list;
80 struct ltt_kernel_stream_list stream_list;
81 struct cds_list_head list;
82 /* Session pointer which has a reference to this object. */
83 struct ltt_kernel_session *session;
84 bool sent_to_consumer;
85 };
86
87 /* Metadata */
88 struct ltt_kernel_metadata {
89 int fd;
90 uint64_t key; /* Key to reference this channel with the consumer. */
91 struct lttng_channel *conf;
92 };
93
94 /* Channel stream */
95 struct ltt_kernel_stream {
96 int fd;
97 int state;
98 int cpu;
99 bool sent_to_consumer;
100 /* Format is %s_%d respectively channel name and CPU number. */
101 char name[DEFAULT_STREAM_NAME_LEN];
102 uint64_t tracefile_size;
103 uint64_t tracefile_count;
104 struct cds_list_head list;
105 };
106
107 /* Kernel session */
108 struct ltt_kernel_session {
109 int fd;
110 int metadata_stream_fd;
111 int consumer_fds_sent;
112 unsigned int channel_count;
113 unsigned int stream_count_global;
114 struct ltt_kernel_metadata *metadata;
115 struct ltt_kernel_channel_list channel_list;
116 /* UID/GID of the user owning the session */
117 uid_t uid;
118 gid_t gid;
119 struct consumer_output *consumer;
120 /* Tracing session id */
121 uint64_t id;
122 /* Session is active or not meaning it has been started or stopped. */
123 unsigned int active:1;
124 /* Tell or not if the session has to output the traces. */
125 unsigned int output_traces;
126 unsigned int snapshot_mode;
127 unsigned int has_non_default_channel;
128 bool is_live_session;
129 /* Current trace chunk of the ltt_session. */
130 struct lttng_trace_chunk *current_trace_chunk;
131 /* Tracker lists */
132 struct process_attr_tracker *tracker_pid;
133 struct process_attr_tracker *tracker_vpid;
134 struct process_attr_tracker *tracker_uid;
135 struct process_attr_tracker *tracker_vuid;
136 struct process_attr_tracker *tracker_gid;
137 struct process_attr_tracker *tracker_vgid;
138 };
139
140 /*
141 * Lookup functions. NULL is returned if not found.
142 */
143 struct ltt_kernel_event *trace_kernel_get_event_by_name(
144 char *name, struct ltt_kernel_channel *channel,
145 enum lttng_event_type type);
146 struct ltt_kernel_event *trace_kernel_find_event(
147 char *name, struct ltt_kernel_channel *channel,
148 enum lttng_event_type type,
149 struct lttng_bytecode *filter);
150 struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
151 const char *name, struct ltt_kernel_session *session);
152
153 /*
154 * Create functions malloc() the data structure.
155 */
156 struct ltt_kernel_session *trace_kernel_create_session(void);
157 struct ltt_kernel_channel *trace_kernel_create_channel(
158 struct lttng_channel *chan);
159 enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
160 char *filter_expression, struct lttng_bytecode *filter,
161 struct ltt_kernel_event **kernel_event);
162 struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
163 struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
164 unsigned int count);
165 struct ltt_kernel_context *trace_kernel_create_context(
166 struct lttng_kernel_context *ctx);
167 enum lttng_error_code trace_kernel_create_event_notifier_rule(
168 struct lttng_trigger *trigger,
169 uint64_t token,
170 struct ltt_kernel_event_notifier_rule **event_notifier_rule);
171 struct ltt_kernel_context *trace_kernel_copy_context(
172 struct ltt_kernel_context *ctx);
173 enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule(
174 const struct lttng_event_rule *rule,
175 struct lttng_kernel_event_notifier *kernel_event_notifier);
176
177 /*
178 * Destroy functions free() the data structure and remove from linked list if
179 * it's applies.
180 */
181 void trace_kernel_destroy_session(struct ltt_kernel_session *session);
182 void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
183 void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
184 void trace_kernel_destroy_event(struct ltt_kernel_event *event);
185 void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
186 void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
187 void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule);
188 void trace_kernel_free_session(struct ltt_kernel_session *session);
189
190 #endif /* _LTT_TRACE_KERNEL_H */
This page took 0.032908 seconds and 4 git commands to generate.