Fix: return value signedness
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.h
CommitLineData
97ee3a89
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
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.
97ee3a89
DG
7 *
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.
12 *
d14d33bf
AM
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.
97ee3a89
DG
16 */
17
18#ifndef _LTT_TRACE_UST_H
19#define _LTT_TRACE_UST_H
20
3bd1e081 21#include <config.h>
97ee3a89
DG
22#include <limits.h>
23#include <urcu/list.h>
bec39940 24
97ee3a89 25#include <lttng/lttng.h>
10a8a223 26#include <common/hashtable/hashtable.h>
3bd1e081 27
48842b30 28#include "ust-ctl.h"
97ee3a89 29
2bdd86d4
MD
30/* UST Stream list */
31struct ltt_ust_stream_list {
32 unsigned int count;
33 struct cds_list_head head;
34};
35
f6a9efaa
DG
36/* Context hash table nodes */
37struct ltt_ust_context {
38 struct lttng_ust_context ctx;
bec39940 39 struct lttng_ht_node_ulong node;
97ee3a89
DG
40};
41
42/* UST event */
43struct ltt_ust_event {
37357452 44 unsigned int enabled;
f6a9efaa 45 struct lttng_ust_event attr;
bec39940
DG
46 struct lttng_ht *ctx;
47 struct lttng_ht_node_str node;
2bdd86d4
MD
48};
49
50/* UST stream */
51struct ltt_ust_stream {
48842b30
DG
52 int handle;
53 char pathname[PATH_MAX];
13161846 54 struct lttng_ust_object_data *obj;
5af2f756
MD
55 /* Using a list of streams to keep order. */
56 struct cds_list_head list;
97ee3a89
DG
57};
58
59/* UST channel */
60struct ltt_ust_channel {
37357452 61 unsigned int enabled;
44d3bd01 62 char name[LTTNG_UST_SYM_NAME_LEN];
48842b30 63 char pathname[PATH_MAX];
f6a9efaa 64 struct lttng_ust_channel attr;
bec39940
DG
65 struct lttng_ht *ctx;
66 struct lttng_ht *events;
67 struct lttng_ht_node_str node;
97ee3a89
DG
68};
69
70/* UST Metadata */
71struct ltt_ust_metadata {
72 int handle;
13161846 73 struct lttng_ust_object_data *obj;
f6a9efaa 74 char pathname[PATH_MAX]; /* Trace file path name */
44d3bd01 75 struct lttng_ust_channel attr;
13161846 76 struct lttng_ust_object_data *stream_obj;
97ee3a89
DG
77};
78
f6a9efaa
DG
79/* UST domain global (LTTNG_DOMAIN_UST) */
80struct ltt_ust_domain_global {
bec39940 81 struct lttng_ht *channels;
f6a9efaa
DG
82};
83
84/* UST domain pid (LTTNG_DOMAIN_UST_PID) */
85struct ltt_ust_domain_pid {
86 pid_t pid;
bec39940
DG
87 struct lttng_ht *channels;
88 struct lttng_ht_node_ulong node;
f6a9efaa
DG
89};
90
91/* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
92struct ltt_ust_domain_exec {
93 char exec_name[LTTNG_UST_SYM_NAME_LEN];
bec39940
DG
94 struct lttng_ht *channels;
95 struct lttng_ht_node_str node;
f6a9efaa
DG
96};
97
97ee3a89
DG
98/* UST session */
99struct ltt_ust_session {
a991f516 100 int id; /* Unique identifier of session */
36dc12cc 101 int start_trace;
48842b30 102 char pathname[PATH_MAX];
f6a9efaa
DG
103 struct ltt_ust_domain_global domain_global;
104 /*
48842b30
DG
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.
f6a9efaa 108 */
bec39940
DG
109 struct lttng_ht *domain_pid;
110 struct lttng_ht *domain_exec;
6df2e2c9
MD
111 /* UID/GID of the user owning the session */
112 uid_t uid;
113 gid_t gid;
97ee3a89
DG
114};
115
74d0b642 116#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 117
97ee3a89
DG
118/*
119 * Lookup functions. NULL is returned if not found.
120 */
bec39940 121struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 122 char *name);
bec39940 123struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 124 char *name);
97ee3a89
DG
125
126/*
127 * Create functions malloc() the data structure.
128 */
fc4705fe
DG
129struct ltt_ust_session *trace_ust_create_session(char *path,
130 unsigned int session_id, struct lttng_domain *domain);
44d3bd01
DG
131struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
132 char *path);
97ee3a89
DG
133struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
134struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
55cc08a6
DG
135struct ltt_ust_context *trace_ust_create_context(
136 struct lttng_event_context *ctx);
97ee3a89
DG
137
138/*
139 * Destroy functions free() the data structure and remove from linked list if
140 * it's applies.
141 */
142void trace_ust_destroy_session(struct ltt_ust_session *session);
143void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
144void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
145void trace_ust_destroy_event(struct ltt_ust_event *event);
146
74d0b642 147#else /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081
MD
148
149static inline
bec39940 150struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
f6a9efaa 151 char *name)
3bd1e081
MD
152{
153 return NULL;
154}
f6a9efaa 155
3bd1e081 156static inline
bec39940 157struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
f6a9efaa 158 char *name)
3bd1e081
MD
159{
160 return NULL;
161}
f6a9efaa 162
3bd1e081
MD
163static inline
164struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
165 struct lttng_domain *domain)
166{
167 return NULL;
168}
169static inline
170struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
171 char *path)
172{
173 return NULL;
174}
175static inline
176struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
177{
178 return NULL;
179}
180static inline
181struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
182{
183 return NULL;
184}
185
186static inline
187void trace_ust_destroy_session(struct ltt_ust_session *session)
188{
189}
48842b30 190
3bd1e081
MD
191static inline
192void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
193{
194}
48842b30 195
3bd1e081
MD
196static inline
197void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
198{
199}
48842b30 200
3bd1e081
MD
201static inline
202void trace_ust_destroy_event(struct ltt_ust_event *event)
203{
204}
34378f76
DG
205static inline
206struct ltt_ust_context *trace_ust_create_context(
207 struct lttng_event_context *ctx)
208{
209 return NULL;
210}
3bd1e081 211
74d0b642 212#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 213
97ee3a89 214#endif /* _LTT_TRACE_UST_H */
This page took 0.054451 seconds and 4 git commands to generate.