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>
31 struct ltt_ust_stream_list
{
33 struct cds_list_head head
;
36 /* Context hash table nodes */
37 struct ltt_ust_context
{
38 struct lttng_ust_context ctx
;
39 struct lttng_ht_node_ulong node
;
43 struct ltt_ust_event
{
45 struct lttng_ust_event attr
;
47 struct lttng_ht_node_str node
;
51 struct ltt_ust_stream
{
53 char pathname
[PATH_MAX
];
54 struct lttng_ust_object_data
*obj
;
55 /* Using a list of streams to keep order. */
56 struct cds_list_head list
;
60 struct ltt_ust_channel
{
62 char name
[LTTNG_UST_SYM_NAME_LEN
];
63 char pathname
[PATH_MAX
];
64 struct lttng_ust_channel attr
;
66 struct lttng_ht
*events
;
67 struct lttng_ht_node_str node
;
71 struct ltt_ust_metadata
{
73 struct lttng_ust_object_data
*obj
;
74 char pathname
[PATH_MAX
]; /* Trace file path name */
75 struct lttng_ust_channel attr
;
76 struct lttng_ust_object_data
*stream_obj
;
79 /* UST domain global (LTTNG_DOMAIN_UST) */
80 struct ltt_ust_domain_global
{
81 struct lttng_ht
*channels
;
84 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
85 struct ltt_ust_domain_pid
{
87 struct lttng_ht
*channels
;
88 struct lttng_ht_node_ulong node
;
91 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
92 struct ltt_ust_domain_exec
{
93 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
94 struct lttng_ht
*channels
;
95 struct lttng_ht_node_str node
;
99 struct ltt_ust_session
{
100 int id
; /* Unique identifier of session */
102 char pathname
[PATH_MAX
];
103 struct ltt_ust_domain_global domain_global
;
105 * Those two hash tables contains data for a specific UST domain and each
106 * contains a HT of channels. See ltt_ust_domain_exec and
107 * ltt_ust_domain_pid data structures.
109 struct lttng_ht
*domain_pid
;
110 struct lttng_ht
*domain_exec
;
111 /* UID/GID of the user owning the session */
116 #ifdef HAVE_LIBLTTNG_UST_CTL
119 * Lookup functions. NULL is returned if not found.
121 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
123 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
127 * Create functions malloc() the data structure.
129 struct ltt_ust_session
*trace_ust_create_session(char *path
,
130 unsigned int session_id
, struct lttng_domain
*domain
);
131 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
133 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
134 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
135 struct ltt_ust_context
*trace_ust_create_context(
136 struct lttng_event_context
*ctx
);
139 * Destroy functions free() the data structure and remove from linked list if
142 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
143 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
144 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
145 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
147 #else /* HAVE_LIBLTTNG_UST_CTL */
150 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
157 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
164 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
165 struct lttng_domain
*domain
)
170 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
176 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
181 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
187 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
192 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
197 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
202 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
206 struct ltt_ust_context
*trace_ust_create_context(
207 struct lttng_event_context
*ctx
)
212 #endif /* HAVE_LIBLTTNG_UST_CTL */
214 #endif /* _LTT_TRACE_UST_H */