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
;
48 struct lttng_ht_node_str node
;
49 struct lttng_ust_filter_bytecode
*filter
;
53 struct ltt_ust_stream
{
55 char pathname
[PATH_MAX
];
56 /* Format is %s_%d respectively channel name and CPU number. */
57 char name
[DEFAULT_STREAM_NAME_LEN
];
58 struct lttng_ust_object_data
*obj
;
59 /* Using a list of streams to keep order. */
60 struct cds_list_head list
;
64 struct ltt_ust_channel
{
66 char name
[LTTNG_UST_SYM_NAME_LEN
];
67 char pathname
[PATH_MAX
];
68 struct lttng_ust_channel attr
;
70 struct lttng_ht
*events
;
71 struct lttng_ht_node_str node
;
75 struct ltt_ust_metadata
{
77 struct lttng_ust_object_data
*obj
;
78 char pathname
[PATH_MAX
]; /* Trace file path name */
79 struct lttng_ust_channel attr
;
80 struct lttng_ust_object_data
*stream_obj
;
83 /* UST domain global (LTTNG_DOMAIN_UST) */
84 struct ltt_ust_domain_global
{
85 struct lttng_ht
*channels
;
88 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
89 struct ltt_ust_domain_pid
{
91 struct lttng_ht
*channels
;
92 struct lttng_ht_node_ulong node
;
95 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
96 struct ltt_ust_domain_exec
{
97 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
98 struct lttng_ht
*channels
;
99 struct lttng_ht_node_str node
;
103 struct ltt_ust_session
{
104 int id
; /* Unique identifier of session */
106 char pathname
[PATH_MAX
];
107 struct ltt_ust_domain_global domain_global
;
109 * Those two hash tables contains data for a specific UST domain and each
110 * contains a HT of channels. See ltt_ust_domain_exec and
111 * ltt_ust_domain_pid data structures.
113 struct lttng_ht
*domain_pid
;
114 struct lttng_ht
*domain_exec
;
115 /* UID/GID of the user owning the session */
119 * Two consumer_output object are needed where one is for the current
120 * output object and the second one is the temporary object used to store
121 * URI being set by the lttng_set_consumer_uri call. Once
122 * lttng_enable_consumer is called, the two pointers are swapped.
124 struct consumer_output
*consumer
;
125 struct consumer_output
*tmp_consumer
;
126 /* Sequence number for filters so the tracer knows the ordering. */
127 uint64_t filter_seq_num
;
130 #ifdef HAVE_LIBLTTNG_UST_CTL
133 * Lookup functions. NULL is returned if not found.
135 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
137 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
141 * Create functions malloc() the data structure.
143 struct ltt_ust_session
*trace_ust_create_session(char *path
,
144 unsigned int session_id
, struct lttng_domain
*domain
);
145 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
147 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
148 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
149 struct ltt_ust_context
*trace_ust_create_context(
150 struct lttng_event_context
*ctx
);
153 * Destroy functions free() the data structure and remove from linked list if
156 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
157 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
158 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
159 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
161 #else /* HAVE_LIBLTTNG_UST_CTL */
164 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
171 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
178 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
179 struct lttng_domain
*domain
)
184 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
190 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
195 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
201 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
206 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
211 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
216 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
220 struct ltt_ust_context
*trace_ust_create_context(
221 struct lttng_event_context
*ctx
)
226 #endif /* HAVE_LIBLTTNG_UST_CTL */
228 #endif /* _LTT_TRACE_UST_H */