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>
30 #include "../common/hashtable.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 cds_lfht_node node
;
45 struct ltt_ust_event
{
47 struct lttng_ust_event attr
;
49 struct cds_lfht_node node
;
53 struct ltt_ust_stream
{
55 char pathname
[PATH_MAX
];
56 struct lttng_ust_object_data
*obj
;
57 /* Using a list of streams to keep order. */
58 struct cds_list_head list
;
62 struct ltt_ust_channel
{
64 char name
[LTTNG_UST_SYM_NAME_LEN
];
65 char pathname
[PATH_MAX
];
66 struct lttng_ust_channel attr
;
68 struct cds_lfht
*events
;
69 struct cds_lfht_node node
;
73 struct ltt_ust_metadata
{
75 struct lttng_ust_object_data
*obj
;
76 char pathname
[PATH_MAX
]; /* Trace file path name */
77 struct lttng_ust_channel attr
;
78 struct lttng_ust_object_data
*stream_obj
;
81 /* UST domain global (LTTNG_DOMAIN_UST) */
82 struct ltt_ust_domain_global
{
83 struct cds_lfht
*channels
;
86 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
87 struct ltt_ust_domain_pid
{
89 struct cds_lfht
*channels
;
90 struct cds_lfht_node node
;
93 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
94 struct ltt_ust_domain_exec
{
95 char exec_name
[LTTNG_UST_SYM_NAME_LEN
];
96 struct cds_lfht
*channels
;
97 struct cds_lfht_node node
;
101 struct ltt_ust_session
{
102 int id
; /* Unique identifier of session */
104 char pathname
[PATH_MAX
];
105 struct ltt_ust_domain_global domain_global
;
107 * Those two hash tables contains data for a specific UST domain and each
108 * contains a HT of channels. See ltt_ust_domain_exec and
109 * ltt_ust_domain_pid data structures.
111 struct cds_lfht
*domain_pid
;
112 struct cds_lfht
*domain_exec
;
113 /* UID/GID of the user owning the session */
118 #ifdef HAVE_LIBLTTNG_UST_CTL
121 * Lookup functions. NULL is returned if not found.
123 struct ltt_ust_event
*trace_ust_find_event_by_name(struct cds_lfht
*ht
,
125 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct cds_lfht
*ht
,
129 * Create functions malloc() the data structure.
131 struct ltt_ust_session
*trace_ust_create_session(char *path
, int session_id
,
132 struct lttng_domain
*domain
);
133 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
135 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
);
136 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
);
137 struct ltt_ust_context
*trace_ust_create_context(
138 struct lttng_event_context
*ctx
);
141 * Destroy functions free() the data structure and remove from linked list if
144 void trace_ust_destroy_session(struct ltt_ust_session
*session
);
145 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
);
146 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
);
147 void trace_ust_destroy_event(struct ltt_ust_event
*event
);
149 #else /* HAVE_LIBLTTNG_UST_CTL */
152 struct ltt_ust_event
*trace_ust_find_event_by_name(struct cds_lfht
*ht
,
159 struct ltt_ust_channel
*trace_ust_find_channel_by_name(struct cds_lfht
*ht
,
166 struct ltt_ust_session
*trace_ust_create_session(char *path
, pid_t pid
,
167 struct lttng_domain
*domain
)
172 struct ltt_ust_channel
*trace_ust_create_channel(struct lttng_channel
*attr
,
178 struct ltt_ust_event
*trace_ust_create_event(struct lttng_event
*ev
)
183 struct ltt_ust_metadata
*trace_ust_create_metadata(char *path
)
189 void trace_ust_destroy_session(struct ltt_ust_session
*session
)
194 void trace_ust_destroy_metadata(struct ltt_ust_metadata
*metadata
)
199 void trace_ust_destroy_channel(struct ltt_ust_channel
*channel
)
204 void trace_ust_destroy_event(struct ltt_ust_event
*event
)
208 struct ltt_ust_context
*trace_ust_create_context(
209 struct lttng_event_context
*ctx
)
214 #endif /* HAVE_LIBLTTNG_UST_CTL */
216 #endif /* _LTT_TRACE_UST_H */