Rename ltt_ust_stream to ust_app_stream
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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.
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 *
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.
16 */
17
18#ifndef _LTT_TRACE_UST_H
19#define _LTT_TRACE_UST_H
20
21#include <config.h>
22#include <limits.h>
23#include <urcu/list.h>
24
25#include <lttng/lttng.h>
26#include <common/hashtable/hashtable.h>
27#include <common/defaults.h>
28
29#include "consumer.h"
30#include "ust-ctl.h"
31
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
38/* Context hash table nodes */
39struct ltt_ust_context {
40 struct lttng_ust_context ctx;
41 struct lttng_ht_node_ulong node;
42};
43
44/* UST event */
45struct ltt_ust_event {
46 unsigned int enabled;
47 struct lttng_ust_event attr;
48 struct lttng_ht_node_str node;
49 struct lttng_ust_filter_bytecode *filter;
50};
51
52/* UST channel */
53struct ltt_ust_channel {
54 unsigned int enabled;
55 char name[LTTNG_UST_SYM_NAME_LEN];
56 char pathname[PATH_MAX];
57 struct lttng_ust_channel attr;
58 struct lttng_ht *ctx;
59 struct lttng_ht *events;
60 struct lttng_ht_node_str node;
61};
62
63/* UST Metadata */
64struct ltt_ust_metadata {
65 int handle;
66 struct lttng_ust_object_data *obj;
67 char pathname[PATH_MAX]; /* Trace file path name */
68 struct lttng_ust_channel attr;
69 struct lttng_ust_object_data *stream_obj;
70};
71
72/* UST domain global (LTTNG_DOMAIN_UST) */
73struct ltt_ust_domain_global {
74 struct lttng_ht *channels;
75};
76
77/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
78struct ltt_ust_domain_pid {
79 pid_t pid;
80 struct lttng_ht *channels;
81 struct lttng_ht_node_ulong node;
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];
87 struct lttng_ht *channels;
88 struct lttng_ht_node_str node;
89};
90
91/* UST session */
92struct ltt_ust_session {
93 int id; /* Unique identifier of session */
94 int start_trace;
95 char pathname[PATH_MAX];
96 struct ltt_ust_domain_global domain_global;
97 /*
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.
101 */
102 struct lttng_ht *domain_pid;
103 struct lttng_ht *domain_exec;
104 /* UID/GID of the user owning the session */
105 uid_t uid;
106 gid_t gid;
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;
115 /* Sequence number for filters so the tracer knows the ordering. */
116 uint64_t filter_seq_num;
117};
118
119#ifdef HAVE_LIBLTTNG_UST_CTL
120
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
125/*
126 * Lookup functions. NULL is returned if not found.
127 */
128struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
129 char *name, struct lttng_filter_bytecode *filter, int loglevel);
130struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
131 char *name);
132
133/*
134 * Create functions malloc() the data structure.
135 */
136struct ltt_ust_session *trace_ust_create_session(char *path,
137 unsigned int session_id, struct lttng_domain *domain);
138struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
139 char *path);
140struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
141 struct lttng_filter_bytecode *filter);
142struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
143struct ltt_ust_context *trace_ust_create_context(
144 struct lttng_event_context *ctx);
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
155#else /* HAVE_LIBLTTNG_UST_CTL */
156
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}
167static inline
168struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
169 char *name)
170{
171 return NULL;
172}
173
174static inline
175struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
176 struct lttng_domain *domain)
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
187struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
188 struct lttng_filter_bytecode *filter)
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}
202
203static inline
204void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
205{
206}
207
208static inline
209void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
210{
211}
212
213static inline
214void trace_ust_destroy_event(struct ltt_ust_event *event)
215{
216}
217static inline
218struct ltt_ust_context *trace_ust_create_context(
219 struct lttng_event_context *ctx)
220{
221 return NULL;
222}
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}
228
229#endif /* HAVE_LIBLTTNG_UST_CTL */
230
231#endif /* _LTT_TRACE_UST_H */
This page took 0.023341 seconds and 4 git commands to generate.