Commit | Line | Data |
---|---|---|
fda89c9b | 1 | /* |
21cf9b6b | 2 | * Copyright (C) 2011 EfficiOS Inc. |
fda89c9b | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: GPL-2.0-only |
fda89c9b | 5 | * |
fda89c9b DG |
6 | */ |
7 | ||
62499ad6 DG |
8 | #ifndef _LTT_TRACE_KERNEL_H |
9 | #define _LTT_TRACE_KERNEL_H | |
fda89c9b | 10 | |
28f23191 JG |
11 | #include "consumer.hpp" |
12 | #include "tracker.hpp" | |
d4a2a84a | 13 | |
c9e313bc | 14 | #include <common/defaults.hpp> |
28f23191 JG |
15 | #include <common/lttng-kernel-old.hpp> |
16 | #include <common/lttng-kernel.hpp> | |
54012638 | 17 | |
28f23191 JG |
18 | #include <lttng/lttng.h> |
19 | ||
20 | #include <urcu/list.h> | |
00e2e675 | 21 | |
20fe2104 DG |
22 | /* Kernel event list */ |
23 | struct ltt_kernel_event_list { | |
24 | struct cds_list_head head; | |
25 | }; | |
26 | ||
8c0faa1d DG |
27 | /* Channel stream list */ |
28 | struct ltt_kernel_stream_list { | |
29 | struct cds_list_head head; | |
30 | }; | |
31 | ||
32 | /* Channel list */ | |
33 | struct ltt_kernel_channel_list { | |
34 | struct cds_list_head head; | |
35 | }; | |
36 | ||
645328ae | 37 | struct ltt_kernel_context { |
b8e2fb80 | 38 | struct lttng_kernel_abi_context ctx; |
645328ae | 39 | struct cds_list_head list; |
ba985c3a JG |
40 | /* Indicates whether or not the context is in a list. */ |
41 | bool in_list; | |
645328ae DG |
42 | }; |
43 | ||
20fe2104 DG |
44 | /* Kernel event */ |
45 | struct ltt_kernel_event { | |
20fe2104 | 46 | int fd; |
66cefebd | 47 | bool enabled; |
d0ae4ea8 | 48 | enum lttng_event_type type; |
b8e2fb80 | 49 | struct lttng_kernel_abi_event *event; |
20fe2104 | 50 | struct cds_list_head list; |
00a62084 | 51 | char *filter_expression; |
2b00d462 | 52 | struct lttng_bytecode *filter; |
3c02e545 | 53 | struct lttng_userspace_probe_location *userspace_probe_location; |
20fe2104 DG |
54 | }; |
55 | ||
352b58f5 JR |
56 | /* Kernel event */ |
57 | struct ltt_kernel_event_notifier_rule { | |
58 | int fd; | |
90aa04a1 | 59 | uint64_t error_counter_index; |
66cefebd | 60 | bool enabled; |
352b58f5 JR |
61 | enum lttng_event_type type; |
62 | struct lttng_trigger *trigger; | |
63 | uint64_t token; | |
2b00d462 | 64 | const struct lttng_bytecode *filter; |
352b58f5 JR |
65 | struct lttng_userspace_probe_location *userspace_probe_location; |
66 | struct cds_lfht_node ht_node; | |
67 | /* call_rcu delayed reclaim. */ | |
68 | struct rcu_head rcu_node; | |
69 | }; | |
70 | ||
20fe2104 DG |
71 | /* Kernel channel */ |
72 | struct ltt_kernel_channel { | |
73 | int fd; | |
e1f3997a | 74 | uint64_t key; /* Key to reference this channel with the consumer. */ |
66cefebd | 75 | bool enabled; |
8c0faa1d | 76 | unsigned int stream_count; |
cbbbb275 | 77 | unsigned int event_count; |
753873bf | 78 | bool published_to_notification_thread; |
645328ae | 79 | struct cds_list_head ctx_list; |
f3ed775e | 80 | struct lttng_channel *channel; |
20fe2104 | 81 | struct ltt_kernel_event_list events_list; |
8c0faa1d DG |
82 | struct ltt_kernel_stream_list stream_list; |
83 | struct cds_list_head list; | |
fb5f35b6 DG |
84 | /* Session pointer which has a reference to this object. */ |
85 | struct ltt_kernel_session *session; | |
e99f9447 | 86 | bool sent_to_consumer; |
20fe2104 DG |
87 | }; |
88 | ||
aaf26714 DG |
89 | /* Metadata */ |
90 | struct ltt_kernel_metadata { | |
91 | int fd; | |
d40f0359 | 92 | uint64_t key; /* Key to reference this channel with the consumer. */ |
f3ed775e | 93 | struct lttng_channel *conf; |
aaf26714 DG |
94 | }; |
95 | ||
8c0faa1d DG |
96 | /* Channel stream */ |
97 | struct ltt_kernel_stream { | |
98 | int fd; | |
8c0faa1d | 99 | int state; |
ffe60014 | 100 | int cpu; |
6986ab9b | 101 | bool sent_to_consumer; |
00e2e675 | 102 | /* Format is %s_%d respectively channel name and CPU number. */ |
ce2a9e76 | 103 | char name[DEFAULT_STREAM_NAME_LEN]; |
1624d5b7 JD |
104 | uint64_t tracefile_size; |
105 | uint64_t tracefile_count; | |
8c0faa1d DG |
106 | struct cds_list_head list; |
107 | }; | |
108 | ||
20fe2104 DG |
109 | /* Kernel session */ |
110 | struct ltt_kernel_session { | |
111 | int fd; | |
8c0faa1d | 112 | int metadata_stream_fd; |
3bd1e081 | 113 | int consumer_fds_sent; |
8c0faa1d DG |
114 | unsigned int channel_count; |
115 | unsigned int stream_count_global; | |
aaf26714 | 116 | struct ltt_kernel_metadata *metadata; |
8c0faa1d | 117 | struct ltt_kernel_channel_list channel_list; |
6df2e2c9 MD |
118 | /* UID/GID of the user owning the session */ |
119 | uid_t uid; | |
120 | gid_t gid; | |
00e2e675 | 121 | struct consumer_output *consumer; |
53632229 | 122 | /* Tracing session id */ |
d022620a | 123 | uint64_t id; |
14fb1ebe | 124 | /* Session is active or not meaning it has been started or stopped. */ |
66cefebd | 125 | bool active; |
2bba9e53 DG |
126 | /* Tell or not if the session has to output the traces. */ |
127 | unsigned int output_traces; | |
27babd3a | 128 | unsigned int snapshot_mode; |
85076754 | 129 | unsigned int has_non_default_channel; |
a2814ea7 | 130 | bool is_live_session; |
82b69413 JG |
131 | /* Current trace chunk of the ltt_session. */ |
132 | struct lttng_trace_chunk *current_trace_chunk; | |
55c9e7ca | 133 | /* Tracker lists */ |
159b042f JG |
134 | struct process_attr_tracker *tracker_pid; |
135 | struct process_attr_tracker *tracker_vpid; | |
136 | struct process_attr_tracker *tracker_uid; | |
137 | struct process_attr_tracker *tracker_vuid; | |
138 | struct process_attr_tracker *tracker_gid; | |
139 | struct process_attr_tracker *tracker_vgid; | |
fda89c9b DG |
140 | }; |
141 | ||
62499ad6 DG |
142 | /* |
143 | * Lookup functions. NULL is returned if not found. | |
144 | */ | |
28f23191 JG |
145 | struct ltt_kernel_event *trace_kernel_get_event_by_name(char *name, |
146 | struct ltt_kernel_channel *channel, | |
147 | enum lttng_event_type type); | |
148 | struct ltt_kernel_event *trace_kernel_find_event(char *name, | |
149 | struct ltt_kernel_channel *channel, | |
150 | enum lttng_event_type type, | |
151 | struct lttng_bytecode *filter); | |
152 | struct ltt_kernel_channel *trace_kernel_get_channel_by_name(const char *name, | |
153 | struct ltt_kernel_session *session); | |
19e70852 | 154 | |
54012638 | 155 | /* |
c363b55d | 156 | * Create functions malloc() the data structure. |
54012638 | 157 | */ |
cd9adb8b | 158 | struct ltt_kernel_session *trace_kernel_create_session(); |
28f23191 | 159 | struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan); |
71a3bb01 | 160 | enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev, |
28f23191 JG |
161 | char *filter_expression, |
162 | struct lttng_bytecode *filter, | |
163 | struct ltt_kernel_event **kernel_event); | |
cd9adb8b | 164 | struct ltt_kernel_metadata *trace_kernel_create_metadata(); |
28f23191 JG |
165 | struct ltt_kernel_stream *trace_kernel_create_stream(const char *name, unsigned int count); |
166 | struct ltt_kernel_context *trace_kernel_create_context(struct lttng_kernel_abi_context *ctx); | |
7c1f6da2 | 167 | /* Trigger is only non-const to acquire a reference. */ |
352b58f5 | 168 | enum lttng_error_code trace_kernel_create_event_notifier_rule( |
28f23191 JG |
169 | struct lttng_trigger *trigger, |
170 | uint64_t token, | |
171 | uint64_t error_counter_index, | |
172 | struct ltt_kernel_event_notifier_rule **event_notifier_rule); | |
173 | struct ltt_kernel_context *trace_kernel_copy_context(struct ltt_kernel_context *ctx); | |
352b58f5 | 174 | enum lttng_error_code trace_kernel_init_event_notifier_from_event_rule( |
28f23191 JG |
175 | const struct lttng_event_rule *rule, |
176 | struct lttng_kernel_abi_event_notifier *kernel_event_notifier); | |
54012638 | 177 | |
c363b55d DG |
178 | /* |
179 | * Destroy functions free() the data structure and remove from linked list if | |
180 | * it's applies. | |
181 | */ | |
62499ad6 DG |
182 | void trace_kernel_destroy_session(struct ltt_kernel_session *session); |
183 | void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata); | |
184 | void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel); | |
185 | void trace_kernel_destroy_event(struct ltt_kernel_event *event); | |
186 | void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream); | |
645328ae | 187 | void trace_kernel_destroy_context(struct ltt_kernel_context *ctx); |
352b58f5 | 188 | void trace_kernel_destroy_event_notifier_rule(struct ltt_kernel_event_notifier_rule *rule); |
d070c424 | 189 | void trace_kernel_free_session(struct ltt_kernel_session *session); |
c363b55d | 190 | |
62499ad6 | 191 | #endif /* _LTT_TRACE_KERNEL_H */ |