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
24 #include <urcu/list.h>
26 #include <lttng/lttng.h>
27 #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 struct lttng_ust_object_data
*obj
;
56 /* Using a list of streams to keep order. */
57 struct cds_list_head list
;
61 struct ltt_ust_channel
{
63 char name
[LTTNG_UST_SYM_NAME_LEN
];
64 char pathname
[PATH_MAX
];
65 struct lttng_ust_channel attr
;
67 struct lttng_ht
*events
;
68 struct lttng_ht_node_str node
;
72 struct ltt_ust_metadata
{
74 struct lttng_ust_object_data
*obj
;
75 char pathname
[PATH_MAX
]; /* Trace file path name */
76 struct lttng_ust_channel attr
;
77 struct lttng_ust_object_data
*stream_obj
;
80 /* UST domain global (LTTNG_DOMAIN_UST) */
81 struct ltt_ust_domain_global
{
82 struct lttng_ht
*channels
;
85 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
86 struct ltt_ust_domain_pid
{
88 struct lttng_ht
*channels
;
89 struct lttng_ht_node_ulong node
;
92 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
93 struct ltt_ust_domain_exec
{
94 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
95 struct lttng_ht
*channels
;
96 struct lttng_ht_node_str node
;
100 struct ltt_ust_session
{
101 int id
; /* Unique identifier of session */
103 char pathname
[PATH_MAX
];
104 struct ltt_ust_domain_global domain_global
;
106 * Those two hash tables contains data for a specific UST domain and each
107 * contains a HT of channels. See ltt_ust_domain_exec and
108 * ltt_ust_domain_pid data structures.
110 struct lttng_ht
*domain_pid
;
111 struct lttng_ht
*domain_exec
;
112 /* UID/GID of the user owning the session */
117 #ifdef HAVE_LIBLTTNG_UST_CTL
120 * Lookup functions. NULL is returned if not found.
122 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
124 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
128 * Create functions malloc() the data structure.
130 struct ltt_ust_session
*trace_ust_create_session(char *path
, int session_id
,
131 struct lttng_domain
*domain
);
132 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
134 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
135 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
136 struct ltt_ust_context
*trace_ust_create_context(
137 struct lttng_event_context
*ctx
);
140 * Destroy functions free() the data structure and remove from linked list if
143 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
144 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
145 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
146 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
148 #else /* HAVE_LIBLTTNG_UST_CTL */
151 struct ltt_ust_event
*trace_ust_find_event_by_name(struct lttng_ht
*ht
,
158 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct lttng_ht
*ht
,
165 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
166 struct lttng_domain
*domain
)
171 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
177 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
182 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
188 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
193 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
198 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
203 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
207 struct ltt_ust_context
*trace_ust_create_context(
208 struct lttng_event_context
*ctx
)
213 #endif /* HAVE_LIBLTTNG_UST_CTL */
215 #endif /* _LTT_TRACE_UST_H */