Update RCU hashtable from upstream urcu
[lttng-tools.git] / ltt-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>
97ee3a89 26#include <lttng/lttng.h>
3bd1e081
MD
27
28/*
29 * FIXME: temporary workaround: we use a lttng-tools local version of
30 * lttng-ust-abi.h if UST is not found. Eventually, we should use our
31 * own internal structures within lttng-tools instead of relying on the
32 * UST ABI.
33 */
34#ifdef CONFIG_CONFIG_LTTNG_TOOLS_HAVE_UST
35#include <ust/lttng-ust-abi.h>
36#else
37#include "lttng-ust-abi.h"
38#endif
97ee3a89 39
f6a9efaa 40#include "../hashtable/rculfhash.h"
0177d773 41
97ee3a89 42
2bdd86d4
MD
43/* UST Stream list */
44struct ltt_ust_stream_list {
45 unsigned int count;
46 struct cds_list_head head;
47};
48
f6a9efaa
DG
49/* Context hash table nodes */
50struct ltt_ust_context {
51 struct lttng_ust_context ctx;
52 struct cds_lfht_node node;
97ee3a89
DG
53};
54
55/* UST event */
56struct ltt_ust_event {
57 int handle;
58 int enabled;
2bdd86d4 59 struct object_data *obj;
f6a9efaa
DG
60 struct lttng_ust_event attr;
61 struct cds_lfht *ctx;
62 struct cds_lfht_node node;
2bdd86d4
MD
63};
64
65/* UST stream */
66struct ltt_ust_stream {
f6a9efaa 67 /* TODO hashtable */
2bdd86d4
MD
68 struct object_data *obj;
69 struct cds_list_head list;
70 char *pathname;
97ee3a89
DG
71};
72
73/* UST channel */
74struct ltt_ust_channel {
75 int handle;
76 int enabled;
44d3bd01
DG
77 char name[LTTNG_UST_SYM_NAME_LEN];
78 char trace_path[PATH_MAX]; /* Trace file path name */
2bdd86d4 79 struct object_data *obj;
f6a9efaa 80
2bdd86d4
MD
81 unsigned int stream_count;
82 struct ltt_ust_stream_list stream_list;
f6a9efaa
DG
83 struct lttng_ust_channel attr;
84 struct cds_lfht *ctx;
85 struct cds_lfht *events;
86 struct cds_lfht_node node;
97ee3a89
DG
87};
88
89/* UST Metadata */
90struct ltt_ust_metadata {
91 int handle;
2bdd86d4 92 struct object_data *obj;
f6a9efaa 93 char pathname[PATH_MAX]; /* Trace file path name */
44d3bd01 94 struct lttng_ust_channel attr;
2bdd86d4 95 struct object_data *stream_obj;
97ee3a89
DG
96};
97
f6a9efaa
DG
98/* UST domain global (LTTNG_DOMAIN_UST) */
99struct ltt_ust_domain_global {
100 struct cds_lfht *channels;
101};
102
103/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
104struct ltt_ust_domain_pid {
105 pid_t pid;
106 struct cds_lfht *channels;
107 struct cds_lfht_node node;
108};
109
110/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
111struct ltt_ust_domain_exec {
112 char exec_name[LTTNG_UST_SYM_NAME_LEN];
113 struct cds_lfht *channels;
114 struct cds_lfht_node node;
115};
116
97ee3a89
DG
117/* UST session */
118struct ltt_ust_session {
2bdd86d4 119 int sock; /* socket to send cmds to app */
97ee3a89
DG
120 int handle;
121 int enabled;
3bd1e081 122 int consumer_fds_sent;
2bdd86d4 123 int consumer_fd;
44d3bd01 124 char path[PATH_MAX];
97ee3a89 125 struct ltt_ust_metadata *metadata;
2bdd86d4 126 struct object_data *obj;
f6a9efaa
DG
127 struct ltt_ust_domain_global domain_global;
128 /*
129 * Those two hash tables contains data for a specific UST domain and a HT
130 * of channels for each. See ltt_ust_domain_exec and ltt_ust_domain_pid
131 * data structures.
132 */
133 struct cds_lfht *domain_pid;
134 struct cds_lfht *domain_exec;
97ee3a89
DG
135};
136
3bd1e081
MD
137#ifdef CONFIG_LTTNG_TOOLS_HAVE_UST
138
97ee3a89
DG
139/*
140 * Lookup functions. NULL is returned if not found.
141 */
f6a9efaa
DG
142struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht,
143 char *name);
144struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht,
145 char *name);
97ee3a89
DG
146
147/*
148 * Create functions malloc() the data structure.
149 */
44d3bd01
DG
150struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
151 struct lttng_domain *domain);
152struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
153 char *path);
97ee3a89
DG
154struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
155struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
156
157/*
158 * Destroy functions free() the data structure and remove from linked list if
159 * it's applies.
160 */
161void trace_ust_destroy_session(struct ltt_ust_session *session);
162void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
163void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
164void trace_ust_destroy_event(struct ltt_ust_event *event);
165
3bd1e081
MD
166#else
167
168static inline
f6a9efaa
DG
169struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht,
170 char *name)
3bd1e081
MD
171{
172 return NULL;
173}
f6a9efaa 174
3bd1e081 175static inline
f6a9efaa
DG
176struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht,
177 char *name)
3bd1e081
MD
178{
179 return NULL;
180}
f6a9efaa 181
3bd1e081
MD
182static inline
183struct ltt_ust_session *trace_ust_get_session_by_pid(
184 struct ltt_ust_session_list *session_list, pid_t pid)
185{
186 return NULL;
187}
188
189static inline
190struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
191 struct lttng_domain *domain)
192{
193 return NULL;
194}
195static inline
196struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
197 char *path)
198{
199 return NULL;
200}
201static inline
202struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
203{
204 return NULL;
205}
206static inline
207struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
208{
209 return NULL;
210}
211
212static inline
213void trace_ust_destroy_session(struct ltt_ust_session *session)
214{
215}
216static inline
217void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
218{
219}
220static inline
221void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
222{
223}
224static inline
225void trace_ust_destroy_event(struct ltt_ust_event *event)
226{
227}
228
229#endif
230
97ee3a89 231#endif /* _LTT_TRACE_UST_H */
This page took 0.047857 seconds and 4 git commands to generate.