Add filter sequence number to UST
[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
32/* UST Stream list */
33struct ltt_ust_stream_list {
34 unsigned int count;
35 struct cds_list_head head;
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 *ctx;
49 struct lttng_ht_node_str node;
50 struct lttng_ust_filter_bytecode *filter;
51};
52
53/* UST stream */
54struct ltt_ust_stream {
55 int handle;
56 char pathname[PATH_MAX];
57 /* Format is %s_%d respectively channel name and CPU number. */
58 char name[DEFAULT_STREAM_NAME_LEN];
59 struct lttng_ust_object_data *obj;
60 /* Using a list of streams to keep order. */
61 struct cds_list_head list;
62};
63
64/* UST channel */
65struct ltt_ust_channel {
66 unsigned int enabled;
67 char name[LTTNG_UST_SYM_NAME_LEN];
68 char pathname[PATH_MAX];
69 struct lttng_ust_channel attr;
70 struct lttng_ht *ctx;
71 struct lttng_ht *events;
72 struct lttng_ht_node_str node;
73};
74
75/* UST Metadata */
76struct ltt_ust_metadata {
77 int handle;
78 struct lttng_ust_object_data *obj;
79 char pathname[PATH_MAX]; /* Trace file path name */
80 struct lttng_ust_channel attr;
81 struct lttng_ust_object_data *stream_obj;
82};
83
84/* UST domain global (LTTNG_DOMAIN_UST) */
85struct ltt_ust_domain_global {
86 struct lttng_ht *channels;
87};
88
89/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
90struct ltt_ust_domain_pid {
91 pid_t pid;
92 struct lttng_ht *channels;
93 struct lttng_ht_node_ulong node;
94};
95
96/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
97struct ltt_ust_domain_exec {
98 char exec_name[LTTNG_UST_SYM_NAME_LEN];
99 struct lttng_ht *channels;
100 struct lttng_ht_node_str node;
101};
102
103/* UST session */
104struct ltt_ust_session {
105 int id; /* Unique identifier of session */
106 int start_trace;
107 char pathname[PATH_MAX];
108 struct ltt_ust_domain_global domain_global;
109 /*
110 * Those two hash tables contains data for a specific UST domain and each
111 * contains a HT of channels. See ltt_ust_domain_exec and
112 * ltt_ust_domain_pid data structures.
113 */
114 struct lttng_ht *domain_pid;
115 struct lttng_ht *domain_exec;
116 /* UID/GID of the user owning the session */
117 uid_t uid;
118 gid_t gid;
119 /*
120 * Two consumer_output object are needed where one is for the current
121 * output object and the second one is the temporary object used to store
122 * URI being set by the lttng_set_consumer_uri call. Once
123 * lttng_enable_consumer is called, the two pointers are swapped.
124 */
125 struct consumer_output *consumer;
126 struct consumer_output *tmp_consumer;
127 /* Sequence number for filters so the tracer knows the ordering. */
128 uint64_t filter_seq_num;
129};
130
131#ifdef HAVE_LIBLTTNG_UST_CTL
132
133/*
134 * Lookup functions. NULL is returned if not found.
135 */
136struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
137 char *name);
138struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
139 char *name);
140
141/*
142 * Create functions malloc() the data structure.
143 */
144struct ltt_ust_session *trace_ust_create_session(char *path,
145 unsigned int session_id, struct lttng_domain *domain);
146struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
147 char *path);
148struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
149struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
150struct ltt_ust_context *trace_ust_create_context(
151 struct lttng_event_context *ctx);
152
153/*
154 * Destroy functions free() the data structure and remove from linked list if
155 * it's applies.
156 */
157void trace_ust_destroy_session(struct ltt_ust_session *session);
158void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
159void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
160void trace_ust_destroy_event(struct ltt_ust_event *event);
161
162#else /* HAVE_LIBLTTNG_UST_CTL */
163
164static inline
165struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
166 char *name)
167{
168 return NULL;
169}
170
171static inline
172struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
173 char *name)
174{
175 return NULL;
176}
177
178static inline
179struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
180 struct lttng_domain *domain)
181{
182 return NULL;
183}
184static inline
185struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
186 char *path)
187{
188 return NULL;
189}
190static inline
191struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
192{
193 return NULL;
194}
195static inline
196struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
197{
198 return NULL;
199}
200
201static inline
202void trace_ust_destroy_session(struct ltt_ust_session *session)
203{
204}
205
206static inline
207void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
208{
209}
210
211static inline
212void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
213{
214}
215
216static inline
217void trace_ust_destroy_event(struct ltt_ust_event *event)
218{
219}
220static inline
221struct ltt_ust_context *trace_ust_create_context(
222 struct lttng_event_context *ctx)
223{
224 return NULL;
225}
226
227#endif /* HAVE_LIBLTTNG_UST_CTL */
228
229#endif /* _LTT_TRACE_UST_H */
This page took 0.023325 seconds and 4 git commands to generate.