Make MSG() print on stdout instead of stderr
[lttng-tools.git] / lttng-sessiond / trace-ust.h
CommitLineData
97ee3a89
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef _LTT_TRACE_UST_H
20#define _LTT_TRACE_UST_H
21
3bd1e081 22#include <config.h>
97ee3a89 23#include <limits.h>
f6a9efaa 24#include <urcu.h>
97ee3a89 25#include <urcu/list.h>
bec39940 26
97ee3a89 27#include <lttng/lttng.h>
bec39940 28#include <lttng-ht.h>
3bd1e081 29
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
DG
48 struct lttng_ht *ctx;
49 struct lttng_ht_node_str node;
2bdd86d4
MD
50};
51
52/* UST stream */
53struct ltt_ust_stream {
48842b30
DG
54 int handle;
55 char pathname[PATH_MAX];
13161846 56 struct lttng_ust_object_data *obj;
5af2f756
MD
57 /* Using a list of streams to keep order. */
58 struct cds_list_head list;
97ee3a89
DG
59};
60
61/* UST channel */
62struct ltt_ust_channel {
37357452 63 unsigned int enabled;
44d3bd01 64 char name[LTTNG_UST_SYM_NAME_LEN];
48842b30 65 char pathname[PATH_MAX];
f6a9efaa 66 struct lttng_ust_channel attr;
bec39940
DG
67 struct lttng_ht *ctx;
68 struct lttng_ht *events;
69 struct lttng_ht_node_str node;
97ee3a89
DG
70};
71
72/* UST Metadata */
73struct ltt_ust_metadata {
74 int handle;
13161846 75 struct lttng_ust_object_data *obj;
f6a9efaa 76 char pathname[PATH_MAX]; /* Trace file path name */
44d3bd01 77 struct lttng_ust_channel attr;
13161846 78 struct lttng_ust_object_data *stream_obj;
97ee3a89
DG
79};
80
f6a9efaa
DG
81/* UST domain global (LTTNG_DOMAIN_UST) */
82struct ltt_ust_domain_global {
bec39940 83 struct lttng_ht *channels;
f6a9efaa
DG
84};
85
86/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
87struct ltt_ust_domain_pid {
88 pid_t pid;
bec39940
DG
89 struct lttng_ht *channels;
90 struct lttng_ht_node_ulong node;
f6a9efaa
DG
91};
92
93/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
94struct ltt_ust_domain_exec {
95 char exec_name[LTTNG_UST_SYM_NAME_LEN];
bec39940
DG
96 struct lttng_ht *channels;
97 struct lttng_ht_node_str node;
f6a9efaa
DG
98};
99
97ee3a89
DG
100/* UST session */
101struct ltt_ust_session {
a991f516 102 int id; /* Unique identifier of session */
36dc12cc 103 int start_trace;
48842b30 104 char pathname[PATH_MAX];
f6a9efaa
DG
105 struct ltt_ust_domain_global domain_global;
106 /*
48842b30
DG
107 * Those two hash tables contains data for a specific UST domain and each
108 * contains a HT of channels. See ltt_ust_domain_exec and
109 * ltt_ust_domain_pid data structures.
f6a9efaa 110 */
bec39940
DG
111 struct lttng_ht *domain_pid;
112 struct lttng_ht *domain_exec;
6df2e2c9
MD
113 /* UID/GID of the user owning the session */
114 uid_t uid;
115 gid_t gid;
97ee3a89
DG
116};
117
74d0b642 118#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 119
97ee3a89
DG
120/*
121 * Lookup functions. NULL is returned if not found.
122 */
bec39940 123struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 124 char *name);
bec39940 125struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 126 char *name);
97ee3a89
DG
127
128/*
129 * Create functions malloc() the data structure.
130 */
a991f516 131struct ltt_ust_session *trace_ust_create_session(char *path, int session_id,
44d3bd01
DG
132 struct lttng_domain *domain);
133struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
134 char *path);
97ee3a89
DG
135struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
136struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
55cc08a6
DG
137struct ltt_ust_context *trace_ust_create_context(
138 struct lttng_event_context *ctx);
97ee3a89
DG
139
140/*
141 * Destroy functions free() the data structure and remove from linked list if
142 * it's applies.
143 */
144void trace_ust_destroy_session(struct ltt_ust_session *session);
145void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
146void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
147void trace_ust_destroy_event(struct ltt_ust_event *event);
148
74d0b642 149#else /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081
MD
150
151static inline
bec39940 152struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 153 char *name)
3bd1e081
MD
154{
155 return NULL;
156}
f6a9efaa 157
3bd1e081 158static inline
bec39940 159struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 160 char *name)
3bd1e081
MD
161{
162 return NULL;
163}
f6a9efaa 164
3bd1e081
MD
165static inline
166struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
167 struct lttng_domain *domain)
168{
169 return NULL;
170}
171static inline
172struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
173 char *path)
174{
175 return NULL;
176}
177static inline
178struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
179{
180 return NULL;
181}
182static inline
183struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
184{
185 return NULL;
186}
187
188static inline
189void trace_ust_destroy_session(struct ltt_ust_session *session)
190{
191}
48842b30 192
3bd1e081
MD
193static inline
194void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
195{
196}
48842b30 197
3bd1e081
MD
198static inline
199void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
200{
201}
48842b30 202
3bd1e081
MD
203static inline
204void trace_ust_destroy_event(struct ltt_ust_event *event)
205{
206}
34378f76
DG
207static inline
208struct ltt_ust_context *trace_ust_create_context(
209 struct lttng_event_context *ctx)
210{
211 return NULL;
212}
3bd1e081 213
74d0b642 214#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 215
97ee3a89 216#endif /* _LTT_TRACE_UST_H */
This page took 0.03456 seconds and 4 git commands to generate.