Fix: sessiond: no rotation performed from null chunk to new chunk
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.h
CommitLineData
fda89c9b
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
fda89c9b
DG
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
d14d33bf
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
fda89c9b
DG
16 */
17
62499ad6
DG
18#ifndef _LTT_TRACE_KERNEL_H
19#define _LTT_TRACE_KERNEL_H
fda89c9b 20
9e78d6ae 21#include <urcu/list.h>
d4a2a84a 22
f3ed775e 23#include <lttng/lttng.h>
10a8a223 24#include <common/lttng-kernel.h>
4dbc372b 25#include <common/lttng-kernel-old.h>
ce2a9e76 26#include <common/defaults.h>
54012638 27
00e2e675
DG
28#include "consumer.h"
29
20fe2104
DG
30/* Kernel event list */
31struct ltt_kernel_event_list {
32 struct cds_list_head head;
33};
34
8c0faa1d
DG
35/* Channel stream list */
36struct ltt_kernel_stream_list {
37 struct cds_list_head head;
38};
39
40/* Channel list */
41struct ltt_kernel_channel_list {
42 struct cds_list_head head;
43};
44
645328ae
DG
45struct ltt_kernel_context {
46 struct lttng_kernel_context ctx;
47 struct cds_list_head list;
ba985c3a
JG
48 /* Indicates whether or not the context is in a list. */
49 bool in_list;
645328ae
DG
50};
51
20fe2104
DG
52/* Kernel event */
53struct ltt_kernel_event {
20fe2104 54 int fd;
e953ef25 55 int enabled;
d0ae4ea8 56 enum lttng_event_type type;
f34daff7 57 struct lttng_kernel_event *event;
20fe2104 58 struct cds_list_head list;
00a62084
MD
59 char *filter_expression;
60 struct lttng_filter_bytecode *filter;
3c02e545 61 struct lttng_userspace_probe_location *userspace_probe_location;
20fe2104
DG
62};
63
64/* Kernel channel */
65struct ltt_kernel_channel {
66 int fd;
e1f3997a 67 uint64_t key; /* Key to reference this channel with the consumer. */
d36b8583 68 int enabled;
8c0faa1d 69 unsigned int stream_count;
cbbbb275 70 unsigned int event_count;
753873bf 71 bool published_to_notification_thread;
645328ae 72 struct cds_list_head ctx_list;
f3ed775e 73 struct lttng_channel *channel;
20fe2104 74 struct ltt_kernel_event_list events_list;
8c0faa1d
DG
75 struct ltt_kernel_stream_list stream_list;
76 struct cds_list_head list;
fb5f35b6
DG
77 /* Session pointer which has a reference to this object. */
78 struct ltt_kernel_session *session;
e99f9447 79 bool sent_to_consumer;
20fe2104
DG
80};
81
aaf26714
DG
82/* Metadata */
83struct ltt_kernel_metadata {
84 int fd;
d40f0359 85 uint64_t key; /* Key to reference this channel with the consumer. */
f3ed775e 86 struct lttng_channel *conf;
aaf26714
DG
87};
88
8c0faa1d
DG
89/* Channel stream */
90struct ltt_kernel_stream {
91 int fd;
8c0faa1d 92 int state;
ffe60014 93 int cpu;
6986ab9b 94 bool sent_to_consumer;
00e2e675 95 /* Format is %s_%d respectively channel name and CPU number. */
ce2a9e76 96 char name[DEFAULT_STREAM_NAME_LEN];
1624d5b7
JD
97 uint64_t tracefile_size;
98 uint64_t tracefile_count;
8c0faa1d
DG
99 struct cds_list_head list;
100};
101
20fe2104
DG
102/* Kernel session */
103struct ltt_kernel_session {
104 int fd;
8c0faa1d 105 int metadata_stream_fd;
3bd1e081 106 int consumer_fds_sent;
8c0faa1d
DG
107 unsigned int channel_count;
108 unsigned int stream_count_global;
aaf26714 109 struct ltt_kernel_metadata *metadata;
8c0faa1d 110 struct ltt_kernel_channel_list channel_list;
6df2e2c9
MD
111 /* UID/GID of the user owning the session */
112 uid_t uid;
113 gid_t gid;
00e2e675 114 struct consumer_output *consumer;
53632229 115 /* Tracing session id */
d022620a 116 uint64_t id;
14fb1ebe
DG
117 /* Session is active or not meaning it has been started or stopped. */
118 unsigned int active:1;
2bba9e53
DG
119 /* Tell or not if the session has to output the traces. */
120 unsigned int output_traces;
27babd3a 121 unsigned int snapshot_mode;
85076754 122 unsigned int has_non_default_channel;
82b69413
JG
123 /* Current trace chunk of the ltt_session. */
124 struct lttng_trace_chunk *current_trace_chunk;
fda89c9b
DG
125};
126
62499ad6
DG
127/*
128 * Lookup functions. NULL is returned if not found.
129 */
130struct ltt_kernel_event *trace_kernel_get_event_by_name(
d0ae4ea8
MD
131 char *name, struct ltt_kernel_channel *channel,
132 enum lttng_event_type type);
00a62084
MD
133struct ltt_kernel_event *trace_kernel_find_event(
134 char *name, struct ltt_kernel_channel *channel,
135 enum lttng_event_type type,
136 struct lttng_filter_bytecode *filter);
62499ad6 137struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
df4f5a87 138 const char *name, struct ltt_kernel_session *session);
19e70852 139
54012638 140/*
c363b55d 141 * Create functions malloc() the data structure.
54012638 142 */
dec56f6c 143struct ltt_kernel_session *trace_kernel_create_session(void);
fdd9eb17
DG
144struct ltt_kernel_channel *trace_kernel_create_channel(
145 struct lttng_channel *chan);
71a3bb01
FD
146enum lttng_error_code trace_kernel_create_event(struct lttng_event *ev,
147 char *filter_expression, struct lttng_filter_bytecode *filter,
148 struct ltt_kernel_event **kernel_event);
a4b92340 149struct ltt_kernel_metadata *trace_kernel_create_metadata(void);
00e2e675
DG
150struct ltt_kernel_stream *trace_kernel_create_stream(const char *name,
151 unsigned int count);
645328ae
DG
152struct ltt_kernel_context *trace_kernel_create_context(
153 struct lttng_kernel_context *ctx);
df3c77c8
JG
154struct ltt_kernel_context *trace_kernel_copy_context(
155 struct ltt_kernel_context *ctx);
54012638 156
c363b55d
DG
157/*
158 * Destroy functions free() the data structure and remove from linked list if
159 * it's applies.
160 */
62499ad6
DG
161void trace_kernel_destroy_session(struct ltt_kernel_session *session);
162void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
163void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
164void trace_kernel_destroy_event(struct ltt_kernel_event *event);
165void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
645328ae 166void trace_kernel_destroy_context(struct ltt_kernel_context *ctx);
d070c424 167void trace_kernel_free_session(struct ltt_kernel_session *session);
c363b55d 168
62499ad6 169#endif /* _LTT_TRACE_KERNEL_H */
This page took 0.065984 seconds and 4 git commands to generate.