Move LTTng-UST buffer ownership from application to consumer
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.h
CommitLineData
97ee3a89
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.
97ee3a89
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.
97ee3a89
DG
16 */
17
18#ifndef _LTT_TRACE_UST_H
19#define _LTT_TRACE_UST_H
20
3bd1e081 21#include <config.h>
97ee3a89
DG
22#include <limits.h>
23#include <urcu/list.h>
bec39940 24
97ee3a89 25#include <lttng/lttng.h>
10a8a223 26#include <common/hashtable/hashtable.h>
ce2a9e76 27#include <common/defaults.h>
3bd1e081 28
00e2e675 29#include "consumer.h"
48842b30 30#include "ust-ctl.h"
97ee3a89 31
18eace3b
DG
32struct ltt_ust_ht_key {
33 const char *name;
34 const struct lttng_filter_bytecode *filter;
35 enum lttng_ust_loglevel_type loglevel;
36};
37
f6a9efaa
DG
38/* Context hash table nodes */
39struct ltt_ust_context {
40 struct lttng_ust_context ctx;
bec39940 41 struct lttng_ht_node_ulong node;
97ee3a89
DG
42};
43
44/* UST event */
45struct ltt_ust_event {
37357452 46 unsigned int enabled;
f6a9efaa 47 struct lttng_ust_event attr;
bec39940 48 struct lttng_ht_node_str node;
53a80697 49 struct lttng_ust_filter_bytecode *filter;
2bdd86d4
MD
50};
51
97ee3a89
DG
52/* UST channel */
53struct ltt_ust_channel {
37357452 54 unsigned int enabled;
44d3bd01 55 char name[LTTNG_UST_SYM_NAME_LEN];
48842b30 56 char pathname[PATH_MAX];
ffe60014 57 struct lttng_ust_channel_attr attr;
bec39940
DG
58 struct lttng_ht *ctx;
59 struct lttng_ht *events;
60 struct lttng_ht_node_str node;
97ee3a89
DG
61};
62
63/* UST Metadata */
64struct ltt_ust_metadata {
65 int handle;
13161846 66 struct lttng_ust_object_data *obj;
f6a9efaa 67 char pathname[PATH_MAX]; /* Trace file path name */
ffe60014 68 struct lttng_ust_channel_attr attr;
13161846 69 struct lttng_ust_object_data *stream_obj;
97ee3a89
DG
70};
71
f6a9efaa
DG
72/* UST domain global (LTTNG_DOMAIN_UST) */
73struct ltt_ust_domain_global {
bec39940 74 struct lttng_ht *channels;
f6a9efaa
DG
75};
76
77/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
78struct ltt_ust_domain_pid {
79 pid_t pid;
bec39940
DG
80 struct lttng_ht *channels;
81 struct lttng_ht_node_ulong node;
f6a9efaa
DG
82};
83
84/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
85struct ltt_ust_domain_exec {
86 char exec_name[LTTNG_UST_SYM_NAME_LEN];
bec39940
DG
87 struct lttng_ht *channels;
88 struct lttng_ht_node_str node;
f6a9efaa
DG
89};
90
97ee3a89
DG
91/* UST session */
92struct ltt_ust_session {
a991f516 93 int id; /* Unique identifier of session */
36dc12cc 94 int start_trace;
48842b30 95 char pathname[PATH_MAX];
f6a9efaa
DG
96 struct ltt_ust_domain_global domain_global;
97 /*
48842b30
DG
98 * Those two hash tables contains data for a specific UST domain and each
99 * contains a HT of channels. See ltt_ust_domain_exec and
100 * ltt_ust_domain_pid data structures.
f6a9efaa 101 */
bec39940
DG
102 struct lttng_ht *domain_pid;
103 struct lttng_ht *domain_exec;
6df2e2c9
MD
104 /* UID/GID of the user owning the session */
105 uid_t uid;
106 gid_t gid;
00e2e675
DG
107 /*
108 * Two consumer_output object are needed where one is for the current
109 * output object and the second one is the temporary object used to store
110 * URI being set by the lttng_set_consumer_uri call. Once
111 * lttng_enable_consumer is called, the two pointers are swapped.
112 */
113 struct consumer_output *consumer;
114 struct consumer_output *tmp_consumer;
f3f0db50
DG
115 /* Sequence number for filters so the tracer knows the ordering. */
116 uint64_t filter_seq_num;
97ee3a89
DG
117};
118
74d0b642 119#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 120
18eace3b
DG
121int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key);
122int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
123 const void *_key);
124
97ee3a89
DG
125/*
126 * Lookup functions. NULL is returned if not found.
127 */
18eace3b
DG
128struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
129 char *name, struct lttng_filter_bytecode *filter, int loglevel);
bec39940 130struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 131 char *name);
97ee3a89
DG
132
133/*
134 * Create functions malloc() the data structure.
135 */
fc4705fe 136struct ltt_ust_session *trace_ust_create_session(char *path,
fdd9eb17 137 unsigned int session_id);
44d3bd01
DG
138struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
139 char *path);
025faf73
DG
140struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
141 struct lttng_filter_bytecode *filter);
97ee3a89 142struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
55cc08a6
DG
143struct ltt_ust_context *trace_ust_create_context(
144 struct lttng_event_context *ctx);
97ee3a89
DG
145
146/*
147 * Destroy functions free() the data structure and remove from linked list if
148 * it's applies.
149 */
150void trace_ust_destroy_session(struct ltt_ust_session *session);
151void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
152void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
153void trace_ust_destroy_event(struct ltt_ust_event *event);
154
74d0b642 155#else /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 156
37a86c61
DG
157static inline int trace_ust_ht_match_event(struct cds_lfht_node *node,
158 const void *_key)
159{
160 return 0;
161}
162static inline int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
163 const void *_key)
164{
165 return 0;
166}
3bd1e081 167static inline
bec39940 168struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 169 char *name)
3bd1e081
MD
170{
171 return NULL;
172}
f6a9efaa 173
3bd1e081 174static inline
ffe60014
DG
175struct ltt_ust_session *trace_ust_create_session(char *path,
176 unsigned int session_id)
3bd1e081
MD
177{
178 return NULL;
179}
180static inline
181struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
182 char *path)
183{
184 return NULL;
185}
186static inline
025faf73
DG
187struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
188 struct lttng_filter_bytecode *filter)
3bd1e081
MD
189{
190 return NULL;
191}
192static inline
193struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
194{
195 return NULL;
196}
197
198static inline
199void trace_ust_destroy_session(struct ltt_ust_session *session)
200{
201}
48842b30 202
3bd1e081
MD
203static inline
204void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
205{
206}
48842b30 207
3bd1e081
MD
208static inline
209void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
210{
211}
48842b30 212
3bd1e081
MD
213static inline
214void trace_ust_destroy_event(struct ltt_ust_event *event)
215{
216}
34378f76
DG
217static inline
218struct ltt_ust_context *trace_ust_create_context(
219 struct lttng_event_context *ctx)
220{
221 return NULL;
222}
37a86c61
DG
223static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
224 char *name, struct lttng_filter_bytecode *filter, int loglevel)
225{
226 return NULL;
227}
3bd1e081 228
74d0b642 229#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 230
97ee3a89 231#endif /* _LTT_TRACE_UST_H */
This page took 0.046541 seconds and 5 git commands to generate.