Fix: Typo from a previous patch in an assert()
[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};
128
129#ifdef HAVE_LIBLTTNG_UST_CTL
130
131/*
132 * Lookup functions. NULL is returned if not found.
133 */
134struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
135 char *name);
136struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
137 char *name);
138
139/*
140 * Create functions malloc() the data structure.
141 */
142struct ltt_ust_session *trace_ust_create_session(char *path,
143 unsigned int session_id, struct lttng_domain *domain);
144struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
145 char *path);
146struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
147struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
148struct ltt_ust_context *trace_ust_create_context(
149 struct lttng_event_context *ctx);
150
151/*
152 * Destroy functions free() the data structure and remove from linked list if
153 * it's applies.
154 */
155void trace_ust_destroy_session(struct ltt_ust_session *session);
156void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
157void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
158void trace_ust_destroy_event(struct ltt_ust_event *event);
159
160#else /* HAVE_LIBLTTNG_UST_CTL */
161
162static inline
163struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
164 char *name)
165{
166 return NULL;
167}
168
169static inline
170struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
171 char *name)
172{
173 return NULL;
174}
175
176static inline
177struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
178 struct lttng_domain *domain)
179{
180 return NULL;
181}
182static inline
183struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
184 char *path)
185{
186 return NULL;
187}
188static inline
189struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
190{
191 return NULL;
192}
193static inline
194struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
195{
196 return NULL;
197}
198
199static inline
200void trace_ust_destroy_session(struct ltt_ust_session *session)
201{
202}
203
204static inline
205void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
206{
207}
208
209static inline
210void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
211{
212}
213
214static inline
215void trace_ust_destroy_event(struct ltt_ust_event *event)
216{
217}
218static inline
219struct ltt_ust_context *trace_ust_create_context(
220 struct lttng_event_context *ctx)
221{
222 return NULL;
223}
224
225#endif /* HAVE_LIBLTTNG_UST_CTL */
226
227#endif /* _LTT_TRACE_UST_H */
This page took 0.024873 seconds and 5 git commands to generate.