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