493a23636847a65fe3b1c06cedee5057ee1179a9
[lttng-tools.git] / ltt-sessiond / trace.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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; either version 2
7 * of the License, or (at your option) any later version.
8 *
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.
13 *
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.
17 */
18
19 #ifndef _LTT_TRACE_H
20 #define _LTT_TRACE_H
21
22 #include <limits.h>
23 #include <urcu/list.h>
24
25 #include <lttng/lttng.h>
26
27 #include "lttng-kernel.h"
28
29 /* Kernel event list */
30 struct ltt_kernel_event_list {
31 struct cds_list_head head;
32 };
33
34 /* Channel stream list */
35 struct ltt_kernel_stream_list {
36 struct cds_list_head head;
37 };
38
39 /* Channel list */
40 struct ltt_kernel_channel_list {
41 struct cds_list_head head;
42 };
43
44 /* Kernel event */
45 struct ltt_kernel_event {
46 int fd;
47 int enabled;
48 struct lttng_kernel_event *event;
49 struct cds_list_head list;
50 };
51
52 /* Kernel channel */
53 struct ltt_kernel_channel {
54 int fd;
55 int enabled;
56 char *pathname;
57 unsigned int stream_count;
58 struct lttng_channel *channel;
59 struct ltt_kernel_event_list events_list;
60 struct ltt_kernel_stream_list stream_list;
61 struct cds_list_head list;
62 };
63
64 /* Metadata */
65 struct ltt_kernel_metadata {
66 int fd;
67 char *pathname;
68 struct lttng_channel *conf;
69 };
70
71 /* Channel stream */
72 struct ltt_kernel_stream {
73 int fd;
74 char *pathname;
75 int state;
76 struct cds_list_head list;
77 };
78
79 /* Kernel session */
80 struct ltt_kernel_session {
81 int fd;
82 int metadata_stream_fd;
83 int kconsumer_fds_sent;
84 unsigned int channel_count;
85 unsigned int stream_count_global;
86 struct ltt_kernel_metadata *metadata;
87 struct ltt_kernel_channel_list channel_list;
88 };
89
90 /* UST trace representation */
91 struct ltt_ust_trace {
92 struct cds_list_head list;
93 char name[NAME_MAX];
94 int shmid;
95 pid_t pid;
96 struct cds_list_head markers;
97 };
98
99 struct ltt_ust_marker {
100 struct cds_list_head list;
101 char *name;
102 char *channel;
103 };
104
105 /*
106 * Get functions.
107 */
108 struct ltt_kernel_event *get_kernel_event_by_name(
109 char *name, struct ltt_kernel_channel *channel);
110 struct ltt_kernel_channel *get_kernel_channel_by_name(
111 char *name, struct ltt_kernel_session *session);
112
113 /*
114 * Create functions malloc() the data structure.
115 */
116 struct ltt_kernel_session *trace_create_kernel_session(void);
117 struct ltt_kernel_channel *trace_create_kernel_channel(struct lttng_channel *chan);
118 struct ltt_kernel_event *trace_create_kernel_event(struct lttng_event *ev);
119 struct ltt_kernel_metadata *trace_create_kernel_metadata(void);
120 struct ltt_kernel_stream *trace_create_kernel_stream(void);
121
122 /*
123 * Destroy functions free() the data structure and remove from linked list if
124 * it's applies.
125 */
126 void trace_destroy_kernel_session(struct ltt_kernel_session *session);
127 void trace_destroy_kernel_metadata(struct ltt_kernel_metadata *metadata);
128 void trace_destroy_kernel_channel(struct ltt_kernel_channel *channel);
129 void trace_destroy_kernel_event(struct ltt_kernel_event *event);
130 void trace_destroy_kernel_stream(struct ltt_kernel_stream *stream);
131
132 #endif /* _LTT_TRACE_H */
This page took 0.036338 seconds and 4 git commands to generate.