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