Add kernel and UST time namespace context
[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_filter_bytecode *filter;
52 struct lttng_userspace_probe_location *userspace_probe_location;
53 };
54
55 /* Kernel channel */
56 struct ltt_kernel_channel {
57 int fd;
58 uint64_t key; /* Key to reference this channel with the consumer. */
59 int enabled;
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;
71 };
72
73 /* Metadata */
74 struct ltt_kernel_metadata {
75 int fd;
76 uint64_t key; /* Key to reference this channel with the consumer. */
77 struct lttng_channel *conf;
78 };
79
80 /* Channel stream */
81 struct ltt_kernel_stream {
82 int fd;
83 int state;
84 int cpu;
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;
91 };
92
93 /* Kernel session */
94 struct ltt_kernel_session {
95 int fd;
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 */
103 uid_t uid;
104 gid_t gid;
105 struct consumer_output *consumer;
106 /* Tracing session id */
107 uint64_t 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;
117 /* Tracker lists */
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;
124 };
125
126 /*
127 * Lookup functions. NULL is returned if not found.
128 */
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);
138
139 /*
140 * Create functions malloc() the data structure.
141 */
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,
150 unsigned int count);
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);
155
156 /*
157 * Destroy functions free() the data structure and remove from linked list if
158 * it's applies.
159 */
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);
167
168 #endif /* _LTT_TRACE_KERNEL_H */
This page took 0.032051 seconds and 4 git commands to generate.