2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
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.
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.
18 #ifndef _LTT_TRACE_UST_H
19 #define _LTT_TRACE_UST_H
23 #include <urcu/list.h>
25 #include <lttng/lttng.h>
26 #include <common/hashtable/hashtable.h>
27 #include <common/defaults.h>
32 struct ltt_ust_ht_key
{
34 const struct lttng_filter_bytecode
*filter
;
35 enum lttng_ust_loglevel_type loglevel
;
38 /* Context hash table nodes */
39 struct ltt_ust_context
{
40 struct lttng_ust_context ctx
;
41 struct lttng_ht_node_ulong node
;
45 struct ltt_ust_event
{
47 struct lttng_ust_event attr
;
48 struct lttng_ht_node_str node
;
49 struct lttng_ust_filter_bytecode
*filter
;
53 struct ltt_ust_channel
{
55 char name
[LTTNG_UST_SYM_NAME_LEN
];
56 char pathname
[PATH_MAX
];
57 struct lttng_ust_channel attr
;
59 struct lttng_ht
*events
;
60 struct lttng_ht_node_str node
;
64 struct ltt_ust_metadata
{
66 struct lttng_ust_object_data
*obj
;
67 char pathname
[PATH_MAX
]; /* Trace file path name */
68 struct lttng_ust_channel attr
;
69 struct lttng_ust_object_data
*stream_obj
;
72 /* UST domain global (LTTNG_DOMAIN_UST) */
73 struct ltt_ust_domain_global
{
74 struct lttng_ht
*channels
;
77 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
78 struct ltt_ust_domain_pid
{
80 struct lttng_ht
*channels
;
81 struct lttng_ht_node_ulong node
;
84 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
85 struct ltt_ust_domain_exec
{
86 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
87 struct lttng_ht
*channels
;
88 struct lttng_ht_node_str node
;
92 struct ltt_ust_session
{
93 int id
; /* Unique identifier of session */
95 char pathname
[PATH_MAX
];
96 struct ltt_ust_domain_global domain_global
;
98 * Those two hash tables contains data for a specific UST domain and each
99 * contains a HT of channels. See ltt_ust_domain_exec and
100 * ltt_ust_domain_pid data structures.
102 struct lttng_ht
*domain_pid
;
103 struct lttng_ht
*domain_exec
;
104 /* UID/GID of the user owning the session */
108 * Two consumer_output object are needed where one is for the current
109 * output object and the second one is the temporary object used to store
110 * URI being set by the lttng_set_consumer_uri call. Once
111 * lttng_enable_consumer is called, the two pointers are swapped.
113 struct consumer_output
*consumer
;
114 struct consumer_output
*tmp_consumer
;
115 /* Sequence number for filters so the tracer knows the ordering. */
116 uint64_t filter_seq_num
;
119 #ifdef HAVE_LIBLTTNG_UST_CTL
121 int trace_ust_ht_match_event(struct cds_lfht_node
*node
, const void *_key
);
122 int trace_ust_ht_match_event_by_name(struct cds_lfht_node
*node
,
126 * Lookup functions. NULL is returned if not found.
128 struct ltt_ust_event
*trace_ust_find_event(struct lttng_ht
*ht
,
129 char *name
, struct lttng_filter_bytecode
*filter
, int loglevel
);
130 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
134 * Create functions malloc() the data structure.
136 struct ltt_ust_session
*trace_ust_create_session(char *path
,
137 unsigned int session_id
);
138 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
140 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
,
141 struct lttng_filter_bytecode
*filter
);
142 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
143 struct ltt_ust_context
*trace_ust_create_context(
144 struct lttng_event_context
*ctx
);
147 * Destroy functions free() the data structure and remove from linked list if
150 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
151 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
152 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
153 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
155 #else /* HAVE_LIBLTTNG_UST_CTL */
157 static inline int trace_ust_ht_match_event(struct cds_lfht_node
*node
,
162 static inline int trace_ust_ht_match_event_by_name(struct cds_lfht_node
*node
,
168 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
175 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
176 struct lttng_domain
*domain
)
181 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
187 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
,
188 struct lttng_filter_bytecode
*filter
)
193 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
199 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
204 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
209 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
214 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
218 struct ltt_ust_context
*trace_ust_create_context(
219 struct lttng_event_context
*ctx
)
223 static inline struct ltt_ust_event
*trace_ust_find_event(struct lttng_ht
*ht
,
224 char *name
, struct lttng_filter_bytecode
*filter
, int loglevel
)
229 #endif /* HAVE_LIBLTTNG_UST_CTL */
231 #endif /* _LTT_TRACE_UST_H */