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