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>
32 struct ltt_ust_stream_list
{
34 struct cds_list_head head
;
37 /* Context hash table nodes */
38 struct ltt_ust_context
{
39 struct lttng_ust_context ctx
;
40 struct lttng_ht_node_ulong node
;
44 struct ltt_ust_event
{
46 struct lttng_ust_event attr
;
48 struct lttng_ht_node_str node
;
52 struct ltt_ust_stream
{
54 char pathname
[PATH_MAX
];
55 /* Format is %s_%d respectively channel name and CPU number. */
56 char name
[LTTNG_SYMBOL_NAME_LEN
];
57 struct lttng_ust_object_data
*obj
;
58 /* Using a list of streams to keep order. */
59 struct cds_list_head list
;
63 struct ltt_ust_channel
{
65 char name
[LTTNG_UST_SYM_NAME_LEN
];
66 char pathname
[PATH_MAX
];
67 struct lttng_ust_channel attr
;
69 struct lttng_ht
*events
;
70 struct lttng_ht_node_str node
;
74 struct ltt_ust_metadata
{
76 struct lttng_ust_object_data
*obj
;
77 char pathname
[PATH_MAX
]; /* Trace file path name */
78 struct lttng_ust_channel attr
;
79 struct lttng_ust_object_data
*stream_obj
;
82 /* UST domain global (LTTNG_DOMAIN_UST) */
83 struct ltt_ust_domain_global
{
84 struct lttng_ht
*channels
;
87 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
88 struct ltt_ust_domain_pid
{
90 struct lttng_ht
*channels
;
91 struct lttng_ht_node_ulong node
;
94 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
95 struct ltt_ust_domain_exec
{
96 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
97 struct lttng_ht
*channels
;
98 struct lttng_ht_node_str node
;
102 struct ltt_ust_session
{
103 int id
; /* Unique identifier of session */
105 char pathname
[PATH_MAX
];
106 struct ltt_ust_domain_global domain_global
;
108 * Those two hash tables contains data for a specific UST domain and each
109 * contains a HT of channels. See ltt_ust_domain_exec and
110 * ltt_ust_domain_pid data structures.
112 struct lttng_ht
*domain_pid
;
113 struct lttng_ht
*domain_exec
;
114 /* UID/GID of the user owning the session */
118 * Two consumer_output object are needed where one is for the current
119 * output object and the second one is the temporary object used to store
120 * URI being set by the lttng_set_consumer_uri call. Once
121 * lttng_enable_consumer is called, the two pointers are swapped.
123 struct consumer_output
*consumer
;
124 struct consumer_output
*tmp_consumer
;
127 #ifdef HAVE_LIBLTTNG_UST_CTL
130 * Lookup functions. NULL is returned if not found.
132 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
134 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
138 * Create functions malloc() the data structure.
140 struct ltt_ust_session
*trace_ust_create_session(char *path
,
141 unsigned int session_id
, struct lttng_domain
*domain
);
142 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
144 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
145 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
146 struct ltt_ust_context
*trace_ust_create_context(
147 struct lttng_event_context
*ctx
);
150 * Destroy functions free() the data structure and remove from linked list if
153 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
154 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
155 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
156 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
158 #else /* HAVE_LIBLTTNG_UST_CTL */
161 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
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
)
192 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
198 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
203 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
208 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
213 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
217 struct ltt_ust_context
*trace_ust_create_context(
218 struct lttng_event_context
*ctx
)
223 #endif /* HAVE_LIBLTTNG_UST_CTL */
225 #endif /* _LTT_TRACE_UST_H */