2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifndef _LTT_TRACE_UST_H
20 #define _LTT_TRACE_UST_H
25 #include <urcu/list.h>
26 #include <lttng/lttng.h>
29 * FIXME: temporary workaround: we use a lttng-tools local version of
30 * lttng-ust-abi.h if UST is not found. Eventually, we should use our
31 * own internal structures within lttng-tools instead of relying on the
34 #ifdef CONFIG_CONFIG_LTTNG_TOOLS_HAVE_UST
35 #include <ust/lttng-ust-abi.h>
37 #include "lttng-ust-abi.h"
40 #include "../hashtable/rculfhash.h"
44 struct ltt_ust_stream_list
{
46 struct cds_list_head head
;
49 /* Context hash table nodes */
50 struct ltt_ust_context
{
51 struct lttng_ust_context ctx
;
52 struct cds_lfht_node node
;
56 struct ltt_ust_event
{
59 struct object_data
*obj
;
60 struct lttng_ust_event attr
;
62 struct cds_lfht_node node
;
66 struct ltt_ust_stream
{
68 struct object_data
*obj
;
69 struct cds_list_head list
;
74 struct ltt_ust_channel
{
77 char name
[LTTNG_UST_SYM_NAME_LEN
];
78 char trace_path
[PATH_MAX
]; /* Trace file path name */
79 struct object_data
*obj
;
81 unsigned int stream_count
;
82 struct ltt_ust_stream_list stream_list
;
83 struct lttng_ust_channel attr
;
85 struct cds_lfht
*events
;
86 struct cds_lfht_node node
;
90 struct ltt_ust_metadata
{
92 struct object_data
*obj
;
93 char pathname
[PATH_MAX
]; /* Trace file path name */
94 struct lttng_ust_channel attr
;
95 struct object_data
*stream_obj
;
98 /* UST domain global (LTTNG_DOMAIN_UST) */
99 struct ltt_ust_domain_global
{
100 struct cds_lfht
*channels
;
103 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
104 struct ltt_ust_domain_pid
{
106 struct cds_lfht
*channels
;
107 struct cds_lfht_node node
;
110 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
111 struct ltt_ust_domain_exec
{
112 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
113 struct cds_lfht
*channels
;
114 struct cds_lfht_node node
;
118 struct ltt_ust_session
{
119 int sock
; /* socket to send cmds to app */
122 int consumer_fds_sent
;
125 struct ltt_ust_metadata
*metadata
;
126 struct object_data
*obj
;
127 struct ltt_ust_domain_global domain_global
;
129 * Those two hash tables contains data for a specific UST domain and a HT
130 * of channels for each. See ltt_ust_domain_exec and ltt_ust_domain_pid
133 struct cds_lfht
*domain_pid
;
134 struct cds_lfht
*domain_exec
;
137 #ifdef CONFIG_LTTNG_TOOLS_HAVE_UST
140 * Lookup functions. NULL is returned if not found.
142 struct ltt_ust_event
*trace_ust_find_event_by_name(struct cds_lfht
*ht
,
144 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct cds_lfht
*ht
,
148 * Create functions malloc() the data structure.
150 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
151 struct lttng_domain
*domain
);
152 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
154 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
155 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
158 * Destroy functions free() the data structure and remove from linked list if
161 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
162 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
163 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
164 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
169 struct ltt_ust_event
*trace_ust_find_event_by_name(struct cds_lfht
*ht
,
176 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct cds_lfht
*ht
,
183 struct ltt_ust_session
*trace_ust_get_session_by_pid(
184 struct ltt_ust_session_list
*session_list
, pid_t pid
)
190 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
191 struct lttng_domain
*domain
)
196 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
202 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
207 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
213 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
217 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
221 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
225 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
231 #endif /* _LTT_TRACE_UST_H */