Pass lttng_event struct to the set_filter API call
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.h
CommitLineData
97ee3a89
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
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.
97ee3a89
DG
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 *
d14d33bf
AM
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.
97ee3a89
DG
16 */
17
18#ifndef _LTT_TRACE_UST_H
19#define _LTT_TRACE_UST_H
20
3bd1e081 21#include <config.h>
97ee3a89
DG
22#include <limits.h>
23#include <urcu/list.h>
bec39940 24
97ee3a89 25#include <lttng/lttng.h>
10a8a223 26#include <common/hashtable/hashtable.h>
ce2a9e76 27#include <common/defaults.h>
3bd1e081 28
00e2e675 29#include "consumer.h"
48842b30 30#include "ust-ctl.h"
97ee3a89 31
2bdd86d4
MD
32/* UST Stream list */
33struct ltt_ust_stream_list {
34 unsigned int count;
35 struct cds_list_head head;
36};
37
f6a9efaa
DG
38/* Context hash table nodes */
39struct ltt_ust_context {
40 struct lttng_ust_context ctx;
bec39940 41 struct lttng_ht_node_ulong node;
97ee3a89
DG
42};
43
44/* UST event */
45struct ltt_ust_event {
37357452 46 unsigned int enabled;
f6a9efaa 47 struct lttng_ust_event attr;
bec39940 48 struct lttng_ht_node_str node;
53a80697 49 struct lttng_ust_filter_bytecode *filter;
2bdd86d4
MD
50};
51
52/* UST stream */
53struct ltt_ust_stream {
48842b30
DG
54 int handle;
55 char pathname[PATH_MAX];
00e2e675 56 /* Format is %s_%d respectively channel name and CPU number. */
ce2a9e76 57 char name[DEFAULT_STREAM_NAME_LEN];
13161846 58 struct lttng_ust_object_data *obj;
5af2f756
MD
59 /* Using a list of streams to keep order. */
60 struct cds_list_head list;
97ee3a89
DG
61};
62
63/* UST channel */
64struct ltt_ust_channel {
37357452 65 unsigned int enabled;
44d3bd01 66 char name[LTTNG_UST_SYM_NAME_LEN];
48842b30 67 char pathname[PATH_MAX];
f6a9efaa 68 struct lttng_ust_channel attr;
bec39940
DG
69 struct lttng_ht *ctx;
70 struct lttng_ht *events;
71 struct lttng_ht_node_str node;
97ee3a89
DG
72};
73
74/* UST Metadata */
75struct ltt_ust_metadata {
76 int handle;
13161846 77 struct lttng_ust_object_data *obj;
f6a9efaa 78 char pathname[PATH_MAX]; /* Trace file path name */
44d3bd01 79 struct lttng_ust_channel attr;
13161846 80 struct lttng_ust_object_data *stream_obj;
97ee3a89
DG
81};
82
f6a9efaa
DG
83/* UST domain global (LTTNG_DOMAIN_UST) */
84struct ltt_ust_domain_global {
bec39940 85 struct lttng_ht *channels;
f6a9efaa
DG
86};
87
88/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
89struct ltt_ust_domain_pid {
90 pid_t pid;
bec39940
DG
91 struct lttng_ht *channels;
92 struct lttng_ht_node_ulong node;
f6a9efaa
DG
93};
94
95/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
96struct ltt_ust_domain_exec {
97 char exec_name[LTTNG_UST_SYM_NAME_LEN];
bec39940
DG
98 struct lttng_ht *channels;
99 struct lttng_ht_node_str node;
f6a9efaa
DG
100};
101
97ee3a89
DG
102/* UST session */
103struct ltt_ust_session {
a991f516 104 int id; /* Unique identifier of session */
36dc12cc 105 int start_trace;
48842b30 106 char pathname[PATH_MAX];
f6a9efaa
DG
107 struct ltt_ust_domain_global domain_global;
108 /*
48842b30
DG
109 * Those two hash tables contains data for a specific UST domain and each
110 * contains a HT of channels. See ltt_ust_domain_exec and
111 * ltt_ust_domain_pid data structures.
f6a9efaa 112 */
bec39940
DG
113 struct lttng_ht *domain_pid;
114 struct lttng_ht *domain_exec;
6df2e2c9
MD
115 /* UID/GID of the user owning the session */
116 uid_t uid;
117 gid_t gid;
00e2e675
DG
118 /*
119 * Two consumer_output object are needed where one is for the current
120 * output object and the second one is the temporary object used to store
121 * URI being set by the lttng_set_consumer_uri call. Once
122 * lttng_enable_consumer is called, the two pointers are swapped.
123 */
124 struct consumer_output *consumer;
125 struct consumer_output *tmp_consumer;
f3f0db50
DG
126 /* Sequence number for filters so the tracer knows the ordering. */
127 uint64_t filter_seq_num;
97ee3a89
DG
128};
129
74d0b642 130#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 131
97ee3a89
DG
132/*
133 * Lookup functions. NULL is returned if not found.
134 */
bec39940 135struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 136 char *name);
bec39940 137struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 138 char *name);
97ee3a89
DG
139
140/*
141 * Create functions malloc() the data structure.
142 */
fc4705fe
DG
143struct ltt_ust_session *trace_ust_create_session(char *path,
144 unsigned int session_id, struct lttng_domain *domain);
44d3bd01
DG
145struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
146 char *path);
97ee3a89
DG
147struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
148struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
55cc08a6
DG
149struct ltt_ust_context *trace_ust_create_context(
150 struct lttng_event_context *ctx);
97ee3a89
DG
151
152/*
153 * Destroy functions free() the data structure and remove from linked list if
154 * it's applies.
155 */
156void trace_ust_destroy_session(struct ltt_ust_session *session);
157void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
158void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
159void trace_ust_destroy_event(struct ltt_ust_event *event);
160
74d0b642 161#else /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081
MD
162
163static inline
bec39940 164struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 165 char *name)
3bd1e081
MD
166{
167 return NULL;
168}
f6a9efaa 169
3bd1e081 170static inline
bec39940 171struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 172 char *name)
3bd1e081
MD
173{
174 return NULL;
175}
f6a9efaa 176
3bd1e081
MD
177static inline
178struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
179 struct lttng_domain *domain)
180{
181 return NULL;
182}
183static inline
184struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
185 char *path)
186{
187 return NULL;
188}
189static inline
190struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
191{
192 return NULL;
193}
194static inline
195struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
196{
197 return NULL;
198}
199
200static inline
201void trace_ust_destroy_session(struct ltt_ust_session *session)
202{
203}
48842b30 204
3bd1e081
MD
205static inline
206void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
207{
208}
48842b30 209
3bd1e081
MD
210static inline
211void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
212{
213}
48842b30 214
3bd1e081
MD
215static inline
216void trace_ust_destroy_event(struct ltt_ust_event *event)
217{
218}
34378f76
DG
219static inline
220struct ltt_ust_context *trace_ust_create_context(
221 struct lttng_event_context *ctx)
222{
223 return NULL;
224}
3bd1e081 225
74d0b642 226#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 227
97ee3a89 228#endif /* _LTT_TRACE_UST_H */
This page took 0.043985 seconds and 5 git commands to generate.