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>
33 struct ltt_ust_stream_list
{
35 struct cds_list_head head
;
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
;
49 struct lttng_ht_node_str node
;
50 struct lttng_ust_filter_bytecode
*filter
;
54 struct ltt_ust_stream
{
56 char pathname
[PATH_MAX
];
57 /* Format is %s_%d respectively channel name and CPU number. */
58 char name
[DEFAULT_STREAM_NAME_LEN
];
59 struct lttng_ust_object_data
*obj
;
60 /* Using a list of streams to keep order. */
61 struct cds_list_head list
;
65 struct ltt_ust_channel
{
67 char name
[LTTNG_UST_SYM_NAME_LEN
];
68 char pathname
[PATH_MAX
];
69 struct lttng_ust_channel attr
;
71 struct lttng_ht
*events
;
72 struct lttng_ht_node_str node
;
76 struct ltt_ust_metadata
{
78 struct lttng_ust_object_data
*obj
;
79 char pathname
[PATH_MAX
]; /* Trace file path name */
80 struct lttng_ust_channel attr
;
81 struct lttng_ust_object_data
*stream_obj
;
84 /* UST domain global (LTTNG_DOMAIN_UST) */
85 struct ltt_ust_domain_global
{
86 struct lttng_ht
*channels
;
89 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
90 struct ltt_ust_domain_pid
{
92 struct lttng_ht
*channels
;
93 struct lttng_ht_node_ulong node
;
96 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
97 struct ltt_ust_domain_exec
{
98 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
99 struct lttng_ht
*channels
;
100 struct lttng_ht_node_str node
;
104 struct ltt_ust_session
{
105 int id
; /* Unique identifier of session */
107 char pathname
[PATH_MAX
];
108 struct ltt_ust_domain_global domain_global
;
110 * Those two hash tables contains data for a specific UST domain and each
111 * contains a HT of channels. See ltt_ust_domain_exec and
112 * ltt_ust_domain_pid data structures.
114 struct lttng_ht
*domain_pid
;
115 struct lttng_ht
*domain_exec
;
116 /* UID/GID of the user owning the session */
120 * Two consumer_output object are needed where one is for the current
121 * output object and the second one is the temporary object used to store
122 * URI being set by the lttng_set_consumer_uri call. Once
123 * lttng_enable_consumer is called, the two pointers are swapped.
125 struct consumer_output
*consumer
;
126 struct consumer_output
*tmp_consumer
;
129 #ifdef HAVE_LIBLTTNG_UST_CTL
132 * Lookup functions. NULL is returned if not found.
134 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
136 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
140 * Create functions malloc() the data structure.
142 struct ltt_ust_session
*trace_ust_create_session(char *path
,
143 unsigned int session_id
, struct lttng_domain
*domain
);
144 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
146 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
147 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
148 struct ltt_ust_context
*trace_ust_create_context(
149 struct lttng_event_context
*ctx
);
152 * Destroy functions free() the data structure and remove from linked list if
155 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
156 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
157 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
158 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
160 #else /* HAVE_LIBLTTNG_UST_CTL */
163 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
170 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
177 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
178 struct lttng_domain
*domain
)
183 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
189 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
194 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
200 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
205 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
210 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
215 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
219 struct ltt_ust_context
*trace_ust_create_context(
220 struct lttng_event_context
*ctx
)
225 #endif /* HAVE_LIBLTTNG_UST_CTL */
227 #endif /* _LTT_TRACE_UST_H */