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