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